VEX Ultrasonic Ping-Response sensor

Hello,
we are trying to study about rangefinder sensors and we would like to know how to connect it to the roboRio.

Can you post a link or info about which Vex sensor you are trying to use?

If you man the Parallax PING))) Ultrasonic Distance Sensor, this is ready to plug directly into an analog I/O port with nothing but a dual female 3-pin dupont (header) cable. I have personally used it on arduino, and for analog inputs, these seem to be 100% hardware compatible with the 'RIOs. IIRC, the analog read value just needs to be scaled linearly (mx+b) to get range.

Most rangefinder sensors that say they are 5V or 3.3V analog can be used with the analog I/O, though some have more non-linear conversions (we have used a Sharp sensor that had a v=1/r relationship between voltage and range).

Digital rangefinders may be simple binary (yes/no), which is definitely supported on the DIO port, or some sort of serial I/O interface, which would require more specific info to evaluate.

@GeeTwo We are attempting to use the parallax, and are debating if it is supposed to read as digital or analog. Do you have example code (hopefully java) on how to properly use the sensor?
Thanks.

I actually have one three short steps from my computer, for some reason jammed into a giant (~6" long) eraser, most likely by @ExploitSage. I’ve never used with a RIO, only with arduino.

Here’s a document about the sensor:

The bottom line is that it provides range through a timed pulse (see “communication protocol” in the document above). This appears to be similar to the SRF-04 example here:
https://wpilib.screenstepslive.com/s/currentCS/m/java/l/599715-ultrasonic-sensors-measuring-robot-distance-to-a-surface

Edit/add: Note that the burst pulse is 0.2ms long. As sound travels ~343 m/s (1140 ft/s), this pulse is physically about 7cm or 3" long as it travels. This sensor will be mostly useless at ranges less than a couple of inches, and has an inherent uncertainty of roughly half the pulse length stated above.

Oh, and yes, it does actually look like a digital device.

OK, major update. There are 3-pin and 4-pin versions. If you have a 4 pin version, you must initiate the pulse through the input pin (Trig). If you have a 3 pin version, it apparently fires automatically you need to trigger the pulse output on the same pin as you read the input.

Tweaky points: I have the 4 pin version. It turns out that @Pereichi stuck it in the eraser.

We have the 3 pin version. What doesn’t seem to work is sending the initiate pulse command over the “analog-in” pins.

It looks like you need a DigitalInput to initiate the pulse, and a DigitalOutput to read the results, and they need to be on the same pin. I don’t know if you’re going to have to discard one and instantiate the other to switch, or what. It may end up requiring something in between to make the 3 pin version into a 4 pin device. This would be pretty easy with a small arduino or other processor.