Arduino Forum

Forum 2005-2010 (read only) => Software => Troubleshooting => Topic started by: nako on Dec 14, 2005, 12:57 am

Title: Max/MSP - mutliple serial read
Post by: nako on Dec 14, 2005, 12:57 am
hi guys,

we are doing a max/msp project here at the interactive digital media, at ravensbourne college, uk, and decided to use arduino instead of the teleoboards they have here.

the project is a mixer, where we have 4 digital inputs (switches) and an analog one (weight sensor). we have to send this 5 informations to max so our patch can work the mixer.

at the london workshop, we've learnt how to send the serialport read to max, that's ok. the problem now is how to separate the informations. because we have a weight sensor constantly sending the information to max (byte values), we are not been able to tell when does a switch is turned on and off; it is sent together with the bytes of the weight sensor.

so, question: how to differentiate the serial information? how to tell which switch is on and off and still get the weight sensor information without scrambling everything?

thanks, tchau!
Title: Re: Max/MSP - mutliple serial read
Post by: DojoDave on Dec 14, 2005, 02:33 am
Hej Nako,

Let's take a look at this.

>>the project is a mixer (we are using liquids to control sounds, it is  
quite nice), where we have 4 digital inputs (switches) and an analog  
one (weight sensor). we have to send this 5 informations to max so  
our patch can work the mixer.

The best thing to do in this case is to send all formated somehow. I always recommend to do it making the board send a character to identify the sensor, and a value following, like:

A5
B7
C2
A78
A23
B3
A22
A21
B0
C6
...

The way of doing this from the code is to send:

serialWrite('A');
printInteger(valueSensorA);
serialWrite(10);
serialWrite(13);

serialWrite('B');
...

this allows you to have different latencies for the different sensors

The way of reading this in MAX is a different story. You will have to either convert the patch we made for PureData (look at the www.arduino.ws website for the latest version) or to wait for a couple of days until I get an update from Greg at SFU in Vancouver, who is revising this very same patch for MAX/MSP.

>>so, question: how to differentiate the serial information? how to  
tell which switch is on and off and still get the weight sensor  
information without scrambling everything? I imagine we have to  
configure the digitalread inside max, is that it?

The way to differenciate the different sensors is using the character in the front, that allows you to distinguish between different numeric inputs to the MAX patch.

Was this of any help?

/David@Malmo
Title: Re: Max/MSP - mutliple serial read
Post by: Pedro_Boavida on Feb 13, 2006, 08:14 pm
>to wait for a couple of days until I get an update from Greg at SFU in Vancouver, who is revising this very same patch for MAX/MSP.

Is this patch available online already? Thanks.
Title: Re: Max/MSP - mutliple serial read
Post by: DojoDave on Feb 15, 2006, 06:29 am
Hej,

Oh yes it is at:

http://webzone.k3.mah.se/projects/arduino-workshop/board04/board04.asp?boardID=3

please note that you may have to change the extension to the file.

/David
Title: Re: Max/MSP - mutliple serial read
Post by: ritzdank on Feb 19, 2006, 07:33 pm
hej,

i experienced some glitches (value will jump to zero) while constantly reading the serial data with serial object in max/msp??! do you have any clue? and which metro-time do you use for banging the serial object?

meanwhile, i downloaded the code-sniplet by David Cuartielles, but i couldnt open it, neiter as text, nor as patch? does it contain errors? i´m using max 4.5.4?

Title: Re: Max/MSP - mutliple serial read
Post by: DojoDave on Feb 22, 2006, 02:17 pm
Hej,

did you change the extension from being *.max to have no extension?

/David
Title: Re: Max/MSP - mutliple serial read
Post by: ritzdank on Feb 24, 2006, 07:34 am
yes, i tried it also in max as "open as text" ... here´s a screenshot how it looks like:

http://www.yugo.at/img/arduino.png

meanwhile, have you ever experienced wrong values while reading the data from serialport. sometimes it jumps on 0 without any reason??

thanks
Title: Re: Max/MSP - mutliple serial read
Post by: Pedro_Boavida on Feb 24, 2006, 08:07 pm
I got it to work. just delete the extension and drag it to max msp.

about the jumpy values, yeah I get that as well, I've posted another topic about it but with no success. But do you get that only when reading from max?

Pedro
Title: Re: Max/MSP - mutliple serial read
Post by: nima on Mar 27, 2006, 12:14 pm
hey:

in your Arduino program, make sure you put a delay between printing the integers of your sensor.

So you would you have
printByte ('A');
printInteger (sensor1);
printByte (10);
printByte(13);
delay (20);
printByte ('B');
.......

The delay function is so Max, (as well asd Pure Data) can process the information.  You might want to experiment with the delay (value) to find the duration that is fast but not *too* fast.

-nima at sfu
Title: Re: Max/MSP - mutliple serial read
Post by: Gabe462 on May 04, 2006, 09:03 am
I still can't open that patch. Would someone save it as text and re-post it please?

thanks,
Gabe
Title: Re: Max/MSP - mutliple serial read
Post by: will_schrimshaw on Jul 14, 2006, 11:10 pm
Hi there,
anyone tried to do this with processing? Benoit has been helping out but I'm still not having that much luck.
I'm basically usingthis code (slightly altered ):

http://webzone.k3.mah.se/projects/arduino-workshop/projects/arduino_meets_processing/instructions/ultrasound.html

to read from two ultrasounds on pins 6 and 7 on the i/o.
I have tried formatting the messages as discussed above, i.e:

serialWrite ('A');
printInteger (sensor1);
serialWrite (10);
delay (20);
serialWrite ('B');
printInteger (sensor2);
... and so on.

I can see that the data from both sensors is getting through to processing, yet one is domminant, the other only appears in processing every 8th - 10th line.

any ideas or do you think this is this more of a processing question?

(i hope) this is the relevant processing code:

 if(serial!=10) {        
         buf += char(serial);          
         } else {
         //extract the value from the string 'buf'
         buf = buf.substring(1,buf.length());
         //cast the value to an integer
         value1 = int(buf);
         buf="";
     }

any help greatly appreciated.

will.
Title: Re: Max/MSP - mutliple serial read
Post by: will_schrimshaw on Jul 15, 2006, 03:16 pm
ok, after a long night.... i was looking for the wrong data on the processing side of my project, got it sorted in the end.

will.