Functions > di_anin

Syntax

di_anin is an immediate function that takes one data sample from a single analog input channel. Use di_inlist to stream data from multiple channels.

Syntax

int di_anin (analog_input);

struct di_anin_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 */

}*analog_input;

Parameters

chan

chan allows you to specify the input channel you wish to sample. Values for chan can range from 0 to 255, dependent upon the hardware device.

chan = channel # - 1 for all devices except the DI-220 series (for which the channels are numbered starting at 1).

chan = channel # - 1 + 32*(letter - "A" + 1) for devices on 32-channel expanders labeled by letters.

DI-400, DI-401, DI-410, DI-71x, DI-500, DI-510, DI-720, DI-730, DI-78x, and DI-5001
DI-220, DI-221TC, and DI-222

diff

diff allows you to specify whether the channel specified by chan is single-ended or differential (0 or 1).

DI-210, DI-220, DI-221TC, DI-222, DI-400, DI-410, DI-71x, DI-720, and DI-5001
DI-730
DI-500, DI-510, and DI-78x
DI-401

gain

gain allows you to specify a gain factor (gain index) for the channel specified by chan. Possible gain settings are device dependent. See Gain Reference for a list of all possible gain factors and ranges.

With the DI-221TC, you can specify a gain factor for linear or non-linear inputs.

With the DI-401 this structure element is reserved for compatibility (gain is fixed at 1).

unipolar

unipolar allows you to specify whether the channel specified by chan is a unipolar or bipolar signal. On DI-401 instruments, this structure element is reserved for compatibility. On DI-400, DI-410, DI-500, DI-510, DI-720, DI-730, DI-78x, and DI-5001 instruments, unipolar configuration is not supported (unipolar must be 0).

Return Value

di_anin returns channel data in Counts. The data format is resolution/instrument dependent.

12-bit: DI-220, DI-221, DI-222
14-bit: DI-400, DI-410, DI-500, DI-510, DI-71x, DI-720, DI-730, DI-78x, and DI-5001
16-bit: DI-720, DI-730, DI-78x, and DI-5001

See Converting Counts to Volts.

Dependencies

di_open

Remarks

On Ethernet and USB instruments, this function should not be issued while an input, output, or simultaneous input and output scanning operation is in progress. If it is, the scanning operation will halt. On all other instruments, scanning will not halt when this function is issued, but di_anin will only execute successfully while output scanning (the di_anin function will be ignored when input scanning or simultaneously input and output scanning).

Note: di_anin is not supported on the first eight channels (the high voltage channels located on the front of the instrument) of the DI-730.

Sample Code

#include "200sdk.h"

int errcode;

struct di_anin_struct anin;

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");

anin.chan = 5;

/* channel 5 */

anin.diff = 0;

/* single ended input channel */

anin.gain = 0;

/* gain of 1 */

anin.unipolar = 0;

/* bipolar */

i = di_anin(&anin))

/* get analog input */

printf("Channel 5 = %d",i);

di_close ();

}

 

Copyright © DATAQ Instruments, Inc.