ADS1118
1.0.0
Arduino library for Texas Instruments ADS1118 chip
|
#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 | |
Class representing the ADS1118 sensor chip
ADS1118::ADS1118 | ( | uint8_t | io_pin_cs | ) |
Constructor.
Constructor of the class
io_pin_cs | a byte indicating the pin to be use as the chip select pin (CS) |
void ADS1118::begin | ( | ) |
This method initialize the SPI port and the config register.
This method initialize the SPI port and the config register
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
configRegister | The config register in "union Config" format |
void ADS1118::disablePullup | ( | ) |
Disabling the internal pull-up resistor of the DOUT pin.
Disabling the internal pull-up resistor of the DOUT pin
void ADS1118::enablePullup | ( | ) |
Enabling the internal pull-up resistor of the DOUT pin.
Enabling the internal pull-up resistor of the DOUT pin
uint16_t ADS1118::getADCValue | ( | uint8_t | inputs | ) |
Getting a sample from the specified input.
Getting a sample from the specified input
inputs | Sets 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 |
double ADS1118::getMilliVolts | ( | uint8_t | inputs | ) |
Getting the millivolts from the specified inputs.
Getting the millivolts from the specified inputs
inputs | Sets 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 |
double ADS1118::getMilliVolts | ( | ) |
Getting the millivolts from the settled inputs.
Getting the millivolts from the settled inputs
double ADS1118::getTemperature | ( | ) |
void ADS1118::setContinuousMode | ( | ) |
Setting to continuous adquisition mode.
Setting to continuous adquisition mode
void ADS1118::setFullScaleRange | ( | uint8_t | fsr | ) |
Setting the full scale range in the config register.
Setting the full scale range in the config register
fsr | The 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. |
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.
input | The 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 |
void ADS1118::setSampligRate | ( | uint8_t | samplingRate | ) |
Setting the sampling rate specified in the config register.
Setting the sampling rate specified in the config register
samplingRate | It's the sampling rate: RATE_8SPS, RATE_16SPS, RATE_32SPS, RATE_64SPS, RATE_128SPS, RATE_250SPS, RATE_475SPS, RATE_860SPS |
void ADS1118::setSingleShotMode | ( | ) |
Setting to single shot adquisition and power down mode.
Setting to single shot adquisition and power down mode