ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Signal Triggering for ultrasonic pulse

Hey,

 

actually I am working on a project, where I would like to calculate the distance between my ultrasonic sensor

and my object. I have a NI 9402  and one ultrasonic sensor, which can send and receive the signal.

 

My idea was to generate a signal on channel 0 and to receive the "answer" on channel 3.

It is working ok, but I still have problems in calculating a precise time value to calculate the distance.

 

I would really appreciate if someone would have an idea how to realise thatSmiley Happy

 

Thanks in advance for your help.

 

Kind regards,

Felix

0 Kudos
Message 1 of 3
(3,165 Views)

Hey there Felix,

 

I'm not exactly sure what sort of problems your running into calculating the time value. Could you elaborate?

 

I do have a hunch at what might be going on. You are using a local variable to communicate between the two loops. This can lead to unexpected behavior, since the value of the local variable may change before it is read, leading to a race condition where we do not know what the outcome of the code will be.

 

If you are looking to measure time, and do it in two separate loops, I would look into using something like an FGV timer

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

 

This is a commonly way to measure time in a way that can be used to prevent race conditions.

 

Also, if you ever need to convert LabVIEW code into a different version, you can post the code to the following forum with your request:

http://forums.ni.com/t5/Version-Conversion/bd-p/VersionConversion

Daniel C.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 3
(3,114 Views)

Thanks for your answer. I think that might be the problem.

 

I have tried to implement the timer, but it didn't really worked.

I think I did a mistake. I haven't understood, how to send the different time values between the loops.

 

Could you maybe do me the favor and show me how to fix my VI with the new timer?

 

I would really appreciate that and thanks for your help in advance!

 

Kind regards,

Felix

0 Kudos
Message 3 of 3
(3,091 Views)