Main Site Documentation

How to use Parallax PING)))


#1

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


#2

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:


#3

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.


#4

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


#5

Look here for the ping stuff. Haven’t tested it myself. http://forums.netduino.com/index.php?/topic/139-netduino-and-ping-ultrasonic-sensor


#6

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.


#7

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.


#8

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:


#9

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

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

Cheers
V


#10

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


#11

Maxbotix, nice… ???


#12

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


#13

How about regular text? :smiley:


#14

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


#15

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


#16

How about sharing the code? ;D


#17

^^^ It’s on FEZZer


#18

awesome work. It works very nicely.


#19

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

thx )


#20

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

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