Academic Hardware Products (myDAQ, myRIO)

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use Labview to calculate the distance at which a sensor detects an obstacle?

Is there any way to use labview to do a calculation?

For example, if i were to transmit a 80kHz signal with a sensor, is there any way to use that signal to do calculations such as the distance of the obstacle from the sensor if i the signal were to have an obstacle and reflected back towards the receiving sensor?

0 Kudos
Message 1 of 14
(10,192 Views)

With reference to my original question, i wanted to edit it but noticed that i could not anymore. So i replied to my own question...

 

https://decibel.ni.com/content/docs/DOC-19917 refering to this link, is there any way to modify the program so that it can be done with the Elvis platform instead?

 

0 Kudos
Message 2 of 14
(10,188 Views)

Yes, you can certainly use that sensor with LabVIEW.

 

The LINX toolkit provides VIs for ultrasonic sensors that work with all LINX devices including myRIO, chipKIT and Arduino.

 

If you're using Elvis you'll need to generate a 'trigger pulse' (~10 uS or more digital pulse) to start the sensor, then read the pulse width returned by the sensor.  The return pulse width represents the time distance to the object.  The formula for converting the pulse width into cm or in can be found in the device datasheet.

 

Let us know if you have more questions, and make sure to share the code if you get it working with Elvis.

 

Thanks,

 

-Sam K

LabVIEW Hacker

Join / Follow the LabVIEW Hacker Group on google+

0 Kudos
Message 3 of 14
(10,178 Views)

Hi, 

what if i am using this sensor below instead? GH 311. 

 

However, i am also considering using the 2 sensors without the board, do you know if a simple non-inverting amplifier is able to allow the sensors to work? I tried using the sensor and connecting it to the elvis board by inserting a signal from the analog output but the sensor did not work.

Please get back to me soon! Thanks.

 

Do you think the HC-SR04 works if i want to input a 40kHz sine wave to it? I read the datasheet that you gave, and also some other sites, i saw that it is usually used for robotics and the signal of square waves is sent out automatically from the sensors. 

 

 

 

0 Kudos
Message 4 of 14
(10,025 Views)

Hey w.joey,

 

The way these ultrasonic sensors typically work is that you send them a trigger by setting a digital line high.  This tells the sensor to start.  The sensor then outputs a pulse on a digital line.  The pulse width corresponds to the time it takes the sound wave to travel from the sensor, to an obstacle and back.  You can use the speed of sound to calculate the distance the sounds traveled and determine the distance to the obstacle.

 

Can you give us more details on what exactly you are trying to do?  Why are you planning on using the sensors without the board?  Which specific components do you plan on using and what exactly do you plan to do with them?

 

Thanks!

 

-Sam K

LabVIEW Hacker

Join / Follow the LabVIEW Hacker Group on google+

0 Kudos
Message 5 of 14
(10,016 Views)

Hi,

 

I'm using the Elvis platform to create a sine signal using an Elvis platform and i want to send this signal to the sensors that i have previously mentioned. The sensors independent of any board has a receiving and transmitting sensor each. I want to send the signal to through the transmitting sensor and receive it through the receiving sensor. I wanted to test the sensors to see if it could working first, before using it to detect obstacles and calculating the distance of the obstacle from the sensors. I tried using just the sensors by itself, but it didn't work, so i'm inquiring if you know more about ultrasonic sensors to know if it would working if i added a simple non-inverting amplifier to it.

 

The components i am planning on using is the Elvis platform which i am currently using to create the sine signal using the Arbitrary Waveform Generator, and send the signal to the transmitting sensor, receive it with the receiving sensor and view the waveform on LabVIEW. Then i want to use the sensors to detect obstacles and use labview to calculate the distance of the obstacle from the sensor.

 

I do not have the HC-SR04 board at hand, but i do have the GH 311. I want to know if it would do with what i have in mine, which i have just stated previously.

 

I appreciate your fast response and help with my questions. Look forward to your reply.

Thank you.

 

 

0 Kudos
Message 6 of 14
(10,011 Views)

Hey w.joey,

 

If you need to do the signal generation yourself (for a class?) You can probably get it to work, but you'll almost certainly need an amplifier on both ends (transmit and receive).  I'm not too familiar with the transmitter and receiver components (I've just used the sensor as a unit) but I think its basically a speaker and a microphone.  I'm not sure if there are specific frequencies that they are tuned to, or if you're going to get a bunch of ambient noise on receiver end and have to filter it out yourself.

 

If your end goal is to measure distance I would try to use the GH 311 as a unit with digital I/O (this should be relatively easy with ELVIS).  If you need to bread the sensor down into components you'll probably need to do some research to learn more about how the receiver and transmitter work.

 

Good luck, let us know if there is anything else we can do to help.

 

-Sam K

LabVIEW Hacker

Join / Follow the LabVIEW Hacker Group on google+

 

 

0 Kudos
Message 7 of 14
(10,008 Views)

Hi,

 

How many times do i need to amplify the sensors with the amplifier?

 

As for using the GH 311 as a unit with digital I/O, would it be a problem if i am using analog I/O instead?

I did research but there is really little on the sensors by itself, as well as for the GH 311. I originally planned to use another circuit, but the circuit would be too much trouble to create with individual components, which are more than HC-SR04, i have to solder together.

 

Thank you.

0 Kudos
Message 8 of 14
(10,005 Views)

Hi,

 

May i ask what exactly is it i need to amplify in order for the sensor to work? The voltage or the signal?

I think the amplifier i should use is LM386 or should i use those from the 74XX family?

 

Please get back to me, hope to hear from you again soon.

Thank you.

0 Kudos
Message 9 of 14
(9,991 Views)

Hey w.joey,

 

You could use an analog input and output, but Digital IO would be much easier since that is what the sensor is designed to work with.  Is there a reason you need to use analog?  The data sheet explains everything you need to know to get the sensor working.  I suggest you pick one of the sensors and try to get it working with ELVIS Digital I/O.  Let us know if you have specific questions about how it works.

 

Thanks!

 

-Sam K

LabVIEW Hacker

Join / Follow the LabVIEW Hacker Group on google+

0 Kudos
Message 10 of 14
(9,987 Views)