User manual
Programmer’s Guide Page 33 of 66
(C) Waiting for Interrupt:
ViStatus status;
long timeOut = 100; //
status = AcqrsD1_waitForEndOfAcquisition(instrID, timeOut);
if (status == ACQIRIS_ERROR_ACQ_TIMEOUT) // timeout, stop
STOP ACQUISITION
This method combines low CPU usage with very good response time:
The function enables the instrument‟s 'end-of-acquisition' interrupt and sets up a semaphore that waits for this
interrupt. It then releases the thread by 'going to sleep', thus letting other threads of the application or other
applications use the CPU time. The function returns as soon as the interrupt occurs or when the timeout expires. Note
that the timeout asked for will be clipped to a maximum value of 10 seconds.
The equivalent of the above for a Time-to-Digital Converter would be:
ViStatus status;
long timeOut = 100; //
status = AcqrsT3_waitForEndOfAcquisition(instrumentID, timeOut);
if (status == ACQIRIS_ERROR_ACQ_TIMEOUT) // timeout, stop
status = AcqrsT3_stopAcquisition(instrumentID);
We recommend using AcqrsXX_waitForEndOfAcquisition since it is the most efficient method. The interrupt
latency is of the order of several s, and no CPU time is wasted.
3.10.4. Stopping/Forcing a D1-style Acquisition
The previous section shows a case where an ongoing acquisition must be stopped, typically because there is no
trigger. Also, in some situations you may want to use the digitizer to generate a system trigger under software
control.
If you still would like to have a valid snapshot of the current input signal, you should generate a trigger signal by
software, with the function AcqrsD1_forceTrig or AcqrsD1_forceTrigEx. Typically, the acquisition does not stop
immediately, since the digitizer may continue acquiring some additional data, depending on the delayTime and the
data acquisition time that were initially configured. Thus, the application should again wait for the acquisition to
terminate. Forcing a trigger does not make sense for averagers and analyzers and should not be done.
AcqrsD1_forceTrigEx allows you to generate a trigger out signal which can be synchronized with the sampling
clock if desired.
Use the following code fragment to replace STOP ACQUISITION in the previous section:
{
AcqrsD1_forceTrig(instrID);
if (AcqrsD1_waitForEndOfAcquisition(instrID, timeOut) ==
ACQIRIS_ERROR_ACQ_TIMEOUT)
{
AcqrsD1_stopAcquisition(instrID);
SCREAM, because a major error occurred
}
}
Note that no timeout should ever occur when waiting for a 'forceTrig' to terminate, provided that the timeOut value
was made large enough. If a timeout does occur, this would indicate a failure in the digitizer or the entire system.
For users generating triggers under software control it may be desirable to do the data readout in a way that just gives
the acquired data points and ignores the correction of the data gotten from the horPos measurement of the time from
the trigger to the next data sample. This can be done using the flags parameter of the AqReadParameters structure.