Shop OBEX P1 Docs P2 Docs Learn Events
FastIrRoaming — Parallax Forums

FastIrRoaming

ltmhallltmhall Posts: 102
edited 2007-02-26 00:58 in Robotics
I recently bought the parallax IR emitter/led pair and was trying the FastIrRoaming program on pg 252-253 of the boe bot manual and it seems to be working funny. When both pair sense an object it seems to reverse in a jerking fashion. When I place my hand right in front of both senors it backs up okay. However when I place my hand in front of both sensors from further away my robot starts jerking. The right and left sensor seem to work okay independently from each other. Initially I tried RoamingWithIr.bs2 and it worked perfect. I am not using parallax servo motors. But I dont thinks its the servos because when I disconnected the
servos and just monitored the leds( pin 4 and pin 5) it seems
that when it first detects an object these leds are flickering, which I
think is causing the problem.I tried to experiment with the pulseleft and pulseright values but it had no effect. Is the basic stamp trying to read the sensors to quickly.

Any help would be appreciated.

' Robotics with the Boe-Bot - FastIrRoaming.bs2
' Higher performance IR object detection assisted navigation
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
irDetectLeft VAR Bit ' Variable Declarations
irDetectRight VAR Bit
pulseLeft VAR Word
pulseRight VAR Word
FREQOUT 4, 2000, 3000 ' Signal program start/reset.
DO ' Main Routine
FREQOUT 3, 1, 38500 ' Check IR Detectors
irDetectLeft = IN2
FREQOUT 1, 1, 38500
irDetectRight = IN0
' Decide how to navigate.
IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
HIGH 4
HIGH 5
pulseLeft = 650
pulseRight = 850
ELSEIF (irDetectLeft = 0) THEN
HIGH 5
pulseLeft = 850
pulseRight = 850
ELSEIF (irDetectRight = 0) THEN
HIGH 4
pulseLeft = 650
pulseRight = 650
ELSE
LOW 4
LOW 5
pulseLeft = 850
pulseRight = 650
ENDIF
PULSOUT 15,pulseLeft ' Apply the pulse.
PULSOUT 14,pulseRight
PAUSE 15
LOOP

Post Edited (ltmhall) : 1/19/2007 1:51:03 AM GMT

