AEM
AD7689 Class Reference

#include <ad7689.h>

Inheritance diagram for AD7689:
YADC

Public Member Functions

 AD7689 (const YSPI *const y, uint8_t numberChannels=TOTAL_CHANNELS)
 
void enableFiltering (bool onOff)
 
float acquireChannel (uint8_t channel, uint32_t *timeStamp)
 
float acquireChannel (uint8_t channel)
 
float acquireTemperature ()
 
bool selftest (void)
 
- Public Member Functions inherited from YADC
 YADC (const YSPI *const y)
 

Protected Member Functions

uint16_t shiftTransaction (uint16_t command, bool readback, uint16_t *rb_cmd_ptr) const
 
uint16_t toCommand (AD7689_conf cfg) const
 
AD7689_conf getADCConfig (bool default_config=false)
 
float readTemperature (void)
 
void configureSequencer ()
 
void readChannels (uint8_t channels, uint8_t mode, uint16_t *data, uint16_t *temp)
 
float calculateVoltage (uint16_t sample) const
 
float calculateTemp (uint16_t temp) const
 
uint32_t initSampleTiming (void)
 
void cycleTimingBenchmark (void)
 
uint8_t getInputConfig (uint8_t polarity, bool differential) const
 
float getNegRef (float posR, uint8_t polarity) const
 
uint8_t getRefSrc (uint8_t refS, float posR) const
 
float getPosRef (uint8_t refS, float posR) const
 
- Protected Member Functions inherited from YADC
void selfTestFailed () const
 

Protected Attributes

AD7689_conf conf
 
const float posref
 
const float negref
 
const uint8_t refsrc
 
const uint8_t inputConfig
 
const uint8_t refConfig
 
uint32_t timeStamps [TOTAL_CHANNELS]
 
uint16_t samples [TOTAL_CHANNELS]
 
uint16_t framePeriod
 
uint16_t curTemp
 
uint16_t tempTime
 
uint32_t lastSeqEndTime
 
uint8_t inputCount
 
bool sequencerActive
 
bool filterConfig
 
- Protected Attributes inherited from YADC
const YSPI *const yspi = NULL
 

Detailed Description

Represents the Analog Devices AD7689, an ADC with 8 channels and 16 bit resolution.

Constructor & Destructor Documentation

AD7689::AD7689 ( const YSPI *const  y,
uint8_t  numberChannels = TOTAL_CHANNELS 
)

[AD7689::constructor Create an instance of an AD7689 ADC. using YSPI]

Parameters
yPointer to an instance of YSPI
numberChannelsThe highest channel in use for the application, a value between 1 and 8.
Returns
Instance of the ADC.

Member Function Documentation

float AD7689::acquireChannel ( uint8_t  channel,
uint32_t *  timeStamp 
)

[AD7689::acquireChannel Sample analog input signal along with its time stamp.]

Parameters
channelThe channel to sample, between 1 and 8.
timeStampA pointer to a variable in which the time stamp should be stored.
Returns
Measured voltage.
float AD7689::acquireChannel ( uint8_t  channel)
virtual

[AD7689::acquireChannel Sample analog input signal along with its time stamp.]

Parameters
channelThe channel to sample, between 1 and 8.
Returns
Measured voltage.

Implements YADC.

float AD7689::acquireTemperature ( )

[AD7689::acquireTemperature Measure temperature.]

Returns
Temperature in °C.
float AD7689::calculateTemp ( uint16_t  temp) const
protected

[AD7689::calculateTemp Calculate the ADC temperature based on raw ADC input readin, using internal voltage reference.]

Parameters
tempThe sample to convert. A positive integer between 0 and 65535.
Returns
Temperature in °C.
float AD7689::calculateVoltage ( uint16_t  sample) const
protected

[AD7689::calculateVoltage Calculate an absolute or relative voltage based on raw ADC input reading and specified voltage reference(s).]

Parameters
sampleThe sample to convert. A positive integer between 0 and 65535.
Returns
Calculated voltage.
void AD7689::configureSequencer ( )
protected

[AD7689::configureSequencer Enables the automatic channel sequencer of the ADC and turn on temperature measurements.]

void AD7689::cycleTimingBenchmark ( void  )
protected

[AD7689::cycleTimingBenchmark Measures the time required to transceive a complete 16 bit frame, using the current CPU clock speed. This is required to generate accurate time stamps, if desired. Should be called once when starting the ADC, or whenever the clock frequency is changed (i.e. dynamic clock switching).]

void AD7689::enableFiltering ( bool  onOff)

[AD7689::enableFiltering Configure filtering to reduce bandwidth to 25%.]

Parameters
onOffTrue to turn on filter, False for full bandwidth.
AD7689_conf AD7689::getADCConfig ( bool  default_config = false)
protected

[AD7689::getADCConfig Assemble user settings into a configuration for the ADC, or return a default configuration.]

Parameters
default_configTrue if the default configuration should be returned, False if user settings are to be used.
Returns
Configuration set for the ADC.
uint8_t AD7689::getInputConfig ( uint8_t  polarity,
bool  differential 
) const
protected

AD7689::getInputConfig returns an inputConfig value according to the following truth table differential polarity inputConfig TRUE BIPOLAR_MODE INCC_BIPOLAR_DIFF TRUE !BIPOLAR_MODE INCC_UNIPOLAR_DIFF FALSE BIPOLAR_MODE INCC_BIPOLAR_COM FALSE !BIPOLAR_MODE INCC_UNIPOLAR_REF_GND

