Shop OBEX P1 Docs P2 Docs Learn Events
Storing Multiple Values in one pin. — Parallax Forums

Storing Multiple Values in one pin.

EzsynnEzsynn Posts: 119
edited 2009-02-05 13:57 in Robotics
I've got a PING))) sensor hooked up onto PIN 15. How do I store multiple Values in one PIN port then use them?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
BWIN ON DA POWAH WIFIN U!!!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-02-02 14:58
    "multiple Values in one PIN port" doesn't make sense the way you've said it. Can you give a bit more explanation of what you're trying to do?

    There are plenty of examples on the Parallax website of how to use the PING))) with a Stamp. Have you looked at them? Like most Parallax products, there are links to the documentation and sample code on the product page in the webstore.
  • EzsynnEzsynn Posts: 119
    edited 2009-02-02 20:45
    Mike Green said...
    "multiple Values in one PIN port" doesn't make sense the way you've said it. Can you give a bit more explanation of what you're trying to do?

    There are plenty of examples on the Parallax website of how to use the PING))) with a Stamp. Have you looked at them? Like most Parallax products, there are links to the documentation and sample code on the product page in the webstore.
    I'm trying to Get the Ping to do a distance measure at 5 angles. And store then compare the values.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    BWIN ON DA POWAH WIFIN U!!!
  • Mike GreenMike Green Posts: 23,101
    edited 2009-02-02 21:14
    The PING))) can't store or compare values. Your Stamp program has to do that. The documentation for the PING))) shows how to make a single measurement. The Stamp Manual shows how to declare arrays. You'd use an array to store each of the distance measurements, then your program can go back and analyze the stored values.
  • iDaveiDave Posts: 252
    edited 2009-02-03 00:07
    If you really MUST store all 5 measurments you should use an array like mike said, BUT, if you merely want to store the largest value(to take bot the furthest distance) and at what angle that measurment was found , I used a loop to take the 5 measurements and use 1 variable to hold the biggest one. Following is a copy from my code:

    FOR X = 787 TO 2650  STEP 465      '  these values are for the bs2p, bs2 would be different
        C = C + 1
        FOR XY = 1 TO 35
          PULSOUT 14, X
          PAUSE 20
        NEXT
        PULSOUT 15, 13
        PULSIN  15, 1, TIME
        TIME = TIME */ 102           '   FOR BS2P, NOT BS2
        inches = 890 ** time : time = 0
        IF (inches > BIG) THEN     ' THIS IS WHERE COMPARISON IS MADE
         BIG = inches
         XBIG = C
        ENDIF
      NEXT
    
    C = 0    '  C  MUST BE RESET BEFORE ENTERING BACK IN PREVIOUS LOOP
    
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "THE ONLY TRUE WISDOM IS IN KNOWING YOU KNOW NOTHING." - SOCRATES
  • MovieMakerMovieMaker Posts: 502
    edited 2009-02-03 03:47
    iDAVE,

    How would you change the code slightly to find the shortest distance instead? that way you could know the furtherest and the closest. Hope you don't mind me asking.

    Thanks.
  • iDaveiDave Posts: 252
    edited 2009-02-03 04:10
    No problem MovieMaker. Just simply add another -If then- block after the one that finds the biggest distance. Just do the inverse of it and use a seperate variable to hold the lowest.:

    IF (inches < LOW) THEN ' THIS IS WHERE COMPARISON IS MADE
    LOW = inches
    XLOW = C ' XLOW holds at what measurement position( 1- 5) that was taken
    ENDIF

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "THE ONLY TRUE WISDOM IS IN KNOWING YOU KNOW NOTHING." - SOCRATES
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-02-03 04:26
    Bear in mind that the shortest of five distance measurements could well be erroneous, due to interference. The longest of five measurements is much more likely to be an accurate value.

    -Phil
  • iDaveiDave Posts: 252
    edited 2009-02-03 04:57
    So true. I remember i had to add a statement to screen out values of 0. Don't know if it was my initial screwy wiring or wacky interference. LOL

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "THE ONLY TRUE WISDOM IS IN KNOWING YOU KNOW NOTHING." - SOCRATES
  • EzsynnEzsynn Posts: 119
    edited 2009-02-05 10:22
    I think I'll Settle with 3 points, How do you get it to measure in centimetres?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    BWIN ON DA POWAH WIFIN U!!!
  • Mike GreenMike Green Posts: 23,101
    edited 2009-02-05 13:57
    Read the documentation for the PING))). It shows how to do the conversions for different units.
Sign In or Register to comment.