A CHIP IO library for Python: IO+PWM+SPWM+ADC+Utilities
The LRADC module handles interfacing with the onboard 6-Bit, 2V tolerant ADC in the R8/GR8.
Import the LRADC module as follows
import CHIP_IO.LRADC as LRADC
Enable/Disable the Debug
Parameters
None
Returns
None
Examples
LRADC.toggle_debug()
Check to see if the LRADC device exists
Parameters
None
Returns
boolean - True if LRADC is enabled, False is LRADC is disabled
Examples
LRADC.get_device_exist()
Setup the LRADC, defaults to a sampling rate of 250.
Parameters
rate (optional) - Sampling rate of the LRADC: 32.25, 62.5, 125, 250
Returns
boolean - True if LRADC is enabled, False is LRADC is disabled
Examples
LRADC.setup()
LRADC.setup(32.25)
Get the scaling factor applied to raw values from the LRADC
Parameters
None
Returns
float - scale factor applied to the LRADC Raw data
Examples
factor = LRADC.get_scale_factor()
print(factor)
Get the allowable sample rates for the LRADC
Parameters
None
Returns
tuple - sampling rates of the LRADC
Examples
rates = LRADC.get_allowable_sample_rates()
print(rates)
Set the current sample rates for the LRADC
Parameters
rate - Sample rate, only rates allowable by the LRADC
Returns
float - current sampling rate of the LRADC
Examples
curr_rate = LRADC.set_sample_rate(125.0)
Get the current sample rates for the LRADC
Parameters
None
Returns
float - current sampling rate of the LRADC
Examples
curr_rate = LRADC.get_sample_rate()
Get the raw value for LRADC Channel 0
Parameters
None
Returns
float - current raw value of LRADC Channel 0
Examples
dat = LRADC.get_chan0_raw()
Get the raw value for LRADC Channel 1
Parameters
None
Returns
float - current raw value of LRADC Channel 1
Examples
dat = LRADC.get_chan1_raw()
Get the value for LRADC Channel 0
Parameters
None
Returns
float - current value of LRADC Channel 0
Examples
dat = LRADC.get_chan0()
Get the value for LRADC Channel 1
Parameters
None
Returns
float - current value of LRADC Channel 1
Examples
dat = LRADC.get_chan1()