DNx-AI-208 Analog Input Layer
Chapter 2
8
Programming with the High Level API
Tel: 508-921-4600
www.ueidaq.com
Vers:
4.6
Date: November 2013
File:
AI208 Chap2.fm
© Copyright 2009
United Electronic Industries, Inc.
// Configure channels 0,1 to use a gain of 100 in
// differential mode, program the excitation to 10V and
// turn on scaling with excitation
session.CreateAIExChannel(“pdna://192.168.100.2/Dev0/Ai0,1”, -0.1,
0.1, UeiSensorFullBridge, 10.0, true,
UeiAIChannelInputModeDifferential);
2.3
Configuring
the Timing
You can configure the AI-208 to run in simple mode (point by point) or buffered
mode (ACB mode).
In simple mode, the delay between samples is determined by software on the
host computer.
In buffered mode, the delay between samples is determined by the AI-208 on-
board clock.
The following sample shows how to configure the simple mode. Please refer to
the “UeiDaq Framework User’s Manual” to learn how to use the other timing
modes.
session.ConfigureTimingForSimpleIO();
2.4
Reading
Data
Reading data from the AI-208 is done using a reader object. There is a reader
object to read raw data coming straight from the A/D converter. There is also a
reader object to read data already scaled to volts or mV/V.
The following sample code shows how to create a scaled reader object and read
samples.
// Create a reader and link it to the session’s stream
CUeiAnalogScaledReader reader(session.GetDataStream());
// read one scan, the buffer must be big enough to contain
// one value per channel
double data[2];
reader.ReadSingleScan(data);
2.5
Cleaning-up
the Session
The session object will clean itself up when it goes out of scope or when it is
destroyed. However, you can also clean up the session manually (to reuse the
object with a different set of channels or parameters).
session.CleanUp();