' ========================================================================= ' File....... WebBoeBot.BS2 ' Purpose.... Read Panasonic BL-C30A WebCam Stepper Motor Signals ' And drive Boe Bot ' Author..... Bryan Bergeron, Archetype Technologies, Inc. ' www.ArchetypeTech.com ' Hardware... Parallax BoeBot ' BS2p with (4) 10K pullup resistors TO VDD ' 4N35 optocouplers with (4) 4.7K series INPUT resistors ' Panasonic BL-C30A with stepper motors disconnected ' BoeBot draws 250ma @6V when moving, 80ma @ 6V stopped ' BL-C30A draws 300ma @12V ' Software... Internet Explorer w/ Panasonic Active X component installed ' E-mail..... bergeronbryan@yahoo.com ' Version.... 1.0 ' Using the web interface, click on the ' Up Button -> Forward ' Midle Button (round) -> Stop ' Down Button -> Back ' Right Button -> Right ' Left Button -> Left ' Modify rates to suit your bot's construction ' ' {$STAMP BS2p} ' {$PBASIC 2.5} ' ========================================================================= ' ====[ I/O ]============================================================= Front PIN 7 ' use 10K Pullup Resistor Back PIN 8 ' use 10K Pullup Resistor Right PIN 9 ' use 10K Pullup Resistor Left PIN 10 ' use 10K Pullup Resistor LeftServo PIN 12 ' Verify this matches your BoeBot RightServo PIN 13 ' ' ' ====[ Variables ]======================================================== STATE VAR Byte ' State of Machine ' ====[ Constants ]========================================================= S CON 1 ' Stop B CON 2 ' Back F CON 3 ' Front L CON 4 ' Left R CON 5 ' Right ' ====[ Initialization ]==================================================== State = S 'Stop ' ====[ Main ]============================================================== Main: IF (STATE = S) AND (Left = 0) THEN State = L PAUSE 800 ' Pause for signal train to complete ENDIF IF (STATE = S) AND (Right = 0) THEN State = R PAUSE 800 ' Right and left trains are longer ENDIF IF (STATE = S) AND (Front = 0) THEN State = F PAUSE 400 ' Front and back trains are shorter ENDIF IF (STATE = S) AND (Back = 0) THEN State = B PAUSE 400 ENDIF IF (STATE = R) AND (Left = 0) THEN State = S PAUSE 800 ENDIF IF (STATE = L) AND (Right = 0) THEN State = S PAUSE 800 ENDIF IF (STATE = F) AND (Front = 0) THEN State = S PAUSE 800 ENDIF IF (STATE = B) AND (Back = 0) THEN State = S PAUSE 800 ENDIF GOSUB Motor GOTO Main END Motor: ' DEBUG DEC State, CR IF STATE = S THEN PULSOUT LeftServo, 750 PULSOUT RightServo,750 PAUSE 20 ENDIF IF STATE = B THEN PULSOUT RightServo, 650 PULSOUT LeftServo, 850 PAUSE 20 ENDIF IF STATE = F THEN PULSOUT RightServo, 850 PULSOUT LeftServo, 650 PAUSE 20 ENDIF IF STATE = L THEN PULSOUT RightServo, 650 PULSOUT LeftServo, 650 PAUSE 20 ENDIF IF STATE = R THEN PULSOUT RightServo, 850 PULSOUT LeftServo, 850 PAUSE 20 ENDIF RETURN