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

Detailed Description

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>

+ Inheritance diagram for ClearCore::MotorDriver:
+ Collaboration diagram for ClearCore::MotorDriver:

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 Types

enum  HlfbStates { HLFB_DEASSERTED , HLFB_ASSERTED , HLFB_HAS_MEASUREMENT , HLFB_UNKNOWN }
 Return state when HLFB state is requested. More...
 
enum  HlfbModes { HLFB_MODE_STATIC , HLFB_MODE_HAS_PWM , HLFB_MODE_HAS_BIPOLAR_PWM }
 Setup the HLFB query to match the ClearPath™ Motor's HLFB signaling format. More...
 
enum  HlfbCarrierFrequency { HLFB_CARRIER_45_HZ , HLFB_CARRIER_482_HZ }
 High-Level Feedback (HLFB) carrier frequency: 45 Hz or 482 Hz.
 
enum  MotorReadyStates {
  MOTOR_DISABLED = 0 , MOTOR_ENABLING , MOTOR_FAULTED , MOTOR_READY ,
  MOTOR_MOVING
}
 Motor readiness states. More...
 
- 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...
 
- Public Types inherited from ClearCore::StepGenerator
enum  MoveTarget { MOVE_TARGET_ABSOLUTE , MOVE_TARGET_REL_END_POSN }
 

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 HlfbStatesHlfbState ()
 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 StatusRegMotorStatusReg ()
 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 AlertRegMotorAlertReg ()
 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
 

Member Enumeration Documentation

◆ HlfbModes

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.

Note
Applicable ClearPath HLFB modes:
  • Servo On
  • In Range
  • All Systems Go (ASG)
  • ASG - Latched
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.

Note
If there is no more PWM signaling the HlfbState() function will return the digital state until another PWM is signaled.
Applicable ClearPath HLFB modes:
  • Speed Output
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.

Note
If there is no more PWM signaling the HlfbState() function will return the digital state until another PWM is signaled.
Applicable ClearPath HLFB modes:
  • Measured Torque
  • ASG - w/Measured Torque
  • ASG - Latched - w/Measured Torque

◆ HlfbStates

Return state when HLFB state is requested.

See also
HlfbMode for setting operational mode of HLFB to accommodate PWM measurement modes versus static state modes.
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

◆ MotorReadyStates

Motor readiness states.

Note
This is a field in the StatusRegMotor.
Enumerator
MOTOR_DISABLED 

The motor is not enabled.

MOTOR_ENABLING 

The motor is in the process of enabling.

MOTOR_FAULTED 

The motor is enabled and not moving, but HLFB is not asserted.

MOTOR_READY 

The motor is enabled and HLFB is not deasserted (asserted or has PWM).

MOTOR_MOVING 

The motor is enabled and moving.

Member Function Documentation

◆ AlertReg()

volatile const AlertRegMotor & ClearCore::MotorDriver::AlertReg ( )
inline

Accessor for the current Motor Alert Register.

// Motion on M-0 was canceled because the motor was disabled
}
volatile const AlertRegMotor & AlertReg()
Accessor for the current Motor Alert Register.
Definition MotorDriver.h:874
MotorDriver ConnectorM0
M-0 connector instance.
uint16_t MotionCanceledMotorDisabled
Definition MotorDriver.h:383
struct ClearCore::MotorDriver::AlertRegMotor::@3 bit

◆ BrakeOutput() [1/2]

ClearCorePins ClearCore::MotorDriver::BrakeOutput ( )
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.

// M-0's brake output is currently set to IO-2 and enabled.
}
@ CLEARCORE_PIN_IO2
[02] IO-2 ClearCore::DigitalInOut Connector
Definition SysConnectors.h:58
bool BrakeOutput(ClearCorePins pin)
Set the associated brake output connector.
// M-0's brake output is currently disabled.
}
@ CLEARCORE_PIN_INVALID
Invalid connector index.
Definition SysConnectors.h:55
Returns
The pin representing the digital output connector configured to be this motor's brake output, or CLEARCORE_PIN_INVALID if no such connector has been configured.

◆ BrakeOutput() [2/2]

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.

Note
ClearCore will energize (disengage) the brake when the configured motor is enabled AND the HLFB reading of that motor is NOT deasserted.
// First configure IO-2 to be a digital output
ConnectorIO2.Mode(Connector::OUTPUT_DIGITAL); // Arduino: pinMode(IO2, OUTPUT);
// M-0's brake output is now set to IO-2 and enabled.
}
@ OUTPUT_DIGITAL
Definition Connector.h:98
virtual ConnectorModes Mode() override
Get the connector's operational mode.
Definition DigitalInOut.h:85
DigitalInOut ConnectorIO2
IO-2 connector instance.
// M-0's brake output is now disabled.
}
Parameters
[in]pinThe pin representing the connector to use as the brake output for this motor. If CLEARCORE_PIN_INVALID is supplied, brake output is disabled.
Returns
True if the brake output was successfully set and enabled, or successfully disabled; false if a pin other than CLEARCORE_PIN_INVALID was supplied that isn't a valid digital output pin.

◆ ClearAlerts()

void ClearCore::MotorDriver::ClearAlerts ( uint32_t  mask = UINT32_MAX)
inline

Clear the Motor Alert Register. Motion will be prevented if any Alert Register bits are set.

// Clear any alerts that have accumulated for M-0.
void ClearAlerts(uint32_t mask=UINT32_MAX)
Clear the Motor Alert Register. Motion will be prevented if any Alert Register bits are set.
Definition MotorDriver.h:887

◆ EnableActiveLevel() [1/2]

bool ClearCore::MotorDriver::EnableActiveLevel ( )
inline

Get the active level for the Enable signal. The default is active low.

Returns
True if the enable signal is configured to be active high; false if configured to be active low.

◆ EnableActiveLevel() [2/2]

void ClearCore::MotorDriver::EnableActiveLevel ( bool  activeLevel)
inline

Set the active level for the Enable signal. The default is active low.

Parameters
[in]activeLevelTrue for active high; false for active low.

◆ EnableConnector() [1/2]

ClearCorePins ClearCore::MotorDriver::EnableConnector ( )
inline

Get the digital input connector used to control the state of the enable signal.

// Connector DI-8 is currently configured to control the enable
// signal for motor M-0.
}
@ CLEARCORE_PIN_DI8
[08] DI-8 ClearCore::DigitalIn Connector
Definition SysConnectors.h:64
bool EnableConnector(ClearCorePins pin)
Returns
The pin representing the digital input connector configured to control this motor's enable signal, or CLEARCORE_PIN_INVALID if no such connector has been configured.

◆ EnableConnector() [2/2]

bool ClearCore::MotorDriver::EnableConnector ( ClearCorePins  pin)

Set the digital input connector used to control the state of the enable signal.

// Connector DI-6 was successfully configured to control the enable
// signal for motor M-0.
}
@ CLEARCORE_PIN_DI6
[06] DI-6 ClearCore::DigitalIn Connector
Definition SysConnectors.h:62
Parameters
[in]pinThe pin representing the digital input connector that will control the state of this motor's enable signal.
Returns
True if the enable connector was configured successfully.

◆ EnableRequest() [1/2]

bool ClearCore::MotorDriver::EnableRequest ( )
inline

Accessor for the enable request state of the motor.

// Save the state of M-0's enable line
bool enableState = ConnectorM0.EnableRequest();
bool EnableRequest()
Accessor for the enable request state of the motor.
Definition MotorDriver.h:544
Returns
The current state of the motor's Enable input
Examples
EncoderInputExamples/FollowEncoder/FollowEncoder.cpp, and FollowEncoder.cpp.

◆ EnableRequest() [2/2]

void ClearCore::MotorDriver::EnableRequest ( bool  value)

Function to request the motor to enable or disable.

// Send an enable request to M-0's ClearPath motor
Note
Any active step and direction moves on this MotorDriver connector will be terminated if value is false.
Parameters
[in]valueThe boolean state to be passed to the motor's Enable input

◆ EnableTriggerPulse()

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:

  • Move Incremental Distance
  • Pulse Burst Positioning
  • Multiple Sensor Positioning
// Send a single trigger pulse of 25ms on M-0's enable that blocks
// further code execution until the pulse is finished.
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 ...
Note
The time specified by time_ms is checked at the SysTick rate.
If the motor EnableRequest is false when this function is called, the function will return without doing anything.
time_ms specifies both the asserted and de-asserted pulse widths. The total time for sending the pulses is 2 * pulseCount * time_ms.
Parameters
[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.

◆ EnableTriggerPulseActive()

volatile const bool & ClearCore::MotorDriver::EnableTriggerPulseActive ( )
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.

// Begin a train of five pulses on M-0's enable that do not block
// further code execution until the pulse train is finished.
// Perform other processing here that does not have to wait for the
// trigger pulses to be sent...
continue; // Wait for the trigger pulses to be sent
}
// Trigger pulses have all been sent.
// Now it is safe to change inputs, etc.
volatile const bool & EnableTriggerPulseActive()
Check to see if enable trigger pulses are actively being sent.
Definition MotorDriver.h:653

◆ EStopConnector() [1/2]

ClearCorePins ClearCore::MotorDriver::EStopConnector ( )
inline

Get the digital input connector used to control the E-Stop input for this motor.

// Connector DI-6 is currently configured as an E-Stop input for
// motor M-0.
}
bool EStopConnector(ClearCorePins pin)
Returns
The Pin representing the digital input connector configured as an E-Stop input for this motor, or CLEARCORE_PIN_INVALID if no such connector has been configured.
For use with Step and Direction mode.

◆ EStopConnector() [2/2]

bool ClearCore::MotorDriver::EStopConnector ( ClearCorePins  pin)

Set the digital input connector used as an E-Stop signal.

// Connector DI-6 was successfully configured to act as an E-Stop
// input signal for motor M-0.
}
Note
The input configured as an E-Stop must be Normally Closed (NC) to function correctly with this feature.

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.

Attention
To recover from an E-Stop:
  1. Ensure you are not activley commanding any further motion. Any new motion command in any direction will cause the alert to persist or reappear (even commanding 0 velocity or commanding to hold the current position).
  2. Use ClearAlerts() to clear the alerts register. This allows further motion to be commanded.
Parameters
[in]pinThe pin representing the digital input connector that will act as an E-Stop signal for this motor.
Returns
True if the E-Stop connector was configured successfully.
For use with Step and Direction mode.

◆ HlfbActiveLevel() [1/2]

bool ClearCore::MotorDriver::HlfbActiveLevel ( )
inline

Get the active level for the HLFB signal. The default is active high.

Returns
True if the HLFB signal is configured to be active high; false if configured to be active low.

◆ HlfbActiveLevel() [2/2]

void ClearCore::MotorDriver::HlfbActiveLevel ( bool  activeLevel)
inline

Set the active level for the HLFB signal. The default is active high.

Parameters
[in]activeLevelTrue for active high; false for active low.

◆ HlfbCarrier() [1/2]

HlfbCarrierFrequency ClearCore::MotorDriver::HlfbCarrier ( )
inline

This motor's HLFB carrier frequency.

// Do work that depends on the current HLFB carrier frequency
case MotorDriver::HLFB_CARRIER_45_HZ:
// Slow HLFB carrier. Do something.
break;
case MotorDriver::HLFB_CARRIER_482_HZ:
default:
// Fast HLFB carrier. Do something else.
break;
}
bool HlfbCarrier(HlfbCarrierFrequency freq)
Set the HLFB carrier frequency signal.
Definition MotorDriver.h:773
Returns
The HLFB carrier frequency.

◆ HlfbCarrier() [2/2]

bool ClearCore::MotorDriver::HlfbCarrier ( HlfbCarrierFrequency  freq)
inline

Set the HLFB carrier frequency signal.

// Set motor M-0 to use the higher HFLB carrier frequency (482 Hz)
ConnectorM0.HlfbCarrier(MotorDriver::HLFB_CARRIER_482_HZ);
Returns
True if the HLFB carrier frequency was correctly set
Examples
EncoderInputExamples/FollowEncoder/FollowEncoder.cpp, and FollowEncoder.cpp.

◆ HlfbFilterLength()

void ClearCore::MotorDriver::HlfbFilterLength ( uint16_t  samples)
inline

Sets the filter length in samples. The default is 3 samples.

Restarts any in progress filtering.

// Set M-0's HLFB filter to 5 samples (1ms)
void HlfbFilterLength(uint16_t samples)
Sets the filter length in samples. The default is 3 samples.
Definition MotorDriver.h:442
Note
One sample time is 200 microseconds.
Parameters
[in]samplesThe length of the filter to set in samples

◆ HlfbHasFallen()

bool ClearCore::MotorDriver::HlfbHasFallen ( )
inline

Clear on read accessor for HLFB falling edge detection.

// M-0 HLFB falling edge detected
}
bool HlfbHasFallen()
Clear on read accessor for HLFB falling edge detection.
Definition MotorDriver.h:759
Returns
True if the HLFB input state has fallen since last poll

◆ HlfbHasRisen()

bool ClearCore::MotorDriver::HlfbHasRisen ( )
inline

Clear on read accessor for HLFB rising edge detection.

// M-0 HLFB rising edge detected
}
bool HlfbHasRisen()
Clear on read accessor for HLFB rising edge detection.
Definition MotorDriver.h:744
Returns
True if the HLFB input state has risen since last poll

◆ HlfbInputStatus()

bool ClearCore::MotorDriver::HlfbInputStatus ( )
inline

Get the HLFB input status.

Returns
True if the HLFB state is currently asserted or is actively detecting a PWM signal.

◆ HlfbMode() [1/2]

HlfbModes ClearCore::MotorDriver::HlfbMode ( )
inline

Accessor for current HLFB operational mode.

// M-0's HLFB mode is set to static
}
@ HLFB_MODE_STATIC
Definition MotorDriver.h:178
void HlfbMode(HlfbModes newMode)
Sets operational mode of the HLFB to match up with the HLFB configuration of a ClearPathâ„¢ motor.
Definition MotorDriver.h:709
Returns
Current HLFB mode

◆ HlfbMode() [2/2]

void ClearCore::MotorDriver::HlfbMode ( HlfbModes  newMode)
inline

Sets operational mode of the HLFB to match up with the HLFB configuration of a ClearPath™ motor.

// Set M-0's HLFB mode to bipolar PWM
@ HLFB_MODE_HAS_BIPOLAR_PWM
Definition MotorDriver.h:204
Parameters
[in]newModeHLFB mode to switch to
Examples
EncoderInputExamples/FollowEncoder/FollowEncoder.cpp, and FollowEncoder.cpp.

◆ HlfbPercent()

volatile const float & ClearCore::MotorDriver::HlfbPercent ( )
inline

Returns the percent of Peak Torque/Max Speed based on the current HLFB PWM duty cycle.

// Save the current duty cycle of M-0's HLFB
float currentDuty = ConnectorM0.HlfbPercent();
volatile const float & HlfbPercent()
Returns the percent of Peak Torque/Max Speed based on the current HLFB PWM duty cycle.
Definition MotorDriver.h:694
Note
This function is only applicable when the HlfbMode is set to HLFB_MODE_HAS_PWM or HLFB_MODE_HAS_BIPOLAR_PWM.
Returns
Returns HLFB_DUTY_UNKNOWN number if no update has been detected.
Note
The correct HLFB carrier frequency must be set using HlfbCarrier().

◆ HlfbState()

volatile const HlfbStates & ClearCore::MotorDriver::HlfbState ( )
inline

Return the latest HLFB state information.

// M-0's HLFB is fully asserted
}
@ HLFB_ASSERTED
Definition MotorDriver.h:152
volatile const HlfbStates & HlfbState()
Return the latest HLFB state information.
Definition MotorDriver.h:672
Returns
When configured in HLFB_MODE_STATIC mode, this returns the current HLFB state.
For HLFB_MODE_HAS_PWM, the HLFB_ASSERTED or HLFB_DEASSERTED state is returned if no PWM has been detected for 2 milliseconds.
Examples
EncoderInputExamples/FollowEncoder/FollowEncoder.cpp, and FollowEncoder.cpp.

◆ InputAConnector() [1/2]

ClearCorePins ClearCore::MotorDriver::InputAConnector ( )
inline

Get the digital input connector used to control the state of the Input A signal.

// Connector DI-8 is currently configured to control the Input A
// signal for motor M-0.
}
bool InputAConnector(ClearCorePins pin)
Returns
The pin representing the digital input connector configured to control this motor's Input A signal, or CLEARCORE_PIN_INVALID if no such connector has been configured.
For use with ClearPath-MC.

◆ InputAConnector() [2/2]

bool ClearCore::MotorDriver::InputAConnector ( ClearCorePins  pin)

Set the digital input connector used to control the state of the Input A signal.

// Connector DI-6 was successfully configured to control the Input A
// signal for motor M-0.
}
Parameters
[in]pinThe pin representing the digital input connector that will control the state of this motor's Input A signal.
Returns
True if the Input A connector was configured successfully.
For use with ClearPath-MC.

◆ InputBConnector() [1/2]

ClearCorePins ClearCore::MotorDriver::InputBConnector ( )
inline

Get the digital input connector used to control the state of the Input B signal.

// Connector DI-8 is currently configured to control the Input B
// signal for motor M-0.
}
bool InputBConnector(ClearCorePins pin)
Returns
The pin representing the digital input connector configured to control this motor's Input B signal, or CLEARCORE_PIN_INVALID if no such connector has been configured.
For use with ClearPath-MC.

◆ InputBConnector() [2/2]

bool ClearCore::MotorDriver::InputBConnector ( ClearCorePins  pin)

Set the digital input connector used to control the state of the Input B signal.

// Connector DI-6 was successfully configured to control the Input B
// signal for motor M-0.
}
Parameters
[in]pinThe pin representing the digital input connector that will control the state of this motor's Input B signal.
Returns
True if the Input B connector was configured successfully.
For use with ClearPath-MC.

◆ IsInHwFault()

bool ClearCore::MotorDriver::IsInHwFault ( )
inlineoverridevirtual

Check whether the connector is in a hardware fault state.

// M-0 is in a fault state
}
bool IsInHwFault() override
Check whether the connector is in a hardware fault state.
Definition MotorDriver.h:823
Returns
Connector is in fault

Implements ClearCore::Connector.

◆ IsWritable()

bool ClearCore::MotorDriver::IsWritable ( )
inlineoverridevirtual

Get R/W status of the connector.

if (ConnectorAlias.IsWritable()) {
// This generic connector variable is writable
}
Returns
True because the connector is always writable

Reimplemented from ClearCore::DigitalIn.

◆ LimitSwitchNeg() [1/2]

ClearCorePins ClearCore::MotorDriver::LimitSwitchNeg ( )
inline

Get the associated negative limit switch output connector.

// M-0's negative limit switch is currently set to IO-2 and enabled.
}
bool LimitSwitchNeg(ClearCorePins pin)
Set the associated negative limit switch connector.
// M-0's negative limit switch is currently disabled.
}
Returns
The pin representing the digital output connector configured to be this motor's negative limit, or CLEARCORE_PIN_INVALID if no such connector has been configured.
For use with Step and Direction mode.

◆ LimitSwitchNeg() [2/2]

bool ClearCore::MotorDriver::LimitSwitchNeg ( ClearCorePins  pin)

Set the associated negative limit switch connector.

// M-0's negative limit switch is now set to IO-2 and enabled.
}
// M-0's negative limit switch is now disabled.
}
Note
The input configured as a limit switch must be a Normally Closed (NC) switch or NPN/NC sensor to function correctly with this feature.

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.

Attention
To recover from reaching a limit switch:
  1. Ensure you are not activley commanding any further motion. Any new motion command in the same direction as the limit will cause the alert to persist or reappear (even commanding 0 velocity or commanding to hold the current position).
  2. Use ClearAlerts() to clear the alerts register. This allows further motion to be commanded. Ensure this motion is in the opposite direction of this limit switch.
Parameters
[in]pinThe 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.
Returns
True if the negative limit switch was successfully set and enabled, or successfully disabled; false if a pin other than CLEARCORE_PIN_INVALID was supplied that isn't a valid digital input pin.
For use with Step and Direction mode.

◆ LimitSwitchPos() [1/2]

ClearCorePins ClearCore::MotorDriver::LimitSwitchPos ( )
inline

Get the associated positive limit switch output connector.

// M-0's positive limit switch is currently set to IO-2 and enabled.
}
bool LimitSwitchPos(ClearCorePins pin)
Set the associated positive limit switch connector.
// M-0's positive limit switch is currently disabled.
}
Returns
The pin representing the digital output connector configured to be this motor's positive limit, or CLEARCORE_PIN_INVALID if no such connector has been configured.
For use with Step and Direction mode.

◆ LimitSwitchPos() [2/2]

bool ClearCore::MotorDriver::LimitSwitchPos ( ClearCorePins  pin)

Set the associated positive limit switch connector.

// M-0's positive limit switch is now set to IO-2 and enabled.
}
// M-0's positive limit switch is now disabled.
}
Note
The input configured as a limit switch must be a Normally Closed (NC) switch or NPN/NC sensor to function correctly with this feature.

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.

Attention
To recover from reaching a limit switch:
  1. Ensure you are not activley commanding any further motion. Any new motion command in the same direction as the limit will cause the alert to persist or reappear (even commanding 0 velocity or commanding to hold the current position).
  2. Use ClearAlerts() to clear the alerts register. This allows further motion to be commanded. Ensure this motion is in the opposite direction of this limit switch.
Parameters
[in]pinThe 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.
Returns
True if the positive limit switch was successfully set and enabled, or successfully disabled; false if a pin other than CLEARCORE_PIN_INVALID was supplied that isn't a valid digital input pin.
For use with Step and Direction mode.

◆ Mode()

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

Get the connector's operational mode.

// M-0 is in A-Direct, B-PWM mode
}
@ CPM_MODE_A_DIRECT_B_PWM
Definition Connector.h:133
virtual ConnectorModes Mode() override
Get the connector's operational mode.
Definition MotorDriver.h:1153
Returns
The connector's current operational mode.

Reimplemented from ClearCore::DigitalIn.

◆ MotorInADuty()

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.

// Send a max duty cycle on M-0's input A line
bool MotorInADuty(uint8_t duty)
Function to set the duty cycle of a PWM signal being sent to the motor's Input A.
Parameters
[in]dutyThe PWM duty cycle
For use with ClearPath-MC.

◆ MotorInAState() [1/2]

bool ClearCore::MotorDriver::MotorInAState ( )

Accessor for the state of the motor's Input A.

// M-0's ClearPath motor has its input A raised
}
bool MotorInAState()
Accessor for the state of the motor's Input A.
Returns
The current state of Input A
For use with ClearPath-MC.

◆ MotorInAState() [2/2]

bool ClearCore::MotorDriver::MotorInAState ( bool  value)

Function to set the state of the motor's Input A.

// Turn off M-0's ClearPath motor's input A
Parameters
[in]valueThe boolean state to be passed to the input
For use with ClearPath-MC.

◆ MotorInBDuty()

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.

// Send a max duty cycle on M-0's input B line
bool MotorInBDuty(uint8_t duty)
Function to set the duty cycle of a PWM signal being sent to the motor's Input B.
Parameters
[in]dutyThe PWM duty cycle
For use with ClearPath-MC.

◆ MotorInBState() [1/2]

bool ClearCore::MotorDriver::MotorInBState ( )

Accessor for the state of the motor's Input B.

// M-0's ClearPath motor has its input B raised
}
bool MotorInBState()
Accessor for the state of the motor's Input B.
Returns
The current state of Input B
For use with ClearPath-MC.

◆ MotorInBState() [2/2]

bool ClearCore::MotorDriver::MotorInBState ( bool  value)

Function to set the value of the motor's Input B.

// Turn off M-0's ClearPath motor's input B
Parameters
[in]valueThe boolean state to be passed to the input
For use with ClearPath-MC.

◆ Move()

virtual bool ClearCore::MotorDriver::Move ( int32_t  dist,
MoveTarget  moveTarget = MOVE_TARGET_REL_END_POSN 
)
overridevirtual

Issues a positional move for the specified distance.

Note
When making absolute moves, ClearCore tracks the current position based on the zero position at program-start. If there is a move in progress when a new move is issued, the target position will be adjusted according to the moveTarget parameter, the new acceleration and velocity limits will be applied, and the new move is merged seamlessly with the previous motion. If you want to make sure that the previous move fully completes without being merged with a new command, wait for StepsComplete() to return true.
// Interrupt any on-going move and move to the absolute position 5000
ConnectorM0.Move(5000, StepGenerator::MOVE_TARGET_ABSOLUTE);
virtual bool Move(int32_t dist, MoveTarget moveTarget=MOVE_TARGET_REL_END_POSN) override
Issues a positional move for the specified distance.
Parameters
[in]distThe 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
For use with Step and Direction mode.

Reimplemented from ClearCore::StepGenerator.

Examples
EncoderInputExamples/FollowEncoder/FollowEncoder.cpp, and FollowEncoder.cpp.

◆ MoveVelocity()

virtual bool ClearCore::MotorDriver::MoveVelocity ( int32_t  velocity)
overridevirtual

Issues a velocity move at the specified velocity.

// Perform a velocity move
virtual bool MoveVelocity(int32_t velocity) override
Issues a velocity move at the specified velocity.
Note
Any existing move will be immediately overwritten with the new velocity.
Parameters
[in]velocityThe velocity of the move in step pulses/second.
For use with Step and Direction mode.

Reimplemented from ClearCore::StepGenerator.

Examples
EncoderInputExamples/FollowEncoder/FollowEncoder.cpp, and FollowEncoder.cpp.

◆ PolarityInvertSDDirection()

bool ClearCore::MotorDriver::PolarityInvertSDDirection ( bool  invert)

Function to invert the default polarity of the direction signal of this motor.

// M-0's direction signal was successfully inverted
}
bool PolarityInvertSDDirection(bool invert)
Function to invert the default polarity of the direction signal of this motor.
Note
This inversion function is only usable in Step & Direction mode.
Parameters
[in]invertIf true, signal inversion will be turned on

◆ PolarityInvertSDEnable()

bool ClearCore::MotorDriver::PolarityInvertSDEnable ( bool  invert)

Function to invert the default polarity of the enable signal of this motor.

// M-0's enable signal was successfully inverted
}
bool PolarityInvertSDEnable(bool invert)
Function to invert the default polarity of the enable signal of this motor.
Note
This inversion function is only usable in Step & Direction mode.
Parameters
[in]invertIf true, signal inversion will be turned on

◆ PolarityInvertSDHlfb()

bool ClearCore::MotorDriver::PolarityInvertSDHlfb ( bool  invert)

Function to invert the default polarity of the HLFB signal of this motor.

// M-0's HLFB signal was successfully inverted
}
bool PolarityInvertSDHlfb(bool invert)
Function to invert the default polarity of the HLFB signal of this motor.
Note
This inversion function is only usable in Step & Direction mode.
Parameters
[in]invertIf true, signal inversion will be turned on

◆ StatusReg()

volatile const StatusRegMotor & ClearCore::MotorDriver::StatusReg ( )
inline

Accessor for the current Motor Status Register.

// M-0 is currently in motion
}
volatile const StatusRegMotor & StatusReg()
Accessor for the current Motor Status Register.
Definition MotorDriver.h:835
struct ClearCore::MotorDriver::StatusRegMotor::@2 bit
uint32_t StepsActive
Definition MotorDriver.h:269
Examples
EncoderInputExamples/FollowEncoder/FollowEncoder.cpp, and FollowEncoder.cpp.

◆ StatusRegFallen()

StatusRegMotor ClearCore::MotorDriver::StatusRegFallen ( )

Clear on read accessor for Motor Status Register falling edge detection.

// M-0's requested enable state went from "on" to "off" since
// the last status poll.
}
StatusRegMotor StatusRegFallen()
Clear on read accessor for Motor Status Register falling edge detection.
uint32_t Enabled
Definition MotorDriver.h:289

◆ StatusRegRisen()

StatusRegMotor ClearCore::MotorDriver::StatusRegRisen ( )

Clear on read accessor for Motor Status Register rising edge detection.

// M-0's requested enable state went from "off" to "on" since
// the last status poll.
}
StatusRegMotor StatusRegRisen()
Clear on read accessor for Motor Status Register rising edge detection.

◆ Type()

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

Get connector type.

if (ConnectorAlias.Type() == Connector::CPM_TYPE) {
// This generic connector variable is a MotorDriver connector
}
@ CPM_TYPE
Definition Connector.h:264
Returns
The type of the current connector.

Reimplemented from ClearCore::DigitalIn.

◆ ValidateMove()

bool ClearCore::MotorDriver::ValidateMove ( bool  negDirection)

Verify that the motor is in a good state before sending a move command.

Returns
True if the motor is ready for a move command; false if there is a configuration setting or error that would (or should) prevent motion.
For use with Step and Direction mode.

Member Data Documentation

◆ HLFB_DUTY_UNKNOWN

const int16_t ClearCore::MotorDriver::HLFB_DUTY_UNKNOWN = -9999
static

Constant returned when HLFB duty cannot be determined.


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