my mac freezes when using arduino + max

hi everybody,
i just got my arduino board. i'm really happy with it because it works really well and is easy to use for someone who has no clue about phys. comp. (like me).
but one thing that really scares me is that my computer gets really bad freezes when using my board with max/msp.
i have simple test setup where i measure the light intensity with a photo-resistor. in max i use the serial object to get the data inside the computer and then use this data to drive a sine-oscillator. in the beginning it seems to work fine but sometimes, like when editing the patch or using some max-ui elements the computer doesn't react anymore: i can't use the mouse or the keyboard, but no error message or 'reboot screen' appear and for example iTunes keeps on playing...
really strange stuff and all i can do is shut down my computer by holding down the powerbutton. i'm on powerbook g4 ppc 1.67 Ghz, 1.5 gb ram, mac os 10.4.7, arduino 04 and max/msp 4.5.7.

maybe someone has an idea what could be wrong?
thanks a lot,
stephen

p.s: while using max/msp i always close the arduino-app so there should be no interference

// this is my max code

max v2;
#N vpatcher 37 59 851 872;
#P window setfont "Sans Serif" 9.;
#N vpatcher 37 59 637 459;
#P window setfont "Sans Serif" 9.;
#P newex 50 153 64 196617 fromsymbol;
#P newex 50 50 53 196617 sel 10 13;
#P newex 50 84 61 196617 zl group 64;
#P newex 50 116 40 196617 itoa;
#P inlet 50 30 15 0;
#P outlet 50 175 15 0;
#P connect 1 0 4 0;
#P connect 4 2 3 0;
#P connect 4 1 3 0;
#P connect 3 0 2 0;
#P connect 2 0 5 0;
#P connect 5 0 0 0;
#P pop;
#P newobj 133 256 58 196617 p asc2max;
#P message 58 454 37 196617 $1 20;
#P newex 58 478 53 196617 line~ 440;
#P user gain~ 58 595 24 100 158 0 1.071519 7.94321 10.;
#P message 116 700 29 196617 stop;
#P message 105 681 67 196617 startwindow;
#P newex 58 736 31 196617 dac~;
#P newex 58 539 40 196617 cycle~;
#P newex 58 396 31 196617 mtof;
#P newex 58 371 105 196617 scale 0 1024 84. 36.;
#N vpatcher 37 59 637 459;
#P window setfont "Sans Serif" 9.;
#P message 50 50 34 196617 1000;
#P message 95 51 14 196617 0;
#P inlet 50 30 15 0;
#P outlet 50 70 15 0;
#P outlet 95 71 15 0;
#P connect 2 0 4 0;
#P connect 4 0 1 0;
#P connect 2 0 3 0;
#P connect 3 0 0 0;
#P pop;
#P newobj 288 259 42 196617 p reset;
#P button 306 229 15 0;
#P number 58 326 48 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 296 318 70 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 226 317 45 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 227 287 40 196617 trough;
#P newex 291 289 40 196617 peak;
#P user multiSlider 203 378 238 183 0. 1000. 1 3433 15 0 0 2 0 0 0;
#M frgb 0 0 0;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P newex 478 404 32 196617 print;
#P number 461 383 117 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 133 116 15 0;
#P newex 133 143 52 196617 metro 20;
#P message 62 198 44 196617 getbaud;
#P window linecount 2;
#P comment 228 197 358 196617 bang will cause received characters to be printed in Max window , and a count of read characters to be sent from the right outlet , prepended by 'read';
#P window linecount 7;
#P comment 189 45 243 196617 Arguments are: 1. letter abbreviation for port or port name -- a is the first logical port in your computer , b is the second , etc. (default a) ; 2. baud rate (default 4800) ; 3. data bits (default 8) ; 4. stop bits (default 1) ; 5. parity (default 0 (no)) ;;
#P window linecount 1;
#P message 155 201 32 196617 print;
#P button 119 175 15 0;
#P newex 133 227 71 196617 serial b 9600;
#P connect 27 0 15 0;
#P connect 15 0 18 0;
#P connect 18 0 19 0;
#P connect 19 0 26 0;
#P connect 26 0 25 0;
#P connect 25 0 20 0;
#P connect 20 0 24 0;
#P connect 24 0 21 0;
#P connect 23 0 21 0;
#P connect 22 0 21 0;
#P connect 24 0 21 1;
#P connect 7 0 6 0;
#P connect 1 0 0 0;
#P connect 2 0 0 0;
#P connect 5 0 0 0;
#P connect 6 0 0 0;
#P connect 0 0 27 0;
#P connect 27 0 10 0;
#P connect 12 0 13 0;
#P connect 27 0 12 0;
#P connect 17 0 12 1;
#P connect 16 0 17 0;
#P connect 27 0 11 0;
#P connect 11 0 14 0;
#P connect 17 1 11 1;
#P pop;

