LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you capture times using an event marker?

I am collecting data using the NI 6071E DAQ card through an SCB-100 terminal. I want to capture the times that a digital signal begins to produce an "ON" value.

 

For this application, I am gathering analog data and attempting to use the digital signals as an event marker (that activate when an external switch is closed). I collect the analog data at 10,000 Hz for 10 seconds.

 

How would I perform such a task?

 

Thanks! 

0 Kudos
Message 1 of 9
(3,205 Views)

it can be done...use of elapsed timer, shift regs.,bool logic and data arrays

 

Spoiler
dig input.png

 

Message 2 of 9
(3,186 Views)

Thanks for the speedy response to this question. I have tried it and verified that it does work.

 

I am wondering if there is a way to improve the accuracy of the time measurement. The elapsed timer only gives time output in milliseconds, and the while loop only updates every 745 Hz. For our measurements, we are measuring the analog data at 10,000 Hz or more. Is there a way to increase the frequency that the while loop updates? Then I could use the iteration marker and determine time using that.

Or are there any better ways of doing this?

 

Thanks again!

0 Kudos
Message 3 of 9
(3,149 Views)

Holloway,

 

There is a timer that provides greater than 1ms resolution: http://zone.ni.com/devzone/cda/epd/p/id/3582

 

That said, I think you will be hard pressed to get your loop to run consistently at 10k.  

James K.
National Instruments
Applications Engineer
0 Kudos
Message 4 of 9
(3,124 Views)

Hi Holloway,

 

You'll want to use hardware timing to get the best accuracy possible.

 

So it sounds like you might want to know on which AI sample the digital line went high?  If that's the case, you can export the analog input sample clock and wire it to the source of one of the on-board counters.  Connect the external digital signal to the gate of the counter.  Configure an edge count task with a sample clock (gate == sample clock source, source == input terminal, don't use any triggering just start the counter task before starting your analog input task).  The example I linked specifies which input terminal the counter uses, but I don't believe this property is supported on the 6071E (just delete the property node and use the default terminal).

 

In this configuraiton, whenever your external digital signal goes high, you will sample the current count of the counter (which would correspond to the current AI sample).  Reading back the counter at the end will tell you on which AI sample the line went high.  Alternatively, you could switch the source/gate if it makes more sense to get one sample per ai sample (e.g. [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, ...]) although this results in much more data than the other method.

 

I believe on the 6071E you'll have to export the ai sample clock onto PFI 7 then physically wire it to the counter input pin.  Newer DAQ devices have more internal routing options, but I believe the 6071E does not have a direct route for what you need.

 

 

 

Best Regards,

John Passiak
0 Kudos
Message 5 of 9
(3,114 Views)

I have Labview 7.1 on a computer running Windows XP, and I have been experimenting with the timed loop feature, but I have been unable to set the time frequency rate at something other than the 1 kHz sample rate that is standard for that function. I realize this induces some lag into the system, but there is a way for me to make sequential measurements of the analog system while taking digital measurements of the time if I use the timed loop. Can you tell me how to change the frequency on the timed loop?

 

If it requires wiring the ao clock to a counter (or generating a clock signal from a counter), can you explain how to do that? I have been using LabVIEW exclusively for analog signals, and I feel digital signal generation is fairly complicated.

0 Kudos
Message 6 of 9
(3,082 Views)

Using a timed-loop (or any other software-timing) is going to be suboptimal since it introduces OS non-determinism into your timestamps.  Did my previous post make sense?  I don't think you should be looking at timed loops (but maybe I'm not quite understanding what it is you are trying to do).

 

You can use DAQmx Export Signal.vi to export the AI sample clock (I actually think on the 6071E it might just always be present on PFI7, but I don't recall as it's been ages since I've used an E Series).  Using the counter as I mentioned earlier, you can tell with certainty which AI sample correlates to when your external signal went high.

 

 

Best Regards,

John Passiak
0 Kudos
Message 7 of 9
(3,071 Views)

Preferably, I'd like to use the digital inputs as the 6071E only has 2 ports for counters and I was hoping to set up multiple event markers using the different digital inputs.

 

Can you explain to me what the non-determinism is in using timed loops? My goal of using the digital inputs is to be able to have an accurate time marker of when an event occurred during one run. 

 

We are currently gathering analog data from several transducers using the following, simple VI that was designed by someone who does not currently work at our facility. 

 

Current VI setup.JPG

 

With the event markers, we are hoping to capture times while the analog data is collecting. This would provide us with relative instances so we could compare transducer data trends that occur during the analog acquisition to time events. We're looking for one of the following:

 

* Time measurement relative to a fixed or arbitrary signal 

* Digital data vs. time, where a digital signal is captured every microseconds

* Absolute time reference to when a digital signal produces an "on" state

* Sample or loop iteration number of a consistently-sampled event that allows us to determine differences between times

 

We also are attempting to gather all of these on digital input lines, as it would offer us 8 channels on our existing device. If we could acquire any of these using a digital signal, it would allow us to determine what we need. However, I don't know how to create a VI that would perform any of these tasks, and as of yet I've had a lot of trouble dealing with digital signal acquisition. Can you direct me to a help topic on how to create one of these, or is this not a possible task? 

0 Kudos
Message 8 of 9
(3,051 Views)

I guess the course of action depends on your timing accuracy requirements.

 

 

The digital inputs on the 6071E are software-timed only.  The general form for a software-timed digital input task looks like this (also see apok's example earlier this thread which is more tailored to your use-case):

 

Read Dig Chan.png

 

The problem with this is that the timing of the loop is not guaranteed as your OS may prioritize some other action (running a virus scan, windows update, whatever else...).  Even without this consideration, the time it takes to execute a DAQmx Read call is likely greater than 100 us (it sounds like you want to run a 10 kHz software polling loop)--you'd have to benchmark this with your system and hardware setup to find out for sure though.

 

 

For more precise (as well as faster) timing, you'll typically want to use some sort of hardware buffering.  For example, your analog input task is using a sample clock to latch the input data into a buffer on the hardware--the software just reads back the entire buffer at the end of the acquisition and doesn't affect the timing of the samples.  You would ideally want something similar for your digital inputs.  If you have extra analog channels maybe you could just use those instead of the digital inputs?  If not, the counters can give you equivalent information without relying on software-timing (there are only 2 of these though).  The digital input lines however, do not support this.

 

 

Newer DAQ hardware (e.g. M Series except the 621x, X Series) does support clocked digital inputs.  The solution you're really looking for is probably to share the analog input sample clock and use this to time a digital input task, but this would require a new hardware purchase.  The counter method I mentioned earlier would work well on your current hardware but only for 2 lines.

 

 

Best Regards,

John Passiak
0 Kudos
Message 9 of 9
(3,036 Views)