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

Detailed Description

ClearCore analog input connector class.

This manages an analog input connector on the ClearCore board. This connector can also be configured as a digital input.

The following connector instances support analog input functionality:

For more detailed information on the ClearCore Connector interface, check out the ClearCore Connector System informational page.

ClearCore analog input connector class. More...

#include <DigitalInAnalogIn.h>

+ Inheritance diagram for ClearCore::DigitalInAnalogIn:
+ Collaboration diagram for ClearCore::DigitalInAnalogIn:

Public Member Functions

virtual ConnectorModes Mode () override
 Get the connector's operational mode.
 
bool Mode (ConnectorModes newMode) override
 Set the connector's operational mode.
 
Connector::ConnectorTypes Type () override
 Get connector type.
 
bool IsWritable () override
 Is this connector able to be written to?
 
bool FilterTc (uint16_t tc, AdcManager::FilterUnits theUnits)
 Set the time constant for the analog input filter.
 
int16_t State () override
 Get the connector's last majority-filtered sampled value.
 
float AnalogVoltage ()
 Returns the analog voltage of the connector in volts.
 
- Public Member Functions inherited from ClearCore::DigitalIn
void FilterLength (uint16_t length, FilterUnits units=FILTER_UNIT_SAMPLES)
 Set the connector's digital transition filter length. The default digital filter length for digital input connectors is 3 samples.
 
uint16_t FilterLength ()
 Get the connector's digital filter length in samples. The default is 3 samples.
 
bool InputRisen ()
 Clear on read accessor for this connector's rising input state.
 
bool InputFallen ()
 Clear on read accessor for this connector's falling input state.
 
bool InterruptHandlerSet (voidFuncPtr callback=nullptr, InputManager::InterruptTrigger trigger=InputManager::InterruptTrigger::RISING, bool enable=true)
 Register the interrupt service routine to be triggered when the given input state condition is met on this connector.
 
void InterruptEnable (bool enable)
 Enable or disable the interrupt on this connector.
 
- Public Member Functions inherited from ClearCore::Connector
void Reinitialize ()
 Reinitialize this connector to the power-up state.
 
int32_t ConnectorIndex ()
 Accessor for the bit index of this connector in the input register.
 
virtual bool State (int16_t newState)=0
 Set the state of a R/W connector.
 
virtual bool IsInHwFault ()=0
 Get whether the connector is in a hardware fault state.
 
uint32_t InputRegMask ()
 Get a bit mask representing this connector.
 

Static Public Attributes

static const uint16_t ANALOG_INPUT_FILTER_TC_MS_DEFAULT = 2
 

Additional Inherited Members

- Public Types inherited from ClearCore::DigitalIn
enum  FilterUnits { FILTER_UNIT_MS , FILTER_UNIT_SAMPLES }
 Units for the digital filter length. More...
 
- Public Types inherited from ClearCore::Connector
enum  ConnectorModes {
  INVALID_NONE , INPUT_ANALOG , INPUT_DIGITAL , OUTPUT_ANALOG ,
  OUTPUT_DIGITAL , OUTPUT_H_BRIDGE , OUTPUT_PWM , OUTPUT_TONE ,
  OUTPUT_WAVE , CPM_MODE_A_DIRECT_B_DIRECT , CPM_MODE_STEP_AND_DIR , CPM_MODE_A_DIRECT_B_PWM ,
  CPM_MODE_A_PWM_B_PWM , TTL , RS232 , SPI ,
  CCIO , USB_CDC
}
 All possible operational modes for a connector. More...
 
enum  ConnectorTypes {
  DIGITAL_IN_TYPE , DIGITAL_IN_OUT_TYPE , SHIFT_REG_TYPE , ANALOG_IN_DIGITAL_IN_TYPE ,
  ANALOG_OUT_DIGITAL_IN_OUT_TYPE , H_BRIDGE_TYPE , CPM_TYPE , SERIAL_TYPE ,
  SERIAL_USB_TYPE , CCIO_DIGITAL_IN_OUT_TYPE
}
 The different types of ClearCore connectors. More...
 

