Csound Csound-dev Csound-tekno Search About

[Csnd] Re: Re: Re: Re: Re: Re: Re: Re: serial opcode...

Date2008-04-17 14:47
From"Art Hunkins"
Subject[Csnd] Re: Re: Re: Re: Re: Re: Re: Re: serial opcode...
Just a note about gamepads:
 
They are easy to interface with Csound (whether USB or otherwise) as they all emulate the ASCII keyboard, which in turn is read by sensekey. In my realtime works, I routinely create versions with sensekey for ASCII keyboard performance. Then (in Windows) I use the utility JoyToKey to map gamepad functions to the ASCII keys I need.
 
My recent article in the Csound Journal described this procedure a bit.
 
Art Hunkins
----- Original Message -----
Sent: Thursday, April 17, 2008 4:12 AM
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,

I would think the best bet right now, is to use the python opcodes and
pySerial:
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.
We do need a serial in opcode - as in PD or Max.  That would be awesome
and
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.
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"