Academic Hardware Products (myDAQ, myRIO)

cancel
Showing results for 
Search instead for 
Did you mean: 

Ultrasone distance measurement

In my current assignment, I am to create a program in labview that continuously measures a distance between 20 cm and 1 meter, using a small speaker and microphone as transmitter and receiver of a 40 kHz signal. (SR-40-R-10B)

We are using the NI-USB-6212 hardware card with NI-DAQmx driver software.


I think I have a pretty good idea about how it should work, but I haven't got a clue how to do it (in Labview)

 

Basically, I'd think a short 40 kHz pulse could be transmitted, while also starting a timer. Then, the input-channel waits for its input (being the signal received by the microphone), which stops the timer. Use x= v/t (with v speed of sound, t = elapsed time) and you have the distance. Repeat this 10x per second and you have a 'continuous' measurement.

 

Please see the attachment for what I have so far, but it's not much.

I have also looked at the .vi file provided here: (https://decibel.ni.com/content/docs/DOC-19917) but I could not figure out how it worked, even though it seems so easy. However, it seems there is some hardware/programming in the chip itself, whereas I only have a transmitter & receiver and the 6212-card.

 

Any help would be greatly appreciated! I think it should be rather simple, but it just won't come to me.

 

0 Kudos
Message 1 of 4
(5,872 Views)

Hello,

 

Thanks for your posting in this forum and hope that I can assist you to go further.

I found an example in the link below that you can start with and hope it could be useful.

 

https://decibel.ni.com/content/docs/DOC-19917

 

If you have any question, it could be great to hear it from you.

 

Regards,

Hossein

0 Kudos
Message 2 of 4
(5,867 Views)

Thanks for your reply, but the link you provided is the same I mentioned in my post 😉

 

Anyway, I finished the program now in a slightly different way than I first thought. I thought I'd just upload it here in case anyone has a similar problem later on / needs inspiration.

 

The program works between 0 and 150 cm (tested), but possibly even at larger distances. I kept having a 3-5 cm deviation though, and I'm not sure what causes it.

 

0 Kudos
Message 3 of 4
(5,863 Views)

Hi,

 

Sorry for that Smiley Embarassed

I couldn't see what the problem is in your vi but I think that the sampling rate has influence in your measurement. If that is not high enough you will lose some info of your signal and causes some jitter which has influence in your accuracy.

I found another example in the link below.

I hope this helps

Smiley Wink

 

http://zone.ni.com/devzone/cda/epd/p/id/6470

Regards,

Hossein

0 Kudos
Message 4 of 4
(5,856 Views)