Shop OBEX P1 Docs P2 Docs Learn Events
problem understanding ping sensor — Parallax Forums

problem understanding ping sensor

justin weberjustin weber Posts: 36
edited 2008-04-19 22:39 in Propeller 1
It seems that the ping sensor likes to return 5 alot. Here is my code:
CON

_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000

VAR
long range
OBJ

tv : "tv_text"
ping : "Ping"

PUB main
tv.start(12)
repeat
range := ping.Inches(0)
tv.dec(range)
waitcnt(clkfreq / 10 + cnt)
tv.out($0d)

hardware-wise I have the vcc to 5V on the propeller starter board and gnd to the vss. SIG is connected to p0 with a 1k resistor. This program should be returning a reading in inches, but it displays 5 ALOT and other values randomly, but always returns to displaying 5's. I don't know if the demo from the exchange works, because I don't have a LED debug display, so i'm sending it to tv term instead.

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-04-18 21:43
    Hi justin, did you ever figure out what what happening with your setup, or get help with this?

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

    Parallax, Inc.
  • souplogicsouplogic Posts: 8
    edited 2008-04-19 22:39
    From my experience with the ping as a prop newbie, I would say make sure you are supplying the board with enough voltage and make check other low level, physical conditions.

    I had problems for the longest time because I was supplying the the protoboard with 5V (thinking that this was sufficient as the prob runs on 5V), but the actual power requirement for the board is 6-9V. Not realizing this took me down the confusing path of debugging code that wasn't buggy.
Sign In or Register to comment.