Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Determine analog sample count of digital event

I will be doing a long term (1+ hour) continuous acquisition at 100KS/s and will need to coorelate digital input events with the analog data.
 
The question is, can I find out what the analog sample count was when the digital input edge happened?
 
Please provide any insight as to how to do this.  By the way, I do not speak LabView so any code needs to be CVI, C++, or VB.  Thanks.
 
I have 2 NI PCI-6154 DAQ cards connected with an RTSI cable.

Message Edited by RedWoods on 04-05-2007 10:45 AM

0 Kudos
Message 1 of 4
(3,281 Views)
Hi RedWoods,

Could you please provide a little more insight into your application.  It seems as if you will have only one digital edge taking place?  When you say you want to find the analog sample count, do you mean that you want to find how many analog samples have been acquired at the time the digital edge took place?  If that is the case, and please correct me if I am wrong, you would be better off using a reference trigger. 

A Reference trigger establishes the reference point in a set of input samples. You can configure this trigger to occur on a digital edge, a digital pattern, an analog edge, or when an analog signal enters or leaves a window. Data acquired up to the reference point is pretrigger data. Data acquired after this reference point is posttrigger data.

DAQmxCfgDigEdgeRefTrig

int32 DAQmxCfgDigEdgeRefTrig (TaskHandle taskHandle, const char triggerSource[], int32 triggerEdge, uInt32 pretriggerSamples);

Purpose

Configures the task to stop the acquisition when the device acquires all pretrigger samples, detects a rising or falling edge of a digital signal, and acquires all posttrigger samples.

Hope that helps.

Regards,
Raajit L
National Instruments
0 Kudos
Message 2 of 4
(3,246 Views)
Thanks for your reply.  Let me be more specific.
 
I will be monitoring multiple digital inputs on the DAQ card throughout the acquisition period (1+ hours at 100kS/s).  The digitals will be asynchronous and may occur many times.  For example, if I get digital state changes at (relative to the start of the acquisition) 1s, 10s, 100s, and 1000s I need to find out in code (in as close to real-time as possible) that a digital change occurred at 100,000 samples, 1,000,000 samples, 10,000,000 samples, and 100,000,000 samples respectively.
 
I hope this helps clarify and thanks for your help.
 
0 Kudos
Message 3 of 4
(3,247 Views)
Hello RedWoods,

Unfortunately, the NI PCI-6154 only has static Digital Input/Output lines and not correlated (or hardware timed) Digital I/O. This makes it a little more challenging to synchronize different operations, but not impossible. I would recommend that you examine the DAQmxRegisterSignalEvent function. This function "Registers a callback function to receive an event when the specified hardware even occurs." Amongst the valid hardware events are change detection events, which are "signal[s] a DIO device generates after it detects a change—a rising edge, a falling edge, or both rising and falling edges—on the data lines."

You could register a change detection event for your digital lines and then count the number of elements in your analog input array in the callback function. This would give you the number of samples that you had read into the program at the time of the digital pulse. The only problem with this method is that the number of samples in the analog input array is only updated when you read data from the DAQ card to the program using one of the DAQmxRead functions. I am assuming you would probably acquire your analog signal continuously at a rate of 100kS/s as you described in your previous post. So, you would use the numSampsPerChan parameter to determine how many samples to read from the DAQ device to your computer and then you would execute this read continuously for an hour or so. In effect, you would have a maximum error of numSampsPerChan in your number of samples because the digital change event would be processed between reads from the DAQ device. Depending on the precision you require, this error may or may not be acceptable. However, there is no way to synchronize static digital acquisition with the analog acquisition in hardware.

You also mentioned that you have multiple NI PCI-6154 devices connected with RTSI cables. If you are trying to monitor digital lines on multiple devices for change detection, you will need to export these signals to the device that is acquiring the analog signal. This can be accomplished using the DAQmxExportSignal function, which is described as such:

"Routes a control signal to the specified terminal. The output terminal can reside on the device that generates the control signal or on a different device. Use this function to share clocks and triggers between multiple tasks and devices. The routes created by this function are task-based routes."

In this way, you can share the digital lines on multiple boards and monitor each one for a change event. For more information about the functions I have described I would recommend that you view the NI-DAQmx C Reference Help. This document should be located on your computer by going to Start>>All Programs>>National Instruments>>NI-DAQ>>NI-DAQmx C Reference Help.


Matt Anderson

Hardware Services Marketing Manager
National Instruments
0 Kudos
Message 4 of 4
(3,223 Views)