How to use Parallax PING)))

Hello,
Another basic question:
what’s the best way to read the Parallax ultrasonic sensor?

The sensor has one pin that is initialized by a 2-5ms high pulse, and the sensor returns a highg pulse equal in length to the tieme take by the ping.

I imagine the idea would be something like this:

Set port high for the init time. Change port to edge triggered input. Start some sort of timer on the high edge, stop on low the low edge and convert time to distance.
Would this work? Is there a stopwatch enywhere in the NETMF? Are there any examples how this is done.

Thank you
Yuriy

I don’t think that NetMF is fast enough to do this, you need some sort of realtime processing for this. Even Interrupts can be a millisecond behind or even more (including the timestamp) as far as i’m aware. This would make measuring distance based on time extremely difficult.

I do however suggest you try it and see. If you record the DateTime.Now.Ticks or get Ticks from System.Environment - then look at the tick count on the interrupt and see what the difference was. If this is reliable (ie: within the PING)))'s margin of error) then it looks like you have a solution :slight_smile:

Probably the best you can get is puting your sensor on interupt pin (both edges). Interupts gets a timestamp when they occur. You then just need to calculate difference between them.

Anyway, Mark is right - you should try it yourself.

I think sparkfun sell those with some little built in circuitry so you get the distance as serial data

Look here for the ping stuff. Haven’t tested it myself. Netduino and Ping))) Ultrasonic Sensor? - Netduino 2 (and Netduino 1) - Netduino Forums

ycroosh

Let us know if you try this and, if so how well it works.

I want to get an ultrasonic myself. It’s cheaper to pay more at Radio Shack than to buy online and pay for shipping.

If I were to get it online I’d get a Maxbotix or the like, as it will out distances in voltages and you can use MarkH’s assembly to save development time.

I have a SRF-08 from DavenTech but haven’t tried it on a Domino. It would work since it uses I2C and you simply send a ping command and then it collects data via a PIC chip for up to 14 echoes. It stores it in milliseconds, inches or centimeter format which you can access at anytime after the ping. It has a bonus of a CDS light sensor as well.

Yeah, the Parallax I have emits serial data that is a snap to convert into meters or feet. 2 lines of C++ on the Arduino.

I’d love to hook one up and provide everyone with some working code, but my Panda Tinkerer’s Kit still hasn’t been shipped (HINT, HINT)

:slight_smile:

I have uploaded the code I am using in my projects.

http://www.fezzer.com/project/172/parallax-ping-sensor/

Cheers
V

˙˙˙ʎןןɐǝɹ ʇuɐʍ noʎ ʇndʇno ɹǝʌǝʇɐɥʍ ʇǝb uɐɔ noʎ ǝsnɐɔǝq xıʇoqxɐɯ ǝɥʇ ɹǝɟǝɹd ı

Maxbotix, nice… ???

¡doʇs ˙ʎɐʍ ʇɐɥʇ pɐǝɹ oʇ pɹɐɥ ʎןןɐǝɹ sı ʇı ¡¡¡sʎnb

How about regular text? :smiley:

Architect,
You’re the … uhm, PERSON. The code works great.
It looks like the accuracy is pretty good (I get +/- 5mm off, which is good enough for my applications). Keep in mind that i have a lot of threads running and raising events (drivetrain asks for direction every 200ms, heartbeat blinks LED every .5 s, LCD is constantly updating, etc,)

I experimented with the interrupt approach but for some reason I can’t set/use interrupts on TriStatePort (when I call EnableInterrupt or add a handler I get an InvalidOperationException from Microsoft.SPOT.Hardware).

Overall it appears that PING))) is useable on FEZ Domino…

Thank you
Yuriy

I am glad you like it. I will look into interrupts and might have an example later.

How about sharing the code? ;D

^^^ It’s on FEZZer

awesome work. It works very nicely.

Architect, can you give a new link for Parallax Ping))) Sensor?

thx )

It is here http://www.tinyclr.com/codeshare/entry/123

everything was moves to local codeshare. Welcome to the community.