Uhhhhhh.......help anybody?

Hi there,

Well, i’ve banged my head against programming now for a few weeks and am getting close to my answer. However, i am still stumped on somethings that, perhaps, one of you may be able to explain to me in plain english.

Below is the code i am having trouble with for my application. Two items are stumping me.

First, I am having a problem sending one motor in the counterclockwise direction for, say, 10 inches, and the other motor in clockwise direction for 14 inches. Can i get my high torque motors to move in increments of approximately 1 inch with the basic atom and the sabertooth 2 x 10 combo?

Second (or in addition to), can i manipulate the code to provide more precision to the motor movements (maybe higher release of current)?

(and i guess a third would be…do i have anything superfulous in my code?)
Any help here would be tremendous.

Thanks and have a good day,

Brian

**counter VAR byte
movemm Var byte
move_left VAR byte
LR_speed VAR byte
UD_speed VAR byte
low 0 'output pin 0 is set to low for positive pulses
low 1 'output pin 1 is set to low for positive pulses
sound 9, [100\880, 100\988, 100\1046, 100\1175]

movemm = 1 'initialize motors
LR_speed = 150 'motor 1 stop value.
UD_speed = 150 'motor 2 stop value.
gosub genpulse '???motor control

movemm = 5 'want the motor to move 5 inches
LR_speed = 100 'motor 1 clockwise
UD_speed = 150 'motor 2 stop value
gosub genpulse '???motor control
pause 1500

movemm = 5 'want the motor to move 5 inches
LR_speed = 200 'motor 1 counter clockwise
UD_speed = 150 'motor 2 stop value
gosub genpulse '???motor control
pause 1500

movemm = 14 'want the motor to move 14 inches
LR_speed = 150 'motor 1 stop value
UD_speed = 200 'motor 2 counterclockwise
gosub genpulse '???motor control
pause 1500

movemm = 1
LR_speed = 150 'Left stop value.
UD_speed = 150 'Right stop value.
gosub genpulse '???motor control

end

genpulse:
for counter = 1 to (30*movemm) 'approx 5 second duration
pulsout 0,(LR_speed * 10) 'does this increase current to motors, perhaps providing more precision?
pulsout 1,(UD_speed * 10) 'does this increase current to motors, perhaps providing more precision?
pause 20 'is this the time it pauses for before running the program?
next
return**

You can not accomplish this using just a Sabertooth motor controller. You would have to add shaft encoders to your motors to be able to tell how far they have traveled and stop them at the appropriate distance.

Not that I am aware of.

8-Dale

A higher release of current would just cause the motor to generate more torque, which is not a factor in precision. I agree with linuxguy in that you will need shaft encoders for repeatable accurate results.

You can’t release current. Current draw is a result of applying a voltage to a load. Because the properties of the motor (load) do not change you can only vary the voltage. This is what the Sabertooth does.

E (voltage) / R (motors resistance) = I (current)

So if you want to rotate motors open loop (no encoder feedback) then you can only vary the voltage. You can turn the motor on for x amount of time, and adjust the time until the motor rotates the distance you want it to. However there are some variables that can cause errors. The load on the motor will effect how fast it rotates with the same voltage. Changes in the voltage supply will also change the results. So to make an open loop motor control system as accurate as possible you need to use a regulated supply so the motor controllers voltage does not change, and the motors load must always be consistent.

The fast answer is, in order to do accurate motor control you need encoders, but the fact is a workable open loop system can be made to work if the project has the right fit. However if the load on the motors varies wildly you are pretty much sunk. Good luck with it!

Thanks for the feedback,

An alternative startegy i can use will be to combine sensors with the motors. Writing a program that would go something like:

“motor 1 run, sensor 1 detects black tape, engine 1 shut off. Engines wait for 5 seconds, then run again until tape detected again and shut off. motor 2 runs, sensor 2 detects black tape, engine 2 shut off…”

I need to order 2 of the single line detectors…can anyone suggest changes in my previously posted code anything regarding the insertion of 2 detectors in my programming (1 for each motor)?

Thanks in advance,

Brian

So what you wanna build is a line tracing robot right?
Go to Society of Robots and they have a tutorial for that exact application.
I’m sorry I can’t help more with your programing, I’m in the same predictament as you, almost.

whats your dip switches set to?