Overview
For applications that require the operation of a motor, ClearCore offers a suite of options to control up to four motors simultaneously. The MotorManager class handles the configuration of the
physical motor connectors (M-0 through M-3) on the ClearCore board. In code, these motor connectors are represented and controlled by instances of the MotorDriver class (ConnectorM0 through
ConnectorM3).
The MotorDriver class is designed to facilitate and fully exercise all the features of a Teknic ClearPath motor, however generic stepper motor drives may be used as well. For simplicity's sake
this document will assume a ClearPath motor is being used when describing the features of the MotorDriver class.
Wiring and Initialization
- Before beginning to use the ClearCore, set up and connect a ClearPath motor to a host PC. Then, using Teknic's MSP software, configure and tune the ClearPath to the desired specifications. For
more information on these steps refer to the manual for your ClearPath motor found here.
- Connect the ClearPath to one of the ClearCore's motor connectors (M-0, M-1, M-2, or M-3) with an 8-pin Molex Mini-fit control cable.
- Any of the four connectors may be used in any order. For example, M-2 may be used without occupying M-0 and M-1.
- Note the operational mode and the HLFB mode of the ClearPath in MSP.
Motor Manager
The MotorManager class controls the configuration of the actual motor connectors, not the MotorDriver objects associated with the connectors. The manager has APIs for setting the controller mode of
the connectors as well as the clock rate of the connectors.
Motor Input Clocking
- The MotorManager sets the input clock rate for all motor connectors on the ClearCore; connectors' clock rates may not be set individually.
bool MotorInputClocking(MotorClockRates newRate)
Sets the output step rate for the motor step generators.
@ CLOCK_RATE_NORMAL
Definition MotorManager.h:59
MotorManager & MotorMgr
Motor connector manager.
- The clock rates may be set to LOW, NORMAL, or HIGH:
- LOW is 100 kHz
- NORMAL is 500 kHz
- HIGH is 2 MHz
- Note that a HIGH clock rate may induce errors with a ClearPath motor.
- The MotorManager class sets the motor controller mode in pairs. The controller mode may be set on M-0 and M-1, M-2 and M-3, or all 4 connectors at once. Modes may not be set on individual connectors.
@ CPM_MODE_STEP_AND_DIR
Definition Connector.h:126
bool MotorModeSet(MotorPair motorPair, Connector::ConnectorModes newMode)
Sets the operational mode for the specified MotorDriver connectors.
@ MOTOR_M2M3
Definition MotorManager.h:77
- There are four controller modes that correspond to various ClearPath operating modes:
- CPM_MODE_STEP_AND_DIR - For generic stepper motor drives or a ClearPath in Step & Direction mode
- CPM_MODE_A_DIRECT_B_DIRECT - Compatible with ClearPath modes that require direct control of the A and B motor input signals (e.g., Incremental
Distance).
- CPM_MODE_A_DIRECT_B_PWM - Compatible with operational modes where motor input A is controlled by the user directly and motor input B is controlled
with a PWM signal (e.g., Follow Digital Torque).
- CPM_MODE_A_PWM_B_PWM - Compatible with Follow Digital Velocity: Bipolar PWM Command with Variable Torque operational mode where both motor inputs A and
B are controlled with PWM signals.
Motor Driver
The MotorDriver class contains interfaces for controlling and communicating with a motor attached to a ClearCore motor connector. There are APIs provided to manipulate all the input lines of a
ClearPath as well as functions to interact with HLFB. The MotorDriver class also contains functions for motion generation by inheriting from the StepGenerator class. More information on the
MotorDriver's motion generation features may be found on the Step and Direction Control page.
Motor Inputs
- The MotorDriver class provides interfaces for all of ClearPath's motor inputs: A, B, and Enable.
- The status of the motor's enable line may be checked and set by the EnableRequest function.
}
bool EnableRequest()
Accessor for the enable request state of the motor.
Definition MotorDriver.h:544
MotorDriver ConnectorM0
M-0 connector instance.
- For ClearPath modes that require a short off-on pulse of the enable line, such as to trigger a move, use the EnableTriggerPulse function.
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 ...
- ClearPath inputs A and B may be controlled as boolean values using the MotorInAState and MotorInBState functions. The
ClearPath motor inputs may also have a PWM wave sent to them by the ClearCore using the MotorInADuty and MotorInBDuty functions
(when in the correct connector modes).
@ CPM_MODE_A_PWM_B_PWM
Definition Connector.h:140
bool MotorInBDuty(uint8_t duty)
Function to set the duty cycle of a PWM signal being sent to the motor's Input B.
MotorDriver ConnectorM2
M-2 connector instance.
- For generic stepper motor drives that may be controlled by inverted signals all of the MotorDriver's motor input signals may be inverted.
bool PolarityInvertSDEnable(bool invert)
Function to invert the default polarity of the enable signal of this motor.
HLFB
A key feature of ClearPath is the High-Level Feedback (HLFB) that can be output by the ClearPath to report on various motor statuses. For more information on HLFB you may reference the ClearPath
manual for your motor. The manuals may be found here and here for DC- and AC-input ClearPaths, respectively.
- The MotorDriver class contains several functions and configuration options so HLFB can be fully utilized in motor control applications.
- HlfbState may return as ASSERTED, DEASSERTED, or that a PWM signal has been measured.
HLFB_HAS_MEASUREMENT will only be returned when there is an active PWM signal or there has been a PWM since the last read of HlfbState.
}
@ HLFB_HAS_MEASUREMENT
Definition MotorDriver.h:157
volatile const HlfbStates & HlfbState()
Return the latest HLFB state information.
Definition MotorDriver.h:672
- The MotorDriver's HLFB interface can be set to three different modes that correspond to various HLFB modes on your ClearPath motor:
- HLFB_MODE_STATIC - For use with ClearPath HLFB modes that only read as asserted or deasserted, such as ServoOn.
- HLFB_MODE_HAS_PWM - For modes where the HLFB signal may have a 0-100% PWM component, such as Speed Output.
- HLFB_MODE_HAS_BIPOLAR_PWM - For modes where the HLFB signal may have a -100 to 100% PWM component, such as ASG-Position with Measured Torque.