ClearCore Library
List of all members | Public Member Functions
ClearCore::DigitalInOutAnalogOut Class Reference

Detailed Description

ClearCore digital input/output with analog current output Connector class.

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

The following connector instances support analog output functionality:

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

ClearCore digital input/output with analog current output Connector class. More...

#include <DigitalInOutAnalogOut.h>

+ Inheritance diagram for ClearCore::DigitalInOutAnalogOut:
+ Collaboration diagram for ClearCore::DigitalInOutAnalogOut:

Public Member Functions

virtual ConnectorModes Mode () override
 Get the connector's operational mode. More...
 
bool Mode (ConnectorModes newMode) override
 Set connector's operational mode. More...
 
Connector::ConnectorTypes Type () override
 Get connector type. More...
 
bool IsWritable () override
 Get R/W status of the connector. More...
 
int16_t State () override
 Get connector's last sampled digital value. More...
 
bool State (int16_t newState) override
 Set the output value of the connector. More...
 
void AnalogWrite (uint16_t value)
 Command the DAC to output a (calibrated) value. More...
 
void OutputCurrent (uint16_t currentuA)
 Command the DAC to output the given number of microamps (uA). More...
 
- Public Member Functions inherited from ClearCore::DigitalInOut
bool IsInHwFault () override
 Get whether the connector is in a hardware fault state. More...
 
void OutputPulsesStart (uint32_t onTime, uint32_t offTime, uint16_t pulseCount=0, bool blockUntilDone=false)
 Start an output pulse. More...
 
void OutputPulsesStop (bool stopImmediately=true)
 Stop an output pulse. More...
 
volatile const bool & OutputPulsesActive ()
 Check the output pulse state. More...
 
bool PwmDuty (uint8_t newDuty)
 Set the PWM duty on the I/O pin. More...
 
- 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. More...
 
uint16_t FilterLength ()
 Get the connector's digital filter length in samples. The default is 3 samples. More...
 
bool InputRisen ()
 Clear on read accessor for this connector's rising input state. More...
 
bool InputFallen ()
 Clear on read accessor for this connector's falling input state. More...
 
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. More...
 
void InterruptEnable (bool enable)
 Enable or disable the interrupt on this connector. More...
 
- Public Member Functions inherited from ClearCore::Connector
void Reinitialize ()
 Reinitialize this connector to the power-up state. More...
 
int32_t ConnectorIndex ()
 Accessor for the bit index of this connector in the input register. More...
 
uint32_t InputRegMask ()
 Get a bit mask representing this connector. More...
 

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

void ClearCore::DigitalInOutAnalogOut::AnalogWrite ( uint16_t  value)

Command the DAC to output a (calibrated) value.

A value of 2047 corresponds to maximum (20 mA) current output, and a value of 0 corresponds to minimum (0 mA) current output.

// Configure IO-0 for analog output
// Output the maximum analog voltage to IO-0
Parameters
[in]valueThe raw 11-bit DAC value to command analog current.
bool ClearCore::DigitalInOutAnalogOut::IsWritable ( )
overridevirtual

Get R/W status of the connector.

// IO-0 is in output mode
}
Returns
False if the connector is read-only.

Reimplemented from ClearCore::DigitalInOut.

virtual ConnectorModes ClearCore::DigitalInOutAnalogOut::Mode ( )
inlineoverridevirtual
bool ClearCore::DigitalInOutAnalogOut::Mode ( ConnectorModes  newMode)
overridevirtual

Set connector's operational mode.

// Set IO-0's mode to be an analog output
Parameters
[in]newModeThe new operational mode to be set. The valid modes for this connector type are:
Returns
True if the mode change was successful.

Reimplemented from ClearCore::DigitalInOut.

void ClearCore::DigitalInOutAnalogOut::OutputCurrent ( uint16_t  currentuA)

Command the DAC to output the given number of microamps (uA).

// Configure IO-0 for analog output
// Output 5000 uA (5 mA) to IO-0's analog output
Parameters
[in]currentuAOutput current command in microamps (uA).
Examples:
AnalogIOExamples/WriteAnalogCurrentOutput/WriteAnalogCurrentOutput.cpp.
int16_t ClearCore::DigitalInOutAnalogOut::State ( )
overridevirtual

Get connector's last sampled digital value.

In digital modes, return the current digital state; in analog output mode, returns 0.

// IO-0's input is currently high
}
Returns
0 when in analog output mode; the current digital state otherwise

Reimplemented from ClearCore::DigitalInOut.

Examples:
AnalogIOExamples/ReadAnalogInput/ReadAnalogInput.cpp, DigitalIOExamples/WriteDigitalOutput/WriteDigitalOutput.cpp, EthernetExamples/EthernetTcpClientHelloWorld/EthernetTcpClientHelloWorld.cpp, and EthernetExamples/EthernetTcpServerHelloWorld_automatic/EthernetTcpServerHelloWorld_automatic.cpp.
bool ClearCore::DigitalInOutAnalogOut::State ( int16_t  newState)
overridevirtual

Set the output value of the connector.

When in digital modes, set the digital output value via DigitalInOut class. When in analog output mode, write the analog value out. Valid analog values are unsigned 11-bit integers, where 0 corresponds to 0 mA (minimum current output) and 2047 corresponds to 20 mA (maximum current output).

// Configure IO-0 for analog output
// Write a (scaled) analog value to IO-0's output
Parameters
[in]newStateThe value to be output

Reimplemented from ClearCore::DigitalInOut.

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

Get connector type.

if (ConnectorAlias.Type() ==
// This generic connector variable is a DigitalInOutAnalogOut
// connector
}
Returns
The type of the current connector.

Reimplemented from ClearCore::DigitalInOut.


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