3.3 Interrupt-Based AD Sample or Scan
Description
Interrupt-based analog input operations are necessary when conversions must be performed at high sampling rates. They differ in operation from standard A/D samples and scans in that they perform a preset number of conversions per function call, rather than taking a single sample or scan. There are a number of different options that can be set for interrupt-based operations; these are explained in the interrupt-based operations chapter. The Universal Driver functions for A/D sample and scan operations are dscADSampleInt and dscADScanInt.
Step-By-Step Instructions
Create and initialize an A/D settings structure (DSCADSETTINGS).
Call dscADSetSettings and pass it a pointer to this structure in order to setup the driver for A/D operations.
Create and initialize an analog I/O interrupts structure (DSCAIOINT).
Initialize the sample_values buffer in the DSCAIOINT structure by allocating sufficient memory to store the results of the interrupt operations. The memory required is:
Memory = sizeof(WORD) * num_conversions
Call dscADSampleInt or dscADScanInt and pass it a pointer to the above-mentioned DSCAIOINT structure to begin interrupt operation. The interrupt operations will now run in a separate system thread until either they reach the maximum number of conversions specified (one-shot mode only) or they are cancelled by a call to dscCancelOp.
Example of Usage for Interrupt-Based A/D Sample or Scan
NOTE: Boards can only achieve interrupt rates that divide evenly into their onboard counters, so the driver will attempt to find the rate closest to that which you specified.
Last updated