LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Measuring elapsed time

First off I'm quite new to LV, so apologies if the questions in this post are a bit naive.

 

My lab partner and I are trying to build an ultrasonic positions sensor by sending out pulses of 40kHz waves (each pulse about 0.1ms long, with a pulse freq. around 100Hz) and timing how long it takes for each pulse to return. Our trouble right now is with the timing portion: we seem to have run into trouble by simultaneously using traditional DAQ and DAQmx VI's. My questions:

 

  1. Are we correct that LV won't allow us to use both the traditional DAQ and DAQmx at the same time?
  2. Our lab DAQ's are model PCI-MIO-16E-4, and we use BNC-2120 I/O boards. Apparently this model DAQ has a 20MHz clock built in, which we'd like to use for our timing. If we're using strictly DAQmx VI's, which one would work best for our timing purposes? We need to have it start counting when the signal is sent out, stop when the receiver gets the signal, output the measurement, then reset. (I realize this will require more than one VI.) We had been using the Event or Time Counter Config VI, but that's a traditional DAQ VI.
  3. We think we ought to be using a timed loop running at 100Hz (each iteration would involve sending out and receiving signal, and measuring elapsed time). Would there be reason to use a different structure?  

 

Ideally we'd be figuring these issues out on our own. But we've only just started using the program, and apparently the version we get for home use doesn't have all the DAQ/DAQmx VI's available on our lab computers (to which we have access only a few afternoons per week). Incidentally, would there be any way to load those VI's onto our own laptops, even though we haven't got DAQ's?

 

Thanks in advance for any help. 

 

 

0 Kudos
Message 1 of 22
(5,350 Views)

Hi PatrickBM,

   1)Better use Daqmx vis than traditional daq Vis..

    2) For your application you can a sequence strucuture ,where in first frame you will send a pulse throgh analog out,start the timer,in the second frame  you will place a while loop which will be waiting for the loop to receive thorugh analog input,once received stop the loop,stop the timer and give the difference between the two timer values along with some calculation...

 

 

 

Thanks and regards,

srikrishnaNF

Regards,
Srikrishna


0 Kudos
Message 2 of 22
(5,335 Views)

Hi PatrickBM,

 

Take a look at the DAQ Meas Two-Edge Separation.vi Example in the NI Example Finder.  You can open it by going to Help»Find Examples... in LabVIEW.  Click the search tab and type "two edge".  That example VI should get you started.

0 Kudos
Message 3 of 22
(5,312 Views)

Thanks for the responses.

 

Unfortunately, the version of LV made available for our download (7.1 Professional Development System) doesn't include any of the DAQmx VI's. Consequently, I don't have access to the "DAQ Measure Two-Edge Separation" VI, the DAQmx help files, etc.

 

Is it possible to download these DAQmx VI's and add them to my version of LV on my laptop? Would I be able to experiment with any of these VI's on my laptop even though it doesn't have a DAQ? (Obviously those parts of a VI that required my specifying things like hardware channels would be useless.) 

0 Kudos
Message 4 of 22
(5,287 Views)

You should be able to download the appropriate DAQmx drivers for your version of LabVIEW. If you have Measurement and Automation Explorer (MAX) you will be able to simulate some devices with limited capability.

 

Hope this helps.

Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 5 of 22
(5,279 Views)

Hi Patrick,

 

Since you've gotten a couple posts with different ideas, let me try to consolidate some of the info.  First, to answer your original questions:

1.  For new applications we recommend DAQmx over Traditional DAQ.  Traditional DAQ is no longer being actively developed and does not support our recent hardware--it would be better to familiarize yourself with DAQmx if starting from scratch (even more so if you ever plan on upgrading to a more recent DAQ device).  You cannot control a single device simultaneously with DAQmx and Traditional DAQ.

 

 

2. The Two Edge Separation example from post #3 is unfortunately not a feature of our E Series DAQ Devices (including the PCI-MIO-16E-4).  The E Series User Manual describes which counter task types are available on page 5-10

 

The counters are the only subsystems that directly use the 20 MHz timebase.  It sounds like the accuracy of the measurement between when the signal is sent out and when the signal is received is the most important so we wouldn't want to compromise here by using a SW-timed measurement.  I think we can configure the counters to measure what you need, but see below for some follow-up questions so we can determine the best course of action for the structure of the program.

 

 

3. The program structure that you want to use is going to depend on how accurate the timing of each part needs to be.  Using SW-timing is going to give the least accurate results (but perhaps the exact timing of the 100 Hz pulse frequency isn't so important for your application).

 

 

As far as the DAQmx VIs, you can choose to include them when you install DAQmx to the system (should be part of the Typical Install for every supported version of LV that you have on your PC).  If you want to install DAQmx on your own laptop to develop at home you can download the latest version compatible with LV 7.1 here (you can even simulate the hardware to make sure you are configuring supported properties and are using correct syntax).

 

 

To help determine the best way to structure the program with your given hardware, we'll need to know the following information:

1.  Regarding the RX signal (presumably connected to an Analog Input channel):

a)  What is the amplitude of the signal in volts?

b)  Does the receiver pick up the signal sent by the transmitter or just the reflected version?  If it does pick up the direct transmitted signal, what is its amplitude in volts?

c)  Is it a requirement to be able to see the received signal graphically or do you merely have to detect when it occurs?

 

2.  How accurate does the 100 Hz frequency need to be which is initiating the output of the .1 ms pulse of the 40 kHz sine wave?  Is it OK if this runs slower if necessary?

 

3.  Regarding the difference measurement:

a)  What is the range of values you expect to see?

b)  What is the resolution of the measurement that you require?

 

