Shop OBEX P1 Docs P2 Docs Learn Events
PING bracket — Parallax Forums

PING bracket

Jimi FreemanJimi Freeman Posts: 46
edited 2009-02-02 00:13 in BASIC Stamp
My bracket arrived today , and after assembly, i run the demo roaming w/ ping. The bot sits in one spot, and the servo turns completely to the right, and attempts to keep turning but its too far. Is something burnt up?

Comments

  • FranklinFranklin Posts: 4,747
    edited 2009-01-22 01:46
    Your code is probably wrong. Run a test program to find out what values are full left, center and full right then stay within those numbers.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Jimi FreemanJimi Freeman Posts: 46
    edited 2009-01-22 01:51
    I am running the stock code from the parallax PING ))) page.... romaing with ping... does that make a difference?
  • FranklinFranklin Posts: 4,747
    edited 2009-01-22 01:55
    It could, how do you have it wired up and please attach your actual code to your next post and tell us which stamp you are using.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Jimi FreemanJimi Freeman Posts: 46
    edited 2009-01-22 02:07
    ' =========================================================================
    '
    '   File...... RoamingWithPING.bs2
    '   Purpose... Roam And Scan Using PING))) Mounting Bracket
    '   Author.... Parallax, Inc.
    '   E-mail.... support@parallax.com
    '   Started...
    '   Updated... 12-21-2005
    '
    '   {$STAMP BS2}
    '   {$PBASIC 2.5}
    '
    ' =========================================================================
    
    
    ' -----[noparse][[/noparse] Program Description ]---------------------------------------------
    
    ' This programs demonstrates roaming with the Parallax PING))) Mounting
    ' Bracket, which allows you to pan-scan with your Parallax PING))) sensor.
    '
    ' This program assumes you have already set your BOE-Bot up for roaming
    ' with IR sensors.  You must also have the PING))) Mounting bracket
    ' installed as per the instructions, with the servo connected to P14 and
    ' the PING))) sensor connected to P15.
    '
    ' Due to the way the PING))) bracket mounts you may have to trim your IR
    ' detectors down so that they don't stick up in the way of the moving
    ' PING))) bracket as it rotates.  It's best to angle them off at 45
    ' degree angles so that the BOE-Bot doesn't run into anything while
    ' moving along a wall at a narrow angle.
    '
    ' The BOE-Bot will now roam around and when it senses an object, it will
    ' scan within a 180 degree field of view for the clearest path, which it
    ' will then navigate scanning for an object again.  The IR Sensors prevent
    ' hitting a wall when coming at it from a narrow angle where the PING)))
    ' might have trouble seeing it due to the lack of reflection of sound.
    '
    ' Calibration is important to this code working properly.  If you do not
    ' have the correct values for your servos then you may get strange results
    ' from your BOE-Bot.  The necessary calibration information is listed in
    ' each section of the code where it is required.
    
    ' -----[noparse][[/noparse] Revision History ]------------------------------------------------
    
    ' This code is basically a modified version of the Roaming With IR code
    ' from the Robotics With The BOE-Bot Manual, written by Andy Lindsay.
    ' Much of the original code was left untouched so you can see how it was
    ' altered.
    
    
    ' -----[noparse][[/noparse] I/O Definitions ]-------------------------------------------------
    
    Piezo           PIN     4               ' Piezo Speaker
    RightServo      PIN     12              ' Right Servo
    LeftServo       PIN     13              ' Left Servo
    PingServo       PIN     14              ' PING))) Servo
    Ping            PIN     15              ' PING))) Sensor
    
    
    ' -----[noparse][[/noparse] Variables ]-------------------------------------------------------
    
    irDetectLeft    VAR     Bit             ' Variable For Left IR Input
    irDetectRight   VAR     Bit             ' Variable For Right IR Input
    pulseCount      VAR     Byte            ' Used For Measuring Turns
    distance        VAR     Word            ' Current Distance Of Object
    oldDistance     VAR     Word            ' Old Distance Value
    counter         VAR     Word            ' PING))) Cycle Counter
    task            VAR     Nib             ' Current Task
    
    
    ' -----[noparse][[/noparse] Initialization ]--------------------------------------------------
    
    FREQOUT Piezo, 2000, 3000               ' Signal Program Start/Reset
    
    
    ' -----[noparse][[/noparse] Program Code ]----------------------------------------------------
    
    Main:
    DO
    
      FREQOUT 8, 1, 38500                   ' Emit 38.5 kHz IR To Left
      irDetectLeft = IN9                    ' Store IR Detection Values
    
      FREQOUT 2, 1, 38500                   ' Emit 38.5 kHz IR To Right
      irDetectRight = IN0                   ' Store IR Detection Values
    
      IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
        GOSUB Ping_Around                   ' Object Detected via IR Forward
      ELSEIF (irDetectLeft = 0) THEN
        GOSUB Ping_Around                   ' Object Detected via IR Left
      ELSEIF (irDetectRight = 0) THEN
        GOSUB Ping_Around                   ' Object Detected via IR Right
      ENDIF
    
      counter = counter + 1                 ' Increment Passive Counter
    
      IF counter > 10 THEN                  ' Wait For 10 Servo Pulses
        GOSUB Ping_Out                      ' Activate PING)))
      ENDIF
    
      IF (distance > 30) THEN               ' Is Object Farther Than 30 cm?
        GOSUB Forward_Pulse                 ' If Yes Go Forward
      ELSE
        GOSUB Ping_Around                   ' Otherwise Scan For Clear Path
      ENDIF
    
    LOOP
    
    
    ' -----[noparse][[/noparse] Subroutines ]-----------------------------------------------------
    
    ' *************************************************************************
    ' * USE THE APPROPRIATE PULSOUT VALUES TO MAKE YOUR BOE-BOT MOVE FORWARD  *
    ' * WHILE THE PING))) IS FACING FORWARD.                                  *
    ' *************************************************************************
    
    Forward_Pulse:                          ' Send A Single Forward Pulse
      PULSOUT PingServo, 750                ' Ping Servo Forward Pulse Value
      PULSOUT LeftServo, 850                ' Left Servo Forward Pulse Value
      PULSOUT RightServo, 650               ' Right Servo Forward Pulse Value
      PAUSE 20                              ' Refresh Delay
      RETURN
    
    ' *************************************************************************
    ' * USE THE APPROPRIATE PULSOUT VALUES TO MAKE YOUR BOE-BOT TURN LEFT 90  *
    ' * DEGREES.  USE THE SAME VALUE AS ABOVE FOR THE PING))) BRACKET SERVO.  *
    ' *************************************************************************
    
    Turn_Left:                              ' Left Turn, About 45 Degrees
      FOR pulseCount = 0 TO 7               ' Number Of Pulses To Turn
        PULSOUT PingServo, 750              ' Ping Servo Forward Pulse Value
        PULSOUT LeftServo, 650              ' Left Servo Left Pulse Value
        PULSOUT RightServo, 650             ' Right Servo Left Pulse Value
        PAUSE 20                            ' Refresh Delay
      NEXT
      RETURN
    
    ' *************************************************************************
    ' * USE THE APPROPRIATE PULSOUT VALUES TO MAKE YOUR BOE-BOT TURN RIGHT 90 *
    ' * DEGREES.  USE THE SAME VALUE AS ABOVE FOR THE PING))) BRACKET SERVO.  *
    ' *************************************************************************
    
    Turn_Right:                             ' Right Turn, About 45 Degrees
      FOR pulseCount = 0 TO 7               ' Number Of Pulses To Turn
        PULSOUT PingServo, 750              ' Ping Servo Forward Pulse Value
        PULSOUT LeftServo, 850              ' Left Servo Right Pulse Value
        PULSOUT RightServo, 850             ' Right Servo Right Pulse Value
        PAUSE 20                            ' Refresh Delay
      NEXT
      RETURN
    
    ' *************************************************************************
    ' * USE THE APPROPRIATE PULSOUT VALUES TO MAKE YOUR BOE-BOT MOVE BACKWARD *
    ' * WHILE THE PING))) IS FACING FORWARD.                                  *
    ' *************************************************************************
    
    Back_Up:                                ' Back Up
      FOR pulseCount = 0 TO 40              ' Number Of Pulses To Backup
        PULSOUT PingServo, 750              ' Ping Servo Forward Pulse Value
        PULSOUT LeftServo, 650              ' Left Servo Backup Pulse Value
        PULSOUT RightServo, 850             ' Right Servo Backup Pulse Value
        PAUSE 20                            ' Refresh Delay
      NEXT
      RETURN
    
    Ping_Out:                               ' PING)))
      counter = 0                           ' Reset Passive Delay Counter
      LOW Ping                              ' Force PING))) Line Low
      PULSOUT Ping, 5                       ' Activate PING))) Pulse
      PULSIN  Ping, 1, distance             ' Receive Return Pulse
      distance = distance ** 2257           ' Calculate Distance
      RETURN
    
    Ping_Around:                            ' Start 180 Degree Pan-Scan
      counter = 0                           ' Reset Passive Delay Counter
      oldDistance = 30                      ' Current Old Distance Values
      task = 0                              ' Current Task Priority
    
    ' *************************************************************************
    ' * USE THE APPROPRIATE PULSOUT VALUE TO MAKE YOUR PING)))                *
    ' * TURN 90 DEGREES LEFT.                                                 *
    ' *************************************************************************
    
      FOR pulseCount = 0 TO 20              ' Number Of Pulses To Spin
        LOW Ping                            ' Force PING))) Line Low
        PULSOUT PingServo, 1085             ' Ping Servo 90 Left Pulse Value
        PULSOUT Ping, 5                     ' Activate PING)))
        PULSIN  Ping, 1, distance           ' Receive Distance Value
        PAUSE 20                            ' Refresh Delay
      NEXT
    
      distance = distance ** 2257           ' Calculate Distance In cm
      IF distance > oldDistance THEN        ' Is distance > Last Clear Path
        oldDistance = distance              ' Update oldDistance Value
        task = 1
      ENDIF
    
    ' *************************************************************************
    ' * USE THE APPROPRIATE PULSOUT VALUE TO MAKE YOUR PING)))                *
    ' * TURN 45 DEGREES LEFT.                                                 *
    ' *************************************************************************
    
      FOR pulseCount = 0 TO 20              ' Number Of Pulses To Spin
        LOW Ping                            ' Force PING))) Line Low
        PULSOUT PingServo, 850              ' Ping Servo 45 Left Pulse Value
        PULSOUT Ping, 5                     ' Activate PING)))
        PULSIN  Ping, 1, distance           ' Receive Distance Value
        PAUSE 20                            ' Refresh Delay
      NEXT
    
      distance = distance ** 2257           ' Calculate Distance In cm
      IF distance > oldDistance THEN        ' Is distance > Last Clear Path
        oldDistance = distance              ' Update oldDistance Value
        task = 2
      ENDIF
    
    ' *************************************************************************
    ' * USE THE APPROPRIATE PULSOUT VALUE TO MAKE YOUR PING)))                *
    ' * TURN 45 DEGREES RIGHT.                                                *
    ' *************************************************************************
    
      FOR pulseCount = 0 TO 20              ' Number Of Pulses To Spin
        LOW Ping                            ' Force PING))) Line Low
        PULSOUT PingServo, 400              ' Ping Servo 45 Right Pulse Value
        PULSOUT Ping, 5                     ' Activate PING)))
        PULSIN  Ping, 1, distance           ' Receive Distance Value
        PAUSE 20                            ' Refresh Delay
      NEXT
    
      distance = distance ** 2257           ' Calculate Distance In cm
      IF distance > oldDistance THEN        ' Is distance > Last Clear Path
        oldDistance = distance              ' Update oldDistance Value
        task = 3
      ENDIF
    
    ' *************************************************************************
    ' * USE THE APPROPRIATE PULSOUT VALUE TO MAKE YOUR PING)))                *
    ' * TURN 90 DEGREES RIGHT.                                                *
    ' *************************************************************************
    
      FOR pulseCount = 0 TO 20              ' Number Of Pulses To Spin
        LOW Ping                            ' Force PING))) Line Low
        PULSOUT PingServo, 225              ' Ping Servo 90 Right Pulse Value
        PULSOUT Ping, 5                     ' Activate PING)))
        PULSIN  Ping, 1, distance           ' Receive Distance Value
        PAUSE 20                            ' Refresh Delay
      NEXT
    
      distance = distance ** 2257           ' Calculate Distance In cm
      IF distance > oldDistance THEN        ' Is distance > Last Clear Path
        oldDistance = distance              ' Update oldDistance Value
        task = 4
      ENDIF
    
      ON task GOSUB Task0, Task1, Task2, Task3, Task4
    
      distance = 50                         ' Prevent Scan From Looping
    
      RETURN
    
    Task0:                                  ' Forward Was Clearest Path
      GOSUB Turn_Right                      ' This Could Mean Narrow Path
      GOSUB Turn_Right                      ' So We'll Turn Around
      GOSUB Turn_Right                      ' You Can Change The Behavior
      GOSUB Turn_Right                      ' Of Any Of The Tasks
      RETURN
    
    Task1:                                  ' 90 Degrees Left Was Clearest
      GOSUB Turn_Left
      GOSUB Turn_Left
      RETURN
    
    Task2:                                  ' 45 Degrees Left Was Clearest
      GOSUB Turn_Left
      RETURN
    
    Task3:                                  ' 45 Degrees Right Was Clearest
      GOSUB Turn_Right
      RETURN
    
    Task4:                                  ' 90 Degrees Right Was Clearest
      GOSUB Turn_Right
      GOSUB Turn_Right
      RETURN
    




    I have the PING ))) sensor going to servo port 15, the servo that controls the bracket going to 14.

    The IR leds are connected as specified in the Building and testing the IR PAIRS, activity $1 page 237 of the boe bot..... they are working circuits, and they can navigate the activity correctly.
  • SRLMSRLM Posts: 5,045
    edited 2009-01-22 02:12
    For large piece of code, attach it using the attachment manager, not embed it into your post.

    Anyway, I have a standard servo where the left is about 800uS, the center is about 1250uS, and the right is about 1600uS. So, there are variations in manufacturing that you may have to take into account.
  • GeorgeLGeorgeL Posts: 131
    edited 2009-01-22 06:23
    I think you might have hooked up the LCD extension cable used to connect the PING))) and the BOE-Bot board incorrectly. Make sure if you are using the servo ports that you dont have the sides reversed.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-01-22 17:36
    As per the notes in the code, it assumes you have your BOE-Bot configured for Roaming with IR. If you do not have the IR sensors installed the program will not function properly. In this case you could add them, or use the Simple Roaming with PING))) program we have on our website. It does not require the IR sensors. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • Jimi FreemanJimi Freeman Posts: 46
    edited 2009-01-23 02:38
    Chris... that is how I have it configured now, and it is still doing the same thing....
    PS.. according to this code http://www.parallax.com/Portals/0/Downloads/src/prod/RoamingWithPING-V1.0.zip , it does require the leds?

    Post Edited (Jimi Freeman) : 1/23/2009 2:44:02 AM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-01-23 17:07
    With that code the LEDs are required. Of course, if you have them connected then Romaing with IR code from the BOE bot should run...does it? If not there is another issue. You might want to try the code located here.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • Jimi FreemanJimi Freeman Posts: 46
    edited 2009-01-25 02:00
    I uploaded the copy of roaming with ping simple to the bot, and at first, it works ok, but after about 5 seconds, it only looks right, and goes in a circle?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-01-26 17:13
    Sounds like low batteries maybe? There’s nothing about the code itself that would cause it to that after a short while.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • Jimi FreemanJimi Freeman Posts: 46
    edited 2009-02-01 02:05
    Chris! Thankes. It was a battery issue. I purchased the RFID reader, and man does that thing suck down batteries! ... replacing them made the code work..
    I think I need to add more weight to the back near the caster? He does this thing where he kinda hops / tilts forward and backwards as moving.....any suggestions?
  • SRLMSRLM Posts: 5,045
    edited 2009-02-01 03:00
    You can turn the RFID reader on and off. When it's off (green light on) it uses much less current then when it's on.
  • Jimi FreemanJimi Freeman Posts: 46
    edited 2009-02-01 15:32
    What should I do about the weight issue?
  • Mike GreenMike Green Posts: 23,101
    edited 2009-02-01 15:58
    If you're not using NiMH rechargables, you should consider that. If you do get NiMHs, you should have 5 cells rather than 4 and the extra battery holder can be glued on the chassis just above the caster and wired in series with the existing 4 cell battery holder. RadioShack has a single AA cell holder with leads attached.

    The extra cell adds weight to the caster and the rear of the BoeBot and it adds about 1.2V to the 4.8V from the standard 4-cell battery holder when you're using rechargables.
  • SRLMSRLM Posts: 5,045
    edited 2009-02-02 00:13
    Also, there are four ways to mount the servos (inside frame/outside frame and axle forward/axle back). If you haven't already, try flipping the servos so that the axle is as close as possible to the front.
Sign In or Register to comment.