ClearCore Library
Loading...
Searching...
No Matches
Step and Direction Control

Overview

For applications that require motion control of a connected motor ClearCore provides a motion generation class called StepGenerator. StepGenerator is one of the parent classes of MotorDriver.
This allows all motor configuration functions and motion generation functions to be accessed by the same MotorDriver object.

The StepGenerator class is designed to facilitate 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 StepGenerator 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.
  • Using MSP, set the ClearPath's mode to Step and Direction. The StepGenerator will not function correctly if the ClearPath is in another operational mode.
  • Attach the ClearPath to a motor connector, M-0, M-1, M-2, or M-3, on the ClearCore using the blue 8-pin data cable (Teknic P/N CPM-CABLE-CTRL-MM660).
    • 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.
  • Using the ClearCore's MotorManager, set the motor connector into Connector::CPM_MODE_STEP_AND_DIR mode using the MotorManager::MotorModeSet() function. The StepGenerator will not function if the
    connector is in another mode.
    • The MotorModeSet() function sets a pair of motor connectors into the specified mode. Choose the pair that includes the connector you'd like to use. The pairs are M-0/M-1 and M-2/M-3.

Motion Parameters

The StepGenerator generates a move profile using pre-defined motion parameters set by the user. These parameters may be changed "on the fly"; newly commanded moves will immediately interrupt any currently active move. An easy way to check the move's state, provided by StepGenerator, is by polling the StepGenerator::StepsComplete() function. This will return a boolean value representing whether the StepGenerator is outputting steps. Note that depending on your mechanics the motor shaft may still be moving even if the value is false.

Position Reference

Velocity and Acceleration

Motion Commands

The StepGenerator class provides movement functions which can have various behaviors depending on the pre-defined motion parameters and the parameters passed into the functions.

Regardless of which move command is issued, they may both be stopped by calling the StepGenerator::MoveStopAbrupt() function.

Positional Move

  • Generates a triangle movement profile that obeys the set maximum velocity and acceleration limits.
  • The function returns true if the movement can start. The move will be rejected if the commanded position reference would result
    in no motion or if an alert is present in the motor's Alert Register.
  • The StepGenerator::Move() function by default commands a relative move.
    // Move 500 step pulses in the positive direction from the current position reference (ie 1250 -> 1750)
    virtual bool Move(int32_t dist, MoveTarget moveTarget=MOVE_TARGET_REL_END_POSN) override
    Issues a positional move for the specified distance.
  • Setting the moveTarget parameter to MOVE_TARGET_ABSOLUTE will command a move to the (passed-in) absolute position reference.
    // Move the motor from its current position reference to -2500 (ie 850 -> -2500)
    ConnectorM0.Move(-2500, StepGenerator::MOVE_TARGET_ABSOLUTE);

Velocity Move

  • Begins a continuous move at the specified velocity using the pre-defined max acceleration.
  • Calling StepGenerator::MoveVelocity() will overwrite any currently active positional move.
  • The function returns true if the movement can start. The move will be rejected if the commanded position reference would result
    in no motion or if an alert is present in the motor's Alert Register.
    // Move the motor 50000 step pulses
    // This will be rejected
    virtual bool MoveVelocity(int32_t velocity) override
    Issues a velocity move at the specified velocity.
  • Commanding a velocity move during another velocity move will cause the first move to smoothly accelerate/decelerate to the new velocity.
    // Move the motor at 10000 step pulses/second
    // This will ramp up the speed to 15000 step pulses/second.