Forums > MaxMSP

Losing serial-usb connection after some time

October 31, 2009 | 11:40 pm

I’m stumped.. I have an system where an Arduino communicates with a Mac Mini running a Max patch that I created. Max is basically just listening to the "serial" port (which is of course USB connected right to the arduino) with a metro banging it all the time. It works fine most of the time, but sometimes it just stops hearing the Arduino’s messages – maybe twice a day or so. I thought it could be something related to inactivity in the system – too much time without hearing anything from the port – so the arduino sends a keepalive message every 30 seconds. Still has the same problem. Restarting the max patch fixes the issue, so the problem isn’t in the software on the arduino.. it’s still sending the whole time, max just isn’t hearing it. I am using the latest FTDI drivers – my next step is probably going to use a Keyspan USB-serial adapter and connect the serial cable directly to pins 1 & 2 on the arduino, bypassing the FTDI usb-serial business. One clue that I found today is: I opened ZTerm and after quitting ZTerm (with the Max patch open the whole time), the patch had snapped out of it and was hearing the messages on the port again! I’d love a software solution that doesn’t involve me soldering, etc since this is in a museum that is live (and justifiably annoyed). If I don’t try this Keyspan solution I described, am I going to have to have some kind of cron job that tries to access the port somehow to snap max out of its possible serialfunk every minute??? I hate hacks. Anyone else had this trouble? Is this Max or the FTDI driver???

Thanks for any (urgently needed) help,
Rob


November 3, 2009 | 12:17 am

Nobody else having trouble with Arduino < -> Max over long-ish periods of time?


November 3, 2009 | 3:43 pm

I’ve had arduinos running for months with no problem, so as far as I know there isn’t some built in time out.

You mention that all is well on restart, and therefore your sketch is OK. That’s not a good assumption. When you restart max and connect to the arduino via serial, it’s resets the arduino, so there very well could be something locking up in your sketch. Do you have any visual indicator on the arduino that it is still sending data (e.g. the status LED?).

Also, your plan to connect to a keyspan serial adapter won’t work…they speak 2 different flavors of serial…rs232 for the keyspan, TTL for the arduino. You need a level shifter (e.g. a max232 chip) to convert the signals.

Without a sketch, patch, or any system info, there isn’t much help anyone can give at the moment. One thing to look at in your sketch is if anything is counter or time-based. Those often lead to issues when running for a long time due to the limits of how large a number the arduino can represent.

David


November 3, 2009 | 11:17 pm

Thanks David,

I’m 99% sure the problem is not with the Arduino.. I started with the firmata firmware and then completely rewrote it with a new sketch that just sends a byte every time a switch is flipped – so the problem has occurred with two totally different sketches (also the current sketch is dead simple really).

Restarting Max does not restart the Arduino. Also, the problem is resolved not only by restarting Max but also by starting Zterm while the patch is running – that seems to jumpstart Max into listening to the port again.

Thanks for mentioning the keyspan thing – I should’ve mentioned that I plan to use a max232 with it. I am still going to try that since I’m really convinced after all my troubleshooting that the problem is either with the ftdi driver, max’s serial business, or the combination of the two. It seems like nobody has experienced this problem, though, since there haven’t been any other complaints here. My other next step is to change the patch so it logs the incoming serial data to a file with a timestamp so I can see when it stops. (Every 30 seconds, the Arduino sends a byte even if there is no activity)

Best case scenario is that the USB cable was bad – I haven’t checked back after replacing it. Smile

rob


March 1, 2010 | 12:15 am

Hey Rob I have the same problem. Have you found a solution? You can read about my problem here it sounds almost exactly the same as yours. I also have an installation in a public area. Here is a link to my problem. http://cycling74.com/forums/topic.php?id=25012&replies=2#post-125994


March 1, 2010 | 12:52 am

Oh yeah also I have to plugin the Arduino (via usb) after MaxMsp has booted then start MaxMsp patch in order to secure a connection. Do you have to do that?


Viewing 6 posts - 1 through 6 (of 6 total)