pyupm_ads1x15 module

class pyupm_ads1x15.ADS1015(bus, address=72, vref=2.048)[source]

Bases: pyupm_ads1x15.ADS1X15, pyupm_ads1x15.IADC

API for ADS1015.

ID: ADS1015

Name: 12-bit ADC with Integrated MUX, PGA, Comparator, Oscillator, and Reference

Category: electric

Manufacturer: ti adafruit

Connection: i2c

Link:http://www.ti.com/lit/ds/symlink/ads1015.pdf The ADS1013, ADS1014, and ADS1015 are precision analog-to-digital converters (ADCs) with 12 bits of resolution offered in an ultra-small, leadless QFN-10 package or an MSOP-10 package. The ADS1013/4/5 are designed with precision, power, and ease of implementation in mind. The ADS1013/4/5 feature an onboard reference and oscillator. Data is transferred via an I2C-compatible serial interface; four I2C slave addresses can be selected. The ADS1013/4/5 operate from a single power supply ranging from 2.0V to 5.5V. The ADS1013/4/5 can perform conversions at rates up to 3300 samples per second (SPS). An onboard PGA is available on the ADS1014 and ADS1015 that offers input ranges from the supply to as low as +/- 256mV, allowing both large and small signals to be measured with high resolution. The ADS1015 also features an input multiplexer (MUX) that provides two differential or four single-ended inputs. The ADS1013/4/5 operate either in continuous conversion mode or a single- shot mode that automatically powers down after a conversion and greatly reduces current consumption during idle periods. The ADS1013/4/5 are specified from -40 deg C to +125 deg C.

Tested with Adafriut ADS1015 board:https://www.adafruit.com/products/1083

C++ includes: ads1015.hpp

SPS_128 = 0
SPS_1600 = 128
SPS_2400 = 160
SPS_250 = 32
SPS_3300 = 192
SPS_490 = 64
SPS_920 = 96
getModuleName()[source]

const char * getModuleName()

Returns module name

modulename as const char*

getNumInputs()[source]

unsigned int getNumInputs()

Get number of inputs

number of inputs

getRawValue(input)[source]

uint16_t getRawValue(unsigned int input)

Read current value for current single ended analogue input

current conversion value

getResolutionInBits()[source]

unsigned int getResolutionInBits()

Read current voltage for current single ended analogue input

current voltage

getVoltage(input)[source]

float getVoltage(unsigned int input)

Read current voltage for current single ended analogue input

current voltage

setSPS(*args)[source]

void setSPS(ADSSAMPLERATE rate=SPS_1600)

Sets the sample rate of the device. This function needs to be overridden in subclasses as the ADS1115 and ADS1015 have different sample rates.

rate: ADSSAMPLERATE enum

class pyupm_ads1x15.ADS1115(bus, address=72)[source]

Bases: pyupm_ads1x15.ADS1X15

API for ADS1115.

ID: ADS1115

Name: 16-bit ADC with Integrated MUX, PGA, Comparator, Oscillator, and Reference

Category: electric

Manufacturer: ti adafruit

Connection: i2c

Link:http://www.ti.com/lit/ds/symlink/ads1115.pdf The ADS1113, ADS1114, and ADS1115 are precision analog-to-digital converters (ADCs) with 16 bits of resolution offered in an ultra-small, leadless QFN-10 package or an MSOP-10 package. The ADS1113/4/5 are designed with precision, power, and ease of implementation in mind. The ADS1113/4/5 feature an onboard reference and oscillator. Data is transferred via an I2C-compatible serial interface; four I2C slave addresses can be selected. The ADS1113/4/5 operate from a single power supply ranging from 2.0V to 5.5V. The ADS1113/4/5 can perform conversions at rates up to 860 samples per second (SPS). An onboard PGA is available on the ADS1114 and ADS1115 that offers input ranges from the supply to as low as +/- 256mV, allowing both large and small signals to be measured with high resolution. The ADS1115 also features an input multiplexer (MUX) that provides two differential or four single-ended inputs. The ADS1113/4/5 operate either in continuous conversion mode or a single- shot mode that automatically powers down after a conversion and greatly reduces current consumption during idle periods. The ADS1113/4/5 are specified from -40 deg C to +125 deg C.

Tested with DIYMall ADS1115 board. Also available from Adafruit:https://www.adafruit.com/products/1085

C++ includes: ads1115.hpp

SPS_128 = 128
SPS_16 = 32
SPS_250 = 160
SPS_32 = 64
SPS_475 = 192
SPS_64 = 96
SPS_8 = 0
SPS_860 = 224
setSPS(*args)[source]

void setSPS(ADSDATARATE rate=ADS1115::SPS_128)

Sets the sample rate of the device. This function needs to be overridden in subclasses as the ADS1115 and ADS1015 have different sample rates.

rate: ADSSAMPLERATE enum

class pyupm_ads1x15.ADS1X15(*args, **kwargs)[source]

Bases: object

CONVERSION_RDY = 4
CQUE_1CONV = 0
CQUE_2CONV = 1
CQUE_4CONV = 2
CQUE_NONE = 3
DIFF_0_1 = 0
DIFF_0_3 = 4096
DIFF_1_3 = 8192
DIFF_2_3 = 12288
GAIN_EIGHT = 2048
GAIN_FOUR = 1536
GAIN_ONE = 512
GAIN_SIXTEEN = 2560
GAIN_TWO = 1024
GAIN_TWOTHIRDS = 0
SINGLE_0 = 16384
SINGLE_1 = 20480
SINGLE_2 = 24576
SINGLE_3 = 28672
SPS_DEFAULT = 128
THRESH_DEFAULT = 5
THRESH_HIGH = 3
THRESH_LOW = 2
getCompLatch()[source]

