ClearCore Library
List of all members | Classes | Public Types | Public Member Functions
ClearCore::StepGenerator Class Referenceabstract

Detailed Description

ClearCore Step and Direction generator class.

This class manages the generation and communication of movement profiles for the MotorDriver connectors.

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.

ClearCore Step and Direction generator class. More...

#include <StepGenerator.h>

+ Inheritance diagram for ClearCore::StepGenerator:

Public Types

enum  MoveTarget { MOVE_TARGET_ABSOLUTE, MOVE_TARGET_REL_END_POSN }
 

Public Member Functions

virtual bool Move (int32_t dist, MoveTarget moveTarget=MOVE_TARGET_REL_END_POSN)
 Issues a positional move for the specified distance. More...
 
virtual bool MoveVelocity (int32_t velocity)
 Issues a velocity move at the specified velocity. More...
 
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...
 

Member Function Documentation

void ClearCore::StepGenerator::AccelMax ( uint32_t  accelMax)

Sets the maximum acceleration in step pulses per second^2.

Value will be clipped if out of bounds

// Set the StepGenerator's maximum velocity to 15000 step pulses/sec^2
Parameters
[in]accelMaxThe new acceleration limit
Note
For use with Step and Direction mode.
Examples:
EncoderInputExamples/FollowEncoder/FollowEncoder.cpp.
bool ClearCore::StepGenerator::CruiseVelocityReached ( )
inline

Function to check if the commanded move is at the cruising velocity - Acceleration portion of movement has finished.

// The commanded move is at the cruising velocity
}
Returns
Returns true if there the move is in the cruise state
Note
The motor will still need to decelerate after cruising
For use with Step and Direction mode.
void ClearCore::StepGenerator::EStopDecelMax ( uint32_t  decelMax)

Sets the maximum deceleration for E-stop Deceleration in step pulses per second^2. This is only for MoveStopDecel.

Value will be clipped if out of bounds

// Set the StepGenerator's maximum E-stop deceleration to 15000 step pulses/sec^2
Parameters
[in]decelMaxThe new e-stop deceleration limit
Note
For use with Step and Direction mode.
virtual bool ClearCore::StepGenerator::Move ( int32_t  dist,
MoveTarget  moveTarget = MOVE_TARGET_REL_END_POSN 
)
virtual

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 in ClearCore::MotorDriver.

void ClearCore::StepGenerator::MoveStopAbrupt ( )

Interrupts the current move; the motor may stop abruptly.

// Command an abrupt stop
Note
For use with Step and Direction mode.
void ClearCore::StepGenerator::MoveStopDecel ( uint32_t  decelMax = 0)

Interrupts any current move and commands the motor to stop. The stopping acceleration used will be the higher of either

  • 1) the move's current acceleration rate, or
  • 2) the value of EStopDecelMax.

This function's decelMax parameter can be used to update the EStopDecelMax value used for stopping.

// Ramp to a stop at a decel rate of 100000 pulses/sec^2
Parameters
[in]decelMaxThe new EStop deceleration rate to set instead of the value that was set prior to issuing the move. Passing 0 maintains the EStopDecelMax that was previously set.
Note
For use with Step and Direction mode.
virtual bool ClearCore::StepGenerator::MoveVelocity ( int32_t  velocity)
virtual

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 in ClearCore::MotorDriver.

volatile const int32_t& ClearCore::StepGenerator::PositionRefCommanded ( )
inline

Accessor for the StepGenerator's position reference.

// M-0's position reference is above 5000
}
Returns
Returns the absolute commanded position.
Note
For use with Step and Direction mode.
void ClearCore::StepGenerator::PositionRefSet ( int32_t  posn)
inline

Sets the absolute commanded position to the given value.

// Set the StepGenerator's position reference to -5000
Parameters
[in]posnThe new position to be set.
Note
For use with Step and Direction mode.
bool ClearCore::StepGenerator::StepsComplete ( )
inline

Function to check if no steps are currently being commanded to the motor.

// No more steps are being commanded
}
Returns
Returns true if there is no valid current command.
Note
The motor may still be moving after steps are done being sent.
For use with Step and Direction mode.
void ClearCore::StepGenerator::VelMax ( uint32_t  velMax)

Sets the maximum velocity for position moves, in step pulses per second.

// Set the StepGenerator's maximum velocity to 1200 step pulses/sec
Parameters
[in]velMaxThe new velocity limit
Note
For use with Step and Direction mode.
Examples:
EncoderInputExamples/FollowEncoder/FollowEncoder.cpp.
int32_t ClearCore::StepGenerator::VelocityRefCommanded ( )

Accessor for the StepGenerator's momentary velocity.

// M-0's current velocity is above 1000
}
Returns
Returns the momentary commanded velocity.
Note
For use with Step and Direction mode.

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