Sabre Tooth 2x5 Motor Controller |
After a bit of experimentation I find the right setup for a simple serial connection at 9600 baud rate. In this mode you send the motor a value from 1 to 127 to control motor A (1=full reverse, 64=stop,127=full forwards), and 128 to 255 to control motor B in a similar fashion. In addition, sending a 0 instantly stops both motors.
To get things going, here's the first basic circuit I build:
Circuit diagram of Arduino connected to Sabre Tooth |
So that's the circuit, here it is built:
Arduino connected to Sabre Tooth, controlling a 12V DC motor. |
#include <SoftwareSerial.h>
SoftwareSerial MotorSerial(3,2);
void setup()
{
MotorSerial.begin(9600);
Serial.begin(9600);
Serial.println("Hello");
}
void loop()
{
//gradually take motors from full stop to full reverse
for(int i = 64; i >= 1; i--)
{
MotorSerial.write(i);
MotorSerial.write(i+128);
delay(100);
}
//take motors from full reverse, back to stop and then to full forwards
for(int i = 1; i <= 127; i++)
{
MotorSerial.write(i);
MotorSerial.write(i+128);
delay(100);
}
//take motors back down to full stop
for(int i = 127; i >= 64; i--)
{
MotorSerial.write(i);
MotorSerial.write(i+128);
delay(100);
}
}
In the setup function I simply initialize a software serial connection, which is transmitting via GPIO 3 at 9600 baud. The main loop simply sends different values to the motors to slowly get to full speed in one direction, then gradually go to full speed in the other direction, and eventually come back to a stop.
And finally, a video of it in action:
All good. Massive thumbs up to Dimension Engineering - this piece of kit isn't just really powerful - it's really easy to use. Not the cheapest of controlellers, but I'd highly recommend it if you're willing to spend a few pounds.
Terima kasih atas artikelnya :)
ReplyDeleteGood Luck