Max/MSP - mutliple serial read

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!

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

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.

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

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?

Hej,

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

/David

yes, i tried it also in max as "open as text" ... here´s a screenshot how it looks like:


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

thanks

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

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

I still can't open that patch. Would someone save it as text and re-post it please?

thanks,
Gabe

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.

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.