sub_get_product_id

Top  Previous  Next
Got to SUB-20 page

Synopsis

int sub_adc_single( sub_handle hndl, int* data, int mux );

int sub_adc_read( sub_handle hndl, int* data, int* mux, int reads );

 

Read single or multiple ADC conversion result(s)

Parameters

data - buffer to store conversion result(s)

mux - ADC input channel multiplexer control code(s). See table below.

reads - number of results to read

 

ADC mux code

Single Ended

Differential

Positive

Differential

Negative

Gain

ADC_S0

ADC0

N.A.

ADC_S1

ADC1

ADC_S2

ADC2

ADC_S3

ADC3

ADC_S4

ADC4

ADC_S5

ADC5

ADC_S6

ADC6

ADC_S7

ADC7

ADC_D10_10X

N.A.

ADC1

ADC0

10

ADC_D10_200X

ADC1

ADC0

200

ADC_D32_10X

ADC3

ADC2

10

ADC_D32_200X

ADC3

ADC2

200

ADC_D01

ADC0

ADC1

N.A.

ADC_D21

ADC2

ADC1

ADC_D31

ADC3

ADC1

ADC_D41

ADC4

ADC1

ADC_D51

ADC5

ADC1

ADC_D61

ADC6

ADC1

ADC_D71

ADC7

ADC1

ADC_D02

ADC0

ADC2

ADC_D12

ADC2

ADC2

ADC_D32

ADC3

ADC2

ADC_D42

ADC4

ADC2

ADC_D52

ADC5

ADC2

ADC_1_1V

Internal 1.1V

N.A.

ADC_GND

Analog GND

ADC Result

For single ended conversion:

 

For differential:

ADC is a result of conversion. Note that the result of differential conversion is signed and can be negative.

Return value

On success function returns 0. Otherwise error code.

Example

int adc, adc_buf[3], adc_mux[3];

 

sub_adc_single( fd, &adc, ADC_S0 );   /* Read ADC on ADC0 input */

 

adc_mux[0] = ADC_S0;

adc_mux[1] = ADC_S2;

adc_mux[2] = ADC_S3;

sub_adc_read( fd, adc_buf, adc_mux, 3 ); /* Read ADC on ADC0,2,3 inputs */