User manual
Programmer’s Guide Page 32 of 66
3.10.1. Starting an Acquisition
Use the following line of code for starting an acquisition in a D1-style instrument:
AcqrsD1_acquire(instrID); // start the acquisition
or the following line of code for starting an acquisition on a Time-to-Digital Converter:
AcqrsT3_acquire(instrumentID); // start the acquisition
One such command is required for each module in use. However, if several digitizers are combined to a single
MultiInstrument with AS bus, only a single command is needed for the combined instrument.
3.10.2. Checking if Ready for Trigger
If many modules are being used it may be useful to know when they are all ready to accept a trigger. This can be
done by verifying that they are all finished with their pre-trigger phase (PreTrigger = 0) by using the call below to all
instruments (or the last instrument started):
Acqrs_getInstrumentInfo(instrID, "IsPreTriggerRunning", &PreTrigger);
3.10.3. Waiting for End of Acquisition
Usually data cannot be read from the instrument until the acquisition is terminated. The application may wait for an
acquisition to end either by polling or by waiting for interrupt.
(A) Simple Polling: use the following code fragment for polling the interrupt status:
ViBoolean done = 0;
long timeoutCounter = 100000;
while ((!done) && (--timeoutCounter > 0))
AcqrsD1_acqDone(instrID, &done); // poll for status or
//AcqrsT3_acqDone(instrID, &done); // the Time-to-Digital Converter
equivalent
if (timeoutCounter <= 0) // timeout, stop acquisition
STOP ACQUISITION
NOTE: The code above has the disadvantage of wasting CPU time while checking the instrument status during the
entire acquisition period. In addition, the timeout counter value should be set according to the expected acquisition
time, but the loop time depends on the CPU speed.
(B) More Efficient Polling: use this code fragment to release the polling thread for short periods:
ViBoolean done = 0;
long timeoutCounter = 100;
while ((!done) && (--timeoutCounter > 0))
{
AcqrsD1_acqDone(instrID, &done); // poll for status or
//AcqrsT3_acqDone(instrID, &done); // the Time-to-Digital Converter
equivalent
Sleep(1);
}
if (timeoutCounter <= 0) // timeout, stop acquisition
STOP ACQUISITION
This code puts the polling thread to sleep for periods of 1 ms at a time, letting other threads of the application or
other applications use the CPU time. Setting the timeout counter to 100 means that a total timeout period of 100 ms
is expected.
NOTE: This method still has some drawbacks:
depending on the operating system, the 'Sleep' method often has a granularity of 10 ms or more, rounding any
smaller number up to this minimum value
the response time of the application to the end of acquisition is 50% of the sleep time, on average. With a
granularity of 10 ms, the mean latency is therefore 5 ms. Thus, no more than 200 waveforms per second could
be acquired, because the application wastes time waiting for the acquisition to terminate.