Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Pre-triggered DAQ from C API on 6289 M Series

Hello,

I am having a hard time to implement to following scheme using the NI-DAQmx C API on a 6289 M Series Card.
Here's the story:

1. In order to have a syncronized AO and AI I create two corresponding tasks, where the output task is bound to the "Onboard Clock", wheras the input task is timed by the "SampleClock". The sampleMode is DAQmx_Val_FiniteSamps for both.

2. After starting both Task Clocks the syncronized DAQ is initiated by a call to DAQmxReadAnalogF64.

3. Now the intention is to aquire the samples until a analog input trigger level is reached, which shoud stop the aquisition task and the AO task and return the number of so far aquired samples (sampsPerChanRead) so they can be extracted from the readArray.


The closest solution I found so far from searching this forum and the docs, was to use a pause trigger. The problem with this solution seems to be that is doesn't stop the task but only pauses it.

Any advice on how to implement a solution for this problem is highly appreciated. I just hope that I didn't miss the "obvious solution".

Thanks in advance

Peter
0 Kudos
Message 1 of 3
(3,076 Views)
The closest thing DAQmx has to a Stop trigger is the Reference Trigger. This text is from the DAQmx help under Key Concepts->Reading and Writing Data->Buffering->Reference Triggering and Buffers:

Until the Reference Trigger occurs, the acquisition runs continuously even though you must set the sample mode parameter on the Timing function/VI to Finite Samples. The number of posttrigger samples in your buffer after the acquisition has finished is equal to the value of the samples per channel parameter from the Timing function/VI minus the number of pretrigger samples from the Trigger function/VI. When using a Reference Trigger, the default read position is Relative To First Pretrigger Sample with a read Offset of 0.

To use the reference trigger as a stop trigger, and not lose any data, do the following:
1. Set samples per channel to 4
2. Set pretrigger samples to 2
3. Set your input buffer size to a size big enough to hold all the data without wrapping around.
4. Set the read position to Relative to First Sample before reading

Also, make the analog input task the master (send its sample clock to the analog output task).

Use the Wait Until Task Done function to wait for the task to finish. Query Total Samples Acquired and use that as the value for numSampsPerChan in the DAQmxReadAnalogF64 function.
Message 2 of 3
(3,048 Views)
Hi thayles,


thanks a lot for you reply! Problem solved!

Best regards
Peter
0 Kudos
Message 3 of 3
(3,024 Views)