Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

otADS868x Class Reference
[ADC ADS8681/5/9 - Procedures for 16 bit multi range ADC.ADC ADS8681/5/9 - Procedures for 16 bit multi range ADC.]

Class that allows to use ADS8681/5/9 ADC.

#include <otADS868x.h>


Public Types

enum  InputRange {
  BIP_12V, BIP_10V, BIP_6V, BIP_5V,
  BIP_2_5V, UNI_12V = 8, UNI_10V, UNI_6V,
  UNI_5V
}
enum  RegisterAddress {
  DEVICE_ID_REG = 0x00, RST_PWRCTL_REG = 0x04, SDI_CTL_REG = 0x08, SDO_CTL_REG = 0x0C,
  DATAOUT_CTL_REG = 0x10, RANGE_SEL_REG = 0x14, ALARM_REG = 0x20, ALARM_H_TH_REG = 0x24,
  ALARM_L_TH_REG = 0x28
}
enum  Commands {
  C_NOP = 0x0000, CLEAR_HWORD = 0xC000, READ_HWORD = 0xC800, READ = 0x4800,
  WRITE_1 = 0xD000, WRITE_2 = 0xD200, WRITE_3 = 0xD400, SET_HWORD = 0xD800
}

Public Member Functions

 otADS868x ()
void init ()
void setRange (InputRange rng)
S16 read ()
S16 read (U32 num)
void read (S16 *buff, U32 len)
void read (S16 *buff, U32 len, U32 dly)
void read (S16 *buff, U32 len, U32 dly, U8 timer)
void read (F64 *buff, U32 len, U32 dly, U8 timer)
void add (F64 *buff, U32 len, U32 dly, U8 timer)
U32 evaluateDelay (F32 intervalDelay)
float volt (U16 avg=1)
float toVolt (S16 adu)
bool isBipolar ()
float maxVoltage ()
float minVoltage ()
float lsb ()
S32 toUnipolar (S16 adu)
S16 toADU (F32 volt)
bool trigger (F32 volt, U32 timeout)


Member Enumeration Documentation

enum otADS868x::Commands
 

Enumeration values:
C_NOP  No operation.
CLEAR_HWORD 
  • Any bit marked 1 in the data field results in that particular bit of the specified register being reset to 0, leaving the other bits unchanged.
    • Half-word command (that is, the command functions on 16 bits at a time).
    • LSB of the 9-bit address is always ignored and considered as 0b.
READ_HWORD 
  • Half-word command (that is, the device outputs 16 bits of register data at a time).
    • LSB of the 9-bit address is always ignored and considered as 0b.
    • Upon receiving this command, the device sends out 16 bits of the register in the next frame.
READ  Same as the READ_HWORD except that only eight bits of the register (byte read) are returned in the next frame.
WRITE_1 
  • LSB of the 9-bit address is always ignored and considered as 0b.

  • Half-word write command (two bytes of input data are written into the specified address).
WRITE_2 
  • LSB of the 9-bit address is always ignored and considered as 0b.
    • With this command, only the MS byte of the 16-bit data word is written at the specified register address. The LS byte is ignored.
WRITE_3 
  • LSB of the 9-bit address is always ignored and considered as 0b.
    • With this command, only the LS byte of the 16-bit data word is written at the specified register address. The MS byte is ignored.
SET_HWORD 
  • Any bit marked 1 in the data field results in that particular bit of the specified register being set to 1, leaving the other bits unchanged.
    • Half-word command (that is, the command functions on 16 bits at a time).
    • LSB of the 9-bit address is always ignored and considered as 0b.

enum otADS868x::InputRange
 

Enumeration values:
BIP_12V  Bipolar +/- 12V, FULL-SCALE RANGE: 24.576, LSB: 375.000 uV.
BIP_10V  Bipolar +/- 10V, FULL-SCALE RANGE: 20.480, LSB: 312.500 uV.
BIP_6V  Bipolar +/- 6V, FULL-SCALE RANGE: 12.288, LSB: 187.500 uV.
BIP_5V  Bipolar +/- 5V, FULL-SCALE RANGE: 10.240, LSB: 156.250 uV.
BIP_2_5V  Bipolar +/- 2.5V, FULL-SCALE RANGE: 5.120, LSB: 78.125 uV.
UNI_12V  Unipolar o to 12V, FULL-SCALE RANGE: 12.288, LSB: 185.500 uV.
UNI_10V  Unipolar o to 10V, FULL-SCALE RANGE: 10.240, LSB: 156.250 uV.
UNI_6V  Unipolar o to 6V, FULL-SCALE RANGE: 6.144, LSB: 93.750 uV.
UNI_5V  Unipolar o to 5V, FULL-SCALE RANGE: 5.120, LSB: 78.125 uV.

