Max5 + serial object + Arduino

Feb 12, 2009 at 4:49am

Max5 + serial object + Arduino

Max doesn’t seems to be playing well with an Arduino Duemilanove. I loaded the example program onto the Arduino with Arduino 0013 programming environment. I open the Serial Communication tutorial. The correct serial port and baud rate is in the serial object. I activate the metro and send a byte. I see the RX light up on the Arduino but no data flow through the patch. I send 10 to the Arduino in the Arduino 0013 programming environment and the program runs fine using the Serial Reader in that program.

Any suggestions?

#42254
Feb 12, 2009 at 7:16am

Max & Arduino play fine together, so something isn’t right in your patch or sketch. Posting your patch will get you more help. Posting your sketch might help, too. Have you had any success with the existing Max-Arduino patches & sketches, e.g. “Arduino2Max” patches & sketch?

David

#151199
Feb 12, 2009 at 3:45pm

I am using the Communications Tutorial 2: Serial Communication tutorial patch w/ the sample code provided. None of the third party objects like Arduino2Max work either, thus leading me to believe something is up with the serial object.

Posted the code here:

// Arduino Serial Tester
// rld, cycling’74, 3.2008

long randomvalue = 0; // random value
long countervalue = 0; // counter value
int serialvalue; // value for serial input
int started = 0; // flag for whether we’ve received serial yet

void setup()
{
Serial.begin(9600); // open the arduino serial port
}

void loop()
{
if(Serial.available()) // check to see if there’s serial data in the buffer
{
serialvalue = Serial.read(); // read a byte of serial data
started = 1; // set the started flag to on
}
if(started) { // loop once serial data has been received
randomvalue = random(1000); // pick a new random number
Serial.print(countervalue); // print the counter
Serial.print(” “); // print a space
Serial.print(randomvalue); // print the random value
Serial.print(” “); // print a space
Serial.print(serialvalue); // echo the received serial value
Serial.println(); // print a line-feed
countervalue = (countervalue+1)%1000; // increment the counter
delay(100); // pause
}
}

Max Code:

– Pasted Max Patch, click to expand. –
#151200
Feb 12, 2009 at 4:09pm

Edit – Copy Compressed

#151201
Feb 12, 2009 at 4:14pm

A couple things.

*Make sure you don’t have the Arduino’s serial monitor open at the
same time as Max.
*Make sure you’re talking on the right serial port.
*On the newer Arduinos (Decimillias and later), when a serial
connection opens, you’ll need want to wait a few seconds before
sending any information. This is because of the reset feature that
was built into the bootloader on these versions. It’s looking for
information from the Arduino IDE.

Also, use Copy Compressed when posting patches to the list.

~s

#151202
Feb 12, 2009 at 5:10pm

Ok,

So I’ve tried everything listed here. The Arduino Programming environment isn’t open at the same time Max 5 is. I triple checked the serial port is set to “a” which is my USB serial bus. I waited 10 seconds after resetting the Arduino before activating the metro and sending the byte 10 to the board. RX lights up when I send bytes, but TX does not indicating that something in the transmission back to Max is funky.

Thanks for the advice,
Steve

Whoops, heres the Max code (edit -> Copy Compressed):

– Pasted Max Patch, click to expand. –
#151203
Feb 12, 2009 at 5:54pm

I attempted the same basic patch in Max 4.6 and get the same results, no communication from the Arduino to Max.

#151204
Feb 12, 2009 at 6:21pm

Have you tried just sending information?

////Arduino :: simple serial sender

byte num = 2;
void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.print(num, BYTE);
delay(30);
}

////Max :: simple serial listener

– Pasted Max Patch, click to expand. –
#151205
Feb 12, 2009 at 6:33pm

does it work if you set the port by its name instead of its letter?

see attached patch, which also provides the menu selection of
available ports…

hth

/*j

– Pasted Max Patch, click to expand. –
#151206
Feb 12, 2009 at 6:57pm

No help there either. I hooked the umenu up, no dice, I attempted the simple serial patch, I can send bytes to the Arduino (as indicated by RX lighting up, but TX does not return values to Max). The Max Serial Communication example worked briefly last night. These programs work in the Arduino Environment Serial Monitor.

Arrrgggg.

Steve

#151207
Feb 12, 2009 at 7:26pm

what about other programs?

Processing, Pure Data, etc.?

On Thu, Feb 12, 2009 at 1:57 PM, Steve Belovarich wrote:
>
> No help there either. I hooked the umenu up, no dice, I attempted the simple serial patch, I can send bytes to the Arduino (as indicated by RX lighting up, but TX does not return values to Max). The Max Serial Communication example worked briefly last night. These programs work in the Arduino Environment Serial Monitor.
>
> Arrrgggg.
>

#151208
Feb 12, 2009 at 11:08pm

I haven’t tried other programs, but they won’t help in the context I need to present this lesson in. Thanks for the suggestion.

#151209
Feb 13, 2009 at 12:24am

Hey Stephen,
Everything works over here. One thing you might need to do, however, is hit the reset button on your Arduino after making the connection in Max. I don’t have the Duemilanove, but have the Diecimila and have to do this. I forget why…and don’t recall how you get around this. I usually use an Arduino Pro Mini and don’t have to do this. Anyway, see if that helps.

Also just a side note: you have a “zl group 1000″ in your patch that will actually truncate your list at 256 elements (not that you will ever reach this limit…but still). If you want to work with lists > 256, you need to add an argument to zl, e.g. zl 1000 group 1000″.

David

#151210
Mar 14, 2009 at 3:20am

I suggest downloading Pduino for max-arduino software interfacing.

There is a procedure you have to go through to get your Duema-whatever board working.
Open the Arduino_Test patch.
1) Select the serial port from the umenu

2) RESET the board

3) go about your business setting pins etc.

Took me a while to figure this out but it works like a charm.

Best,
Max

PS this might not be available for Max 5

#151211
Mar 14, 2009 at 10:27pm

here you can find a usefull link for step by step arduino-set up set up . works for max5 and uses an updated version of Firmata.
hope it helps :

http://www.soundplusdesign.com/?p=1305

#151212
Jul 2, 2009 at 5:33am

Hello,
I’m was the getting the same (lack of) results that Stephen was reporting below. However, upon taking the suggestion of resetting the Arduino (thanks, David): blinky blinky!

To be specific about my setup:

Dueimilanove

Running the Arduino sketch and Max patch including with Arduino v. 16.

It might be good to update the documentation of that patch to mention the reset button trick.

Cheers,
Michael

#151213
Jul 2, 2009 at 11:58am

It is awefully nice that usually an arduino reset is not required when a computer running OS X boots and loads a Max patch automatically on start up (with every USB periferal already connnected). This has saved me from having to build an external reset button on an installation that is currently being shown in a gallery.

#151214
Sep 7, 2010 at 2:20pm

I have tried all the max and arduio objects ( patches) and they work for fine.
important to remember is to check the baud rate, as the port identification.
how ever I have a small issue , all of patches read dada from any analog pin even if there is nothing attach to it.
so seems like lots of noise comes from arduino. the data-noise has the same values as if a sensor is attach to it.
any body has this problem tooo.
thank you.

#151215
Sep 7, 2010 at 9:22pm

Hi all
as I have reported that max and arduino do work .
after hrs of testing I did find out the the max msp stop woking with arduino.
it seems like there is a serial overflow, do you guys have any idea how to do a serial flush in max msp.

so will prevent the crash of serial ports.

I am running mac snow leapard and max 5 with a duemilanove.

thank you.

#151216

You must be logged in to reply to this topic.