Shop OBEX P1 Docs P2 Docs Learn Events
Boe-Bot IR code from manual for roaming doesn't work help!! — Parallax Forums

Boe-Bot IR code from manual for roaming doesn't work help!!

dasmith6975dasmith6975 Posts: 6
edited 2015-01-02 21:58 in BASIC Stamp
built the boe-bot with ir sensor for navigation and used code from manual but it doesn't work, anyone know why?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2014-12-29 08:42
    As far as I know, the Roaming with BoeBot program works fine and the hardware hookup in the manual works as well. The hardware and the software have been around and in use for many years. When you say "doesn't work" what do you mean? Have you used the IR LEDs and IR receiver for other things/exercises and did they work properly?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-12-29 10:10
    You should have already done the IR Test programs before you got to this point. I would re-run those programs to verify functionality of the IR detectors.
  • dasmith6975dasmith6975 Posts: 6
    edited 2014-12-29 16:22
    i ran ir test checked good, when i download program robot just goes forward no detecting i used code from 2.2 and 3.0 manual.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-12-29 17:07
    That sounds like a code issue. Did you type the code in? I am thinking there is something missing that is preventing it from doing what is intended.
  • dasmith6975dasmith6975 Posts: 6
    edited 2014-12-30 17:33
    i re typed code 4 times and all it does is go forward here is the code.
    '
    [ Title ]
    ' Robotics with the Boe-Bot - RoamingWithIr.bs2
    ' Adapt RoamingWithWhiskers.bs2 for use with IR object detectors.
    ' {$STAMP BS2} ' Stamp directive.
    ' {$PBASIC 2.5} ' PBASIC directive.

    DEBUG "Program Running!"

    '
    [ Variables ]

    irDetectLeft VAR Bit
    irDetectRight VAR Bit
    pulseCount VAR Byte

    '
    [ Initialization ]

    FREQOUT 4, 2000, 3000 ' Signal program start/reset.

    '
    [ Main Routine ]

    DO
    FREQOUT 8, 1, 38500 ' Store IR detection values in
    irDetectLeft = IN9 ' bit variables.

    FREQOUT 2, 1, 38500
    irDetectRight = IN0

    IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
    GOSUB Back_Up ' Both detect obstacle
    GOSUB Turn_Left ' Back up & U-turn (left twice)
    GOSUB Turn_Left
    ELSEIF (irDetectLeft = 0) THEN ' Left detects
    GOSUB Back_Up ' Back up & turn right
    GOSUB Turn_Right
    ELSEIF (irDetectRight = 0) THEN ' Right detects
    GOSUB Back_Up ' Back up & turn left
    GOSUB Turn_Left
    ELSE ' None detect
    GOSUB Forward_Pulse ' Apply a forward pulse
    ENDIF ' and check again
    LOOP

    '
    [ Subroutines ]

    Forward_Pulse: ' Send a single forward pulse.
    PULSOUT 13,850
    PULSOUT 12,650
    PAUSE 20
    RETURN

    Turn_Left: ' Left turn, about 90-degrees.
    FOR pulseCount = 0 TO 20
    PULSOUT 13, 650
    PULSOUT 12, 650
    PAUSE 20
    NEXT
    RETURN
    Turn_Right:
    FOR pulseCount = 0 TO 20 ' Right turn, about 90-degrees.
    PULSOUT 13, 850
    PULSOUT 12, 850
    PAUSE 20
    NEXT
    RETURN

    Back_Up: ' Back up.
    FOR pulseCount = 0 TO 40
    PULSOUT 13, 650
    PULSOUT 12, 850
    PAUSE 20
    NEXT
    RETURN
  • ercoerco Posts: 20,256
    edited 2014-12-31 07:00
    You should have already done the IR Test programs before you got to this point. I would re-run those programs to verify functionality of the IR detectors.

    +1. Sensors (m)aligned and working properly? Servos centered? New batteries? If all else fails, add some debug statements in your code to monitor sensor output and program flow.
  • PublisonPublison Posts: 12,366
    edited 2014-12-31 07:20
    When posting code, its good to use this link:

    attachment.php?attachmentid=78421&d=1297987572

    It keeps the code formated to see if there are the spaces needed in the code.
  • GenetixGenetix Posts: 1,749
    edited 2014-12-31 10:45
    Check the resistor value you are using with the IR LEDs since you may have changed it from the original value.
    As the resistor value increases the LED gets dimmer and the detection distance drops.
    Try walking up to your BOE-Bot and put something in front of it to see if it's near-sighted.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-12-31 11:50
    I'm not clear if you only ran the IR test before you typed in the main code or if you have run it since the main code doesn't seem to work. You should be able to run the IR test now to confirm the IR sensors are still working. If they work with that test then they should be working with the IR roaming code. If not my best guess (other than a code issue) would be low batteries and the robot resetting. However if that was happening you should be hearing the Piezo beep more than just the one time at the start of the program.
  • ajwardajward Posts: 1,130
    edited 2014-12-31 14:38
    It might help if you could post a picture of your circuit wiring. Some of these circuits can be wired wrong very easily... trust me, I =know=!

    Amanda
  • dasmith6975dasmith6975 Posts: 6
    edited 2014-12-31 16:49
    i re-wired it and rewrote program and it's like i run test for ir's no problem but when i go roam it just go forward and ir's don't do anything.
  • GenetixGenetix Posts: 1,749
    edited 2015-01-01 16:05
    Try new batteries.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-01 19:43
    Genetix wrote: »
    Try new batteries.
    That is what I was going to suggest also. Or, if you have a wall wart try it just for testing.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2015-01-01 20:15
    It would be easy to tell if it were batteries, as per my previous reply, you would hear the piezo repeatedly rather than just once.
  • ercoerco Posts: 20,256
    edited 2015-01-02 21:58
    Try this condensed program. Bot should drive forward until either of the IR sensors is triggered, then just stop. The quickest drive & IR sensor test I can think of. Untested but it should work.
     ' {$STAMP BS2} ' Stamp directive.
     ' {$PBASIC 2.5} ' PBASIC directive.
    
     irDetectLeft VAR Bit
     irDetectRight VAR Bit
     
     DO
     PULSOUT 13,850   ' drive forward
     PULSOUT 12,650
    
     FREQOUT 8, 1, 38500 ' Store IR detection values in
     irDetectLeft = IN9 ' bit variables.
     FREQOUT 2, 1, 38500
     irDetectRight = IN0
    
     IF (irDetectLeft = 0) OR (irDetectRight = 0) THEN exit ' exit if either sensor triggered
     PAUSE 10
     LOOP
    
     exit: STOP
     END
    
Sign In or Register to comment.