ClearCore Library
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. More...
 
virtual bool MoveVelocity (int32_t velocity) override
 Issues a velocity move at the specified velocity. More...
 
void HlfbFilterLength (uint16_t samples)
 Sets the filter length in samples. The default is 3 samples. More...
 
Connector::ConnectorTypes Type () override
 Get connector type. More...
 
bool IsWritable () override
 Get R/W status of the connector. More...
 
bool MotorInAState ()
 Accessor for the state of the motor's Input A. More...
 
bool MotorInAState (bool value)
 Function to set the state of the motor's Input A. More...
 
bool MotorInBState ()
 Accessor for the state of the motor's Input B. More...
 
bool MotorInBState (bool value)
 Function to set the value of the motor's Input B. More...
 
bool EnableRequest ()
 Accessor for the enable request state of the motor. More...
 
void EnableRequest (bool value)
 Function to request the motor to enable or disable. More...
 
bool MotorInADuty (uint8_t duty)
 Function to set the duty cycle of a PWM signal being sent to the motor's Input A. More...
 
bool MotorInBDuty (uint8_t duty)
 Function to set the duty cycle of a PWM signal being sent to the motor's Input B. More...
 
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. More...
 
volatile const bool & EnableTriggerPulseActive ()
 Check to see if enable trigger pulses are actively being sent. More...
 
volatile const HlfbStatesHlfbState ()
 Return the latest HLFB state information. More...
 
volatile const float & HlfbPercent ()
 Returns the percent of Peak Torque/Max Speed based on the current HLFB PWM duty cycle. More...
 
void HlfbMode (HlfbModes newMode)
 Sets operational mode of the HLFB to match up with the HLFB configuration of a ClearPath™ motor. More...
 
HlfbModes HlfbMode ()
 Accessor for current HLFB operational mode. More...
 
bool HlfbHasRisen ()
 Clear on read accessor for HLFB rising edge detection. More...
 
bool HlfbHasFallen ()
 Clear on read accessor for HLFB falling edge detection. More...
 
bool HlfbCarrier (HlfbCarrierFrequency freq)
 Set the HLFB carrier frequency signal. More...
 
HlfbCarrierFrequency HlfbCarrier ()
 This motor's HLFB carrier frequency. More...
 
bool IsInHwFault () override
 Check whether the connector is in a hardware fault state. More...
 
volatile const StatusRegMotorStatusReg ()
 Accessor for the current Motor Status Register. More...
 
StatusRegMotor StatusRegRisen ()
 Clear on read accessor for Motor Status Register rising edge detection. More...
 
StatusRegMotor StatusRegFallen ()
 Clear on read accessor for Motor Status Register falling edge detection. More...
 
volatile const AlertRegMotorAlertReg ()
 Accessor for the current Motor Alert Register. More...
 
void ClearAlerts (uint32_t mask=UINT32_MAX)
 Clear the Motor Alert Register. Motion will be prevented if any Alert Register bits are set. More...
 
bool PolarityInvertSDEnable (bool invert)
 Function to invert the default polarity of the enable signal of this motor. More...
 
bool PolarityInvertSDDirection (bool invert)
 Function to invert the default polarity of the direction signal of this motor. More...
 
bool PolarityInvertSDHlfb (bool invert)
 Function to invert the default polarity of the HLFB signal of this motor. More...
 
bool BrakeOutput (ClearCorePins pin)
 Set the associated brake output connector. More...
 
ClearCorePins BrakeOutput ()
 Get the associated brake output connector. More...
 
bool LimitSwitchPos (ClearCorePins pin)
 Set the associated positive limit switch connector. More...
 
ClearCorePins LimitSwitchPos ()
 Get the associated positive limit switch output connector. More...
 
bool LimitSwitchNeg (ClearCorePins pin)
 Set the associated negative limit switch connector. More...
 
ClearCorePins LimitSwitchNeg ()
 Get the associated negative limit switch output connector. More...
 
virtual ConnectorModes Mode () override
 Get the connector's operational mode. More...
 
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. More...
 
uint16_t FilterLength ()
 Get the connector's digital filter length in samples. The default is 3 samples. More...
 
int16_t State () override
 Get the connector's last majority-filtered sampled value. 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...
 
virtual bool State (int16_t newState)=0
 Set the state of a R/W connector. More...
 
uint32_t InputRegMask ()
 Get a bit mask representing this connector. More...
 
- 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. More...
 
volatile const int32_t & PositionRefCommanded ()
 Accessor for the StepGenerator's position reference. More...
 
