Society of Robots - Robot Forum
Electronics => Electronics => Topic started by: robotcoder on August 20, 2009, 11:48:18 PM
-
I own an Axon and I am thinking about purchasing a sabertooth 2X10 motor controller to control 2 DC motors and the question is how do I interface between the Axon and the sabertooth. Can I control the motors by code that is written and loaded on the Axon?
-
Can I control the motors by code that is written and loaded on the Axon?
Definately. I have a 2x10 and i have interfaced it via UART, and servo commands to my axon compatible board. The sabertooth modules are very easy to use and quite powerful. If you don't mind the cost they are a great investment.
-
Hi All,
I just had a question about the code for the Axon and Sabertooth, and I reliazed I have never posted any of it, so here is my quick code dump:
I connected the Sabertooth to the UART 2 connector, and using the UART protocol to communicate with it ... so, initialize the UARTH like this:
//G=Ground, T=Tx (connect to external Rx), R=Rx (connect to external Tx)
uartSetBaudRate(2, 38400); // set UARTH speed; SABERTOOTH
Admin has already included this function in sensor.c, which works perfectly, of course:
/************SABERTOOTH*******************/
void sabertooth(int m1, int m2)
{
//rprintfInit(uart2SendByte);//select uart2
uart2SendByte(m1);//send a command for motor 1
uart2SendByte(m2);//send a command for motor 2
}
Which I call from my main program, like this backup routing:
void Backup(int Time){
//Backup for Time in ms: Stop, Backup
sabertooth(64,192); //Stop
delay_ms(50); //Pause
sabertooth(64-50,192-50);//Bakup
delay_ms(Time);
}
OR
void SpinRight(int Time)
{
sabertooth(64+50,192-50);
delay_ms(Time);
}
I hope that help someone else ...
VOne
-
Thank you for including your code, I will use it.