![]() |
|
The di_inlist
function initializes the channel input scan list.
Note: This function must be called before di_start_scan
and after di_list_length
.
int di_inlist(input_list); |
|
struct di_inlist_struct{ |
|
unsigned chan; |
/* input channel, 0 to 255 */ |
unsigned diff; |
/* input configuration (single-ended or diff) */ |
unsigned gain; |
/* gain setting */ |
unsigned unipolar; |
/* unipolar/bipolar; 0=bipolar, 1=unipolar */ |
unsigned dig_out_enable; |
/* 1=enables dig out, 0=disables dig out */ |
unsigned dig_out; |
/* digital data */ |
unsigned ave; |
/* sample averaging mode; 0=off, 1=on */ |
unsigned counter; |
/* sample rate counter */ |
}*input_list; |
chan
allows you to specify the input channel you wish to sample. Use chan
to specify the channel order for acquiring data (for example, if you specify inlist[0].chan = 5;
channel 5 will be the first channel in the scan list. Specify inlist[1].chan = 2;
to acquire data from channel 2 as the second channel in the scan list, etc.). You must specify each channel you wish to acquire data from using the inlist
structure (you must set chan
, diff
, gain
, etc for each channel). Values for chan
can range from 0 to 255.
Note: The first channel listed on the input scan list is used as the trigger channel by default. For example, if channel 3 is specified by chan
as the first element in the input scan list, triggering will occur on channel 3. Use the element scnx
in the di_mode
function to specify a different trigger channel.
diff
allows you to specify whether the channel specified by chan
is single-ended or differential.
gain
allows you to specify a gain factor (gain index) for the channel specified by chan
. See Gain Reference for a listing of all possible gain settings for each instrument.
The DI-149 and DI-155 Rate channel (DI2 - channel 9) can contain values of 0-13 that specify gains of 1, 2, 4, 10, 20, 40, 100, 200, 400, 1000, 2000, 4000, 10000, 20000, respectively, applied to a range of 0-20000 Hz. Its data words are unipolar, with hex 8000 for zero and hex 7FFC for 19998.8 Hz. Data words for the counter on channel 10 are also unipolar, with hex 8000 for zero and hex 7FFC for 16383 counts.
For DI-1110, DI-1120, DI-2008, DI-2108 , DI-2108-P, DI-4108, and DI-4208 devices, data words for the counter on channel 10 on each device are also unipolar, with hex 8000 for zero and hex 7FFF for 65535 counts.
Note: With the DI-221TC, you can specify a gain factor for linear or non-linear inputs. This structure element is reserved for compatibility on DI-401 instruments (gain is fixed at 1). With the DI-245, setting data bit 3 in the gain field specifies the higher-voltage DI-245 ranges.
unipolar
allows you to specify whether the channel specified by chan
is a unipolar or bipolar signal. For DI-2108-P, DI-220, DI-221TC, and DI-222 ONLY. For all other instruments, unipolar configuration is not supported - set unipolar = 0.
dig_out_enable
allows you to enable or disable the digital output bits.
dig_out
is a multipurpose structure element. Its function depends on the instrument being used and the status of the dig_out_enable
element.
ave
allows you to enable or disable sample averaging.
When sample averaging is enabled (ave
= 1), up to 32,767 consecutive samples for each entry on the input list can be averaged. All Dataq Instruments hardware products continuously sample and report data using a burst sampling method. When averaging is enabled, data is temporarily stored in an accumulator until the sample interval (specified by counter
) elapses. When the sample interval elapses, the value reported is not a single instantaneous sample but the average of all samples since the last interval.
When sample averaging is disabled (ave
= 0):
counter
allows you to adjust the sample rate counter. Since the input scan list is capable of holding 256 entries, it is possible to program each channel in the input list for a different sampling rate (see Sampling Different Channels at Different Rates). The equation for determining the value required for a specific sampling rate is:
Where:
S = desired sample rate of the input list entry
B = Burst Rate of the instrument
L = Length of the input or output scan list (whichever is greater)
C = counter
Note: counter
MUST be the same for all channels when using the functions di_sample_rate
and di_maximum_rate
.
DI_NO_ERR | No error |
DI_OPENED_ERR | Device not opened |
DI_COMM_ERR | Communication error |
DI_INLIST_ERR | Value in inlist structure out of range |
Since simultaneous input and output operations are possible, some consideration must be given to input and output synchronization. The following table illustrates the order of each input/output operation, with respect to the other operations. In this example, there are 10 elements each in the input and output scan lists. Each input or output is referenced to its position in the input or output scan list.
Sample Number | Analog Input | Analog Output | Digital In Buffer | Digital Out Buffer | Digital Out Inlist | Digital Out Outlist |
1 | - | - | - | - | 0 | - |
2 | - | - | - | 0 | 1 | 0 |
3 | 0 | - | 0 | 1 | 2 | 1 |
4 | 1 | 0 | 1 | 2 | 3 | 2 |
5 | 2 | 1 | 2 | 3 | 4 | 3 |
6 | 3 | 2 | 3 | 4 | 5 | 4 |
7 | 4 | 3 | 4 | 5 | 6 | 5 |
8 | 5 | 4 | 5 | 6 | 7 | 6 |
9 | 6 | 5 | 6 | 7 | 8 | 7 |
10 | 7 | 6 | 7 | 8 | 9 | 8 |
11 | 8 | 7 | 8 | 9 | 0 | 9 |
12 | 9 | 8 | 9 | 0 | 1 | 0 |
13 | 0 | 9 | 0 | 1 | 2 | 1 |
14 | 1 | 0 | 1 | 2 | 3 | 2 |
15 | 2 | 1 | 2 | 3 | 4 | 3 |
16 | 3 | 2 | 3 | 4 | 5 | 4 |
17 | 4 | 3 | 4 | 5 | 6 | 5 |
18 | 5 | 4 | 5 | 6 | 7 | 6 |
19 | 6 | 5 | 6 | 7 | 8 | 7 |
20 | 7 | 6 | 7 | 8 | 9 | 8 |
Note: DI-154, DI-194, DI-195B, DI-145, DI-148, DI-149, DI-158, DI-700, and DI-71x products do not support simultaneous input and output scanning or different channels at different rates.
#include "200sdk.h" |
|
int errcode; |
|
#define IDIM 256 |
/* largest value allowed */ |
struct di_inlist_struct inlist[IDIM] = {0}; |
/* input list cleared */ |
char errstr[255]; |
|
main() |
|
{ |
|
int i; |
|
if(errcode = di_open()){ |
/* open the device for comm */ |
di_strerr(errcode,errstr); |
|
printf("%s",errstr); |
|
} |
|
else |
|
printf("Device installed successfully.....\n"); |
|
/* The following initializes scan list position 0 and must be repeated for all positions intended to be scanned */ |
|
inlist[0].chan = 5; |
/* channel 5 */ |
inlist[0].diff = 0; |
/* single ended */ |
inlist[0].gain = 0; |
/* gain of 1 */ |
inlist[0].unipolar = 0; |
/* bipolar */ |
inlist[0] dig_out_enable = 1 |
/* enable digital output */ |
inlist[0].dig_out = 3; |
/* output digital value 3 */ |
inlist[0].ave = 0; |
/* averaging off */ |
inlist[0].counter = 100; |
/* init counter */ |
di_list_length (IDIM, 0); |
|
if(errcode = di_inlist(inlist)){ |
/* initialize the input list */ |
di_strerr(errcode,errstr); |
|
printf("%s",errstr); |
|
} |
|
else |
|
printf("Input list initialized.....\n"); |
|
di_close(); |
|
} |
Copyright © DATAQ Instruments, Inc.