Parameters
polarityuint8_t polarity value
differentialbool indcating differntial mode or not
Returns
uint8_t inputConfig value according to truth table
float AD7689::getNegRef ( float  posR,
uint8_t  polarity 
) const
protected

AD7689::getNegRef returns a negative reference value according to the following truth table polarity negref BIPOLAR_MODE posR/2.0 !BIPOLAR_MODE 0

  • Parameters
    posRfloat value indicating input positive reference
    polarityuint8_t polarity value
    Returns
    float negative reference value according to truth table
float AD7689::getPosRef ( uint8_t  refS,
float  posR 
) const
protected

AD7689::getPosRef returns a positive reference value according to the following truth table refS posR posref REF_INTERNAL INTERNAL_25 INTERNAL_25; REF_INTERNAL INTERNAL_4096 INTERNAL_4096 REF_INTERNAL anything else INTERNAL_4096 !REF_INTERNAL anything posR

Parameters
refSuint8_t reference source value
posRfloat value indicating input positive reference
Returns
float positive reference value according to truth table
uint8_t AD7689::getRefSrc ( uint8_t  refS,
float  posR 
) const
protected

AD7689::getRefSrc returns a reference source value according to the following truth table refS posR refsrc REF_INTERNAL INTERNAL_25 INT_REF_25; REF_INTERNAL INTERNAL_4096 INT_REF_4096 REF_INTERNAL anything else INT_REF_4096 !REF_INTERNAL anything EXT_REF_TEMP_BUF;

Parameters
refSuint8_t refernece source value
posRfloat positive reference value
Returns
uint8_t refsrc value according to truth table
uint32_t AD7689::initSampleTiming ( void  )
protected

[AD7689::initSampleTiming Reset time stamps for all samples and force an update sequence at the start of the next read command.]

Returns
The current MCU core time.
void AD7689::readChannels ( uint8_t  channels,
uint8_t  mode,
uint16_t *  data,
uint16_t *  temp 
)
protected

[AD7689::readChannels Reads voltages as raw 16 bit ADC samples from selected channels. Temperature also read.]

Parameters
channelsLast channel to read, starting at 0 to max. 7, in differential mode always read even number of channels.
modeInput signal configuration mode: UNIPOLAR_MODE, BIPOLAR_MODE or DIFFERENTIAL_MODE.
dataPointer to a vector holding the data, length depending on channels and mode.
tempPointer to a variable holding the temperature.
float AD7689::readTemperature ( void  )
protected

[AD7689::readTemperature Reads the temperature of the ADC. This function is meant to be called if the ADC is only used as a temperature sensor. Whenever actual ADC values are read, temperature is read along with it, and returned directly. This function disables the sequencer.]

Returns
Internal temperature of the ADC in °C.
bool AD7689::selftest ( void  )
virtual

[AD7689::selftest Verifies that the ADC is properly connected and operational]

Returns
True if the ADC works properly, False if errors were encountered. Check SPI connections if selftest fails repeatedly.

Implements YADC.

uint16_t AD7689::shiftTransaction ( uint16_t  command,
bool  readback,
uint16_t *  rb_cmd_ptr 
) const
protected

[AD7689::shiftTransaction Sends a 16 bit word to the ADC, and simultaneously captures the response. ADC responses lag 2 frames behind on commands. If readback is active, 32 bits will be captured instead of 16.]

Parameters
commandThe 16 bit command to send to the ADC.
readbackTrue if readback is desired, otherwise False.
rb_cmd_ptrA pointer to a variable to store the readback response.
Returns
A 16 bit word received from the ADC, as response to the command from 2 frames ago.
uint16_t AD7689::toCommand ( AD7689_conf  cfg) const
protected

[AD7689::toCommand Converts a command structure to a 16 bit word that can be transmitted over SPI]

Parameters
cfgA configuration set of type AD7689_conf holding the configuration settings.
Returns
A 16 bit configuration command that can be sent to the ADC with shiftTransaction.

Field Documentation

AD7689_conf AD7689::conf
protected

Configuration settings for the ADC.

uint16_t AD7689::curTemp
protected

Last temperature measurement.

bool AD7689::filterConfig
protected

Input filter configuration.

uint16_t AD7689::framePeriod
protected

Length of a single frame, in microseconds.

const uint8_t AD7689::inputConfig
protected

Input channel configuration.

uint8_t AD7689::inputCount
protected

Number of input channels. Even for differential mode.

uint32_t AD7689::lastSeqEndTime
protected

Time stamp of the end of the last data acquisition sequence.

const float AD7689::negref
protected

Negative voltage reference, either COM or ground.

const float AD7689::posref
protected

Positive voltage reference for unipolar or bipolar mode.

const uint8_t AD7689::refConfig
protected

Voltage reference configuration.

const uint8_t AD7689::refsrc
protected

Positive voltage eference source.

uint16_t AD7689::samples[TOTAL_CHANNELS]
protected

Last set of samples for each channel.

bool AD7689::sequencerActive
protected

True when the sequencer is initialized, false at start-up or during self tests

uint16_t AD7689::tempTime
protected

Time stamp for last temperature measurement.

uint32_t AD7689::timeStamps[TOTAL_CHANNELS]
protected

Last set of time stamps for each channel.


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