Christmas day, now programming

Hi,

So it felt like Christmas yesterday. I used the programming 4WD1TST2.BAS Jim offers as a test program to get the engines to run incrementally and, with much excitement, got my robotics running. LIFE! AT LAST! I am using a Sabertooth 2/10 Dual Channel motor controller with the middle wires removed so nothing is coming from the middle row of pins. I have the mixing board set up so mixing mode (switch 1) is off and switch two is down (linear). I have output pins set to low. The microcontroller is running through I/O pins ‘0’ and ‘1’ and I have installed a jumper for this set of pins for ‘VS’. Jumpers are also attached to the A, B and C buttons. (the pictures probably tell the story better than I do!).
Now I am starting to try and understand how to program my robotics. I have two engines and need for each engine to move in one direction, stop, and then move again in the other direction. For example- engine one move forward for 5 seconds, then stop, then backwards for 5. Engine two then does the same thing- and maybe a speaker beep for a second before each respective engine runs…you get it. I thought I was asking very little from my project…obviously not.

Below are codes I have tried for this type of action
and here is my hardware set-up for both the microcontroller and motor controller-any trouble shooting would be tremendous!
http://i235.photobucket.com/albums/ee241/isbndesign/forposting2.jpg
http://i235.photobucket.com/albums/ee241/isbndesign/forposting1.jpg

left_speed = 150 'Left stop value.
right_speed = 150 'Right stop value.
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]
l_dir = 0 'not too sure about what this does
r_dir = 0 'not too sure about what this does
cnt VAR byte 'activate for/next variable
loop: 'loops program to back to this point- starting gate for movement
sound 9, [100\880] 'speaker to beep
pulsout 0,1500 'as I understand output pin 0 is receiving signal for movement in 1500 direction (counter clockwise)- 500 is other direction (clockwise)
pulsout 1,1500 ’ as I understand output pin 1 is receiving signal for movement in 1500 direction (counter clockwise)- 500 is other direction (clockwise)
pause 20 'motors to stop for 20 milliseconds
sound 9, [100\880] 'speaker to beep
pulsout 0,500 'output pin 0 is receiving signal for movement in 1500 direction- 500 is other direction
pulsout 1,500 'output pin 1 is receiving signal for movement in 1500 direction- 500 is other direction
pause 20 'motors to stop for 20 milliseconds
goto loop

NOTHING HAPPENS- ACTUALLY I THINK THE SPEAKER BEEPS INCESSANTLY.

ANOTHER ONE:
temp var byte ’ Variable definitions…I based this from the sample program previously mentioned
left_speed var byte
right_speed var byte
l_dir var bit
r_dir var bit
left_speed = 150 ’ Left stop value.
right_speed = 150 ’ Right stop value.
low 0
low 1
l_dir = 0
r_dir = 0
main:
pulsout 0,500 'output pin 0 is receiving signal for movement in 500 direction- 1500 is other direction
pulsout 1,500 'output pin 1 is receiving signal for movement in 500 direction- 1500 is other direction
pause 20 'motors to stop for 20 milliseconds
goto main

Again, NOTHING HAPPENS! (banging my head against the table I am typing at)

And one more:
OUTPUT 0
cnt VAR byte
loop:
pulsout 0,1500 'motor from I/O pin 0 to move counterclockwise
PAUSE 30 'motor to pause for 30 milliseconds
FOR cnt = 1 to 50
pulsout 1,1500 'motor from I/O pin 1 to move counterclockwise
PAUSE 30 'motor to pause for 30 milliseconds
NEXT
noSwitch: GOTO loop

)))))gasping for air((((((

So….maybe I’ll take up knitting or perhaps underwater basket weaving.

Thanks for any help,

Brian Green

[code]count VAR byte
Left_speed VAR byte
right_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]

loop:
left_speed = 150 'Left stop value.
right_speed = 150 'Right stop value.
gosub genpulse ’ motors control for ~5 sec.

left_speed = 200 'Left CCW value.
right_speed = 150 'Right stop value.
gosub genpulse ’ motors control for ~5 sec.

left_speed = 100 'Left CW value.
right_speed = 150 'Right stop value.
gosub genpulse ’ motors control for ~5 sec.

left_speed = 150 'Left stop value.
right_speed = 150 'Right stop value.
gosub genpulse ’ motors control for ~5 sec.

left_speed = 150 'Left stop value.
right_speed = 200 'Right CCW value.
gosub genpulse ’ motors control for ~5 sec.

left_speed = 150 'Left stop value.
right_speed = 100 'Right CW value.
gosub genpulse ’ motors control for ~5 sec.
goto loop

genpulse:
for count = 1 to 250 'approx 5 second duration
pulsout 0,(left_speed * 10)
pulsout 1,(right_speed * 10)
pause 20
next
return[/code]

[size=200]Thanks a ton, Jim![/size]

Got an error message for the VAR command…It’ll do me good to keep educating and figure this out.

Thanks again, robotics kick a–,

Brian

Whoops, that’s because count is a command. I shouldn’t have used it for variable name. Change it to counter and it will work.

[code]counter VAR byte
Left_speed VAR byte
right_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]

loop:
left_speed = 150 'Left stop value.
right_speed = 150 'Right stop value.
gosub genpulse ’ motors control for ~5 sec.

left_speed = 200 'Left CCW value.
right_speed = 150 'Right stop value.
gosub genpulse ’ motors control for ~5 sec.

left_speed = 100 'Left CW value.
right_speed = 150 'Right stop value.
gosub genpulse ’ motors control for ~5 sec.

left_speed = 150 'Left stop value.
right_speed = 150 'Right stop value.
gosub genpulse ’ motors control for ~5 sec.

left_speed = 150 'Left stop value.
right_speed = 200 'Right CCW value.
gosub genpulse ’ motors control for ~5 sec.

left_speed = 150 'Left stop value.
right_speed = 100 'Right CW value.
gosub genpulse ’ motors control for ~5 sec.
goto loop

genpulse:
for counter = 1 to 250 'approx 5 second duration
pulsout 0,(left_speed * 10)
pulsout 1,(right_speed * 10)
pause 20
next
return[/code]