Comments

  • Steve JoblinSteve Joblin Posts: 784
    edited 2007-01-18 15:30
    1.· You say you are not using Parallax Servos... what make/model are you using?

    2.· Servos need to receive a pulse signal every 20ms ... It looks like you are not allowing enough time delay between sending out your pulses...

    PULSOUT 15,pulseLeft
    PULSOUT 14,pulseRight
    PAUSE 20
  • ltmhallltmhall Posts: 102
    edited 2007-01-18 16:27
    1. I'm using HITEC HS-422 Delux servos. I really don't think its the servos. It seems when I
    ··· place my hand right in front of it it works. However when I placed my hand in front
    ··· right when it starts to sense, my led's kind of flicker, this is even when I disconnect the servos

    2. I tried

    ·· PULSOUT 15,pulseLeft
    ·· PULSOUT 14,pulseRight
    ·· PAUSE 20
    ·· and it didn't work.

    ··

    Post Edited (ltmhall) : 1/19/2007 1:17:27 PM GMT
  • ltmhallltmhall Posts: 102
    edited 2007-01-19 13:16
    Has anyone ever had a problem with the fast IR roaming ?
  • Steve JoblinSteve Joblin Posts: 784
    edited 2007-01-19 14:31
    Your code seems to have extra commands that are not in the code in the book...your program has HIGH and LOW commands... I think that is the problem...
    Your servos should be connected to pins 12 and 13
    Your IR LED's should be connected to Pins 8 and 2
    Your IR Detectors should be connected to Pins 9 and 0
    Your speaker should be connected to Pin 4

    Try to copy and paste this code...
    ' Robotics with the Boe-Bot - FastIrRoaming.bs2
    ' Higher performance IR object detection assisted navigation
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ·
    DEBUG "Program Running!"
    irDetectLeft VAR Bit ' Variable Declarations
    irDetectRight VAR Bit
    pulseLeft VAR Word
    pulseRight VAR Word
    FREQOUT 4, 2000, 3000 ' Signal program start/reset.
    DO ' Main Routine
    FREQOUT 8, 1, 38500 ' Check IR Detectors
    irDetectLeft = IN9
    FREQOUT 2, 1, 38500
    irDetectRight = IN0
    ' Decide how to navigate.
    IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
    pulseLeft = 650
    pulseRight = 850
    ELSEIF (irDetectLeft = 0) THEN
    pulseLeft = 850
    pulseRight = 850
    ELSEIF (irDetectRight = 0) THEN
    pulseLeft = 650
    pulseRight = 650
    ELSE
    pulseLeft = 850
    pulseRight = 650
    ENDIF
    PULSOUT 13,pulseLeft ' Apply the pulse.
    PULSOUT 12,pulseRight
    PAUSE 15
    LOOP ' Repeat main routine

  • ltmhallltmhall Posts: 102
    edited 2007-01-19 14:49
    The HIGH AND LOW commands are just used to flash LED'S when the senors sense zero.
    I don't this will cause a problem, but I will remove them and connect everything like you said.
  • ltmhallltmhall Posts: 102
    edited 2007-01-21 03:37
    I tried setting up the circuit the exact way the boe bot manual shows
    and I removed the HIGH and LOW commands, but it still reacts the
    same way.

    DOES ANYONE ELSE HAVE ANY SUGGESTIONS ?

    Thanks for any suggestions
  • whiditwhidit Posts: 1
    edited 2007-02-24 02:08
    I have this same problem. I believe it is the result of a threshold and bit of noise.
    As a bot approaches an obstacle, the IR sensor begins to get some return signal, the voltage on the output is more than zero, but less than the threshold. So no detection. As the bot gets closer the return signal grows just strong enough for the sensor to output the threshold voltage. If there is any noise in the system (electrical or optical) the signal will bounce back and forth across the threshold. So you get flicker.

    The program works with your hand because you stick your hand closer to the sensor so the signal is well above the threshold. It would actually be very hard to hold your hand at the exactly right position to get flicker.

    The robot is good at finding the flicker band because it moves slowly and precisely from out-of-range to within-range.

    I have not solved the problem yet. I am thinking about a scheme that uses two frequencies for the IR lamp (like is done for distance measuring p271). When the bot gets it first flicker on the less sensitive frequency, then check the output at the higher sensitivity frequency and use that signal, should be cleaner.

    I'd like to hear if you find another solution.
  • WarrlokWarrlok Posts: 77
    edited 2007-02-26 00:58
       ' IRDISTANCEDETECTAND AVOID ramping    SERVO
    

    'Ramping is a common term FOR making the servos speed up AND slow down gradually, no sudden starts, stops OR direction changes.  FOR hill detection AND climbing, it's crucial to have a reliable ramping routine for Boe-Bot navigation.  Without it, the Boe-Bot's abrupt motions cause acceleration measurements to get mixed in with the tilt measurements.  This in turn gives the Boe-Bot a false reading of the hill's steepness.
    

     'THIS PROGRAM WAS PIECED TOGETHER FROM EPROMNAVIGATION AND IR DISTANCE DETECT
    

     'IF the Boe-Bot starts out going backward instead of forward
    

    'Your servo cables may need TO be swapped.  The cable connected TO the Boe-Bot's left servo should be connected to the P13 servo port on the Board of Education.  The cable connected to the right servo should be connected to the P12 port.
    

    
    
    
    
    'v        Fine tune the distances so that they make your Boe-Bot travel in a rectangle.  The turn at the first corner should be left, 90°.  The second should be right, 270°, AND the third should be another left at 90°.
    

    
    
    ' -----[noparse][[/noparse] Title ]-----------------------------------------------------------------------
       ' IR DISTANCEDETECT AND AVOID
    

    '{$STAMP BS2}
    

    '{$PBASIC 2.5}
    

    
    
    ' -----[noparse][[/noparse] EEPROM Data ]--------------------------------------------------------
    

    ' Two DATA directives store the following navigation instructions:
    

    ' Forward, left 90-degrees, forward, right 270-degrees forward,
    

    ' left 90-degrees, forward, stop.
    

    
    
    ' -----[noparse][[/noparse] Variables ]----------------------------------------------------------
    

    
    
    counter        VAR     Byte                  ' FOR...NEXT loop counter
    

    index          VAR     Byte                  ' Points to EEPROM instructions
    

    instruction    VAR     Byte                  ' Stores navigation instruction
    

    pulseCount     VAR     Byte                  ' Stores navigation distance
    

    
    
    pulseLeft      VAR     Word                  ' Stores pulse to left servo
    

    pulseLeftOld   VAR     Word                  ' Previous pulse to left servo
    

    
    
    pulseRight     VAR     Word                  ' Stores pulse to right servo
    

    pulseRightOld  VAR     Word                  ' Previous pulse to right servo
    freqselect          VAR    Nib
    irfrequency         VAR    Word
    irdetectleft        VAR    Bit
    'irdetectcenter      VAR    Bit
    irdetectright       VAR    Bit
    distanceleft        VAR    Nib
    distancecenter      VAR    Nib
    distanceright       VAR    Nib
    

    ' -----[noparse][[/noparse] Initialization ]-----------------------------------------------------
    

    
    
    FREQOUT 4, 2000, 3000                        ' Beep to signify program start
    

    
    
    pulseLeft     = 750                          ' Set all pulse values to center
    

    pulseRight    = 750
    

    pulseLeftOld  = 750
    

    pulseRightOld = 750
    

    
    
    ' -----[noparse][[/noparse] Main Routine ]-------------------------------------------------------
    

    
    
    DO                                           ' Begin main routine
    

      GOSUB get_distances
    

      pulseleft  = pulsecount + 5 - distanceright *2 '- distancecenter *2
      pulseright = pulsecount - 5 + distanceleft *2  '+ distancecenter *2
    

       pulseLeft  = pulseLeft  MIN 650 MAX 850 ' Keep 650 <= durations <= 850
    

       pulseRight = pulseRight MIN 650 MAX 850
    

      ' This FOR...NEXT loop includes a navigation routine with ramping.
    

      FOR counter = 1 TO pulseCount              ' Repeat for number of pulses
    

    
    
        ' Navigation routine sets pulse width based on navigation character.
    

    
    
        ' Increment/decrement routine only changes pulse durations by 2 at a time.
    

        IF pulseLeft > (pulseLeftOld  + 4) THEN pulseleft  = pulseLeftOld  + 4
    

        IF pulseLeft  < (pulseLeftOld  - 4) THEN pulseLeft  = pulseLeftOld  - 4
    

        IF pulseRight > (pulseRightOld + 4) THEN pulseRight = pulseRightOld + 4
    

        IF pulseRight < (pulseRightOld - 4) THEN pulseRight = pulseRightOld - 4
    

    
    
    
    
    
    
        pulseLeftOld  = pulseLeft                ' Remember old values
    

        pulseRightOld = pulseRight
    

    
    
        PULSOUT 13, pulseLeft                    ' Send control pulses to servos
    

        PULSOUT 12, pulseRight
    

        PAUSE 20
    

    
    
      NEXT                                       ' Check FOR counter... condition
    

    
    
    LOOP                                         ' Repeat main routine
    get_distances:
    

         distanceleft   = 0
         'distancecenter = 0
         distanceright  = 0
    

      FOR freqselect = 0 TO 4
    

           LOOKUP freqselect, [noparse][[/noparse]37500,38250,39500,40500,41500], irfrequency
    

           FREQOUT 8,1, irfrequency
           irdetectleft = IN9
           distanceleft = distanceleft + irdetectleft
    

          ' FREQOUT 6,1, irfrequency
          ' irdetectcenter = IN7
          ' distancecenter  = distancecenter + irdetectcenter
    

           FREQOUT 2,1, irfrequency
           irdetectright = IN0
           distanceright = distanceright + irdetectright
         NEXT
         RETURN
    

    i had the same problem and i thought it was like button bounce or the detecters where saying turn left ,turn right and back and forth ,,,try this program i hacked up u can play with the # so it can wedge in tight places its meant for 3ir,s and a motor controller but should work on ur servos and its got ramping and min\max speed control have fun





    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Problems are the "roads" of life,
    solutions are only "onramps" to the next problem



    ············································· "Brad Smith"
    ·
Sign In or Register to comment.