![]() |
|
The di_outlist
function initializes the output list (output functions are not available on all instruments).
Note: This function has to be called after di_list_length and before di_start_scan. Note that the two LSB's of data in each location of the output buffer must be zero.
int di_outlist(output_list); |
|
struct di_outlist_struct{ |
|
unsigned unipolar; |
/* specifies unipolar/bipolar or DAC0/DAC1 */ |
unsigned digital; |
/* specifies digital or analog data */ |
unsigned dig_out_enable; |
/* enables digital output */ |
unsigned dig_data; |
/* digital data is D0 through D7 */ |
unsigned counter; |
/* scan position counter */ |
}*output_list; |
unipolar
specifies a unipolar/bipolar signal for DI-2xx instruments or specifies DAC1/DAC2 for DI-400, DI-410, DI-500, DI-510 and Printer Port versions of the DI-720, DI-730, DI-740, and DI-5001.
digital
= 1 sets the buffer data to digital data
digital
= 0 sets the buffer data to analog data
dig_out_enable
= 1 enabled the digital output
dig_out_enable
= 0 disables the digital output
The digital data is D0 through D7.
Use counter
to specify an output rate.
Where:
O = desired output rate of the output list entry
B = burst rate of the instrument
L = length of the input or output list (whichever is greater)
C = counter
DI_NO_ERR | No error |
DI_OPENED_ERR | Device not opened |
DI_COMM_ERR | Communication error |
DI_OUTLIST_ERR | Value is outlist 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 |
#include "200sdk.h" |
|
int errcode; |
|
#define ODIM 16; |
/* largest value allowed */ |
struct di_outlist_struct outlist[ODIM] = {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 */ |
|
outlist[0].unipolar = 0; |
/* bipolar */ |
outlist[0].digital = 1; |
/* buffer data is digital */ |
outlist[0] dig_out_enable = 0; |
/* disable digital output */ |
outlist[0].dig_data = 0x20; |
/* digital data to be output */ |
outlist[0].counter = 10; |
/* init counter */ |
di_list_length (ODIM, 0); |
|
if(errcode = di_outlist(outlist)){ |
/* initialize output list */ |
di_strerr(errcode,errstr); |
|
printf("%s",errstr); |
|
} |
|
else |
|
printf("Output list initialized.....\n"); |
|
di_close(); |
|
} |
Copyright © DATAQ Instruments, Inc.