ADS1118  1.0.0
Arduino library for Texas Instruments ADS1118 chip
Public Member Functions | Public Attributes | List of all members
ADS1118 Class Reference

#include <ADS1118.h>

Public Member Functions

 ADS1118 (uint8_t io_pin_cs)
 Constructor. More...
 
void begin ()
 This method initialize the SPI port and the config register. More...
 
double getTemperature ()
 Getting the temperature in degrees celsius from the internal sensor of the ADS1118. More...
 
uint16_t getADCValue (uint8_t inputs)
 Getting a sample from the specified input. More...
 
double getMilliVolts (uint8_t inputs)
 Getting the millivolts from the specified inputs. More...
 
double getMilliVolts ()
 Getting the millivolts from the settled inputs. More...
 
void decodeConfigRegister (union Config configRegister)
 Decoding a configRegister structure and then print it out to the Serial port. More...
 
void setSampligRate (uint8_t samplingRate)
 Setting the sampling rate specified in the config register. More...
 
void setFullScaleRange (uint8_t fsr)
 Setting the full scale range in the config register. More...
 
void setContinuousMode ()
 Setting to continuous adquisition mode. More...
 
void setSingleShotMode ()
 Setting to single shot adquisition and power down mode. More...
 
void disablePullup ()
 Disabling the internal pull-up resistor of the DOUT pin. More...
 
void enablePullup ()
 Enabling the internal pull-up resistor of the DOUT pin. More...
 
void setInputSelected (uint8_t input)
 Setting the inputs to be adquired in the config register. More...
 

Public Attributes

const uint8_t DIFF_0_1 = 0b000
 Differential input: Vin=A0-A1.
 
const uint8_t DIFF_0_3 = 0b001
 Differential input: Vin=A0-A3.
 
const uint8_t DIFF_1_3 = 0b010
 Differential input: Vin=A1-A3.
 
const uint8_t DIFF_2_3 = 0b011
 Differential input: Vin=A2-A3.
 
const uint8_t AIN_0 = 0b100
 Single ended input: Vin=A0.
 
const uint8_t AIN_1 = 0b101
 Single ended input: Vin=A1.
 
const uint8_t AIN_2 = 0b110
 Single ended input: Vin=A2.
 
const uint8_t AIN_3 = 0b111
 Single ended input: Vin=A3.
 
union Config configRegister
 Config register.
 
const uint16_t SCLK = 2000000
 ADS1118 SCLK frequency: 4000000 Hz Maximum for ADS1118.
 
const uint8_t START_NOW = 1
 Start of conversion in single-shot mode.
 
const uint8_t ADC_MODE = 0
 External (inputs) voltage reading mode.
 
const uint8_t TEMP_MODE = 1
 Internal temperature sensor reading mode.
 
const uint8_t CONTINUOUS = 0
 Continuous conversion mode.
 
const uint8_t SINGLE_SHOT = 1
 Single-shot conversion and power down mode.
 
const uint8_t PULLUP = 1
 Internal pull-up resistor enabled for DOUT ***DEFAULT.
 
const uint8_t NO_PULLUP = 0
 Internal pull-up resistor disabled.
 
const uint8_t VALID_CFG = 0b01
 Data will be written to Config register.
 
const uint8_t NO_VALID_CFG = 0b00
 Data won't be written to Config register.
 
const uint8_t RESERVED = 1
 Its value is always 1, reserved.
 
const uint8_t FSR_6144 = 0b000
 Range: ±6.144 v. LSB SIZE = 187.5μV.
 
const uint8_t FSR_4096 = 0b001
 Range: ±4.096 v. LSB SIZE = 125μV.
 
const uint8_t FSR_2048 = 0b010
 Range: ±2.048 v. LSB SIZE = 62.5μV ***DEFAULT.
 
const uint8_t FSR_1024 = 0b011
 Range: ±1.024 v. LSB SIZE = 31.25μV.
 
const uint8_t FSR_0512 = 0b100
 Range: ±0.512 v. LSB SIZE = 15.625μV.
 
const uint8_t FSR_0256 = 0b111
 Range: ±0.256 v. LSB SIZE = 7.8125μV.
 
const uint8_t RATE_8SPS = 0b000
 8 samples/s, Tconv=125ms
 
const uint8_t RATE_16SPS = 0b001
 16 samples/s, Tconv=62.5ms
 
const uint8_t RATE_32SPS = 0b010
 32 samples/s, Tconv=31.25ms
 
const uint8_t RATE_64SPS = 0b011
 64 samples/s, Tconv=15.625ms
 
const uint8_t RATE_128SPS = 0b100
 128 samples/s, Tconv=7.8125ms
 
