Shop OBEX P1 Docs P2 Docs Learn Events
Ping Sensor 3.3v Compatible — Parallax Forums

Ping Sensor 3.3v Compatible

corke2013corke2013 Posts: 5
edited 2013-12-24 21:07 in Accessories
Hi all.

I have an arduino due board which only supports maximum 3.3v digital input and output and I am worried that the Ping signal pin might deliver more than 3.3v to the digital input of my board, which would damage the input.
Is the Ping sensor compatible with a 3.3v input, output or do I need to add a resistor, if so what resistance would you suggest?

Thanks!

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-12-11 16:05
    I wasn't aware there were 3.3V Arduino boards...I thought they were all 5V. Nonetheless it's not as simple as just putting a resistor in the path. But fear not, because there is a wealth of information on 5V/3.3V interfacing at the following link.

    http://www.savagecircuits.com/mixedvoltage
  • corke2013corke2013 Posts: 5
    edited 2013-12-11 19:00
    Thanks, helped a lot!
    I think the Bi-Directional MOSFET Voltage Level Converter 3.3V to 5V is my best choice for what I need.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-12-11 19:22
    Unfortunately, the bidirectional MOSFET interface uses pull-ups, and the Ping))) uses a pull-down on its output. This has caused problems on the S2, which uses a similar voltage-level translation scheme, although with an IC rather than discrete transistors. I wrote a Spin object that overcomes this, which you may be able to adapt for the Arduino. It's described here:

    In the event that this is unusable, I would recommend the series-resistor approach.

    -Phil
  • corke2013corke2013 Posts: 5
    edited 2013-12-12 02:42
    Thanks Phill, I will defiantly give that a try, but in the mean time if I had to connect the ping sensor directly to a 3.3v supply instead of 5v would I be risking anything? sorry if its a stupid question, I'm just really cautious as I really don't want to damage my board.
  • corke2013corke2013 Posts: 5
    edited 2013-12-12 03:04
    Okay, with 3.3v I have measured only 2.5mA current draw from the ping device and I am getting accuracy of +-1cm which is quite nice. Not sure how the 3.3v will affect the range of the ping but I suppose it reduces the maximum range and accuracy, but it is perfect for what I am using it for.

    Thanks for the response and help!
    Untitled.jpg
    1024 x 576 - 48K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-12-12 08:35
    I didn't know the Ping))) would work at 3.3V. I'm not sure how reliable it will be. It uses an SX microcontroller, which can run at 3.3V, but it depends upon what its brownout reset voltage is programmed to be. Perhaps Parallax can shed some light here.

    -Phil
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2013-12-12 10:49
    I'd power the Ping at 5V, and use level translation for the signal line for happier coding. Even if the Ping can be reliably powered at 3.3V, without equivalent voltage step-up, the output transducer will not be driven as hard, and I think you could expect a loss of range.

    While there are a number of 3.3V Arduinos, official and unofficial, most of the examples using an Arduino with a Ping assume a 5V part, so that's what the wiring diagrams all show.

    On whether the series resistor will work, your best bet is to ask on the Arduino forums, where members have more experience interfacing a Due with a 5V sensor. My understanding is that the Arm chips are not 5V tolerant.

    While we're on the subject of NON-Due 3.3V Arduinos keep in mind that with most (all?) of these its reference clock runs at half speed (8 MHz rather than 16 MHz). This doesn't affect most things, and I think now all the standard functions and libraries are written to accommodate crystal speed variations. But there are some third-party sketches and class libraries that will not behave correctly when used on an 8 MHz clock. This isn't an issue with the Due, which is a completely different class of microcontroller used. But I thought I'd throw this out for anyone else interested in doing this, but not using a Due.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-12-12 12:12
    The PING))) is not rated to run at 3.3V. Internally there is also a negative 5V generator so that the op-amps run at +5/-5V. Running the PING))) at 3.3V would certainly affect the op-amps. They are what filter and amplify the return signal.
  • blittledblittled Posts: 681
    edited 2013-12-12 12:51
    Gordon is right, you do NOT use the series resistor on a Due. I have one and I haven't tried a 5V sensor on it but everything I have read says the Due is not 5V tolerant.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-12-12 13:11
    If you can't use a series resistor, you could always use two pins from the controller:

    attachment.php?attachmentid=105554&d=1386882663

    I've shown a Schottky diode. It's possible that the Ping)))'s SX is configured for TTL input thresholds, in which case a regular diode (e.g. 1N4148) would work fine.

    -Phil

    Addendum: Come to think of it, I think you can combine both pins into one:

    attachment.php?attachmentid=105555&d=1386882937

    -Phil
    380 x 174 - 1K
    374 x 174 - 1K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-12-13 13:49
    I tried the second circuit above (single-pin) with the Ping))) and a Propeller. I used a 1N4148 instead of a Schottky diode. Here's the scope output:

    attachment.php?attachmentid=105570&d=1386971381

    Both the initiate pulse and the return pulse at the Prop pin are about 3.3V. At the Ping))) pin, the initiate pulse is about 2.8V; the return pulse, 5V. I see no reason that this circuit would not work with the Due board.

    -Phil
    640 x 480 - 16K
  • corke2013corke2013 Posts: 5
    edited 2013-12-21 23:35
    Amazing!

    Thanks a bunch, this was very helpful.
  • KeithEKeithE Posts: 957
    edited 2013-12-24 21:07
    I tried the second circuit above (single-pin) with the Ping))) and a Propeller. I used a 1N4148 instead of a Schottky diode. Here's the scope output:

    Both the initiate pulse and the return pulse at the Prop pin are about 3.3V. At the Ping))) pin, the initiate pulse is about 2.8V; the return pulse, 5V. I see no reason that this circuit would not work with the Due board.

    -Phil

    I was just attempting in interface a Ping))) with a Raspberry Pi running RISC OS, and apparently wasn't paying attention to details so I saw something like Phil's cyan display on my scope. Oops. I was a little confused by the Ping))) document since it mentions 3.3V CMOS microcontrollers, but the "SIG pin" diagram makes it clear that Ping))) is going to drive 5V. Anyways came here to do a sanity check, and then immediately tried Phil's one pin circuit and it works for me. I don't have a variety of resistors handy, so just used three 2.2 kohm resistors to convert 5V down to 3.3V.
Sign In or Register to comment.