AEM
|
#include <ad7689.h>
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 |
Represents the Analog Devices AD7689, an ADC with 8 channels and 16 bit resolution.
AD7689::AD7689 | ( | const YSPI *const | y, |
uint8_t | numberChannels = TOTAL_CHANNELS |
||
) |
float AD7689::acquireChannel | ( | uint8_t | channel, |
uint32_t * | timeStamp | ||
) |
[AD7689::acquireChannel Sample analog input signal along with its time stamp.]
channel | The channel to sample, between 1 and 8. |
timeStamp | A pointer to a variable in which the time stamp should be stored. |
|
virtual |
[AD7689::acquireChannel Sample analog input signal along with its time stamp.]
channel | The channel to sample, between 1 and 8. |
Implements YADC.
float AD7689::acquireTemperature | ( | ) |
[AD7689::acquireTemperature Measure temperature.]
|
protected |
[AD7689::calculateTemp Calculate the ADC temperature based on raw ADC input readin, using internal voltage reference.]
temp | The sample to convert. A positive integer between 0 and 65535. |
|
protected |
[AD7689::calculateVoltage Calculate an absolute or relative voltage based on raw ADC input reading and specified voltage reference(s).]
sample | The sample to convert. A positive integer between 0 and 65535. |
|
protected |
[AD7689::configureSequencer Enables the automatic channel sequencer of the ADC and turn on temperature measurements.]
|
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%.]
onOff | True to turn on filter, False for full bandwidth. |
|
protected |
[AD7689::getADCConfig Assemble user settings into a configuration for the ADC, or return a default configuration.]
default_config | True if the default configuration should be returned, False if user settings are to be used. |
|
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
polarity | uint8_t polarity value |
differential | bool indcating differntial mode or not |
|
protected |
AD7689::getNegRef returns a negative reference value according to the following truth table polarity negref BIPOLAR_MODE posR/2.0 !BIPOLAR_MODE 0
posR | float value indicating input positive reference |
polarity | uint8_t polarity value |
|
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
refS | uint8_t reference source value |
posR | float value indicating input positive reference |
|
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;
refS | uint8_t refernece source value |
posR | float positive reference value |
|
protected |
[AD7689::initSampleTiming Reset time stamps for all samples and force an update sequence at the start of the next read command.]
|
protected |
[AD7689::readChannels Reads voltages as raw 16 bit ADC samples from selected channels. Temperature also read.]
channels | Last channel to read, starting at 0 to max. 7, in differential mode always read even number of channels. |
mode | Input signal configuration mode: UNIPOLAR_MODE, BIPOLAR_MODE or DIFFERENTIAL_MODE. |
data | Pointer to a vector holding the data, length depending on channels and mode. |
temp | Pointer to a variable holding the temperature. |
|
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.]
|
virtual |
[AD7689::selftest Verifies that the ADC is properly connected and operational]
Implements YADC.
|
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.]
command | The 16 bit command to send to the ADC. |
readback | True if readback is desired, otherwise False. |
rb_cmd_ptr | A pointer to a variable to store the readback response. |
|
protected |
[AD7689::toCommand Converts a command structure to a 16 bit word that can be transmitted over SPI]
cfg | A configuration set of type AD7689_conf holding the configuration settings. |
|
protected |
Configuration settings for the ADC.
|
protected |
Last temperature measurement.
|
protected |
Input filter configuration.
|
protected |
Length of a single frame, in microseconds.
|
protected |
Input channel configuration.
|
protected |
Number of input channels. Even for differential mode.
|
protected |
Time stamp of the end of the last data acquisition sequence.
|
protected |
Negative voltage reference, either COM or ground.
|
protected |
Positive voltage reference for unipolar or bipolar mode.
|
protected |
Voltage reference configuration.
|
protected |
Positive voltage eference source.
|
protected |
Last set of samples for each channel.
|
protected |
True when the sequencer is initialized, false at start-up or during self tests
|
protected |
Time stamp for last temperature measurement.
|
protected |
Last set of time stamps for each channel.