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.
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
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.
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.
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…