4.  If necessary, is newer DAQ hardware an option?

 

 

Best Regards,

 

Message Edited by John P on 04-27-2010 07:01 PM
Message Edited by John P on 04-27-2010 07:03 PM
John Passiak
Message 6 of 22
(5,275 Views)

Hi John,

 

Thank you so much for the very detailed reply. And apologies for throwing different questions into the same post.

 

Regarding the actual goals for this application:

 

1.Yes, the receiver is hooked up to one of the analog input channels. (If it helps for timing, we could send the receiver's output to a

comparator set to switch on once the received signal passes a given threshold, then send the comparator output to a digital input.)

a) The amplitude is on the order of 100mV. (We could, if necessary, easily build an analog amplifier using some of the op amps

in our lab.)

b) The receiver will only pick up the reflected waves.

c) We needn't view the received signal graphically -- we only need to measure the time elapsed between when each signal was sent

out and when it was received. (Of course we'll be doing some arithmetic to this time measurement in order to calculate position,

and it would be nice to output that graphically.)

 

2. We could likely tolerate something less than 100Hz; far more important will be the time measurements mentioned above.

 

3. I assume by difference measurement you mean the time elapsed between sending and receiving the ultrasonic pulse. In that case:

a) Roughly speaking, we're expecting times between 0.3ms and 3ms. (We're looking to measure distances up to about 1m; I

assumed our minimum distance would be around 10cm and took the speed of sound as 340m/s.)

b) We'd like to have 1mm resolution, i.e. 3us. However, achieving cm resolution would probably be fine.

 

4. Unfortunately our state is quite broke, so upgraded hardware isn't really an option.

 

One note worth mentioning: we initially planned on measuring 3D position sensing using one transmitter and 3 receivers. Obviously getting this to work in 1D is a prerequisite. Will our hardware support two additional sensors while maintaining the hoped-for accuracy?

0 Kudos
Message 7 of 22
(5,260 Views)

Hi Patrick,

 

The 3 channel requirement does change things a bit--there isn't a good way to directly use the 20 MHz timebase to timestamp all 3 channels (E Series devices only have 2 counters).

 

With your 16E-4 you would probably have to do something like this:

1.  Sample AI continuously at max rate (250 kHz / 3 channels = 83.333 kHz).  AI would be triggered off of the AO Start Trigger (call this t=0).
2.  In software, determine which sample of the AI corresponds to the signal being received on each channel. 
3.  Each sample on a given channel would be ~12 us apart, giving a theoretical resolution of about 4 mm (when measuring sound @340 m/s).  The skew between channels would be 4 us since the board is multiplexed.


If new hardware were an option, I would look into something like the PCIe 6321 (if you have a PCI Express slot available).  You could use the same BNC 2120 but would require a different cable since the M and X Series DAQ boards use a different connector from E series.  The method I would use on this board would be as follows:

1.  Configure a 2-edge separation task for 3 seperate counters (1 for each channel).

 

2.  Use an external comparitor for each channel to convert the received signal into a 0-5V TTL pulse (pulse when the signal is received).

 

3.  Use the AO Start Trigger as the first edge for each of the 2-edge seperation tasks, and the output of the corresponding comparitor as the second (the output of the comparitor would be routed to the counters through one the PFI lines on the X Series).

 

4.  You would be able to measure the number of ticks of the 100 MHz timebase between the two edges, giving a 10 ns resolution.

 

Either option sounds feasible, but it does depend on the ability for the receiver to accurately pick up the signal.  The AI method relies a bit on software for processing, but the actual samples are clocked in by the hardware so you should be able to reliably determine where the signal is received.

 

 

Best Regards,

John Passiak
0 Kudos
Message 8 of 22
(5,248 Views)

Hi John,

 

Unfortunately we can't get new hardware for the project, so we'll have to work within the 16E-4's limits. Based on that, I was hoping you could help with a few follow up questions:

 

  1. Since there are 2 20MHz counters, could we take measurements with 2 receivers (i.e. 2D) and still use this timebase?
  2. I haven't found any sample VI's for measuring the time elapsed between sending out an analog signal on one channel and receiving an analog signal on anther -- are there any? Or more generally, are there any examples of how to trigger a counter to start based on input from one channel, then trigger it to stop based on an input from a second channel?
  3. Would it be possible to use the method you described for something like the PCIe 6321 with our current setup, scaled down to measure 2 channels? In other words, use 2 edge separation tasks, hooking up the receivers to external comparators, etc?

 

Thanks again for your assistance.

 

Regards,

Patrick 

0 Kudos
Message 9 of 22
(5,209 Views)

Hi Patrick,

 

1. I think you're going to be limited to 1 channel unless you want to use an external comparator for each of the two channels.  You would also need an external OR gate since E Series boards don't support two-edge separation mode.  What I'm thinking is:

i.   Export the Analog Output Start Trigger

 

ii.  OR this with the output of your comparitors (one comparitor for each of the 2 channels)

 

iii.  Configure a Period Measurement on each counter to measure the time between the start trigger and the first rising edge on the comparitor.

 

2.  The counters only work with digital signals, which is why you need the external comparitor.  The 16E-4 does support Analog Triggering, so you can work around this for 1 channel by configuring an Analog Trigger on your AI task.  There is an internal signal called Analog Comparison Event which is the result of the comparitor used for analog triggering.  This won't work for two channels since you can only have a single analog trigger.

 

3.  This is what the method above is describing--the only difference is that the 16E-4 doesn't support two-edge separation mode.  Also, the timebase is 20 MHz instead of 100 MHz.

 

 

Best Regards,

 

John Passiak
0 Kudos
Message 10 of 22
(5,188 Views)