Society of Robots - Robot Forum
Software => Software => Topic started by: epicjr77 on April 15, 2008, 08:04:34 PM
-
Right now I have a rc robot with a Sabertooth dual 25A motor driver, and I just bought a parallax discovery kit with the basic stamp 2 micro controller. I am trying to write a program that looks something like this for a differential drive
pseudocode:
if bumper switch is open
drive straight until switch closes
if switch closes
pause
back up
rotate
and loop
The saber tooth looks like there is 2 ways to do it
#1) Mode 1: Analog Input
Analog input mode takes one or two analog inputs and uses those to set the speed and direction
of the motor. The valid input range is 0v to 5v. This makes the Sabertooth easy control using a
potentiometer, the PWM output of a microcontroller (with an RC filter) or an analog circuit.
Major uses include joystick or foot-pedal controlled vehicles, speed and direction control for
pumps and machines, and analog feedback loops.
#2) Simplified Serial Mode
Simplified serial uses TTL level single-byte serial commands to set the motor speed and
direction. This makes it easy to interface to microcontrollers and PCs, without having to
implement a packet-based communications protocol. Simplified serial is a one-direction only
interface. The transmit line from the host is connected to S1. The host’s receive line is not
connected to the Sabertooth. Because of this, multiple drivers can be connected to the same serial
transmitter. If using a true RS-232 device like a PC’s serial port, it is necessary to use a level
converter to shift the –10V to 10V rs-232 levels to the 0v-5v TTL levels the Sabertooth is
expecting. This is usually done with a Max232 type chip. If using a TTL serial device like a
microcontroller, the TX line of the microcontroller may be connected directly to S1.
Because Sabertooth controls two motors with one 8 byte character, when operating in Simplified
Serial mode, each motor has 7 bits of resolution. Sending a character between 1 and 127 will
control motor 1. 1 is full reverse, 64 is stop and 127 is full forward. Sending a character between
128 and 255 will control motor 2. 128 is full reverse, 192 is stop and 255 is full forward.
Character 0 (hex 0x00) is a special case. Sending this character will shut down both motors.
Which is easier? I would like to use choice #2 but I am not sure how to get the basic stamp to output numbers to control the motors?
As for the first way I dont even know where to start
Thanks-John
-
It also has an RC mode, which personally I think is the easiest.
Just send it a signal as if it was a servo, and you're done! The parallax should already come with servo code, and you plug the motor driver in the same way.
(the sabertooth manual will explain how to set it into RC mode)
-
the serial command in basic is SEROUT look it up online , there are plenty of examples
-
I have tried it in Rc mode and it seams like the sabertooth does what it wants, I have written a simple pulsout code just to send the wheels forward, and they will go forward stop reverse and keep changing speeds, almost like a RC car would when it runs out of range, but this is weird becuase when I put it in rc mode and use a remote controll it runs fine? any ideas?
-
Something else I noticed. Dimension engineering said to send pulses from 1000 micro sec to 2000, I have tried thatas well as between 650 to 850, and both do the same thing
-
Just to make sure . . . are your grounds common between your microcontroller and the sabertooth?
-
I am not sure, I am new at this, how would I do that? are you saying I should have a wire going from my 0v on my saber to my Vss on the BS2?
-
ok I figured it out, I ran a ground wire from the saber to the BS2, and then I ran it in normal servo pulse width 650 to 850, thanks for all your help