LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ping ultrasonic on fpga

hello everyone, i'm having some difficulty in getting readings from ping ultrasonic sensor on fpga myrio 1900.... ping sensor uses the same DIO for the trigger and echo, i developed fpga code and tested with hc-sr04 ultrasonic sensor which uses two different DIO channels and it is working fine, but when i change the code to use the same DIO channel i get no readings..... can anyone help me find what is wrong with this code or what am i missing?.... thanks in advance

0 Kudos
Message 1 of 10
(4,551 Views)

I use an HC-SR04 module with LabVIEW FPGA on a SBRIO 9636.  I use 2 pins and it works fine. You cannot 1 pin with the HC-SR04 because one pin is an input and one pin is an output.  when you join them together you are shorting out the pins so you will not be able to drive the trigger pin high (the echo pin will be driving low).  Now, if you have a different variant of the HC-SR04 which tri-states the echo line until it needs to drive high, one pin would work.  It would be nice if this existed but i dont think it does.  It would be possible to design this interface yourself I think, but it would add electronic components to your interface.  If you really need to save on pins then have a think about it, otherwise, use 2 pins. I hope this makes sense.

Let me know how you get on,

MIchael.

0 Kudos
Message 2 of 10
(4,537 Views)

hello Michael, thanks for your reply.... but you didnt understand me... i'm not trying to use the hc-sr04 as 3 pin, i said i tested it with my code and it is working fine... but when i use the code witha ping sensor which already have only 3 pins (1 pin for the trig and echo at the same time)... i cant get any readings

0 Kudos
Message 3 of 10
(4,532 Views)

Do you have an oscilloscope available?  I cant see what is wrong, but i am sure that it will quickly become clear when you see what is happening on the line.  If not, you could wire the line to a spare analogue or digital input and read that input as fast as possible, use a DMA to send the data to a host VI and display the result.  You need to see the two pulses are at the expexcted timing and voltage level.  Could you post a link to the datasheet for the sensor?

0 Kudos
Message 4 of 10
(4,515 Views)

here is a pdf for the datasheet.... i dont have oscilloscope unfortunately....but i will try to use another digital line to monitor the signals, but i think it will be difficult because the signals are in micro seconds....

0 Kudos
Message 5 of 10
(4,512 Views)

they are fast, but then you are using one pin fast already.  use another loop, trigger the aquisition off the first loop with a local variable. it should not be too hard that way.  Analogue would be nice too, so you can see if the output drivers are colliding.   You will see a voltage somewhere between the expected logic levels.

0 Kudos
Message 6 of 10
(4,508 Views)

ok, i will try to monitor the signal and get back to you with the results... thanks for your help 🙂

0 Kudos
Message 7 of 10
(4,504 Views)

Also you need another delay, in the datasheet it states:

Delay before next measurement: 200 µs

0 Kudos
Message 8 of 10
(4,501 Views)

here is what i read on the analog input channel... dont know if it is supposed to be this way

0 Kudos
Message 9 of 10
(4,487 Views)
Does not look great. What is the timebase? And is the voltage mV? Remember to add in the extra delay I mentioned from the datasheet too. Make sure your target is a known distance so you know what should happen too.
0 Kudos
Message 10 of 10
(4,475 Views)