Problem with Roboclaw

Hi, a few weeks ago, I purchased a RoboClaw 2x5A Motor Controller(v4) for my two wheeled robot. I am controlling it with my Arduino Mega 2560 using packet serial mode. Driving motor 1 forward and backwards works perfectly. However, driving motor 2 backwards does not seem to work. In the backwards mode, I send 1 byte and the motor moves forward, and if I send 64 bytes it moves forward at a slower rate. I have also switched the wires, so I know it is not a problem with the motors. Is this a hardware issue, or do you have any other suggestions?
Thanks

Here is my simple test code:

[code]#include <SoftwareSerial.h>

#define address 0x80
int motorCommand = 5; // drive backwards M2
int byteValue = 100; // at slightly less than full speed
int checkSum;

SoftwareSerial roboclaw(6, 5); // setup serial on pin 6 and 5

void setup() {
roboclaw.begin(19200); // initiate communication with roboclaw

}

void loop() {
checkSum = address + motorCommand + byteValue;
roboclaw.write(address);
roboclaw.write(motorCommand);
roboclaw.write(byteValue);
roboclaw.write(checkSum&0x7F);
delay(20); // delay 20ms before sending the next packet
}

[/code]

Hello.

It is not clear to me what behavior you are describing when you say:

However, I briefly looked through your code and did not notice anything obviously wrong. Since you can get the expected behavior out of one motor channel, but not the other, it sounds like the board could be damaged in some way. You might try contacting the manufacturer, Ion Motion Control.

-Brandon

Hi,
Sorry for my lack of response to your helpful reply. It turns out that there was a hardware problem with the board. I ordered a new roboclaw, but now I’m facing a different problem:

I can control the motors perfectly with packet serial; however, I would like to use the controller to read motor encoder information. Here is my simple test code to read Roboclaw information.

[code]#include <SoftwareSerial.h>

#define address 0x80

SoftwareSerial roboclaw(12, 11);

void setup() {
Serial.begin(9600);
Serial.println(“test”);
roboclaw.begin(19200);

}

void loop() {

roboclaw.write(address);
roboclaw.write(90);
int x = roboclaw.available();
delay(10);
Serial.println( x);
}

[/code]

When the arduino sends command 90, the roboclaw is supposed to send back an error status. However, when I run this code, x only equals 0. I have tried multiple baud rates. I have also tried using the roboclaw arduino library, but I can’t get it to work. If you have any suggestions, it would be much appreciated.

I do not see anything wrong with your code, and it sounds like the RoboClaw is configured correctly in Packet Serial Mode if it works to control your motors. You might double check your connections to make sure you have the S2 Signal pin on the RoboClaw connected securely to pin 12 on your Arduino (which is RX according to your code).

-Brandon

Hi,
I am using a male to female jumper wire. I tried replacing it, but the board is still not reading any bytes.

As I said in my previous post, I do not see anything obviously wrong with your code. If your connections are also correct, I am not sure what might be causing the problem. I suggest contacting the manufacturer, Ion Motion Control, for further assistance.

-Brandon