Robot Control Library
ADC

Description

C interface for the Linux IIO ADC driver.

<rc/adc.h>

The Robotics cape and BeagleBone Blue include two voltage dividers for safe measurement of the 2-cell lithium battery voltage and the voltage of any power source connected to the 9-18V DC power jack. These can be read with c_adc_batt() and rc_adc_dc_jack()

There is also a 6-pin JST-SH socket on the Cape for connecting up to 4 potentiometers or general use analog signals. The pinout of this socket is as follows:

All 8 ADC channels on the Sitara including the 4 listed above can be read with rc_adc_read_raw(int ch) which returns the raw integer output of the 12-bit ADC. rc_adc_read_volt(int ch) additionally converts this raw value to a voltage.

See the rc_test_adc example for sample use case.

Functions

int rc_adc_init (void)
 initializes the analog to digital converter for reading More...
 
int rc_adc_cleanup (void)
 Cleans up the ADC subsystem. More...
 
int rc_adc_read_raw (int ch)
 reads the raw integer ADC value for a particular channel More...
 
double rc_adc_read_volt (int ch)
 reads an adc voltage. More...
 
double rc_adc_batt (void)
 reads the voltage of the 2-cell Lithium battery More...
 
double rc_adc_dc_jack (void)
 Reads the voltage of the 9-18v DC jack. More...
 

Function Documentation

◆ rc_adc_init()

int rc_adc_init ( void  )

initializes the analog to digital converter for reading

Returns
0 on success, -1 on failure.
Examples:
rc_balance.c, rc_check_battery.c, rc_dsm_passthrough.c, rc_test_adc.c, and rc_test_servos.c.

◆ rc_adc_cleanup()

int rc_adc_cleanup ( void  )

Cleans up the ADC subsystem.

Call before your program closes down

Returns
0 on success, -1 on failure.
Examples:
rc_check_battery.c, rc_dsm_passthrough.c, rc_test_adc.c, and rc_test_servos.c.

◆ rc_adc_read_raw()

int rc_adc_read_raw ( int  ch)

reads the raw integer ADC value for a particular channel

Parameters
[in]chchannel 0-7
Returns
16-bit adc reading on success, -1 on failure.

◆ rc_adc_read_volt()

double rc_adc_read_volt ( int  ch)

reads an adc voltage.

Parameters
[in]chchannel 0-7
Returns
voltage from 0-1.8v or -1 on error
Examples:
rc_test_adc.c.

◆ rc_adc_batt()

double rc_adc_batt ( void  )

reads the voltage of the 2-cell Lithium battery

Returns
voltage of battery or -1 on failure
Examples:
rc_balance.c, rc_check_battery.c, rc_dsm_passthrough.c, rc_test_adc.c, and rc_test_servos.c.

◆ rc_adc_dc_jack()

double rc_adc_dc_jack ( void  )

Reads the voltage of the 9-18v DC jack.

Returns
Voltage at DC jack or -1 on failure
Examples:
rc_check_battery.c, and rc_test_adc.c.