Shop OBEX P1 Docs P2 Docs Learn Events
Ping))) — Parallax Forums

Ping)))

EdgarEdgar Posts: 8
edited 2008-04-09 02:58 in Propeller 1
Hello, I was testing a Ping))) range finder but couldn't get a reading beyond
5 inches. I used the hyper-terminal to read the values:

402us 5'' 138mm



If I put my hands less than 5'' in front of it, it could read the distance.
I set the code to read every 1 second. Here is the code:

CON

  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000

  PING_Pin = 0                                          ' I/O Pin For PING)))


VAR

  long  range
    
OBJ

  Debug: "FullDuplexSerial"  
  ping : "ping"
  
PUB Start

  Debug.start(31, 30, 0, 57600)
  Debug.str(string("Testing begins",10,13)) 

  repeat                                                ' Repeat Forever
  
    range := ping.Ticks(PING_Pin)                       ' Get Range in MicroSeconds
    Debug.dec(range)
    Debug.str(string("us "))
    waitcnt(clkfreq  + cnt)                             ' Pause 1 Second

    range := ping.Inches(PING_Pin)                      ' Get Range In Inches
    Debug.dec(range)
    Debug.str(string("'' "))
    waitcnt(clkfreq  + cnt)                             ' Pause 1 Second

    range := ping.Millimeters(PING_Pin)                 ' Get Range In Millimeters
    Debug.dec(range)
    Debug.str(string("mm",10,13))
    waitcnt(clkfreq  + cnt)                             ' Pause 1 Second



Is it something wrong I did or something wrong with the sensor I have?

- Thanks

Comments

  • TubularTubular Posts: 4,646
    edited 2008-04-08 12:10
    I had the same problem, reading 146mm or anything closer but rarely reading anything further. I think it was the sensor itself. Way back in this forum 1 or 2 others had a similar problem.

    I'll run your code when I get a chance, just to verify.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-04-08 18:33
    Edgar, you may have gotten a defective unit. Contact Tech Support and request an RMA, and we will send you a replacement.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • EdgarEdgar Posts: 8
    edited 2008-04-09 01:35
    I bought it at radioshack, they let me exchange.
    The second one and it works.

    - Thanks
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2008-04-09 02:42
    I had the same problem with mine, but have assumed to be my inexperienced code.
    I haven't had a chance to get it back out and try it again... Maybe it wasn't me. <shrug>

    I'll test it again and see what happens.. Mine was a Radio Shack purchase as well..

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Getting started with the Protoboard? - Propeller Cookbook 1.4
    Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
    Got an SD card? - PropDOS
    A Living Propeller FAQ - The Propeller Wiki
    (Got the Knowledge? Got a Moment? Add something today!)

  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-04-09 02:58
    I'll let our Tech Support manager know about this.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
Sign In or Register to comment.