Diecimila+ Max/MSP trouble

Hi All,
I just got a Diecimila and ran the tutorials and it works perfectly, yet, I have been unable to get Arduino2Max working. After running the code, and loading the patch (and changing the serial port), the Diecimila receives information but fails to transmit anything, as indicated by both the max patch as well as the transmit LED. Has anyone else had this problem? Suggestions? I would really like to use Arduino2Max.

I eventually got the SimpleMessageSystem patch to work, however it took much troubleshooting to figure out it would only work if I started the metro after 11 seconds, anything before would create the same problem outlined above (and I tried the same 11 sec technique on Arduino2Max, but nothing).

I should note that I'm using Max/MSP v. 4.6.3

Any help would be much appreciated! Thank you.

hi

I wrote the Arduino2max patch, but I haven't used it in months... and I don't have MAX on the machine I'm using at the moment so I can't check it.

Can you give some more details about what happens? Once you have uploaded the patch to the Diecimila, do you quit the Arduino? Max need to use the Arduino's USB port, so you can't have them both open. Which lights flash on the Arduino: just the RX?
What happens if you put a print box on the outlet of the serial port in Max?

D

Hi,

Hi Daniel,

I am having the same problem. Everything works fine with my Arduino NG with the ATMEGA8, but not on the Diecimilia.

Yes, I quit Arduino.

Yes, just the RX light flashes - it's receiving communication from Max as the sample rate affects the rate.

Attaching a print to the serial gives me an alternating "status: read 0" and status: write 1"

Thoughts?

Hey Folks,

I will have a copy of MAX in a week or so and will fix it then.

I don't mind doing this, but I didn't write A2M with the intention of supporting it , so in the meantime it would be in the Arduino spirit if you guys take a shot at troubleshooting it and perhaps discovering the problem yourselves. I say this because Arduino code and examples that we use here are not products, they're experimental things that are meant for learning and collaboration.. so we're in this together. One day maybe I'll need to ask you guys for an updated version of the code, that would be good. :slight_smile:

Ok here are some troubleshooting suggestions:

  • add a delay(1000) to the Arudino code to slow down the serial coming back from it, then open the Arduino serial monitor and see what, if anything is coming back

  • if nothing is coming back, load the code below into the Diecimila. It will blink once if an 'r' character is received by the serial port. Then send an "r" character by clicking the appropriate box inside the patcher.

With these two methods you will be able to tell where the problem is: coming into the Arduino, or going out. Post the results if either experiment reveals something....

D

/*  
 *  Arduino2Max
 *  Send pin values from Arduino to MAX/MSP
 *  
 *  Arduino2Max.pde
 *  ------------  
 *  Test sketch to see if 'r' character is received. 
 *  ------------
 *  Copyleft: use as you like
 *  by djmatic 
 *  Based on a sketch and patch by Thomas Ouellet Fredericks  tof.danslchamp.org
 *  
 */


int x = 0;                             // a place to hold pin values

void setup()
{
  Serial.begin(115200);                // 115200 is the default Arduino Bluetooth speed
}


void loop()
{ 

if (Serial.available() != -1){         // Check serial buffer for characters
        
    if (Serial.read() == 'r') {       // If an 'r' is received then read the pins

  digitalWrite(13, HIGH);   // sets the LED on
  delay(300);                   // delay 
  digitalWrite(13, LOW);    // led off 
  delay(300);                   // delay
    }
  }
}

Ok

I just got another copy of MAX (thank you , University of * *), and

initial indications are that you only need to change this line from

if (Serial.available() != -1){         // Check serial buffer for characters

to

if (Serial.available() > 0){         // Check serial buffer for characters

I'm still testing.. Mellis, does the above change seem logical? In terms of code I am still a copy and paste kind of guy.

D

PS: another issue, although small, is that any change to serial port settings in MAX triggers the Diecimila's auto reset. So far, applying the above code change and waiting a few seconds before starting the serial connection seems to work perfectly!

Let me know if it works for you too, and I'll post up a new version.

here is the revised Arduino-side code, please test and post your results. Seems to work perfectly.

/*  
 *  Arduino2Max
 *  Send pin values from Arduino to MAX/MSP
 *  
 *  Arduino2Max.pde
 *  ------------  
 *  Latest update: September 2007
 *  ------------
 *  Copyleft: use as you like
 *  by djmatic 
 *  Based on a sketch and patch by Thomas Ouellet Fredericks  tof.danslchamp.org
 *  
 */


int x = 0;                              // a place to hold pin values
int ledpin = 13;

void setup()
{
  Serial.begin(115200);               // 115200 is the default Arduino Bluetooth speed
  digitalWrite(13,HIGH);              ///startup blink
  delay(600);
  digitalWrite(13,LOW);
  pinMode(13,INPUT);
}



void loop()
{ 

if (Serial.available() > 0){         // Check serial buffer for characters
        
    if (Serial.read() == 'r') {       // If an 'r' is received then read the pins
    
for (int pin= 0; pin<=5; pin++){      // Read and send analog pins 0-5
    x = analogRead(pin);
    sendValue (x);
    }

for (int pin= 2; pin<=13; pin++){     // Read and send digital pins 2-13
    x = digitalRead(pin);
    sendValue (x);
    }
  
    Serial.println();                 // Send a carriage returnt to mark end of pin data. 
    delay (5);                        // add a delay to prevent crashing/overloading of the serial port
  
  }

 }
}

void sendValue (int x){              // function to send the pin value followed by a "space". 
 Serial.print(x);
 Serial.print(32, BYTE); 
}