nervous robot

nickcinquino

New Member
Hi Picaxe Forum,
I'm messing with a simple robot, 14M2 controlled, two motors controlled by dual L9110 H-bridge board. On running the program, which is set up for parallel process, if the bump switch is engaged during highs of "search", outputs go nuts for unknown reason (it simulates perfectly). If the bump switch is hit during a pause in "search", it works fine. Any thoughts on whats wrong? Very likely crazy code on my part but I'll be darned if I can find a bug! Thanks for any help.

start0:
output c.4, b.5, c.2, c.1
input b.3 ;high c.4, c.2 fwd
symbol sw1 = pinb.3 ;high b.5, c.1 rev
if sw1 = 1 then search ;high c.4, c.2 turn L
low c.4, b.5, c.2, c.1 ;high b.5, c.1 turn R
#simtask all
goto start0


start1:
if pin3 = 1 then evadeR
goto start1


search:
for b0 = 1 to 2
high c.4
high c.2
pause 1500
low c.4
low c.2
pause 800
high b.5
high c.2
pause 800
low b.5
low c.2
pause 800
high c.4
high c.2
pause 1500
low c.4
low c.2
pause 800
high b.5
high c.2
pause 800
low b.5
low c.2
pause 200
next b0
goto start0


evadeR:
suspend 0
high b.5, c.1
pause 1000
low b.5, c.1
pause 300
high c.4, c.1
pause 1000
low c.4, c.1
pause 200
resume 0
goto start1
 
I have never had much luck with multiple processes and found that interrupts can act unexpectedly also. I think I would start with your start0 routine. It seems to be initializing everything, things that only need to be done once. If you just do a "nothing" loop at the end of initializing everything, you might see different results. Like this: a=0:do:loop until a=1. I think when you have more than one process, you have to be careful with variables and such. I don't think basic is good for multi-processes. Figure out a way to do it with just one main process, it will work better.
 
Back
Top