Foreground acquisition with one-step commands – Measurement Computing WaveBook rev.3.0 User Manual
Page 178
C-4 daqX API - Programming Models,
6-22-99
WaveBook User’s Manual
Foreground Acquisition with One-Step Commands
This section shows the use of several one-step analog input
routines. These commands are easier to use than low-level
commands but less flexible in scan configuration. These
commands provide a single function call to configure and
acquire analog input data. This example demonstrates the
use of the four Daq*’s one-step ADC functions. Functions
used include:
•
VBdaqAdcRd&(handle&,chan&, sample%,
gain&)
•
VBdaqAdcRdN&(handle&,chan&, Buf%(),
count&, trigger%, level%, freq!,
gain&,flags&)
•
VBdaqAdcRdScan&(handle&,startChan&,
endChan&, Buf%(), gain&, flags&)
•
VBdaqAdcRdScanN&(handle&,startChan&,
endChan&, Buf%(), count&,
triggerSource&, level%, freq!, gain&,
flags&)
This program will initialize the Daq* hardware, then take
readings from the analog input channels in the base unit
(not the expansion cards). First, some constants need to be
defined and variables dimensioned.
At this point, the data is in
the buffer provided by the
user in binary format.
At this point, the data is in
the buffer provided by the
user in binary format.
At this point, the data is in
the buffer provided by the
user in binary format.
At this point, the data is in
the buffer provided by the
user in binary format.
User Code
User Code
User Code
User Code
Read 1 sample from
1 channel.
daqAdcRd
Read multiple samples from
1 channel.
daqAdcRdN
daqAdcRdScan
Read multiple samples from
multiple channels.
daqAdcRdScanN
Read 1 sample from multiple
channels.
Const freq! = 1000!
‘1000Hz sample rate
Const gain& = DgainX1&
‘gain of x1
Const flags& = DafAnalog&+DafUnipolar&
‘unipolar mode on
Const scans& = 9
‘number of scans to acquire
Const channels& = 8
‘number of channels to scan
Const rising& = DatdRisingEdge
‘XXXX I have no idea
Const HYSTERESIS& = 0.1
‘with a hysteresis of .1
Dim buf%(scans& * channels&)
‘array buffer to hold data
Dim handle&
‘handle for WaveBook device
Dim i&, j&
‘counter variables
Dim sample%
‘hold a single reading
Dim ret&
‘function return value
The following code assumes that the Daq* device has been successfully opened and the handle& value is
a valid handle to the device. All the following one-step functions define the channel scan groups to be
bipolar input channels. Specifying this configuration uses the DafAnalog and the DafUnipolar values
in the flags parameter. The flags parameter is a bit-mask field in which each bit specifies the
characteristics of the channel(s) specified. In this case, the DafAnalog and the DafUnipolar values
are added together to form the appropriate bit mask for the specified flags parameter.
The next line requests 1 reading from 1 channel with a gain of ×1. The gain& constant is defined as
DgainX1&
, defined constant from DaqX.bas and included at the beginning of this program. Likewise, the
flags&
constant parameter is defined to be the sum of the DafAnalog and DafUnipolar flags, which are
also defined in DaqX.bas.
ret& = VBdaqAdcRd&(handle& 1, sample%, gain&, flags&)
Print Format$“& ####”; “Result of AdcRd:”; sample%(0)
The next line requests 10 readings from channel 1 at a gain of ×1, using immediate triggering at 1 kHz.
ret& = VBdaqAdcRdN&(handle&,1, buf%(), scans&, DatsImmediate&, rising&, 0!,
freq!, gain&, flags&)
Print “Results of AdcRdN: ”;
For x& = 0 To 9
Print Format$ “#### ”; buf%(x&);
Next x&
The program will then collect one sample of channels 1 through 8 using the VBdaqAdcRdScan function.