Sabertooth with Raspberry Pi

Hello , is possible to control DC motors with Sabertooth 2X12 connected to PWM pins ( rspi 3 B => GPIO16 , GPIO 19) ?

GPIO16 will be connected to S1
GPIO 19 will be connected to S2

Sabertooth DIP Settings 1 OFF 2 ON 3 ON 4 OFF 5 ON 6 OFF

Am I right ? Coding structure given below, I don’t know how to control, what’s wrong with my program ?

[code]
#define Motr1 4 // GPIO 16
#define Motr2 12 // GPIO 19

pinMode(Motr1, OUTPUT);
pinMode(Motr2, OUTPUT);

softPwmCreate(Motr1,0,100); // PWM Initialization
softPwmCreate(Motr2,0,100);

void RobotMotion::Forward_Manual_Motion() on
{
softPwmWrite(Motr2, 13);
softPwmWrite(Motr1, 13);
}

void RobotMotion::Stop_motion()
{
qDebug()<< “Robot stop” ;
softPwmWrite(Motr1,14);
softPwmWrite(Motr2,14);
delay(1000);
}

void RobotMotion::Backward_motion()
{
softPwmWrite(Motr1, 16);
softPwmWrite(Motr2, 16);
}[/code]

How to control direction ? I have tried with this programming but motor not stopping properly. Kindly help me to solve the problem.

Thanks

Hi,

From your details concerning the Sabertooth DIP settings, your are currently in R/C input mode (switch 1 down, switch 2 up) using the following options:
switch 3 up: lithium protection mode off (good for NiMH/NiCd/alkaline batteries).
switch 4 down: independent mode
switch 5 up: exponential response
switch 6 down: microcontroller mode

From what we understand of Wiring Pi and the software PWM library, this allows you to create a PWM signal on a pin.

This is probably where your problem is, since the Sabertooth is set to R/C input mode, which means it expects something like this (specifically, this). But, your library produces something like this.
These two types of signals are incompatible.

Therefore, you have a two main options available:

]Change your Sabertooth settings to go into analog mode. Make sure to add an RC filter on the PWM output. There are some details in the manual on page 10./:m]
]Change your code in the RPi to output a proper R/C-type signal using a different library (example tutorial)./:m]

Sincerely,