int32_t VelocityRefCommanded ()
 Accessor for the StepGenerator's momentary velocity. More...
 
void VelMax (uint32_t velMax)
 Sets the maximum velocity for position moves, in step pulses per second. More...
 
void AccelMax (uint32_t accelMax)
 Sets the maximum acceleration in step pulses per second^2. More...
 
void EStopDecelMax (uint32_t decelMax)
 Sets the maximum deceleration for E-stop Deceleration in step pulses per second^2. This is only for MoveStopDecel. More...
 
bool StepsComplete ()
 Function to check if no steps are currently being commanded to the motor. More...
 
bool CruiseVelocityReached ()
 Function to check if the commanded move is at the cruising velocity - Acceleration portion of movement has finished. More...
 

Static Public Attributes

static const int16_t HLFB_DUTY_UNKNOWN = -9999
 

Member Enumeration Documentation

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

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

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 asserted.

MOTOR_MOVING 

The motor is enabled and moving.

Member Function Documentation

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
}
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.

// M-0's brake output is now set to IO-2 and enabled.
}
// 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.
Note
Available with software version 1.1 or greater. See Installation and Update Instructions for information on updating library versions.
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.
}
// M-0's brake output is currently disabled.
}
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.
Note
Available with software version 1.1 or greater. See Installation and Update Instructions for information on updating library versions.
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 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.
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.
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.
}
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.
Note
Available with software version 1.1 or greater. See Installation and Update Instructions for information on updating library versions.
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.
}
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.
Note
Available with software version 1.1 or greater. See Installation and Update Instructions for information on updating library versions.
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();
Returns
The current state of the motor's Enable input
Examples:
EncoderInputExamples/FollowEncoder/FollowEncoder.cpp.
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
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.
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.
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.
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.
}
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.
Note
For use with Step and Direction mode.
Available with software version 1.1 or greater. See Installation and Update Instructions for information on updating library versions.
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.
}
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.
Note
For use with Step and Direction mode.
Available with software version 1.1 or greater. See Installation and Update Instructions for information on updating library versions.
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.
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.
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
Note
Available with software version 1.1 or greater. See Installation and Update Instructions for information on updating library versions.
Examples:
EncoderInputExamples/FollowEncoder/FollowEncoder.cpp.
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;
}
Returns
The HLFB carrier frequency.
Note
Available with software version 1.1 or greater. See Installation and Update Instructions for information on updating library versions.
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)
Note
One sample time is 200 microseconds.
Parameters
[in]samplesThe length of the filter to set in samples
bool ClearCore::MotorDriver::HlfbHasFallen ( )
inline

Clear on read accessor for HLFB falling edge detection.

// M-0 HLFB falling edge detected
}
Returns
True if the HLFB input state has fallen since last poll
bool ClearCore::MotorDriver::HlfbHasRisen ( )
inline

Clear on read accessor for HLFB rising edge detection.

// M-0 HLFB rising edge detected
}
Returns
True if the HLFB input state has risen since last poll
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.
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
Parameters
[in]newModeHLFB mode to switch to
Examples:
EncoderInputExamples/FollowEncoder/FollowEncoder.cpp.
HlfbModes ClearCore::MotorDriver::HlfbMode ( )
inline

Accessor for current HLFB operational mode.

// M-0's HLFB mode is set to static
}
Returns
Current HLFB mode
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();
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().
volatile const HlfbStates& ClearCore::MotorDriver::HlfbState ( )
inline

Return the latest HLFB state information.

// M-0's HLFB is fully asserted
}
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.
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.
Note
For use with ClearPath-MC.
Available with software version 1.1 or greater. See Installation and Update Instructions for information on updating library versions.
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.
}
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.
Note
For use with ClearPath-MC.
Available with software version 1.1 or greater. See Installation and Update Instructions for information on updating library versions.
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.
Note
For use with ClearPath-MC.
Available with software version 1.1 or greater. See Installation and Update Instructions for information on updating library versions.
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.
}
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.
Note
For use with ClearPath-MC.
Available with software version 1.1 or greater. See Installation and Update Instructions for information on updating library versions.
bool ClearCore::MotorDriver::IsInHwFault ( )
inlineoverridevirtual

Check whether the connector is in a hardware fault state.

// M-0 is in a fault state
}
Returns
Connector is in fault

Implements ClearCore::Connector.

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.

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

Set the associated negative limit switch connector.

When the input is deasserted (LED off) on the connector associated with this limit, all motion in the negative direction will be stopped (i.e. use a Normally Closed (NC) switch on this connector).

