Shop OBEX P1 Docs P2 Docs Learn Events
Adding Multinple PING Ultra sound sensor... please help!!!! — Parallax Forums

Adding Multinple PING Ultra sound sensor... please help!!!!

yeyo1982yeyo1982 Posts: 5
edited 2008-10-15 16:48 in Learn with BlocklyProp
Hi all!

So I have recently started using microcontrollers for class with fellow classmate thetarbe,

My problem is this. I have gotten then code for the PING Ultrasound sensor and it works fine. I just want to add another PING Ultrasound sensor to have two. How would i modify the syntax?


Here is a copy of the current syntax.... thanks!


' Smart Sensors and Applications - PingMeasureCmAndIn.bs2
' Measure distance with Ping))) sensor and display in both in & cm
' {$STAMP BS2}
' {$PBASIC 2.5}
' Conversion constants for room temperature measurements.
CmConstant CON 2260
InConstant CON 890
cmDistance VAR Word
inDistance VAR Word
time VAR Word
DO
PULSOUT 15, 5
PULSIN 15, 1, time
cmDistance = cmConstant ** time
inDistance = inConstant ** time
DEBUG HOME, DEC3 cmDistance, " cm"
DEBUG CR, DEC3 inDistance, " in"
PAUSE 100
LOOP

Comments

  • yeyo1982yeyo1982 Posts: 5
    edited 2007-10-23 21:00
    here is a jpeg of the circuit board
    162 x 167 - 61K
  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-23 21:01
    The PULSOUT followed by the PULSIN are the important statements. The rest just converts time in "Stamp units" to distance and displays it.
    All you need is a 2nd PULSOUT and PULSIN with the proper pin number. If you need to keep the 2nd set of measurements around, you will need another set of variables with different names. Try it. You might want to put a little delay between the two PING measurements to allow echos in the room to die out. 50-100ms would be more than enough.
  • yeyo1982yeyo1982 Posts: 5
    edited 2007-10-23 21:28
    great i got them to both work but i have having a little trouble with the syntax to keep the second set of measurements around ..... the output is supposed to display onscreen.... how would i rename the variables? And the command for delay is PAUSE correct? this is my new syntax.... please advise... and i appreciate all the help I would've never gotten this on my own.



    ' Smart Sensors and Applications - PingMeasureCmAndIn.bs2
    ' Measure distance with Ping))) sensor and display in both in & cm
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ' Conversion constants for room temperature measurements.
    CmConstant CON 2260
    InConstant CON 890
    cmDistance VAR Word
    inDistance VAR Word
    time VAR Word
    DO
    PULSOUT 15, 5
    PULSIN 15, 1, time

    PAUSE 500

    PULSOUT 14, 5
    PULSIN 14, 1, time

    cmDistance = cmConstant ** time
    inDistance = inConstant ** time
    DEBUG HOME, DEC3 cmDistance, " cm"
    DEBUG CR, DEC3 inDistance, " in"
    PAUSE 100
    LOOP
  • yeyo1982yeyo1982 Posts: 5
    edited 2007-10-23 22:24
    success so far!
    got both sensors to diplay on-screen....

    next step : To put both sensor display results on a small LCD screen

    any advice?!?!?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-24 00:05
    You can't use the same variable (time) for two different readings (unless you display the one result, then do the 2nd reading since the variable's value isn't needed then). The way you've written it, you're throwing the reading from the first PING away. I suggest you duplicate the cmDistance= statement, the inDistance= statement, and the two DEBUG statements and put the duplicate before the PAUSE 500 statement. You'll see the first value for 1/2 second, then the second for 1/10 second (you probably want to lengthen both pauses).
  • yeyo1982yeyo1982 Posts: 5
    edited 2007-10-24 00:24
    hey Mike thanks for your help.... I got ur latest reply a little too late... I'm not sure I understand what your saying, you have to excuse me, I am very new to this..... BUT I did manage to do what I intended to do... here is a pic of what I will turn in for class tommorrow
    1650 x 1650 - 2M
  • shahrul mustafashahrul mustafa Posts: 1
    edited 2007-12-04 07:32
    hye..i'm new here...i wanna ask for PING )) code work as obstacle avoidance...i'm using 3 PING))) so could you please help for source code for PING)) receive or transmit PRIORITY...and how it's work as obstacle avoidance for my mobile robot...thanx...
  • DgswanerDgswaner Posts: 795
    edited 2008-01-04 16:56
    The Code is on the product page the PING. All the PING does is measure distance. so you need to write code that says if the distance is less than you want. stop or turn. many people put the PING on a servo pan it back and forth while measuring distance.

    Good luck!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster

    DGSwaner
  • tinatina Posts: 3
    edited 2008-10-04 23:25
    Hi ,..I am new to this field....please help me out to work on ifre red sensor...i have got the code for ping sensor from website..please helpme out in changing the direction of robot if it finds any obstacle in its path,....
    thanks..
  • Mike GreenMike Green Posts: 23,101
    edited 2008-10-04 23:39
    Look here (www.parallax.com/tabid/535/Default.aspx) for the "Robotics with the BoeBot" and the "IR Remote for the BoeBot Robot" tutorials. These discuss various aspects of the use of IR for robotics, particularly navigation and remote control. There's a sample program in Robotics with the BoeBot for obstacle avoidance. Look at chapters 7 and 8 particularly.

    By the way, it's against forum rules to post multiple messages on the same subject. Please delete your other message. Use the X icon in the upper right corner of the message box.
  • tinatina Posts: 3
    edited 2008-10-05 05:29
    Thank you so much for your valuable information..
  • susansusan Posts: 1
    edited 2008-10-15 16:44
    Hello...I am new person to this field please help me getting exact code for infrared sensor to detect an object in its path and measure distance from it and if the distance is less than some value it has to take a turn from there...I want to map the movement of the robot on a paper.(distance travelled by it and it turns when it finds an obstacle in its way)..Please help me...
  • Mike GreenMike Green Posts: 23,101
    edited 2008-10-15 16:48
    Start with the tutorials I mentioned earlier in this thread. These have lots of sample programs in them.
Sign In or Register to comment.