Hi, I was recently using my Smc05a motor controller over xbee to drive two motors on my robot.
The motor controller had been working perfectly for the last five months until today when it failed unexpectedly during typical use.
I’ve had no issue with the motor controller before, and I haven’t changed the wiring nor the code in the time since then.
The code supplied is the exact code that was working and in use before the motor controller failed. It runs on the receiving Arduino Uno on the back of the robot and communicates with the transmitter (Arduino Uno + Xbee + Xbee shield + joystick shield) over serial.
I’ve already double-checked the Xbees in case they were the source of the problem but they’re still working properly.
Besides the Xbees, they’re are no other additional parts besides a switch, an indicator LED and of course, the motors.
It’s unlikely both motors failed at the exact same time and I’ve also inspected that they still work.
Furthermore I’ve swapped the batteries and replaced them with fully charged batteries to see if that was the issue.
The motor controller is powered by 4 AA batteries and so never exceeds 7V at any time.
The Serial Input pin of the motor controller is connected to the Arduino and doesn’t exceed 5.5V.
The reset pin is connected to pin 8 of the Arduino and I have a function in my code that takes it LOW and then HIGH with a 100ms delay before any serial data is sent as recommended.
I also have a safety switch in place so no data is transmitted to the motor controller when I upload code to the Arduino.
Again, I would like to say that I haven’t changed the wiring in some time and the motor controller was in use when it failed. The fault wasn’t with accidentally uploading code to the motor controller, overheating, lose wiring or drawing too much power. It failed in use when it stopped responding to serial commands over the Xbees.
Since the motor controller failed I’ve tried to run it without the Xbees and every other inessential component but to no avail.
I haven’t had any of the LEDs on the motor controller light since it broke down. As well as that there’s no evidence that the motor controller burned out or signs of damage on the chip.
Below is the code for the Arduino Receiver and Arduino Transmitter that was running when the motor controller was in use.
Transmitter:
const byte PIN_ANALOG_X = 0;
const byte PIN_ANALOG_Y = 1;
void setup()
{
Serial.begin(9600);
}
void loop()
{
int throttle = 0;
throttle = analogRead(PIN_ANALOG_Y);
throttle = map(throttle, 0, 1023, -127, 127);
int Direct = 0;
Direct = analogRead(PIN_ANALOG_X);
Direct = map(Direct, 0, 1023, -127, 127);
if(throttle>0 && (Direct >= -50 && Direct <= 50)) /*FORWARDS*/
{
Serial.println("F");
}
else if(throttle<0 && (Direct >= -50 && Direct <= 50)) /*BACKWARDS*/
{
Serial.println("B");
}
else if (Direct<-50 && throttle>=0) /*LEFT*/
{
Serial.println("L");
}
else if (Direct>50 && throttle>=0) /*RIGHT*/
{
Serial.println("R");
}
else if (Direct<-50 && throttle<0) /*LEFT BACKWARDS*/
{
Serial.println("A");
}
else if (Direct>50 && throttle<0) /*RIGHT BACKWARDS*/
{
Serial.println("D");
}
else /*STATIONARY*/
{
Serial.println("S");
}
delay(250);
}
Receiver:
int rst = 8; //reset pin of motor controller connected to digital pin 8
char msg = ' '; //contains the message from the arduino transmitter
int ledPin = 13;
void setup()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(rst, OUTPUT);
digitalWrite(rst, LOW);
delay(100);
digitalWrite(rst, HIGH); //reset pin must be kept high to operate
delay(100);
}
void loop()
{
//Note: 0x05 - BACK LEFT, 0x07 - BACK RIGHT
while(Serial.available() > 0) {
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
msg = Serial.read();
if(msg == 'F'){ /*FORWARDS*/
//motor_left 0x05 & 0x04
Serial.write(0x80); //start byte
Serial.write(0x00); //device byte
Serial.write(0x04); //motor # and direction, binary: 101
Serial.write(127); //motor speed
//motor_right 0x07 & 0x06
Serial.write(0x80); //start byte
Serial.write(0x00); //device byte
Serial.write(0x06); //motor # and direction, binary: 101
Serial.write(127); //motor speed
Serial.println("Received:" + msg);
}
if(msg == 'B'){ /*Backwards*/
//motor_left 0x05 & 0x04
Serial.write(0x80); //start byte
Serial.write(0x00); //device byte
Serial.write(0x05); //motor # and direction, binary: 101
Serial.write(127); //motor speed
//motor_right 0x07 & 0x06
Serial.write(0x80); //start byte
Serial.write(0x00); //device byte
Serial.write(0x07); //motor # and direction, binary: 101
Serial.write(127); //motor speed
Serial.println("Received:" + msg);
}
if(msg == 'L'){ /*LEFT*/
//motor_left 0x05 & 0x04
Serial.write(0x80); //start byte
Serial.write(0x00); //device byte
Serial.write(0x05); //motor # and direction, binary: 101
Serial.write(127); //motor speed
//motor_right 0x07 & 0x06
Serial.write(0x80); //start byte
Serial.write(0x00); //device byte
Serial.write(0x06); //motor # and direction, binary: 101
Serial.write(127); //motor speed
Serial.println("Received:" + msg);
}
if(msg == 'R'){ /*RIGHT*/
//motor_left 0x05 & 0x04
Serial.write(0x80); //start byte
Serial.write(0x00); //device byte
Serial.write(0x04); //motor # and direction, binary: 101
Serial.write(127); //motor speed
//motor_right 0x07 & 0x06
Serial.write(0x80); //start byte
Serial.write(0x00); //device byte
Serial.write(0x07); //motor # and direction, binary: 101
Serial.write(127); //motor speed
Serial.println("Received:" + msg);
}
if(msg == 'A'){ /*LEFT BACKWARDS*/
//motor_left 0x05 & 0x04
Serial.write(0x80); //start byte
Serial.write(0x00); //device byte
Serial.write(0x04); //motor # and direction, binary: 101
Serial.write(127); //motor speed
//motor_right 0x07 & 0x06
Serial.write(0x80); //start byte
Serial.write(0x00); //device byte
Serial.write(0x07); //motor # and direction, binary: 101
Serial.write(127); //motor speed
Serial.println("Received:" + msg);
}
if(msg == 'D'){ /*RIGHT BACKWARDS*/
//motor_left 0x05 & 0x04
Serial.write(0x80); //start byte
Serial.write(0x00); //device byte
Serial.write(0x05); //motor # and direction, binary: 101
Serial.write(127); //motor speed
//motor_right 0x07 & 0x06
Serial.write(0x80); //start byte
Serial.write(0x00); //device byte
Serial.write(0x06); //motor # and direction, binary: 101
Serial.write(127); //motor speed
Serial.println("Received:" + msg);
}
else if(msg == 'S'){ /*STATIONARY*/
//motor_left 0x05 & 0x04
Serial.write(0x80); //start byte
Serial.write(0x00); //device byte
Serial.write(0x05); //motor # and direction, binary: 101
Serial.write(0); //motor speed
//motor_right 0x07 & 0x06
Serial.write(0x80); //start byte
Serial.write(0x00); //device byte
Serial.write(0x07); //motor # and direction, binary: 101
Serial.write(0); //motor speed
Serial.println("Received:" + msg);
}
}
}
I appreciate in advance any help offered, thank you.
P.S I wasn’t able to upload any photos besides the invoice because I kept getting the error - “This attachment is invalid”