LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

using an HC-SR04 ultrasonic ranging module with a MyRio

Hello,

 

I am attempting to use a NI MyRio to aquire data from an HC-SR04 ultrasonic ranging unit and am having very little success. I am able to "activate" the unit, and I can see from use of an oscilloscope that it is functioning properly, but I am unable to recieve or interpet the data from the unit. I have done some poking around the forums but similar solutions to this seem to be all for the DAQ or for fpga manipulation and I'm trying to get this done in a VI (I know little to know about the FPGA and programming it).

 

basicly the HC-SR04 requires a pulse of 10uS length to activate and send out a single range test, it then sends a pulse signal back on a different pin and the length of the pulse is how you determine the distance to the object being ranged. 

 

so i suppose what I'm asking is "is there any way to build a VI to time how long a digital signal is high for in labview on a MyRio unit?"

 

here is a product sheet for the HC-SR04 if it helps

 

http://www.micropik.com/PDF/HCSR04.pdf

 

https://docs.google.com/document/d/1Y-yZnNhMYy7rwhAgyL_pfa39RsB-x2qR4vP8saG73rE/edit

 

thank you

0 Kudos
Message 1 of 8
(5,632 Views)

Use a digitial input and edge detection functions in FPGA code compared to the FPGA clock to determine the timing of the rising edge and the falling edge.

0 Kudos
Message 2 of 8
(5,612 Views)

Im very new to using the labview software and am unfamiliar with use of FPGA coding.. could you maybe ellaborate, or is there a solution using non FPGA?

 

thank you

0 Kudos
Message 3 of 8
(5,565 Views)

I have an update to this issue. I am now able to get a relatively stable readout of the distance through some measurement taking and calculations, however I am having a new problem now with the code I am using to do this. I have posted images of the code for reference. 

 

in the code I am using an incrementing counter to run the right most loop a certain number of times so that the Digital input (echo signal) is able to check over and over again if the signal is high or low. it counts how many highs it sees and that value is represented in "true count". I then characterized the amount of "true counts" that correspond to certain distances (see graph image) and applied this math to that count so that it represented a real distance. this seems to work well enough as long as the incrementing counter I mentioned earlier is set to 600 or more ticks, however the lower I go the more speradic the values I view for "true count" and on "distance in cm" become, they even seem to be jumping between the actual distance and a flat zero.

 

does anyone know of or see a reason why this may be happening?

 

or have a better solution to this task?

 

thank you,

Zach Koerner

0 Kudos
Message 4 of 8
(5,544 Views)

Since you said you were new to LabVIEW and FPGA, I would go through all of this: http://www.ni.com/tutorial/14532/en/

 

0 Kudos
Message 5 of 8
(5,500 Views)

can do. thank you for the link

 

0 Kudos
Message 6 of 8
(5,478 Views)

please could you send me the code which you made it.

 

0 Kudos
Message 7 of 8
(5,120 Views)

Hey man!!!

Do you have the vi? 

 

Thanks a lot!!!

0 Kudos
Message 8 of 8
(4,104 Views)