enum otADS868x::RegisterAddress
 

Enumeration values:
DEVICE_ID_REG  Device ID register.
RST_PWRCTL_REG  Reset and power control register.
SDI_CTL_REG  SDI data input control register.
SDO_CTL_REG  SDO-x data input control register.
DATAOUT_CTL_REG  Output data control register.
RANGE_SEL_REG  Input range selection control register.
ALARM_REG  ALARM output register.
ALARM_H_TH_REG  ALARM high threshold and hysteresis register.
ALARM_L_TH_REG  ALARM low threshold register.


Constructor & Destructor Documentation

otADS868x.otADS868x  ) 
 

Create the class


Member Function Documentation

void otADS868x.add F64 buff,
U32  len,
U32  dly,
U8  timer
 

Read a stream of raw data from ADC with current settings and add to storage buffer.

Parameters:
buff Pointer to storage area where ADC values are written
len Number of samples to read and store
dly Delay executed after every sample as us.
timer Timer id used for the interval delay

U32 otADS868x.evaluateDelay F32  intervalDelay  ) 
 

Calculate a constant to have a desired interval time

Parameters:
intervalDelay time interval between one datum and another in ms
Returns:
A number that can be used as constant in dly of read method.
See also:
read

void otADS868x.init  ) 
 

Init SPI related channel and initial settings

bool otADS868x.isBipolar  ) 
 

Check if the setted range is bipolar.

Returns:
True if bipolar.

float otADS868x.lsb  ) 
 

Bit weight as volt

Returns:
Bit weight

float otADS868x.maxVoltage  ) 
 

Check maximum allowed input voltage

Returns:
Maximum voltage

float otADS868x.minVoltage  ) 
 

Check minimum allowed input voltage

Returns:
Minimum voltage

void otADS868x.read F64 buff,
U32  len,
U32  dly,
U8  timer
 

Read a stream of raw data from ADC with current settings.

Parameters:
buff Pointer to storage area where ADC values are written
len Number of samples to read and store
dly Delay executed after every sample as us.
timer Timer id used for the interval delay

void otADS868x.read S16 buff,
U32  len,
U32  dly,
U8  timer
 

Read a stream of raw data from ADC with current settings.

Parameters:
buff Pointer to storage area where ADC values are written
len Number of samples to read and store
dly Delay executed after every sample as us.
timer Timer id used for the interval delay

void otADS868x.read S16 buff,
U32  len,
U32  dly
 

Read a stream of raw data from ADC with current settings. Total Delay for data stored in SDRAM us = len * (1.49001 + dly / 11.11110232) Value for requested interval delay dly = (us - 1.49001) * 11.11110232

Parameters:
buff Pointer to storage area where ADC values are written
len Number of samples to read and store
dly Delay executed after every sample. Is execute the SSYNC instruction for DLY time.
See also:
evaluateDelay

void otADS868x.read S16 buff,
U32  len
 

Read a stream of raw data from ADC with current settings. Read is at the maximum speed.

Parameters:
buff Pointer to storage area where ADC values are written
len Number of samples to read and store

S16 otADS868x.read U32  num  ) 
 

Read an averaged raw data from ADC with current settings

Parameters:
num Number of samples
Returns:
ADC average value as ADU. Two's complement is used for sampled data.

S16 otADS868x.read  ) 
 

Read a raw data from ADC with current settings

Returns:
ADC value as ADU. Two's complement is used for sampled data.

void otADS868x.setRange InputRange  rng  ) 
 

Specify the ADC range

Parameters:
rng Input range see InputRange

S16 otADS868x.toADU F32  volt  ) 
 

Convert from volt to ADU

Returns:
ADU value

S32 otADS868x.toUnipolar S16  adu  ) 
 

From two's complement to unsigned

Parameters:
adu Two's complement ADC value
Returns:
Unsigned ADC value

float otADS868x.toVolt S16  adu  ) 
 

Convert from ADU to Volt.

Parameters:
adu ADC sampled value
Returns:
Voltage measured

bool otADS868x.trigger F32  volt,
U32  timeout
 

Reads continuously and returns if the read value is greater than the set value or the timeout is reached.

Parameters:
volt Trigger level as volt
timeout Timeout value, approximately 1us per count.
Returns:
True if trigger is reached else a timeout is occurred.

float otADS868x.volt U16  avg = 1  ) 
 

Read a sample from ADC and return its value as Volt

Parameters:
avg Number of samples to average, default 1
Returns:
Voltage measured


The documentation for this class was generated from the following file: footer
otStudio - Library Reference - (C) 2020-23 Officina Turini, All Rights Reserved
Document built with Doxygen 1.4.0