I am trying to configure a trigger trigger ( reference trigger) with my DAQ device using the NI-DAQmx driver. However, after I start the task, the program does not seem to acquire the reference correctly. Instead of acquiring both the pre-shot and post-shot samples, I can only read the samples that were acquired before. Why does this happen?
This can happen if the reference trigger is arriving earlier than expected and the device does not have enough time to acquire all the pre-trigger samples before it occurs. This would cause the DAQmx task to appear to be not being triggered.
For example, let's say you are looking to acquire nine (9) samples before the shot and one later. (Actually, the size of the device's buffer will be much larger, as can be found in the device's specifications, but small numbers will be used to simplify the task.) The following image shows the configuration with 9 pre-shot samples and one post-shot.
In this image, the voltage levels are being read in a DAQmx input task. Voltage samples are being taken at regular intervals, which is being specified by the DAQmx Timing VI sampling clock . The use of an analog input signal is only as an example, the DAQmx task with the reference trigger can have any kind of input, including a counter input task, a hardware digital input or some X series device .
You can see in the blue letters how the DAQmx task is configured, and how triggers or triggers are actually executed in red. The legend "Ref Trig Expected" refers to the first point in time in which the trigger can be read by the DAQmx task. The legend "Ref Trig Actual" indicates the point in time in which the trigger actually occurs. The samples that are acquired are the black dots, and the DAQmx task starts when it is delivered to the hardware, shown in black on the left side of the graph.
In this case, 9 pre-trigger samples have been specified in the DAQmx task. This means that NI-DAQmx will wait for 9 samples to be obtained before looking for a shot. In other words, the hardware will ignore any shot that arrives until at least 9 samples have been acquired. This information can be found on page 4-37 of the X series User Manual , whose link is below in the "Related Links" section. No error will result if this is the case.
If more than 9 pre-trigger samples are acquired before the trigger arrives, the buffer will simply overwrite the old samples to ensure that only the most recent data before the trigger is obtained. This behavior is normal expected in any case.
After 9 pre-trigger samples are acquired, the DAQ device will start looking for a shot. When it arrives, the remaining samples (or in the upper image, the only remaining sample) is stored as post-trigger data and then the DAQmx task is considered complete.
To determine if this is happening in your system, or to prevent this from happening in the future, you can make the following modifications to your program.