Functions > di_anout

Syntax

di_anout is an immediate function that writes (outputs) a 2's complement, left justified value to the DAC.

Note: The di_anout function will be ignored while output scanning or simultaneously input and output scanning.

Syntax

int di_anout (dac_data, range);

unsigned dac_data;

/* value to ouput to the DAC */

unsigned range;

/* specifies which DAC to write to OR unipolar/bipolar (22x products) */

Parameters

dac_data

The value that gets written to the DAC is instrument dependent.

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

See Converting Counts to Volts.

range

range specifies which DAC to write to or, for DI-220, DI-221TC, and DI-222 instruments, bipolar/unipolar operation.

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

Return Value

DI_NO_ERR No error
DI_OPENED_ERR Device not opened
DI_COMM_ERR Communication error
DI_ANOUT_ERR Analog output error

Dependencies

di_open

Remarks

Note: If di_close is called immediately after di_anout, the device will close before di_anout is completed.

Use the following tables for reference.

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

Sample Code

#include "200sdk.h"

int i;

char errstr[255];

main()

{

if(errcode = di_open()){

/* open the device for comm */

di_strerr(errcode,errstr);

printf("%s",errstr);

}

else

printf("Device installed successfully.....\n");

i = 5 . 16;

/* this left justifies the data */

i = i & 0XFFFC;

/* the lower 2 bits should be zero */

if(errcode = di_anout(i,0)){

/* output i to DAC */

di_strerr(errcode,errstr);

printf("%s",errstr);

}

else

printf("Analog output successful.....\n");

di_close ();

}

 

Copyright © DATAQ Instruments, Inc.