Hardware Developers Community - NI sbRIO & SOM

cancel
Showing results for 
Search instead for 
Did you mean: 

monitoring hcsr04

How to monitoring distance with hcsr04 ultarasonic sensor on sbrio 9637?

0 Kudos
Message 1 of 2
(3,446 Views)

This unit uses digital only to do the ranging and timing measurements to do the distance calculation.  You'd only need two channels it looks like.  Trigger (output) and Echo (input).

 

Implement in the FPGA and output the trigger pulse, and then monitor the input echo channel for the Echo F-> T rising edge (save time in clock ticks or us) then monitor for T -> F transition, subtract the two to get the high time then convert per manual:

 

Formula: uS / 58 = centimeters or uS / 148 =inch; or: the range = high level time * velocity (340M/S) / 2

 

They suggest in the manual to wait at least 60ms  between output triggers in order to prevent trigger signal interfering with the echo signal.

 

You can then publish the distance result through one of the FPGA mechanisms for use on the FPGA or send it over to the RT via Front Panel indicator or DMA.  You'll probably only need Tag access type though, through programmatic front panel method.

 

To physically connect it you need to access the DIO lines on the IDC connector - you can do that various ways - here is an easy one: http://sine.ni.com/nips/cds/view/p/lang/en/nid/213313

 

Have you taken the Embedded Control and Monitoring using LabVIEW course?

Ryan Vallieu CLA, CLED
Senior Systems Analyst II
NASA Ames Research Center
0 Kudos
Message 2 of 2
(3,436 Views)