scirpd01.bas

I tried out the scirpd01.bas program for my Octabot. This is the program available for download in the rovers section here - it doesn’t work right.

I found two bugs, which I fixed:

  1. The left motor running opposite of the right motor was not taken into consideration.

  2. The add to and subtract from motor speed calls were reversed.

I also changed the IRPD code to a subroutine patterned after what I have in my software. I added two constants to allow the minimum and maximum motor speeds to be easier to tweak. I also converted the main program loop to a while/wend construct because I despise backward gotos. I also speeded up the response time for my Octabot.

I believe this version of scirpd01.bas works as the original author intended now and it does indeed provide for a very fluid motion for the robot.

[code]’ By Lewis Mazer Jr 11-09-03
’ For Atom and New IRPD
'Slick1

’ Modified by Dale Weber [email protected] 24-Oct-2006
’ Add and Subtract speed calls were reversed - FIXED
’ Left Motor normal reverse direction was not taken into consideration - FIXED
’ Converted the main loop to a while/wend - I don’t like backward gotos
’ Changed the IRPD code to a subroutine taken from my Octabot software, with the
’ for - next loops removed to allow it to work better here.
’ Added two constants for min and max speed
’ Decreased the minimum speed to -1100 and increased the maximum speed to 1100
’ This new version seems to work as the original author intended.
'-----------Set Const---------------

’ Motor Setup

rightm con p1 ’ Change pin number to pin you are using for your right motor
rightd con 1 ’ Right Motor normal direction

leftm con p0 ’ Change pin number to pin you are using for your left motor
leftd con -1 ’ Left Motor normal direction


’ IRPD Setup

rights con p12 'Change pin number to pin you are using for your right led Voilet wire
lefts con p13 'Change pin number to pin you are using for your left led Blue wire
sensor var in14 'Change pin number to pin you are using for your sensor Yellow wire


’ Speed Control Setup

minspeed con -1100
maxspeed con 1100


'----------- Variables-----------

’ Motor Control

templ var bit
tempr var bit
left var sword
right var sword
rr var word

'----------- Initialize Motor Control Variables -----------

right = 0 'Begin with stopped vehicle
left = 0
rr = 100 'Change this ramp rate number higher to speed up response time,
’ Lower to slow


'----------- Main Program-----------

pause 1000

while 1
’ Check the IRPD for obstacle
gosub Check_IRPD

’ ------------------Servo Control -------------------------------------
’ Each pass adjusts the servo speed and direction slightly.
’ Subtracting from the servo speed builds toward reverse direction.
’ Adding to the servo speed builds toward forward direction.

branch tempr , [sub_left, add_left]

sub_left:
left = (left - rr) min minspeed ’ Miniumum Speed
goto done_left

add_left:
left = (left + rr) max maxspeed ’ Maximum Speed

done_left:

branch templ , [sub_right, add_right]

sub_right:
right = (right - rr) min minspeed 'min_speed
goto done_right

add_right:
right = (right + rr) max maxspeed 'max_speed

done_right:

'---- Output to the servos -----
servo rightm, right * rightd, 1
servo leftm, left * leftd, 1

wend

end

Check_IRPD
’ Check the Left IR Emitter
high lefts
pause 1
templ = sensor
low lefts
pause 1

' Check the Right IR Emitter	
high rights
pause 1
tempr = sensor
low rights
pause 1

return[/code]

This version should work as intended with any BOE-Bot, carpet rover, or similar robot.

8-Dale