// this is the arduino code:

int analogInput = 3;
int value = 0;

void setup(){
// declaration of pin modes
pinMode(analogInput, INPUT);
// begin sending over serial port
Serial.begin(9600);
}

void loop(){
// read the value on analog input
value = analogRead(analogInput);

// print out value over the serial port
Serial.println(value);
delay(20);
}

I think I'm having the exact same problem. I am on OS X 10.4.7 running MAX/MSP 4.5. Sometimes everything works fine, but often Max crashes and i can not force quit. Then i have to reboot.

Some things I've noticed:

If I connect my USB to the board before starting MAX and disconnect after quitting MAX, sometimes things work out. However, the last few times i've tried to quit max or close the patch that i have open, max has crashed.

If i disconnect while max is running, or try to upload firmware using the arduino app then max always crashes.

Once max crashes i can find nothing to bring it back. I was hoping to do a performance using my ardiuno board next weekend, but am now very concerned that the performance will have to go on without it. :frowning:

Hope someone can figure this one out. Thanks,

-peter

p.s. my ardiuno code looks like this:

/* Inputs to PD


  • This program sends data from a bunch of inputs to PD
  • over the serial port (works on PC: Windows and Linux, and MAC)
  • The code reads 3 potentiometers and 6 buttons plugged to Arduino
  • input and sends the data back to the computer.
  • On the other side there will be a PureData sketch running
  • comport2000 and will use the data to change a sound or video
  • file properties.
  • The buttons will be characterized with '1' or '0' depending on
  • their state, while potentiometers will be characterized with a
  • 10 bits integer in the range 0..1024
  • The first sensor will be marked with 'A' (ascii 65), the second
  • with 'B', and so on. The end of sensor reading is marked with
  • the characters EOLN (ascii 10).
  • (cleft) 2005 DojoDave for K3
  • @author: David Cuartielles
  • @context: ID3 - K3 - MAH - Sweden
    */

int ledPin = 13; // declare the pin with the LED
int pushButton = 0; // declare the value
int writeChar = 65; // declare the first reading as 'A'
int value = 0; // value to read the different sensors
int ledStatus = LOW; // status of the LED

void setup() {
pinMode(ledPin, OUTPUT); // declare the LED as output
Serial.begin(9600); // intitialize the serial port
}

void loop() {

writeChar = 65; //Sets the sensor idendifier
// character back to 'A'.

// read the pushbuttons
for(pushButton=2;pushButton<8;pushButton++){
Serial.print(writeChar, BYTE);
value = digitalRead(pushButton); // reads the value at a digital input
if (value)
{
Serial.print('0');
} else {
Serial.print('1');
}
Serial.println();
writeChar = writeChar + 1;
delay(10);
}

ledStatus = !ledStatus;
digitalWrite(ledPin, ledStatus);
}

It sounds like a problem with the USB drivers (from FTDI, the company that makes the USB chip on the Arduino board) we use to communicate with the Arduino board. Upgrading to the latest version might help. Try downloading them from http://www.ftdichip.com/Drivers/VCP.htm. Also, see http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1143197735 for information on uninstalling the old version of the driver (or you could try the simpler instructions from FTDI in http://www.ftdichip.com/Documents/InstallGuides/Mac_OS_X_Installation_Guide.pdf).