Asked — Edited

Analog Motor Speed With Joystick ?

Hello, I do not know if the subject has already been treated.

I buy a 2X5 sabertooth I configure like this: I control my motors with a joystick gamepad with the joystick panel, it works. The problem is that it is all or nothing: the motors run in full speed or not run. I will wish that I push the joystick a little, the engines run slowly and more quickly when I push the joystick away. A kind of analog response in fact.

Does anyone have an idea of ??configuration?

Skip to comments


Upgrade to ARC Pro

Elevate your robot's capabilities to the next level with Synthiam ARC Pro, unlocking a world of possibilities in robot programming.

United Kingdom

The sabertooth uses Simple Serial for control. Basically a command of 1-127 will drive the motor forwards and 128-255 will drive it in reverse. 0 will stop it.

So what you need to do is use the Joystick variables to change the SendSerial command.

SendSerial( digitalPort, baudRate, data, ... )

So you change the data to suit. You can use EZ-Script to get the Joystick variable and convert it to a number between 1 and 127 for forwards, depending on the Y value of the joystick, or 128 and 255 if reverse.

I don't have a Sabertooth to play with so can't really offer much more than that. The documentation I just read wasn't exactly great since it said it's 1-127 for forward and 1-127 for reverse too...

But some code example, which needs to be adjusted to suit (I also don't have ARC to hand so my joystick variable may be wrong);

# Convert the current joystick position to sabertooth command
# Joystick variable 0 to 100 (check this) therefore each increment equals 1.27 on the sabertooth
$sabertoothcmd = $JoystickY*1.27
# Round the number to an integer for the sabertooth
$sabertoothcmd = Round($sabertoothcmd,0)
# Send the command to the sabertooth
SendSerial(D0, 9800, $sabertoothcmd)
# Wait for the joystick to move before proceeding
# Loop back to the begining

Something like that.

Of course, there may be a place in the joystick control for putting the script which may remove some of the code, without ARC I am unsure as I don't use a joystick so have limited knowledge on that part.


Thanks, i will explore this idea !:)


I use a 2X12 Sabertooth and it works great. On the dip switch I have 1,3 & 6 on. I see Rich has a good example of a control script, he uses different numbers than I use though. Maybe he has documentation for a single motor drive. On mine it is Motor 1: 1 is full reverse, 64 is stop and 127 is full forward. Motor 2: 128 is full reverse, 192 is stop and 255 is full forward. So in Riches example I would add another speed for Motor 2 i.e SendSerial(D0, 9800, $sabertoothcmd, $Motor2speedcomand) ,also my baud rate is 38400. I know I don't have the same one your using but if you get in a bind my setup may help. Good luck!

United Kingdom

I have no documentation, my script was an example and needs adjusting to suit.

Your numbers (@purple) are probably the correct ones:)


Use a script for control motors with the joystick works but there is a response time, lack of reactivité

After several tries, the simplest was to configure my sabertooth in R/C and configure the joystick setting in "joystick servo control" It works perfectly:) And I chosen the speed maximal of motor by adjusting the min and max servo position in Joystick setting.

What I shall like making, it is to be able to modify these min and max servo position via a script: when I will press on a button of my gamepad, it makes pass in mode "superior speed "

Have you an idea for this ?