Quote:
Originally Posted by Jared
I'm not sure this will work for a few reasons. First, I doubt that our setup with Java on the cRIO (or Java running on anything) will time the 30 microsecond pulse very accurately if you set it up the way you have it now.
Also, you'd need to run this loop really quickly to capture the pulse. If you're one inch away, your pulse is less than a millisecond away. It's possible to miss pulses entirely.
You really should use interrupts for this, or you should just add an arduino board that communicates with the cRIO with serial. I bet somebody has written an arduino library for this sensor.
Also, your timing method doesn't seem to compare the two FPGA timestamps to find the duration of the pulse. I don't think your two while loops will work the way you'd like them to.
|
I was going to use a Parallax Propeller board. I've never used an Arduino, but have used many of Parallax products, including this sensor in the past. Parallax itself provides libraries which should be sufficient to perform this task.
Quote:
Originally Posted by cgmv123
I wasn't sure how effective this code would be. I was just trying to provide a starting point for the OP.
I should have subtracted starttime. Added now.
|
That was the one thing I was wondering. If you disregard the start time, the measurement would be quite wrong!
It is a good starting point and I am happy that you shared this. We are pressed for time in our team and we just got a bot ready to program using. That means that our programming team is heavily behind at this moment.
I am considering telling my team not to waste time on sonar. I am already able to make vision systems that are able to mimmic this functionality, but without the main issues such as range, accuracy and constant calibration. This sensor is also quite slow, not fast enough for powering automated movement. The main use for this is obstacle detection while moving when video stabilization is not enough to remove the motion blur.