[Csnd] Re: Re: Re: Re: Re: Re: Re: serial opcode...
Date | 2008-04-17 09:12 |
From | Eirik Blekesaune |
Subject | [Csnd] Re: Re: Re: Re: Re: Re: Re: serial opcode... |
We've been using the Firmata sketch for the Arduino, developed by Hans Christoph Steiner and Joe Turners pyduino class for interfacing with the Arduino. What's nice about using the Firmata firmware is that you can control the Arduino from your host software. Here's how you set up Python to communicate with an Arduino and poll an analog pin: 1. Download Firmata (http://www.arduino.cc/playground/Interfacing/Firmata) and send the sketch to your Arduino. 2. Download the Pyduino class (http://orphans.atspace.com/pyduino-0.1.tar.gz). You also have to install pyserial (pyserial.sourceforge.net/). On Windows you need to install Python WIN32 Extensions (http://starship.python.net/crew/mhammond/win32/Downloads.html) as well. I haven't tried this on Linux, so if someone could figure out how to do it, please post. 3. Open a Python shell and execute following lines: #import the pyduino library import pyduino '''create an instance of Arduino with the location of your serial connection as argument. On OSX and Linux the Arduino shows up as tty.usbserial-XXXXXXXXX, where the Xs is your unique Arduino "name". Type 'ls /dev/tty.*' in a Terminal to find the name for your Arduino. On Win you use "COM9" for example. The correct comport number can be found in Hardware Manager. If your Arduino shows up with a two digit number (COM11) you have to use the "//./COMx" format as argument.''' ar = pyduino.Arduino("/dev/tty.usbserial-A1001NMs") #You have to notify your Arduino which pins you want to poll/write upon each .iterate() ar.analog[0].set_active(1) #Set up a loop while 1: ... ar.iterate() #this function has to be calles for each polling and writing from/to your Arduino. ... ar.analog[0].read() #Then read the result from the arduino instance. 733 690 633 633 570 502 434 372 372 319 276 242 207 184 The Arduino instance has two arrays, analog and digital, where the values polled from the pins are stored after each iteration. Sending the pin value to your Csound instance through the API would be something like: analog0 = ar.analog[0].read() self.csound.SetChannel("mod", analog0) I would actually propose developing a pyduino opcode as well as a general comport opcode, considering the poularity of the Arduino. Opcodes for interfacing to HID devices would be great as well. Making it easier to use devices like SpaceNavigator and gamepads or Dan Overholts CUI (www.create.ucsb.edu/~dano/CUI/). Hope this is helpful. -Eirik Arthur Blekesaune Oeyvind Brandtsegg wrote: One of my co-teachers, Eirik Blekesaunet, wrote some python code to access the arduino for a realtime Python/Csound setup we used for teaching recently. If someone's interested I could make it available. Oeyvind 2008/4/16, Andres Cabrera <mantaraya36@gmail.com>: Hi, pySerial:I would think the best bet right now, is to use the python opcodes and http://pyserial.sourceforge.net/ Cheers, Andr�s On Wed, Apr 16, 2008 at 8:10 AM, Dr. Richard Boulanger <rboulanger@berklee.edu> wrote: It would be great to be able to use the Arduino directly in Csound5. As we can in Max and PD. andWe do need a serial in opcode - as in PD or Max. That would be awesome useful. -dB On Apr 16, 2008, at 8:31 AM, Rory Walsh wrote: In my case I want to receive information from an arduino electronic prototyping board. I have had good success with it in Pd but would like direct access to that info in Csound without using OSC or csoundapi~ etc. I thought that perhaps someone may have looked into this in the past and had some old code lying around. It seems a whole lot easier to do it in linux than on windows due to the lack of a win32 posix terminal interface. I will take a look at the pd code and see if I can make sense of it. While I'm looking at it I'll no doubt be reminded of the fact that the Csound plugin API is so much prettier than the Pd one! Rory. jpff wrote: Seems an odd thing to do; on my machines a user program does not have acces to the serial port. Why just teh serial port? Why not any device? ==John ffitch Send bugs reports to this list. To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" Send bugs reports to this list. To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" Send bugs reports to this list. To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" Send bugs reports to this list. csound"To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe Send bugs reports to this list. To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribecsound" |
Date | 2008-04-17 10:02 |
From | Rory Walsh |
Subject | [Csnd] Re: Re: Re: Re: Re: Re: Re: Re: serial opcode... |
Hi Eirik, I have a simple version almost working with the Simple Message System sketch which also allows one to write to the arduino afaik. It's not a good as the Firmata sketch but I understand it much better! If I can get a version going using the SMS I will take a look at implementing a firmata version. Write now I'm only interested in retrieving data from the Arduino although the possibility of have an audio controlled Csound robot is tempted! Rory. p.s. thanks for the instruction about pyduino, I downloaded and tried uploading the firmata and running the example python script but I get nothing. I also tried the pd version and I still get nothing. Eirik Blekesaune wrote: > We've been using the Firmata sketch for the Arduino, developed by Hans > Christoph Steiner and Joe Turners pyduino class for interfacing with the > Arduino. > > What's nice about using the Firmata firmware is that you can control the > Arduino from your host software. > > Here's how you set up Python to communicate with an Arduino and poll an > analog pin: > |
Date | 2008-04-18 06:14 |
From | "Dr. Richard Boulanger" |
Subject | [Csnd] Re: serial opcode... |
Thanks... This is very helpful. -dB On Apr 17, 2008, at 4:12 AM, Eirik Blekesaune wrote:
|