Shop OBEX P1 Docs P2 Docs Learn Events
Ping Sensor-BoE — Parallax Forums

Ping Sensor-BoE

Hello, I'm working on making the servo motor move with every ping that it hits.
I will be using 3 different ping sensors, I also want them to ping at about 12 cm out, but when i plug in the second one it goes below 2 cm and it stays in theloop and never stops . I need to know a way to get all 3 pings to work, not just 1.
Can you help me?

Comments

  • How quickly are you firing each sensor? To avoid other sensors from hearing someone else's chirp and giving erroneous data, you should allow for at least 20+ milliseconds before firing another sensor. You want to make sure there is only one ultrasonic burst flying around and only the sending sensor is listening for it. If you fire the second sensor too soon it will probably pick up the first sensors chirp and falsely report an echo from something closer than it really is.
  • CmConstant CON 2260
    InConstant CON 890
    cmDistance VAR Word
    inDistance VAR Word
    time VAR Word
    col VAR Nib
    counter VAR Word
    reps VAR Nib

    DO
    PULSOUT 15, 5
    PULSIN 15, 1, time
    cmDistance = cmConstant ** time
    inDistance = inConstant ** time
    DEBUG HOME, DEC3 cmDistance, " cm"
    DEBUG CR, DEC3 inDistance, " in"

    IF (cmDistance < 5) THEN

    DEBUG CR, "Clockwise 10 o'clock", CR
    FOR counter = 1 TO 150
    PULSOUT 14, 1000
    PAUSE 20

    NEXT
    ENDIF

    IF (cmDistance < 5) THEN
    DEBUG "Clockwise 2 o'clock", CR
    FOR counter = 1 TO 150
    PULSOUT 14, 500
    PAUSE 20
    NEXT
    ENDIF
    LOOP
  • Here is my program just for 2 ping sensors. I would like it to work, as when i pass in front of it while less than 12cm it will turn to that specific ping
  • Here is what it looks like connected to the board
    1512 x 1512 - 946K
    1512 x 1512 - 905K
  • Where is the code for the second Ping? Looking at your pictures I see a second, unterminated cable lying next to an unconnected Ping. The other end terminates on the project board paralleling the first Ping's cable. If you are using two Pings, each one must be connected to a separate I/O pin on the Stamp. And the second Ping must have programming to operate it separately from the other Ping.
  • Okay, so you are saying that I need to change my wiring and make a code for the second ping. How do i separate the first ping from the second ping in my code?
  • Connect your 2nd Ping to P13 (Just the blue wire in the first picture).
    CmConstant    CON   2260
    InConstant    CON   890
    cmDistance  VAR   Word
    inDistance  VAR   Word
    time        VAR   Word
    col VAR Nib
    counter VAR Word
    reps VAR Nib
    
    DO
      PULSOUT 15, 5
      PULSIN 15, 1, time
      cmDistance = cmConstant ** time
      inDistance = inConstant ** time
      DEBUG HOME, DEC3 cmDistance, " cm"
      DEBUG CR, DEC3 inDistance, " in"
    
        IF (cmDistance < 5) THEN
    
        DEBUG CR, "Clockwise 10 o'clock", CR
    FOR counter = 1 TO 150
     PULSOUT 14, 1000
     PAUSE 20
    
    NEXT
    ENDIF
    
    PAUSE 50          ' wait for Ping1 pulses to fade away
    
      PULSOUT 13, 5
      PULSIN 13, 1, time
      cmDistance = cmConstant ** time
      inDistance = inConstant ** time
      DEBUG HOME, DEC3 cmDistance, " cm"
      DEBUG CR, DEC3 inDistance, " in"
    
    
          IF (cmDistance < 5) THEN
          DEBUG "Clockwise 2 o'clock", CR
    FOR counter = 1 TO 150
     PULSOUT 14, 500
     PAUSE 20
    NEXT
     ENDIF
    
    PAUSE 50       '  wait for Ping2 pulses to fade away
    
    LOOP
    
Sign In or Register to comment.