Shop OBEX P1 Docs P2 Docs Learn Events
PSoC and PING))) — Parallax Forums

PSoC and PING)))

cjackelcjackel Posts: 4
edited 2011-04-10 17:04 in Accessories
I would appreciate any assistance on how to implement
bidirectional single pin I/O with the PSoC microcontroller and PING))) sensor.

I have read the PING))) data sheet but there is nothing specific to the
PSoC microcontroller.

I realize I have to send a TTL pulse from the PSoC to the PING, and then
measure the return pulse from the PING in order to calculate the distance
sensed by the PING.

How is this done with the PSoC ? I know it will involve an interrupt routine
and timer, but I was hoping someone has already implemented the code.

Thank you.
-Chuck

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-04-10 10:29
    We can't help you with the PSoC coding. You'll have to study the PSoC documentation and ask people on any PSoC support forums for help with implementation. The PING is very straightforward to use. As you've noted, you have to make one of the PSoC I/O pins a low output, change it to high for about 5us, then low again. Sometime after that (maybe 500us), you set the I/O pin to input mode and wait for the I/O pin to go high. At that point, you start timing. When the I/O pin goes low again you stop timing. That's it. You can do the timing with loops or with a hardware timer. You can use interrupts or not.
  • cjackelcjackel Posts: 4
    edited 2011-04-10 13:00
    Thank you for the suggestions.

    I need a quick solution that at least shows the output signal from the PING))).

    How would I connect the PING))) to an o-scope since the signal connection
    is both an input and output?

    Would connecting the scope to the terminals on the back of the PING))) board where
    the two sensors are soldered to the PCB bypass the control circuitry of the PING)))
    and allow me to view the signal directly?

    Thanks again.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-04-10 13:27
    I would connect the scope to the data line from the PING (and ground/Vss of course). The reason is that you'll see the start pulse from the PSoC as well and you can use that for syncing the sweep. If you get the scope sweep speed right, you can watch the varying width of the response from the PING.

    You might start experimenting by having the PSoC generate one 5us pulse in response to a pushbutton switch closure then 500us later set the I/O pin to input mode. A single 5us pulse shouldn't be hard to do, leaving the I/O pin in input mode. You can see the response of the PING on the scope and play with putting your hand or other barrier in front to see what happens. Note that the PING has an LED that will flash when it sees the pulse from the PSoC.
  • cjackelcjackel Posts: 4
    edited 2011-04-10 13:31
    Thanks.

    Maybe I'm misunderstanding the datasheet, but does the PING))) need a pulse from the PSoC
    every time a distance needs to be measured?

    Or is the start pulse from the PSoC a one-time only event that simply starts the PING))) ?
  • Mike GreenMike Green Posts: 23,101
    edited 2011-04-10 14:20
    The pulse from the PSoC is a "per measurement" event.

    The PING))) uses the 5us pulse to start the overall timing. It initiates the ultrasonic pulse being transmitted. The rest of the timing for a sequence is laid out graphically in the datasheet. The transmitter is turned on for about 200us as shown. Somewhere during that time, the PING's data line is brought high. Shortly after that, the sound pulse ends and the PING's receiver is enabled. When the returning echo is detected by the receiver, the data line is brought low and everything is reset for the next cycle. There's a minimum 200us delay from the end of the PING's response to the next start pulse and there's a timeout on the receiver of about 18.5ms. All of this is in the datasheet.
  • cjackelcjackel Posts: 4
    edited 2011-04-10 17:04
    Ok. So the Input Trigger Pulse is sent by the PSoC every cycle? I see the waveform in the datasheet, but its not clear to me if the entire cycle is repeated.

    Thanks.
Sign In or Register to comment.