Page 1 of 1

Arduino Mega 2560 : Serial 1,2,3 do not work?

PostPosted: Thu Oct 03, 2013 4:29 pm
by faisal
hi,

Im planning to use arduino mega 2560 to control 2 stepper motor driver SD02B from cytron. for the first driver, i have to connect its Tx0 of Arduino's Rx0 and its Rx to Arduino' Tx0. this is shown in the manual of the stepper motor driver SD02B. so i assume that for the second driver, i just connect it's Tx to arduino's Rx1 and and it's Rx to Arduino's Tx1.

in the Arduino IDE, i just modify the code provided by Cytron: i just added Serial1.begin(9600) in void setup() and and add few lines in void loop() Serial1.print('O'),Serial1.print('S') and so on, exactly copied the example given, but just added "1" in Serial.print and Serial.write.

but after i upload the program, nothing happened to the second motor, thou the first motor works. i checked the driver with test button on the driver, and the motor moved, which means motor and driver arent broken.

my question:
is it arduino's IDE problem? (since some example from arduino's website also cannot be uploaded, the IDE dont recognize some of the commands in the examples given)
or is it arduino mega 2560 hardware problem? (because i tested with some other simple program, but Serial 1, 2, and 3 still doesnt work)
or is it my lack of understanding of how to connect the second driver to the arduino hardware? ( if so, how how i actually connect them?)

Re: Arduino Mega 2560 : Serial 1,2,3 do not work?

PostPosted: Thu Oct 03, 2013 5:55 pm
by robosang
Share a few clear photos of the wiring connection and the sketch here.

Re: Arduino Mega 2560 : Serial 1,2,3 do not work?

PostPosted: Fri Oct 04, 2013 12:11 pm
by faisal
these are the sketch and the diagram for my project.

CODE: SELECT_ALL_CODE
void setup()
{
  Serial.begin(9600);
  Serial1.begin(9600);
 
}

void loop()
{
  Serial.print('O');  // turn on stepper motor 1
  Serial.print('S');  // set speed
  Serial.write(10);   // to 10

  Serial.print('<');  // rotate counterclockwise
  Serial.print('M');  // set micro-stepping to
  Serial.write(1);    // 1
  Serial.print('G');  // run the stepper motor
  delay(3000);

  Serial1.print('O');  // turn on stepper motor 2
  Serial1.print('S');  // set speed
  Serial1.write(10);   // to 10

  Serial1.print('<');  // rotate counterclockwise
  Serial1.print('M');  // set micro-stepping to
  Serial1.write(1);    // 1
  Serial1.print('G');  // run the stepper motor
  delay(3000);

}

Re: Arduino Mega 2560 : Serial 1,2,3 do not work?

PostPosted: Thu Oct 10, 2013 4:38 pm
by sich
I've tested your code with my Mega 2560 and it works on both uart channels. Perhaps one of the SD02B is not working well. Have u tried to switch the two driver on different uart channel?

Re: Arduino Mega 2560 : Serial 1,2,3 do not work?

PostPosted: Fri Oct 11, 2013 6:40 pm
by faisal
Thanks for confirming the connection and the code. i found out the problem yesterday. there were 2 big problems. one is the Arduino's new IDE. i changed to the older version (version 0022), after searching for solution in here and also arduino's website. the second is the driver. one of them dont really work. when i push the test button, the LEDs blink, but when i upload the program, the motor doesnt move LEDs dont blink.