3.1 Performing an AD Conversion


When you perform an A/D conversion, you are getting a digital reading of an analog voltage signal applied to one of the A/D board's analog input channels. The A/D board uses a device called an analog-to-digital (A/D) converter to convert the real-world analog signal (temperature, pressure, tank level, speed, etc.) into a digital value that the digital computer electronics can handle. This digital value can be translated back to the input voltage using the conversion formulas provided in the board's user manual.
Typically the digital value, or the underlying voltage, is then converted to engineering units, such as temperature or speed, using the appropriate conversion formula for the device or sensor that generated the original voltage signal. These conversion formulas are provided by the manufacturer of the device or sensor. Both conversions (digital to volts and volts to engineering units) can be combined into a single formula if desired. The Universal Driver function name for A/D conversions is dscADSample.

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.
Call dscADSample and pass it a pointer to your sample variable (DSCSAMPLE) this will generate an A/D conversion and the result will be stored in your sample variable.
Example of Usage for dscADSample
DSCB dscb;
DSCADSETTINGS dscadsettings;
DSCSAMPLE dscsample;
/* Step 1 */
// These are example values; your application will vary.
// See DSCADSETTINGS struct and hardware manuals for details.
dscadsettings.current_channel = 0;
dscadsettings.gain = GAIN_1;
dscadsettings.range = RANGE_5;
dscadsettings.polarity = UNIPOLAR;
dscadsettings.load_cal = 0;
//scan_interval of 20 microseconds (default value), For DMM32, Hercules, DMM48
dscadsettings.scan_interval = 0;
/* Step 2 */
if ((result = dscADSetSettings(dscb, &dscadsettings)) != DE_NONE)
return result;
/* Step 3 */
if ((result = dscADSample(dscb, &dscsample)) != DE_NONE)
return result;