bool getCompLatch(void)

Returns bool representing the state of the comparator latching functionality. False = Non Latching comparator (default) True = Latching Comparator

getCompMode()[source]

bool getCompMode(void)

Returns the comparator mode. False = Traditional comparator with Hysteresis (default) True = Window Comparator

getCompPol()[source]

bool getCompPol(void)

Get comparator polarity. Reports the polarity of the ALERT/RDY pin. Returns: False = Active Low (default) True = Active High

getCompQue()[source]

ADSCOMP getCompQue(void)

Returns ADSCOMP value representing the state of comparator queue.

CQUE_1CONV = Assert after one conversion CQUE_2CONV = Assert after two conversions CQUE_2CONV = Assert after four conversions CQUE_NONE = Disable comparator (default)

getContinuous()[source]

bool getContinuous(void)

Returns bool reflecting state of device mode bit.

False = Power Down Single shot mode (default) True = Continuous conversion mode

getGain()[source]

ADSGAIN getGain()

Returns the current gain setting being used by the device as an ADSGAIN value.

getLastSample(*args)[source]

float getLastSample(int reg=ADS1X15_REG_POINTER_CONVERT)

Returns the contents of conversion register without performing a conversion operation. Will use a multiplier based on the current gain setting to give the voltage as a float. Used internally to return the HI and LOW threshold values.

reg: uint8_t value specifying register to read. Should generally be called with no parameter.

getSPS()[source]

ADSSAMPLERATE getSPS(void)

Returns the current device sample rate a an ADSSAMPLERATE value.

getSample(*args)[source]

float getSample(ADSMUXMODE mode=ADS1X15::DIFF_0_1)

Performs a read as specified by ADS1X15::ADSMUXMOE and returns the value as a float. Uses getLastSample() internally to return voltage value.

mode ADSMUXMODE specifying inputs to be sampled.

getThresh(*args)[source]

float getThresh(ADSTHRESH reg=THRESH_DEFAULT)

Returns current high or low threshold setting.

reg: ADSTHRES enum value. Returns 0.0 unless THRESH_HIGH or THRESH_LOW requested.

name()[source]

std::string name()

Returns the name of the sensor

setCompLatch(mode=False)[source]

void setCompLatch(bool mode=false)

Sets bit controlling comparator operation.

mode: bool False = Non Latching comparator (default) True = Latching Comparator

setCompMode(mode=False)[source]

void setCompMode(bool mode=false)

Sets the comparator mode of the device.

mode: bool value denoting mode. False = Traditional comparator with Hysteresis (default) True = Window Comparator

setCompPol(mode=False)[source]

void setCompPol(bool mode=false)

Sets the comparator polarity. Controls the polarity of the ALERT/RDY pin.

mode: bool. False = Active Low (default) True = Active High

setCompQue(*args)[source]

void setCompQue(ADSCOMP mode=ADS1X15::CQUE_NONE)

Sets bits controlling Comparator queue operation.

mode: ADSCOMP enum. CQUE_1CONV = Assert after one conversion CQUE_2CONV = Assert after two conversions CQUE_2CONV = Assert after four conversions CQUE_NONE = Disable comparator (default)

setContinuous(mode=False)[source]

void setContinuous(bool mode=false)

Sets the state of device mode but.

mode: bool False = Power Down Single shot mode (default) True = Continuous conversion mode

setGain(*args)[source]

void setGain(ADSGAIN gain=ADS1X15::GAIN_TWO)

Sets the PGA gain bits to the desired gain. Default is +/- 2.094 volts.

gain: ADSGAIN value reprenting the desired gain. See warnings in spec sheet.

setSPS(rate)[source]

void setSPS(ADSSAMPLERATE rate)

Sets the sample rate of the device. This function needs to be overrode in subclasses as the ADS1115 and ADS1015 have different data rates.

ADSSAMPLERATE: enum SPS_DEFAULT = 0x0080

setThresh(*args)[source]

void setThresh(ADSTHRESH reg=THRESH_DEFAULT, float value=0.0)

Sets threshold levels or configures for conversion ready operation of ALERT/RDY output.

reg: ADSTHRESH enum

value: float value to set threshold register to.

THRESH_LOW = Sets low thresh register. THRESH_HIGH = Sets high thresh register. CONVERSION_RDY = Configures conversion ready operation THRESH_DEFAULT = resets high/low registers to startup values.

class pyupm_ads1x15.IADC(*args, **kwargs)[source]

Bases: pyupm_ads1x15.IModuleStatus

Interface for ADC Sensors.

C++ includes: iADC.hpp

getNumInputs()[source]

virtual unsigned int getNumInputs()=0

getRawValue(input)[source]

virtual uint16_t getRawValue(unsigned int input)=0

getResolutionInBits()[source]

virtual unsigned int getResolutionInBits()=0

getVoltage(input)[source]

virtual float getVoltage(unsigned int input)=0

class pyupm_ads1x15.IModuleStatus(*args, **kwargs)[source]

Bases: object

getModuleName()[source]

virtual const char* getModuleName()=0

Returns name of module. This is the string in library name after libupm_

name of module