// M-0's negative limit switch is now set to IO-2 and enabled.
}
// M-0's negative limit switch is now disabled.
}
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.
Note
For use with Step and Direction mode.
Available with software version 1.1 or greater. See Installation and Update Instructions for information on updating library versions.
ClearCorePins ClearCore::MotorDriver::LimitSwitchNeg ( )
inline

Get the associated negative limit switch output connector.

When the input is deasserted (LED off) on the connector associated with this limit, all motion in the negative direction will be stopped (i.e. use a Normally Closed (NC) switch on this connector).

// M-0's negative limit switch is currently set to IO-2 and enabled.
}
// 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.
Note
For use with Step and Direction mode.
Available with software version 1.1 or greater. See Installation and Update Instructions for information on updating library versions.
bool ClearCore::MotorDriver::LimitSwitchPos ( ClearCorePins  pin)

Set the associated positive limit switch connector.

When the input is deasserted (LED off) on the connector associated with this limit, all motion in the positive direction will be stopped (i.e. use a Normally Closed (NC) switch on this connector).

// M-0's positive limit switch is now set to IO-2 and enabled.
}
// M-0's positive limit switch is now disabled.
}
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.
Note
For use with Step and Direction mode.
Available with software version 1.1 or greater. See Installation and Update Instructions for information on updating library versions.
ClearCorePins ClearCore::MotorDriver::LimitSwitchPos ( )
inline

Get the associated positive limit switch output connector.

When the input is deasserted (LED off) on the connector associated with this limit, all motion in the positive direction will be stopped (i.e. use a Normally Closed (NC) switch on this connector).

// M-0's positive limit switch is currently set to IO-2 and enabled.
}
// 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.
Note
For use with Step and Direction mode.
Available with software version 1.1 or greater. See Installation and Update Instructions for information on updating library versions.
virtual ConnectorModes ClearCore::MotorDriver::Mode ( )
inlineoverridevirtual

Get the connector's operational mode.

// M-0 is in A-Direct, B-PWM mode
}
Returns
The connector's current 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.

// Send a max duty cycle on M-0's input A line
Parameters
[in]dutyThe PWM duty cycle
Note
For use with ClearPath-MC.
bool ClearCore::MotorDriver::MotorInAState ( )

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

// M-0's ClearPath motor has its input A raised
}
Returns
The current state of Input A
Note
For use with ClearPath-MC.
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
Note
For use with ClearPath-MC.
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
Parameters
[in]dutyThe PWM duty cycle
Note
For use with ClearPath-MC.
bool ClearCore::MotorDriver::MotorInBState ( )

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

// M-0's ClearPath motor has its input B raised
}
Returns
The current state of Input B
Note
For use with ClearPath-MC.
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
Note
For use with ClearPath-MC.
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);
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
Note
For use with Step and Direction mode.

Reimplemented from ClearCore::StepGenerator.

Examples:
EncoderInputExamples/FollowEncoder/FollowEncoder.cpp.
virtual bool ClearCore::MotorDriver::MoveVelocity ( int32_t  velocity)
overridevirtual

Issues a velocity move at the specified velocity.

// Perform a velocity move
Note
Any existing move will be immediately overwritten with the new velocity.
Parameters
[in]velocityThe velocity of the move in step pulses/second.
Note
For use with Step and Direction mode.

Reimplemented from ClearCore::StepGenerator.

Examples:
EncoderInputExamples/FollowEncoder/FollowEncoder.cpp.
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
}
Note
This inversion function is only usable in Step & Direction mode.
Parameters
[in]invertIf 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.

// M-0's enable signal was successfully inverted
}
Note
This inversion function is only usable in Step & Direction mode.
Parameters
[in]invertIf 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.

// M-0's HLFB signal was successfully inverted
}
Note
This inversion function is only usable in Step & Direction mode.
Parameters
[in]invertIf true, signal inversion will be turned on
volatile const StatusRegMotor& ClearCore::MotorDriver::StatusReg ( )
inline

Accessor for the current Motor Status Register.

// M-0 is currently in motion
}
Examples:
EncoderInputExamples/FollowEncoder/FollowEncoder.cpp.
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 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.
}
Connector::ConnectorTypes ClearCore::MotorDriver::Type ( )
inlineoverridevirtual

Get connector type.

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

Reimplemented from ClearCore::DigitalIn.

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.
Note
For use with Step and Direction mode.
Available with software version 1.1 or greater. See Installation and Update Instructions for information on updating library versions.

Member Data Documentation

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: