ClearCore Library
|
ClearCore motor connector class.
This class manages a motor connector on the ClearCore board.
The following connector instances support motor functionality:
For more detailed information on the ClearCore Motor Control and Motion Generation systems, check out the Motor Control System and Step and Direction Control informational pages.
For more detailed information on the ClearCore Connector interface, check out the ClearCore Connector System informational page.
ClearCore motor connector class. More...
#include <MotorDriver.h>
Classes | |
union | AlertRegMotor |
Accumulating register of alerts that have occurred on this motor. Intended for use in Step and Direction mode. More... | |
union | PolarityInversionsSD |
A small register with bit and field views. This allows easy configuration for steppers that use an inverted signal on one of the main input signals. See PolarityInvertSDEnable(bool invert), PolarityInvertSDDirection(bool invert), and PolarityInvertSDHlfb(bool invert). More... | |
union | StatusRegMotor |
Register access for information about the motor's operating status. Intended for use in Step and Direction mode. More... | |
Public Member Functions | |
bool | ValidateMove (bool negDirection) |
virtual bool | Move (int32_t dist, MoveTarget moveTarget=MOVE_TARGET_REL_END_POSN) override |
Issues a positional move for the specified distance. | |
virtual bool | MoveVelocity (int32_t velocity) override |
Issues a velocity move at the specified velocity. | |
void | HlfbFilterLength (uint16_t samples) |
Sets the filter length in samples. The default is 3 samples. | |
Connector::ConnectorTypes | Type () override |
Get connector type. | |
bool | IsWritable () override |
Get R/W status of the connector. | |
bool | MotorInAState () |
Accessor for the state of the motor's Input A. | |
bool | MotorInAState (bool value) |
Function to set the state of the motor's Input A. | |
bool | MotorInBState () |
Accessor for the state of the motor's Input B. | |
bool | MotorInBState (bool value) |
Function to set the value of the motor's Input B. | |
bool | EnableRequest () |
Accessor for the enable request state of the motor. | |
void | EnableRequest (bool value) |
Function to request the motor to enable or disable. | |
bool | MotorInADuty (uint8_t duty) |
Function to set the duty cycle of a PWM signal being sent to the motor's Input A. | |
bool | MotorInBDuty (uint8_t duty) |
Function to set the duty cycle of a PWM signal being sent to the motor's Input B. | |
void | EnableTriggerPulse (uint16_t pulseCount=1, uint32_t time_ms=DEFAULT_TRIGGER_PULSE_WIDTH_MS, bool blockUntilDone=false) |
Sends trigger pulse(s) to a connected ClearPath™ motor by de-asserting the enable signal for time_ms milliseconds. | |
volatile const bool & | EnableTriggerPulseActive () |
Check to see if enable trigger pulses are actively being sent. | |
volatile const HlfbStates & | HlfbState () |
Return the latest HLFB state information. | |
volatile const float & | HlfbPercent () |
Returns the percent of Peak Torque/Max Speed based on the current HLFB PWM duty cycle. | |
void | HlfbMode (HlfbModes newMode) |
Sets operational mode of the HLFB to match up with the HLFB configuration of a ClearPath™ motor. | |
HlfbModes | HlfbMode () |
Accessor for current HLFB operational mode. | |
bool | HlfbHasRisen () |
Clear on read accessor for HLFB rising edge detection. | |
bool | HlfbHasFallen () |
Clear on read accessor for HLFB falling edge detection. | |
bool | HlfbCarrier (HlfbCarrierFrequency freq) |
Set the HLFB carrier frequency signal. | |
HlfbCarrierFrequency | HlfbCarrier () |
This motor's HLFB carrier frequency. | |
bool | IsInHwFault () override |
Check whether the connector is in a hardware fault state. | |
volatile const StatusRegMotor & | StatusReg () |
Accessor for the current Motor Status Register. | |
StatusRegMotor | StatusRegRisen () |
Clear on read accessor for Motor Status Register rising edge detection. | |
StatusRegMotor | StatusRegFallen () |
Clear on read accessor for Motor Status Register falling edge detection. | |
volatile const AlertRegMotor & | AlertReg () |
Accessor for the current Motor Alert Register. | |
void | ClearAlerts (uint32_t mask=UINT32_MAX) |
Clear the Motor Alert Register. Motion will be prevented if any Alert Register bits are set. | |
bool | PolarityInvertSDEnable (bool invert) |
Function to invert the default polarity of the enable signal of this motor. | |
bool | PolarityInvertSDDirection (bool invert) |
Function to invert the default polarity of the direction signal of this motor. | |
bool | PolarityInvertSDHlfb (bool invert) |
Function to invert the default polarity of the HLFB signal of this motor. | |
bool | BrakeOutput (ClearCorePins pin) |
Set the associated brake output connector. | |
ClearCorePins | BrakeOutput () |
Get the associated brake output connector. | |
bool | LimitSwitchPos (ClearCorePins pin) |
Set the associated positive limit switch connector. | |
ClearCorePins | LimitSwitchPos () |
Get the associated positive limit switch output connector. | |
bool | LimitSwitchNeg (ClearCorePins pin) |
Set the associated negative limit switch connector. | |
ClearCorePins | LimitSwitchNeg () |
Get the associated negative limit switch output connector. | |
virtual ConnectorModes | Mode () override |
Get the connector's operational mode. | |
bool | EnableConnector (ClearCorePins pin) |
ClearCorePins | EnableConnector () |
bool | InputAConnector (ClearCorePins pin) |
ClearCorePins | InputAConnector () |
bool | InputBConnector (ClearCorePins pin) |
ClearCorePins | InputBConnector () |
bool | EStopConnector (ClearCorePins pin) |
ClearCorePins | EStopConnector () |
bool | HlfbInputStatus () |
void | EnableActiveLevel (bool activeLevel) |
bool | EnableActiveLevel () |
void | HlfbActiveLevel (bool activeLevel) |
bool | HlfbActiveLevel () |
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. | |
int16_t | State () override |
Get the connector's last majority-filtered sampled value. | |
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. | |
uint32_t | InputRegMask () |
Get a bit mask representing this connector. | |
Public Member Functions inherited from ClearCore::StepGenerator | |
void | MoveStopAbrupt () |
void | MoveStopDecel (uint32_t decelMax=0) |
void | PositionRefSet (int32_t posn) |
Sets the absolute commanded position to the given value. | |
volatile const int32_t & | PositionRefCommanded () |
Accessor for the StepGenerator's position reference. | |
int32_t | VelocityRefCommanded () |
Accessor for the StepGenerator's momentary velocity. | |
void | VelMax (uint32_t velMax) |
Sets the maximum velocity for position moves, in step pulses per second. | |
void | AccelMax (uint32_t accelMax) |
Sets the maximum acceleration in step pulses per second^2. | |
void | EStopDecelMax (uint32_t decelMax) |
Sets the maximum deceleration for E-stop Deceleration in step pulses per second^2. This is only for MoveStopDecel. | |
bool | StepsComplete () |
Function to check if no steps are currently being commanded to the motor. | |
bool | CruiseVelocityReached () |
Function to check if the commanded move is at the cruising velocity - Acceleration portion of movement has finished. | |
Static Public Attributes | |
static const int16_t | HLFB_DUTY_UNKNOWN = -9999 |
Setup the HLFB query to match the ClearPath™ Motor's HLFB signaling format.
Enumerator | |
---|---|
HLFB_MODE_STATIC | Use the current digital state of the HLFB input.
|
HLFB_MODE_HAS_PWM | The HLFB signal may have a 0-100% PWM component. If HLFB_HAS_MEASUREMENT occurred since the last query, invoke the HlfbPercent() function to get the last period measured.
|
HLFB_MODE_HAS_BIPOLAR_PWM | The HLFB signal may have a -100% to +100% PWM component. If HLFB_HAS_MEASUREMENT occurred since the last query, invoke the HlfbPercent() function to get the last period measured.
|
Return state when HLFB state is requested.
Enumerator | |
---|---|
HLFB_DEASSERTED | HLFB is de-asserted. |
HLFB_ASSERTED | HLFB is asserted. |
HLFB_HAS_MEASUREMENT | For HLFB with PWM modes, this would signal that the HlfbPercent function has a new update. |
HLFB_UNKNOWN | Unknown state |
Motor readiness states.
|
inline |
Accessor for the current Motor Alert Register.
|
inline |
Get the associated brake output connector.
Brake output mode uses HLFB readings from a connected ClearPath motor to energize or de-energize a connected brake. HLFB must be configured for either "ASG with Measured Torque" or "Servo On" for the automatic brake to function correctly. The motor connectors M-0 through M-3 can be mapped to any of the ClearCore outputs IO-0 through IO-5, or to any attached CCIO-8 output pin.
bool ClearCore::MotorDriver::BrakeOutput | ( | ClearCorePins | pin | ) |
Set the associated brake output connector.
Brake output mode uses HLFB readings from a connected ClearPath motor to energize or de-energize a connected brake. HLFB must be configured for either "ASG with Measured Torque" or "Servo On" for the automatic brake to function correctly. The motor connectors M-0 through M-3 can be mapped to any of the ClearCore outputs IO-0 through IO-5, or to any attached CCIO-8 output pin.
[in] | pin | The pin representing the connector to use as the brake output for this motor. If CLEARCORE_PIN_INVALID is supplied, brake output is disabled. |
|
inline |
Clear the Motor Alert Register. Motion will be prevented if any Alert Register bits are set.
|
inline |
Get the active level for the Enable signal. The default is active low.
|
inline |
Set the active level for the Enable signal. The default is active low.
[in] | activeLevel | True for active high; false for active low. |
|
inline |
Get the digital input connector used to control the state of the enable signal.
bool ClearCore::MotorDriver::EnableConnector | ( | ClearCorePins | pin | ) |
Set the digital input connector used to control the state of the enable signal.
[in] | pin | The pin representing the digital input connector that will control the state of this motor's enable signal. |
|
inline |
Accessor for the enable request state of the motor.
void ClearCore::MotorDriver::EnableRequest | ( | bool | value | ) |
Function to request the motor to enable or disable.
[in] | value | The boolean state to be passed to the motor's Enable input |
void ClearCore::MotorDriver::EnableTriggerPulse | ( | uint16_t | pulseCount = 1 , |
uint32_t | time_ms = DEFAULT_TRIGGER_PULSE_WIDTH_MS , |
||
bool | blockUntilDone = false |
||
) |
Sends trigger pulse(s) to a connected ClearPath™ motor by de-asserting the enable signal for time_ms milliseconds.
The pulse duration (time_ms) must be within the Trigger Pulse range set in the MSP software. The default trigger pulse will not suffice if not changed within MSP. If the pulse duration is too short, the pulse will be ignored. If the pulse duration is too long, the motor will momentarily disable.
This function can be used with the following ClearPath™ operating modes:
[in] | pulseCount | (optional) The number of times to pulse the enable signal. Default: 1. |
[in] | time_ms | (optional) The amount of time to pull the enable signal low, in milliseconds. Default: DEFAULT_TRIGGER_PULSE_WIDTH_MS. |
[in] | blockUntilDone | (optional) If true, block further code execution until the pulses have finished being sent. Default: false. |
|
inline |
Check to see if enable trigger pulses are actively being sent.
When using the non-blocking option of EnableTriggerPulse, this function allows you to check if the trigger pulse sequence is still being sent.
|
inline |
Get the digital input connector used to control the E-Stop input for this motor.
bool ClearCore::MotorDriver::EStopConnector | ( | ClearCorePins | pin | ) |
Set the digital input connector used as an E-Stop signal.
If motion is commanded in any direction and the configured input is de-asserted, the specified motor will be commanded to decelerate immediatley (at the greater deceleration rate of EStopDecelMax or AccelMax)
Next, the MotionCanceledSensorEStop alert will be set to TRUE. Any alerts will prevent further motion (in any direction) until cleared.
[in] | pin | The pin representing the digital input connector that will act as an E-Stop signal for this motor. |
|
inline |
Get the active level for the HLFB signal. The default is active high.
|
inline |
Set the active level for the HLFB signal. The default is active high.
[in] | activeLevel | True for active high; false for active low. |
|
inline |
This motor's HLFB carrier frequency.
|
inline |
Set the HLFB carrier frequency signal.
|
inline |
Sets the filter length in samples. The default is 3 samples.
Restarts any in progress filtering.
[in] | samples | The length of the filter to set in samples |
|
inline |
Clear on read accessor for HLFB falling edge detection.
|
inline |
Clear on read accessor for HLFB rising edge detection.
|
inline |
Get the HLFB input status.
|
inline |
Accessor for current HLFB operational mode.
|
inline |
Sets operational mode of the HLFB to match up with the HLFB configuration of a ClearPath™ motor.
[in] | newMode | HLFB mode to switch to |
|
inline |
Returns the percent of Peak Torque/Max Speed based on the current HLFB PWM duty cycle.
|
inline |
Return the latest HLFB state information.
|
inline |
Get the digital input connector used to control the state of the Input A signal.
bool ClearCore::MotorDriver::InputAConnector | ( | ClearCorePins | pin | ) |
Set the digital input connector used to control the state of the Input A signal.
[in] | pin | The pin representing the digital input connector that will control the state of this motor's Input A signal. |
|
inline |
Get the digital input connector used to control the state of the Input B signal.
bool ClearCore::MotorDriver::InputBConnector | ( | ClearCorePins | pin | ) |
Set the digital input connector used to control the state of the Input B signal.
[in] | pin | The pin representing the digital input connector that will control the state of this motor's Input B signal. |
|
inlineoverridevirtual |
Check whether the connector is in a hardware fault state.
Implements ClearCore::Connector.
|
inlineoverridevirtual |
Get R/W status of the connector.
Reimplemented from ClearCore::DigitalIn.
|
inline |
Get the associated negative limit switch output connector.
bool ClearCore::MotorDriver::LimitSwitchNeg | ( | ClearCorePins | pin | ) |
Set the associated negative limit switch connector.
If motion is commanded in the negative direction and the configured input is de-asserted, the specified motor will be commanded to decelerate immediatley (at the greater deceleration rate of EStopDecelMax or AccelMax)
Next, the MotionCanceledNegativeLimit alert will be set to TRUE. Any alerts will prevent further motion (in any direction) until cleared.
[in] | pin | The pin representing the connector to use as the negative limit switch for this motor. If CLEARCORE_PIN_INVALID is supplied, the negative limit is disabled. |
|
inline |
Get the associated positive limit switch output connector.
bool ClearCore::MotorDriver::LimitSwitchPos | ( | ClearCorePins | pin | ) |
Set the associated positive limit switch connector.
If motion is commanded in the positive direction and the configured input is de-asserted, the specified motor will be commanded to decelerate immediatley (at the greater deceleration rate of EStopDecelMax or AccelMax)
Next, the MotionCanceledPositiveLimit alert will be set to TRUE. Any alerts will prevent further motion (in any direction) until cleared.
[in] | pin | The pin representing the connector to use as the positive limit switch for this motor. If CLEARCORE_PIN_INVALID is supplied, the positive limit is disabled. |
|
inlineoverridevirtual |
Get the connector's operational mode.
Reimplemented from ClearCore::DigitalIn.
bool ClearCore::MotorDriver::MotorInADuty | ( | uint8_t | duty | ) |
Function to set the duty cycle of a PWM signal being sent to the motor's Input A.
[in] | duty | The PWM duty cycle |
bool ClearCore::MotorDriver::MotorInAState | ( | ) |
Accessor for the state of the motor's Input A.
bool ClearCore::MotorDriver::MotorInAState | ( | bool | value | ) |
Function to set the state of the motor's Input A.
[in] | value | The boolean state to be passed to the input |
bool ClearCore::MotorDriver::MotorInBDuty | ( | uint8_t | duty | ) |
Function to set the duty cycle of a PWM signal being sent to the motor's Input B.
[in] | duty | The PWM duty cycle |
bool ClearCore::MotorDriver::MotorInBState | ( | ) |
Accessor for the state of the motor's Input B.
bool ClearCore::MotorDriver::MotorInBState | ( | bool | value | ) |
Function to set the value of the motor's Input B.
[in] | value | The boolean state to be passed to the input |
|
overridevirtual |
Issues a positional move for the specified distance.
[in] | dist | The distance of the move in step pulses |
[in] | moveTarget | (optional) Specify the type of movement that should be done. Absolute or relative to the end position of the current move. Invalid will result in move relative to the end position. Default: MOVE_TARGET_REL_END_POSN |
Reimplemented from ClearCore::StepGenerator.
|
overridevirtual |
Issues a velocity move at the specified velocity.
[in] | velocity | The velocity of the move in step pulses/second. |
Reimplemented from ClearCore::StepGenerator.
bool ClearCore::MotorDriver::PolarityInvertSDDirection | ( | bool | invert | ) |
Function to invert the default polarity of the direction signal of this motor.
[in] | invert | If true, signal inversion will be turned on |
bool ClearCore::MotorDriver::PolarityInvertSDEnable | ( | bool | invert | ) |
Function to invert the default polarity of the enable signal of this motor.
[in] | invert | If true, signal inversion will be turned on |
bool ClearCore::MotorDriver::PolarityInvertSDHlfb | ( | bool | invert | ) |
Function to invert the default polarity of the HLFB signal of this motor.
[in] | invert | If true, signal inversion will be turned on |
|
inline |
Accessor for the current Motor Status Register.
StatusRegMotor ClearCore::MotorDriver::StatusRegFallen | ( | ) |
Clear on read accessor for Motor Status Register falling edge detection.
StatusRegMotor ClearCore::MotorDriver::StatusRegRisen | ( | ) |
Clear on read accessor for Motor Status Register rising edge detection.
|
inlineoverridevirtual |
Get connector type.
Reimplemented from ClearCore::DigitalIn.
bool ClearCore::MotorDriver::ValidateMove | ( | bool | negDirection | ) |
Verify that the motor is in a good state before sending a move command.
|
static |
Constant returned when HLFB duty cannot be determined.