05-29-2017 06:12 PM
Hi, i'm trying to connect my Ultrasonic sensor to my cRIO to read distance but i'm having some issues. The sensor has 4 pins, echo, trigger, vcc, ground. The trigger is connected to a DO (NI 9472) and the echo (receiver) to DI (NI 9411). The sensor first need to get 10 usec pulse in trigger to activate the echo pin. When echo is activated, it sends a ultrasonic signal and when it bounce and return, thats the distance. My issue is I can't read anything. I want to measure the time when DI is on and when is off. How should i do that? I'm working with FPGA so I thought I could just put the DI and DO in there and control them via RT but i couldnt. Any suggest? Please.
I'm using LV 8.0 and cRIO 9002. Chassis 9104.
Thank you
Solved! Go to Solution.
05-30-2017 06:25 AM
Hello,
could you please attach your VI?
-James
05-30-2017 09:58 AM
This is the VI. In my project, I have this part inside the FPGA. I also tried to connect the DI to the stop control just to stop the process and see if the value measured had congruence with the distance I was using. Thank you for your help
05-31-2017 10:56 AM
Hello rolandonunez,
You must disable the output before you can use the same resource to read input. Here is a link that might help you:
http://zone.ni.com/reference/en-XX/help/371599H-01/lvfpgaconcepts/performing_basic_i_o/
If you want to measure the time from when the digital input was on and then off, you can try something like this:
http://digital.ni.com/public.nsf/allkb/6F6B9F4E149C80578625652800784764
Like the example in the link, you can add another frame for you code and then compare the times.
Hope this helps.
Regards.
05-31-2017 06:25 PM
Here is my code for reading an HC-SR04 in LAbVIEW FPGA:
TriggerTankLevelRead is set True by the Real Time host (cRIO), this kicks off a measurement.
The cRIO then waits about 100mS before reading TankLevelPulse. during this time, the FPGA executed the frames:
DIO1 high, 10uS delay, DIO1 Low. Wait for rising edge, get start time, wait for falling edge, get stop time, subtract times and return pulse length.
Abort is used to get out of the otherwise endless while loops if the sensor is disconnected.
I have been using this code to read liquid level in a tank for a couple of years now, so thumbs up to the sensor, and the software!
I think this will work for you too. Happy to help,
Michael.
06-03-2017 04:27 PM
Thank you very much! It works!
05-03-2018 01:55 AM
Hi Michael.
I was wondering what is the coding for the false condition in the case structure?
Hope that you can help.
05-03-2018 02:50 AM