Multifunction DAQ

Showing results for 
Search instead for 
Did you mean: 

how to setup stop trigger?

There’s a signal(only persist a few seconds) to be measured.I use a digital trigger to start the measurement,but the question is:how to config a digital trigger to use its falling slope to stop a test?
The DAQmx’s function to config a “stop trigger” is called “Reference trigger---DAQmxCfgDigEdgeRefTrig”,which means set up a trigger in finite samples(to set up preSamples count, and the “postSamples”can be auto caculated using “samples per channel” minus “preSamples”.----What does postSamples mean?When then pre-defined slope comes ,the measurement stops,isn’t it? ).
But I want to acquire the data continuously,not stopping until received the digital trigger signal’s falling slope. So before the trigger singal’s falling slope comes,I don’t know how many samples I might have acquired.
What’s more,the “reference trigger” doesn’t support “continuously measurement”,it supports only “finite measurement”.So,when the samples reaches the sample count defined in “DAQmxCfgSampClkTiming”,while the falling slope have not come yet, then the measurement might stop. how can I set up the “stop trigger”?
If there is a way to config this trigger,then the total sample count might exceed the “samples per channel” count,how can I detect when buffer is full?Should I write a cycle to detect the buffer status(using the function “DAQmxGetReadTotalSampPerChanAcquir”)? Would this kind of detection slow down the sample speed?
0 Kudos
Message 1 of 2
Attached is a VI that should do what you're asking for. I'll try to explain what the program is doing since it requires you to override a lot of the default behaviors in the driver. Also, the DAQ device you are using doesn't support a true "stop" trigger so I'm using a reference trigger to get as close to the desired functionality as possible.

First, the program configures a finite acquisition that uses both a start trigger and a reference trigger. The acquisition is using the onboard sample clock and will acquire 4 samples (2 pre-trigger samples and 2 post-trigger samples). Four may seem like an odd number here, but it allows us to emulate the functionality of a stop trigger as close as possible. Given this configuration, you must acquire at least 2 samples before the "stop" trigger is recognized, and you must acquire 2 more samples after the "stop" trigger is recognized. Hopefully this restriction is acceptable. You can always discard the last two data points after the stop trigger if they're not of interest, but you're stuck always acquiring at least two points between when the start and stop triggers are recognized.

The program also overrides the default buffer size and read position. By default, the DAQmx driver will pick a buffer size exactly big enough to fit the pre-trigger and post-trigger data (4 samples in this case) and will begin reading data from the start of the pre-trigger data. Explicitly allocating a larger buffer will allow your acquisition to execute without receiving buffer overflow errors, and changing the default read position will allow you to read all of the data between the start and stop triggers as it is acquired and not just the pre-trigger and post-trigger data.

Finally, the while loop takes care of reading the data. In this case, the loop continues to read data until the task is done and there are no longer samples available for reading from the buffer. The number of samples read per iteration is the lesser of the user specified amount or the number of samples available for reading from the buffer.

I hope this helps. Good luck.
Message 2 of 2