Member Function Documentation

◆ AnalogVoltage()

float ClearCore::DigitalInAnalogIn::AnalogVoltage ( )
inline

Returns the analog voltage of the connector in volts.

// Saves A-9's current sampled analog input reading in volts
float analogReadingV = ConnectorA9.AnalogVoltage();
float AnalogVoltage()
Returns the analog voltage of the connector in volts.
Definition DigitalInAnalogIn.h:186
DigitalInAnalogIn ConnectorA9
A-9 connector instance.
Returns
The filtered analog input voltage in volts

◆ FilterTc()

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

Set the time constant for the analog input filter.

Set the time constant of the analog filter to the given value.

// Set A-9's filter time constant to be 10ms
@ FILTER_UNIT_MS
Definition AdcManager.h:79
bool FilterTc(uint16_t tc, AdcManager::FilterUnits theUnits)
Set the time constant for the analog input filter.
Parameters
[in]tcThe time constant to use for the analog filter.
[in]theUnitsThe units of the time constant tc. See AdcManager::FilterUnits.
Returns
success

◆ IsWritable()

bool ClearCore::DigitalInAnalogIn::IsWritable ( )
inlineoverridevirtual

Is this connector able to be written to?

if (!ConnectorAlias.IsWritable()) {
// This generic connector is not an output
}
Returns
False since this is a read-only connector.

Reimplemented from ClearCore::DigitalIn.

◆ Mode() [1/2]

virtual ConnectorModes ClearCore::DigitalInAnalogIn::Mode ( )
inlineoverridevirtual

Get the connector's operational mode.

// A-9 is currently an analog input.
}
@ INPUT_ANALOG
Definition Connector.h:84
virtual ConnectorModes Mode() override
Get the connector's operational mode.
Definition DigitalInAnalogIn.h:89
Returns
The connector's current operational mode.

Reimplemented from ClearCore::DigitalIn.

Examples
ClearCoreCommandProtocol.cpp, and SerialCommExamples/ClearCoreCommandProtocol/ClearCoreCommandProtocol.cpp.

◆ Mode() [2/2]

bool ClearCore::DigitalInAnalogIn::Mode ( ConnectorModes  newMode)
overridevirtual

Set the connector's operational mode.

Set the connector up in the given mode by setting the control bits appropriately; also reset the analog filter to the current value if setting up for analog mode.

// Set A-9's mode to be an analog input
Parameters
[in]newModeThe new mode to be set. The valid modes for this connector type are:
Returns
Returns false if the mode is invalid or setup fails.

Reimplemented from ClearCore::DigitalIn.

◆ State()

int16_t ClearCore::DigitalInAnalogIn::State ( )
overridevirtual

Get the connector's last majority-filtered sampled value.

In digital input mode, return the last filtered digital input state. When in analog input mode, return the last filtered input value.

// Saves A-9's current sampled analog (or digital) input reading
int16_t analogReading = ConnectorA9.State();
int16_t State() override
Get the connector's last majority-filtered sampled value.
Returns
The latest filtered value.

Reimplemented from ClearCore::DigitalIn.

Examples
AnalogIOExamples/ReadAnalogInput/ReadAnalogInput.cpp, and ReadAnalogInput.cpp.

◆ Type()

Connector::ConnectorTypes ClearCore::DigitalInAnalogIn::Type ( )
inlineoverridevirtual

Get connector type.

if (ConnectorAlias.Type() == Connector::ANALOG_IN_DIGITAL_IN_TYPE) {
// This generic connector variable is a DigitalInAnalogIn connector
}
@ ANALOG_IN_DIGITAL_IN_TYPE
Definition Connector.h:218
Returns
The type of this connector (Analog Input)

Reimplemented from ClearCore::DigitalIn.

Member Data Documentation

◆ ANALOG_INPUT_FILTER_TC_MS_DEFAULT

const uint16_t ClearCore::DigitalInAnalogIn::ANALOG_INPUT_FILTER_TC_MS_DEFAULT = 2
static

Default value for the analog input filter time constant: 2 milliseconds.


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