ClearCore Library
Loading...
Searching...
No Matches
List of all members | Public Types | Public Member Functions | Static Public Attributes
ClearCore::AdcManager Class Reference

Detailed Description

ADC Peripheral Manager for the ClearCore Board.

This class manages the ADC peripheral on the Teknic ClearCore.

Utilizes DMA sequence to configure channels, trigger conversion, and read results.

Uses DMAC Channels: 0,1

ADC Peripheral Manager for the ClearCore Board. More...

#include <AdcManager.h>

Public Types

enum  AdcChannels {
  ADC_VSUPPLY_MON = 0 , ADC_AIN12 , ADC_5VOB_MON , ADC_AIN11 ,
  ADC_AIN10 , ADC_AIN09 , ADC_SDRVR3_IMON , ADC_SDRVR2_IMON ,
  ADC_CHANNEL_COUNT
}
 
enum  FilterUnits { FILTER_UNIT_RAW , FILTER_UNIT_MS , FILTER_UNIT_SAMPLES }
 Units for the filter time constant. More...
 

Public Member Functions

bool AdcResolution (uint8_t resolution)
 Configure the ADC conversion resolution.
 
volatile const uint8_t & AdcResolution ()
 Returns the resolution of the ADC.
 
volatile const uint16_t & FilteredResult (AdcChannels adcChannel)
 Returns the filtered ADC result of a specific channel.
 
volatile const uint16_t & ConvertedResult (AdcChannels adcChannel)
 Returns the converted ADC result of a specific channel.
 
bool FilterTc (AdcChannels adcChannel, uint16_t tc, FilterUnits theUnits)
 Sets the IIR filter time constant for an ADC channel.
 
uint16_t FilterTc (AdcChannels adcChannel, FilterUnits theUnits)
 Gets the IIR filter time constant of an ADC channel.
 
bool FilterReset (AdcChannels adcChannel, uint16_t newSetting)
 Resets the filter for an ADC Channel.
 
void AdcTimeoutLimit (uint8_t timeout)
 Configure the ADC conversion timeout.
 
volatile const bool & AdcTimeout ()
 Determine whether the ADC has timed out.
 
float AnalogVoltage (AdcChannels adcChannel)
 Returns the filtered ADC result of a specific channel in volts.
 

Static Public Attributes

static const uint8_t ADC_RESOLUTION_DEFAULT = 12
 
static const uint8_t ADC_TIMEOUT_DEFAULT = 3
 
static const uint32_t ADC_IIR_FILTER_TC_MS = 2
 

Member Enumeration Documentation

◆ AdcChannels

ADC conversion channels.

Note
These are currently assumed to be unsigned values.
Enumerator
ADC_VSUPPLY_MON 

Supply voltage monitor.

ADC_AIN12 

Analog input A-12.

ADC_5VOB_MON 

5V off-board monitor

ADC_AIN11 

Analog input A-11.

ADC_AIN10 

Analog input A-10.

ADC_AIN09 

Analog input A-9.

ADC_SDRVR3_IMON 

Screwdriver M-3 current monitor.

ADC_SDRVR2_IMON 

Screwdriver M-2 current monitor.

◆ FilterUnits

Units for the filter time constant.

Note
One sample time is 200 microseconds, so 1 ms = 5 sample times.
Enumerator
FILTER_UNIT_RAW 

Raw units.

FILTER_UNIT_MS 

Milliseconds.

FILTER_UNIT_SAMPLES 

Sample times.

Member Function Documentation

◆ AdcResolution() [1/2]

volatile const uint8_t & ClearCore::AdcManager::AdcResolution ( )
inline

Returns the resolution of the ADC.

Possible values are: 8, 10, and 12.

// Save the ADC resolution
uint8_t currentResolution = AdcMgr.AdcResolution();
bool AdcResolution(uint8_t resolution)
Configure the ADC conversion resolution.
AdcManager & AdcMgr
ADC module manager.

◆ AdcResolution() [2/2]

bool ClearCore::AdcManager::AdcResolution ( uint8_t  resolution)

Configure the ADC conversion resolution.

ADC naturally supports 12-bit operation. Lower resolution is used to decrease sample time.

Passing an unsupported resolution yields no change and returns false.

Acceptable Inputs:

  • 8-bit
  • 10-bit
  • 12-bit
Note
The default resolution is 12-bit.
// Set the ADC resolution to 10-bit
Parameters
resolutionBit resolution. Acceptable values: 8, 10, and 12.
Returns
Success
Examples
AnalogIOExamples/ReadAnalogInput/ReadAnalogInput.cpp, and ReadAnalogInput.cpp.

◆ AdcTimeout()

volatile const bool & ClearCore::AdcManager::AdcTimeout ( )
inline

Determine whether the ADC has timed out.

// The ADC has timed out
}
volatile const bool & AdcTimeout()
Determine whether the ADC has timed out.
Definition AdcManager.h:295
Returns
true if the ADC has time out, false otherwise.

◆ AdcTimeoutLimit()

void ClearCore::AdcManager::AdcTimeoutLimit ( uint8_t  timeout)
inline

Configure the ADC conversion timeout.

The ADC will post an error to the StatusReg if it is unable to complete a conversion within the number of samples specified by the input of this function.

// Sets the timeout to 10 samples
void AdcTimeoutLimit(uint8_t timeout)
Configure the ADC conversion timeout.
Definition AdcManager.h:280
Parameters
[in]timeoutThe length of the timeout in samples.

◆ AnalogVoltage()

float ClearCore::AdcManager::AnalogVoltage ( AdcChannels  adcChannel)
inline

Returns the filtered ADC result of a specific channel in volts.

// Save the filtered voltage reading on A-10.
@ ADC_AIN10
Analog input A-10.
Definition AdcManager.h:62
float AnalogVoltage(AdcChannels adcChannel)
Returns the filtered ADC result of a specific channel in volts.
Definition AdcManager.h:312
Parameters
[in]adcChannelADC channel to get the voltage reading of.
Returns
Voltage on the given ADC channel.
Note
For performance reasons, does not perform any bounds checking.

◆ ConvertedResult()

volatile const uint16_t & ClearCore::AdcManager::ConvertedResult ( AdcChannels  adcChannel)
inline

Returns the converted ADC result of a specific channel.

// Save the converted ADC reading of analog input A-10.
volatile const uint16_t & ConvertedResult(AdcChannels adcChannel)
Returns the converted ADC result of a specific channel.
Definition AdcManager.h:204
Parameters
[in]adcChannelADC channel to get the results of.
Returns
Converted result.
Note
For performance reasons, does not perform any bounds checking.

◆ FilteredResult()

volatile const uint16_t & ClearCore::AdcManager::FilteredResult ( AdcChannels  adcChannel)
inline

Returns the filtered ADC result of a specific channel.

// Save the filtered ADC reading of analog input A-10.
volatile const uint16_t & FilteredResult(AdcChannels adcChannel)
Returns the filtered ADC result of a specific channel.
Definition AdcManager.h:187
Parameters
[in]adcChannelADC channel to get the filtered results of.
Returns
Filtered result.
Note
For performance reasons, does not perform any bounds checking.

◆ FilterReset()

bool ClearCore::AdcManager::FilterReset ( AdcChannels  adcChannel,
uint16_t  newSetting 
)
inline

Resets the filter for an ADC Channel.

// Resets the filter for A-10 and saves the success status.
bool FilterReset(AdcChannels adcChannel, uint16_t newSetting)
Resets the filter for an ADC Channel.
Definition AdcManager.h:256
Parameters
[in]adcChannelADC Channel filter to reset.
[in]newSettingThe initial filter value.
Returns
Success.

◆ FilterTc() [1/2]

uint16_t ClearCore::AdcManager::FilterTc ( AdcChannels  adcChannel,
FilterUnits  theUnits 
)

Gets the IIR filter time constant of an ADC channel.

// Save the time constant in ms for A-10.
bool FilterTc(AdcChannels adcChannel, uint16_t tc, FilterUnits theUnits)
Sets the IIR filter time constant for an ADC channel.
@ FILTER_UNIT_MS
Definition AdcManager.h:79
Parameters
[in]adcChannelADC channel to get filter constant for.
[in]theUnitsThe units of the returned time constant. See FilterUnits.
Returns
Time constant value in the specified units, or 0 if the ADC channel is invalid.

◆ FilterTc() [2/2]

bool ClearCore::AdcManager::FilterTc ( AdcChannels  adcChannel,
uint16_t  tc,
FilterUnits  theUnits 
)

Sets the IIR filter time constant for an ADC channel.

// Set the filter time constant of A-10 to 15ms and save its success
// status.
bool succeeded = AdcMgr.FilterTc(AdcManager::ADC_AIN10, 15,
Parameters
[in]adcChannelADC channel to set filter constant for
[in]tcThe new filter time constant (99% step change time)
[in]theUnitsThe units of the time constant tc. See FilterUnits.
Returns
Success.

Member Data Documentation

◆ ADC_IIR_FILTER_TC_MS

const uint32_t ClearCore::AdcManager::ADC_IIR_FILTER_TC_MS = 2
static

The default ADC filter time constant, in milliseconds.

◆ ADC_RESOLUTION_DEFAULT

const uint8_t ClearCore::AdcManager::ADC_RESOLUTION_DEFAULT = 12
static

The default resolution of the ADC, in bits.

◆ ADC_TIMEOUT_DEFAULT

const uint8_t ClearCore::AdcManager::ADC_TIMEOUT_DEFAULT = 3
static

The default timeout for waiting on an ADC conversion, in samples.


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