Shop OBEX P1 Docs P2 Docs Learn Events
Eb550 & PIR program problems — Parallax Forums

Eb550 & PIR program problems

BlindmonkBlindmonk Posts: 12
edited 2007-04-29 19:43 in Robotics
HI,

I am working on a Robot that will use the eb500 chip to move the BOE-BOT around and then to trigger the PIR sensor.

So far as of now I have gotten everything to work except I can't figure out a command that will cancel the loop for the PIR sensor and rerun the MAIN program. What I have now is listed below if you have any ideas it would really help.

' {$STAMP BS2}
' {$PBASIC 2.5}
LOW 12
LOW 13

PIR PIN 13 '
Pizo PIN 2 '

counter VAR Byte

LMotor CON 12
RMotor CON 13
CmdData VAR Byte


Main:

SERIN 0,84,[noparse][[/noparse]DEC1 CmdData]
DEBUG DEC1 CmdData
BRANCH CmdData,[noparse][[/noparse]runreset, fastleft, go, fastright, hold, back, gomain]
GOTO Main
DEBUG "connecting",CR

Connect:
PAUSE 1000
SEROUT 1,84,[noparse][[/noparse]"con 00:0C:84:00:42:E9",CR]
DEBUG "connected, attempt commands",CR



runreset:

DEBUG CLS
FOR counter = 40 TO 0
DEBUG HOME, "WARMING UP:", DEC2 counter
PAUSE 1000
NEXT

counter = 0

DEBUG HOME, "WAITING... "

DO
IF PIR = 1 THEN
DEBUG HOME, "Hello.."
OUTPUT 2
FREQOUT 2, 600, 3800
FREQOUT 2, 600, 3650
ENDIF

IF PIR = 0 THEN
DEBUG HOME, "Nothing"
ENDIF
LOOP

gomain:
END
GOTO Main

back:
PULSOUT LMotor,500
PULSOUT RMotor,1000
SEROUT 1,84,[noparse][[/noparse]"up-"]
GOTO Main

fastleft:
PULSOUT LMotor,650
PULSOUT RMotor,650
SEROUT 1,84,[noparse][[/noparse]"left-"]
GOTO Main

go:
PULSOUT LMotor,1000
PULSOUT RMotor,500
SEROUT 1,84,[noparse][[/noparse]"back-"]
GOTO Main

fastright:
PULSOUT LMotor,850
PULSOUT RMotor,850
SEROUT 1,84,[noparse][[/noparse]"right-"]
GOTO Main

Hold:
SEROUT 1,84,[noparse][[/noparse]"hold position "]
GOTO Main

Comments

  • FranklinFranklin Posts: 4,747
    edited 2007-04-27 02:50
    I think you need to draw out your code in a flow chart. Some of your labels fall through to net next function and some like the pir routine have no exit strategy at all. Also you have one of your motors on the same pin as your pir.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • BlindmonkBlindmonk Posts: 12
    edited 2007-04-29 19:12
    I drew it out and I changed the PIR pin to 14 and it works properly, the only thing that I need to figure out is how to end the loop and start the MAIN: program without pressing the reset pin.
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2007-04-29 19:43
    Hi, if you look at the DO-LOOP statement you can program an exit condition, for example this would cause the program to exit the loop when the pir was activated.

    DO WHILE PIR<1

    LOOP

    Jeff T.
Sign In or Register to comment.