const uint8_t RATE_250SPS = 0b101
 250 samples/s, Tconv=4ms
 
const uint8_t RATE_475SPS = 0b110
 475 samples/s, Tconv=2.105ms
 
const uint8_t RATE_860SPS = 0b111
 860 samples/s, Tconv=1.163ms
 

Detailed Description

Class representing the ADS1118 sensor chip

Author
Alvaro Salazar alvar.nosp@m.o@de.nosp@m.nkitr.nosp@m.onik.nosp@m..com

Constructor & Destructor Documentation

◆ ADS1118()

ADS1118::ADS1118 ( uint8_t  io_pin_cs)

Constructor.

Constructor of the class

Parameters
io_pin_csa byte indicating the pin to be use as the chip select pin (CS)

Member Function Documentation

◆ begin()

void ADS1118::begin ( )

This method initialize the SPI port and the config register.

This method initialize the SPI port and the config register

◆ decodeConfigRegister()

void ADS1118::decodeConfigRegister ( union Config  configRegister)

Decoding a configRegister structure and then print it out to the Serial port.

Decoding a configRegister structure and then print it out to the Serial port

Parameters
configRegisterThe config register in "union Config" format

◆ disablePullup()

void ADS1118::disablePullup ( )

Disabling the internal pull-up resistor of the DOUT pin.

Disabling the internal pull-up resistor of the DOUT pin

◆ enablePullup()

void ADS1118::enablePullup ( )

Enabling the internal pull-up resistor of the DOUT pin.

Enabling the internal pull-up resistor of the DOUT pin

◆ getADCValue()

uint16_t ADS1118::getADCValue ( uint8_t  inputs)

Getting a sample from the specified input.

Getting a sample from the specified input

Parameters
inputsSets the input of the ADC: Diferential inputs: DIFF_0_1, DIFF_0_3, DIFF_1_3, DIFF_2_3. Single ended input: AIN_0, AIN_1, AIN_2, AIN_3
Returns
A word containing the ADC value

◆ getMilliVolts() [1/2]

double ADS1118::getMilliVolts ( uint8_t  inputs)

Getting the millivolts from the specified inputs.

Getting the millivolts from the specified inputs

Parameters
inputsSets the inputs to be adquired. Diferential inputs: DIFF_0_1, DIFF_0_3, DIFF_1_3, DIFF_2_3. Single ended input: AIN_0, AIN_1, AIN_2, AIN_3
Returns
A double (32bits) containing the ADC value in millivolts

◆ getMilliVolts() [2/2]

double ADS1118::getMilliVolts ( )

Getting the millivolts from the settled inputs.

Getting the millivolts from the settled inputs

Returns
A double (32bits) containing the ADC value in millivolts

◆ getTemperature()

double ADS1118::getTemperature ( )

Getting the temperature in degrees celsius from the internal sensor of the ADS1118.

Getting the temperature in degrees celsius from the internal sensor of the ADS1118

Returns
A double (32bits) containing the temperature in degrees celsius of the internal sensor

◆ setContinuousMode()

void ADS1118::setContinuousMode ( )

Setting to continuous adquisition mode.

Setting to continuous adquisition mode

◆ setFullScaleRange()

void ADS1118::setFullScaleRange ( uint8_t  fsr)

Setting the full scale range in the config register.

Setting the full scale range in the config register

Parameters
fsrThe full scale range: FSR_6144 (±6.144V)*, FSR_4096(±4.096V)*, FSR_2048(±2.048V), FSR_1024(±1.024V), FSR_0512(±0.512V), FSR_0256(±0.256V). (*) No more than VDD + 0.3 V must be applied to this device.

◆ setInputSelected()

void ADS1118::setInputSelected ( uint8_t  input)

Setting the inputs to be adquired in the config register.

Setting the inputs to be adquired in the config register.

Parameters
inputThe input selected: Diferential inputs: DIFF_0_1, DIFF_0_3, DIFF_1_3, DIFF_2_3. Single ended input: AIN_0, AIN_1, AIN_2, AIN_3

◆ setSampligRate()

void ADS1118::setSampligRate ( uint8_t  samplingRate)

Setting the sampling rate specified in the config register.

Setting the sampling rate specified in the config register

Parameters
samplingRateIt's the sampling rate: RATE_8SPS, RATE_16SPS, RATE_32SPS, RATE_64SPS, RATE_128SPS, RATE_250SPS, RATE_475SPS, RATE_860SPS

◆ setSingleShotMode()

void ADS1118::setSingleShotMode ( )

Setting to single shot adquisition and power down mode.

Setting to single shot adquisition and power down mode


The documentation for this class was generated from the following files: