I’m trying to get a program converted over from Basic Atom to Basic Atom Pro 28 syntax. I’m very new to this game and could sure use some help.
I have a EH1 kit with the IRPD that I’m using for a school project.
I am really having a lot of trouble with getting my head around how to change the code to make this thing work! I can’t get the H1 to walk at all. The servos seem to be maxxed out when this program starts up and just seems to go through the different branch routines one after another without responding to the IRPD (which I’m honestly not sure is really working correctly).
I’m using the h1walk1.bas file that Jim wrote for the Basic Atom:
[code]'Program: H1WALK.BAS
'Connections:
’ output pin 0 = right servo
’ output pin 1 = left servo
’ output pin 2 = center servo
’ output pin 8 = IRPD Left LED enable
’ output pin 9 = IRPD Right LED enable
’ input pin 10 = IRPD IR sensor output
mydir var byte
temp var byte
xx var byte
lsd var byte 'Holds left servo destination.
rsd var byte 'Holds right servo destination.
csd var byte 'Holds center servo destination.
lsp con 0 'Left servo connected to I/O pin 0.
rsp con 1 'Right servo connected to I/O pin 1.
csp con 2 'Center servo connected to I/O pin 2.
lsm con 150 'Left servo mid position.
rsm con 150 'Right servo mid position.
csm con 150 'Center servo mid position.
irpdl con 8 'IRPD Left LED enable.
irpdr con 9 'IRPD Right LED enable.
lift con 45 '(50max) Sets how far legs lift.
stride con 25 '(30max) Sets how far legs travel.
duration con 9 '(8-25) Variable to control how long pulses are generated.
'Change this to make the robot walk faster.
low 0
low 1
low 2
'loop:
’ pulsout lsp,1500 'left servo pulse output
’ pulsout rsp,1500 'right servo pulse output
’ pulsout csp,1500 'center servo pulse output
’ pause 20
'goto loop
goto start
setuplegs:
lsd=lsm 'Lift left side.
rsd=rsm
csd=csm+lift
gosub pout
lsd=lsm-stride 'Left side back.
rsd=rsm
csd=csm+lift
gosub pout
lsd=lsm-stride 'Lift right side.
rsd=rsm
csd=csm-lift
gosub pout
lsd=lsm-stride 'Right side forward.
rsd=rsm-stride
csd=csm-lift
gosub pout
lsd=lsm-stride 'Lower right side, robot sits flat.
rsd=rsm-stride
csd=csm
gosub pout
'pause 1000
start:
mydir = 0
high irpdl
pause 1 'Turn on IRPD left led.
low irpdl
pause 1 'turn off IRPD left led.
high irpdl
pause 1
mydir.bit0 = in10 'put a 1 in mydir.bit0 if no obstacle was detected.
low irpdl
pause 1
high irpdr
pause 1 'Turn on IRPD right led.
low irpdr
pause 1 'turn off IRPD right led.
high irpdr
pause 1
mydir.bit1 = in10 'put a 1 in mydir.bit1 if no obstacle was detected.
low irpdr
pause 1 'mydir holds;
'3 = no obstacle
'2 = left side obstacle
'1 = right side obstacle
'0 = left and right side obstacle
branch mydir,[backup,turnleft,turnright,forward] 'Make some decisions on the behavior.
forward: 'Go forward.
lsd=lsm-stride 'Left side up.
rsd=rsm-stride
csd=csm+lift
gosub pout
lsd=lsm+stride 'Stride one.
rsd=rsm+stride
csd=csm+lift
gosub pout
lsd=lsm+stride 'Right side up.
rsd=rsm+stride
csd=csm-lift
gosub pout
lsd=lsm-stride 'Stride two.
rsd=rsm-stride
csd=csm-lift
gosub pout
goto start
backup:
for xx = 1 to 4
lsd=lsm-stride
rsd=rsm-stride
csd=csm
gosub pout
next
for xx = 1 to 4
lsd=lsm-stride 'Left side up.
rsd=rsm-stride
csd=csm-lift
gosub pout
lsd=lsm+stride 'Stride one.
rsd=rsm+stride
csd=csm-lift
gosub pout
lsd=lsm+stride 'Right side up.
rsd=rsm+stride
csd=csm+lift
gosub pout
lsd=lsm-stride 'Stride two.
rsd=rsm-stride
csd=csm+lift
gosub pout
next
turnright:
for xx = 1 to 4
lsd=lsm-stride
rsd=rsm+stride
csd=csm
gosub pout
next
for xx = 1 to 3
lsd=lsm-stride 'Left side up.
rsd=rsm+stride
csd=csm+lift
gosub pout
lsd=lsm+stride 'Stride one.
rsd=rsm-stride
csd=csm+lift
gosub pout
lsd=lsm+stride 'Right side up.
rsd=rsm-stride
csd=csm-lift
gosub pout
lsd=lsm-stride 'Stride two.
rsd=rsm+stride
csd=csm-lift
gosub pout
next
goto start
turnleft:
for xx = 1 to 4
lsd=lsm+stride
rsd=rsm-stride
csd=csm
gosub pout
next
for xx = 1 to 3
lsd=lsm+stride 'Left side up.
rsd=rsm-stride
csd=csm+lift
gosub pout
lsd=lsm-stride 'Stride one.
rsd=rsm+stride
csd=csm+lift
gosub pout
lsd=lsm-stride 'Right side up.
rsd=rsm+stride
csd=csm-lift
gosub pout
lsd=lsm+stride 'Stride two.
rsd=rsm-stride
csd=csm-lift
gosub pout
next
goto start
pout:
for temp=1 to duration
pulsout lsp,lsd10 'left servo pulse output
pulsout rsp,rsd10 'right servo pulse output
pulsout csp,csd*10 'center servo pulse output
pause 20
next
return[/code]
Please, someone help!!! I’m probably in over my head at this point and I’m running out of time!