adafruit_tla202x

Library for the TI TLA202x 12-bit ADCs

  • Author(s): Bryan Siepert

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_tla202x.CV

struct helper

classmethod add_values(value_tuples)

creates CV entires

classmethod is_valid(value)

Returns true if the given value is a member of the CV

class adafruit_tla202x.DataRate

Options for data_rate, to select the rate at which samples are taken while measuring the voltage across the input pins

Rate Measurement Rate
Rate.RATE_128SPS 128 Samples per second
Rate.RATE_250SPS 250 Samples per second
Rate.RATE_490SPS 490 Samples per second
Rate.RATE_920SPS 920 Samples per second
Rate.RATE_1600SPS 1600 Samples per second
Rate.RATE_2400SPS 2400 Samples per second
Rate.RATE_3300SPS 3300 Samples per second
class adafruit_tla202x.Mode

Options for mode

Mode Description
Mode.CONTINUOUS

In Continuous mode, measurements are taken

continuously and getting voltage

will return the latest measurement.

Mode.ONE_SHOT

Setting the mode to ONE_SHOT takes a single

measurement and then goes into a low power state.

class adafruit_tla202x.Mux

Options for mux to choose the inputs that voltage will be measured across

Mux Positive Pin Negative Pin
Mux.MUX_AIN0_AIN1 AIN 0 AIN 1
Mux.MUX_AIN0_AIN3 AIN 0 AIN 3
Mux.MUX_AIN1_AIN3 AIN 1 AIN 3
Mux.MUX_AIN2_AIN3 AIN 2 AIN 3
Mux.MUX_AIN0_GND AIN 0 GND
Mux.MUX_AIN1_GND AIN 1 GND
Mux.MUX_AIN2_GND AIN 2 GND
Mux.MUX_AIN3_GND AIN 3 GND
class adafruit_tla202x.Range

Options for range, used to select the measurement range by adjusting the gain of the internal amplifier

Range Measurement Range Resolution
Range.RANGE_6_144V ±6.144 V 3 mV
Range.RANGE_4_096V ±4.096 V 2 mV
Range.RANGE_2_048V ±2.048 V 1 mV
Range.RANGE_1_024V ±1.024 V 0.5 mV
Range.RANGE_0_512V ±0.512 V 0.25 mV
class adafruit_tla202x.TLA2024(i2c_bus, address=72)

I2C Interface for analog voltage measurements using the TI TLA2024 12-bit 4-channel ADC

param i2c_bus:The I2C bus that the ADC is on.
param int address:
 The I2C address for the ADC. Defaults to ~0x48
data_rate

selects the rate at which measurement samples are taken. Must be a DataRate . See the documentation for DataRate for more information

input_channel

The channel to be sampled

mode

The measurement mode of the sensor. Must be a Mode. See the documentation for Mode for more information

mux

selects the inputs that voltage will be measured between. Must be a Mux. See the Mux documentation for more information about the available options

range

The measurement range of the ADC, changed by adjusting the Programmable Gain Amplifier range must be a Range. See the documentation for Range for more information

read(channel)

Switch to the given channel and take a single ADC reading in One Shot mode

Parameters:channel – The channel number to switch to, from 0-3
voltage

The voltage between the two selected inputs

analog_in

AnalogIn for ADC readings.

  • Author(s): Bryan Siepert
class adafruit_tla202x.analog_in.AnalogIn(tla, pin)

AnalogIn Mock Implementation for ADC Reads.

Parameters:
  • tla – The TLA202x object.
  • pin (DigitalInOut) – Required ADC channel pin.
deinit()

Release the reference to the TLA202x. Create a new AnalogIn to use it again.

reference_voltage

The maximum voltage measurable (also known as the reference voltage) as a float in Volts. Assumed to be 3.3V but can be overridden using the TLA2024 constructor

value

Returns the value of an ADC channel. The value is scaled to a 16-bit integer from the native 12-bit value.

voltage

Returns the value of an ADC channel in volts as compared to the reference voltage.