Arduino Mega 2560 and Roboclaw 2x5A

Good day,

I need some help with Arduino Mega 2560 and Roboclaw 2x5A. I know that Roboclaw 2x5A have been discontinued for very long time, but that’s all I got for my project and I have to make it work. For information I used 12V DC motor with separate magnetic encoder. But for now, I just want to make the motor working clockwise and counter-clockwise.

I studied the datasheet and user manual, but all of it are for Arduino Uno. Can someone help me for the wiring between Roboclaw 2x5A and Arduino Mega 2560? And I will need some example code. For record, recently I worked Arduino with pinMode and analogWrite code, so I hope someone can help with the code that consist of pinMode and analogWirite, to make it easier for me to edit it to make my mechanism work as I want.

Hope someone can help me with this problem.

Regards,

Hello.

A TTL serial connection is probably the easiest way to connect the two. The SoftwareSerial library that the “SimpleSerial” example in the RoboClaw library uses should work with either an Arduino Mega 2560 or an Arduino Uno. You can read more about the SoftwareSerial library and which pins it works with on which Arduino boards in its documentation page on Arduino’s web site.

It sounds like you are new to programming the Arduino and might just need some general Arduino coding help, however, we recommend contacting Ion Motion Control directly via their forum as they might be able to better answer any detailed questions you have.

-Nathan

Thank you very much for your respond. I will try it first, I hope I can come back to you if there’s any problem in the further. Thank you.

Good day,

I have tried the sofware serial example, but it’s not working, I follow the code from the user manual:

BMSerial mySerial(10,11);
void setup() {
mySerial.begin(38400);
}
void loop() {
mySerial.write(1);
mySerial.write(-127);
delay(2000);
mySerial.write(64);
delay(1000);
mySerial.write(127);
mySerial.write(-1);
delay(2000);
mySerial.write(-64);
delay(1000);
mySerial.write(1);
mySerial.write(-1);
delay(2000);
mySerial.write(0);
delay(1000);
mySerial.write(127);
mySerial.write(-127);
delay(2000);
mySerial.write(0);

I follow the rule, I connected pin S1 to pin 11 and pin S2 to pin 10, but nothing happen. Where did I do wrong? Or maybe I did wrong in the wiring?

And actually this error come up when I put mySerial.write (0) in:

C:\Users\Lenovo\Downloads\Compressed\arduino\RoboClaw\examples\SimpleSerial\SimpleSerial.ino: In function 'void loop()':

SimpleSerial:26: error: call of overloaded 'write(int)' is ambiguous

   mySerial.write(0);

                   ^

C:\Users\Lenovo\Downloads\Compressed\arduino\RoboClaw\examples\SimpleSerial\SimpleSerial.ino:26:19: note: candidates are:

In file included from C:\Users\Lenovo\Downloads\Compressed\arduino\RoboClaw\examples\SimpleSerial\SimpleSerial.ino:2:0:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src/SoftwareSerial.h:102:18: note: virtual size_t SoftwareSerial::write(uint8_t)

   virtual size_t write(uint8_t byte);

                  ^

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Stream.h:26:0,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:232,

                 from sketch\SimpleSerial.ino.cpp:1:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:49:12: note: size_t Print::write(const char*)

     size_t write(const char *str) {

            ^

SimpleSerial:31: error: call of overloaded 'write(int)' is ambiguous

   mySerial.write(0);

                   ^

C:\Users\Lenovo\Downloads\Compressed\arduino\RoboClaw\examples\SimpleSerial\SimpleSerial.ino:31:19: note: candidates are:

In file included from C:\Users\Lenovo\Downloads\Compressed\arduino\RoboClaw\examples\SimpleSerial\SimpleSerial.ino:2:0:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src/SoftwareSerial.h:102:18: note: virtual size_t SoftwareSerial::write(uint8_t)

   virtual size_t write(uint8_t byte);

                  ^

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Stream.h:26:0,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:232,

                 from sketch\SimpleSerial.ino.cpp:1:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:49:12: note: size_t Print::write(const char*)

     size_t write(const char *str) {

            ^

exit status 1
call of overloaded 'write(int)' is ambiguous

That appears to be a problem with the BMSerial library. It appears that Ion Motion Control has changed their library and the latest files from their site use the SoftwareSerial library I mentioned before instead of the BMSerial library. You might try downloading and installing the latest RoboClaw Arduino library from Ion Motion Control’s web site or contacting Ion Motion Control directly.

-Nathan