title |
---|
FlexyStepper |
#include <FlexyStepper.h>
Name | |
---|---|
FlexyStepper() constructor for the stepper class |
|
void | connectToPins(byte stepPinNumber, byte directionPinNumber) connect the stepper object to the IO pins |
void | setStepsPerMillimeter(float motorStepPerMillimeter) set the number of steps the motor has per millimeters |
float | getCurrentPositionInMillimeters() get the current position of the motor in millimeters, this functions is updated while the motor moves |
void | setCurrentPositionInMillimeters(float currentPositionInMillimeters) set the current position of the motor in millimeters, this does not move the motor |
void | setSpeedInMillimetersPerSecond(float speedInMillimetersPerSecond) set the maximum speed, units in millimeters/second, this is the maximum speed reached while accelerating |
void | setAccelerationInMillimetersPerSecondPerSecond(float accelerationInMillimetersPerSecondPerSecond) set the rate of acceleration, units in millimeters/second/second |
bool | moveToHomeInMillimeters(long directionTowardHome, float speedInMillimetersPerSecond, long maxDistanceToMoveInMillimeters, int homeLimitSwitchPin) home the motor by moving until the homing sensor is activated, then set the position to zero, with units in millimeters |
void | moveRelativeInMillimeters(float distanceToMoveInMillimeters) move relative to the current position, units are in millimeters, this function does not return until the move is complete |
void | setTargetPositionRelativeInMillimeters(float distanceToMoveInMillimeters) setup a move relative to the current position, units are in millimeters, no motion occurs until processMove() is called |
void | moveToPositionInMillimeters(float absolutePositionToMoveToInMillimeters) move to the given absolute position, units are in millimeters, this function does not return until the move is complete |
void | setTargetPositionInMillimeters(float absolutePositionToMoveToInMillimeters) setup a move, units are in millimeters, no motion occurs until processMove() is called |
float | getCurrentVelocityInMillimetersPerSecond() Get the current velocity of the motor in millimeters/second. |
void | setStepsPerRevolution(float motorStepPerRevolution) set the number of steps the motor has per revolution |
void | setCurrentPositionInRevolutions(float currentPositionInRevolutions) set the current position of the motor in revolutions, this does not move the motor |
float | getCurrentPositionInRevolutions() get the current position of the motor in revolutions, this functions is updated while the motor moves |
void | setSpeedInRevolutionsPerSecond(float speedInRevolutionsPerSecond) set the maximum speed, units in revolutions/second, this is the maximum speed reached while accelerating |
void | setAccelerationInRevolutionsPerSecondPerSecond(float accelerationInRevolutionsPerSecondPerSecond) set the rate of acceleration, units in revolutions/second/second |
bool | moveToHomeInRevolutions(long directionTowardHome, float speedInRevolutionsPerSecond, long maxDistanceToMoveInRevolutions, int homeLimitSwitchPin) home the motor by moving until the homing sensor is activated, then set the position to zero, with units in revolutions |
void | moveRelativeInRevolutions(float distanceToMoveInRevolutions) move relative to the current position, units are in revolutions, this function does not return until the move is complete |
void | setTargetPositionRelativeInRevolutions(float distanceToMoveInRevolutions) setup a move relative to the current position, units are in revolutions, no motion occurs until processMove() is called |
void | moveToPositionInRevolutions(float absolutePositionToMoveToInRevolutions) move to the given absolute position, units are in revolutions, this function does not return until the move is complete |
void | setTargetPositionInRevolutions(float absolutePositionToMoveToInRevolutions) setup a move, units are in revolutions, no motion occurs until processMove() is called |
float | getCurrentVelocityInRevolutionsPerSecond() Get the current velocity of the motor in revolutions/second. |
void | setCurrentPositionInSteps(long currentPositionInSteps) set the current position of the motor in steps, this does not move the motor |
long | getCurrentPositionInSteps() get the current position of the motor in steps, this functions is updated while the motor moves |
void | setSpeedInStepsPerSecond(float speedInStepsPerSecond) set the maximum speed, units in steps/second, this is the maximum speed reached while accelerating |
void | setAccelerationInStepsPerSecondPerSecond(float accelerationInStepsPerSecondPerSecond) set the rate of acceleration, units in steps/second/second |
bool | moveToHomeInSteps(long directionTowardHome, float speedInStepsPerSecond, long maxDistanceToMoveInSteps, int homeSwitchPin) home the motor by moving until the homing sensor is activated, then set the position to zero with units in steps |
void | moveRelativeInSteps(long distanceToMoveInSteps) move relative to the current position, units are in steps, this function does not return until the move is complete |
void | setTargetPositionRelativeInSteps(long distanceToMoveInSteps) setup a move relative to the current position, units are in steps, no motion occurs until processMove() is called |
void | moveToPositionInSteps(long absolutePositionToMoveToInSteps) move to the given absolute position, units are in steps, this function does not return until the move is complete |
void | setTargetPositionInSteps(long absolutePositionToMoveToInSteps) setup a move, units are in steps, no motion occurs until processMove() is called |
void | setTargetPositionToStop() setup a "Stop" to begin the process of decelerating from the current velocity to zero, decelerating requires calls to processMove() until the move is complete |
bool | motionComplete() check if the motor has competed its move to the target position |
float | getCurrentVelocityInStepsPerSecond() Get the current velocity of the motor in steps/second. |
bool | processMovement(void ) if it is time, move one step |
FlexyStepper()
constructor for the stepper class
void connectToPins(
byte stepPinNumber,
byte directionPinNumber
)
connect the stepper object to the IO pins
Parameters:
- stepPinNumber IO pin number for the Step
- directionPinNumber IO pin number for the direction bit
- enablePinNumber IO pin number for the enable bit (LOW is enabled). set to 0 if enable is not supported
void setStepsPerMillimeter(
float motorStepPerMillimeter
)
set the number of steps the motor has per millimeters
float getCurrentPositionInMillimeters()
get the current position of the motor in millimeters, this functions is updated while the motor moves
Return: a signed motor position in millimeters returned
void setCurrentPositionInMillimeters(
float currentPositionInMillimeters
)
set the current position of the motor in millimeters, this does not move the motor
void setSpeedInMillimetersPerSecond(
float speedInMillimetersPerSecond
)
set the maximum speed, units in millimeters/second, this is the maximum speed reached while accelerating
Parameters:
- speedInMillimetersPerSecond speed to accelerate up to, units in millimeters/second
void setAccelerationInMillimetersPerSecondPerSecond(
float accelerationInMillimetersPerSecondPerSecond
)
set the rate of acceleration, units in millimeters/second/second
Parameters:
- accelerationInMillimetersPerSecondPerSecond accelerationInMillimetersPerSecondPerSecond = rate of acceleration, units in millimeters/second/second
bool moveToHomeInMillimeters(
long directionTowardHome,
float speedInMillimetersPerSecond,
long maxDistanceToMoveInMillimeters,
int homeLimitSwitchPin
)
home the motor by moving until the homing sensor is activated, then set the position to zero, with units in millimeters
Parameters:
- directionTowardHome 1 to move in a positive direction, -1 to move in a negative directions
- speedInMillimetersPerSecond speed to accelerate up to while moving toward home, units in millimeters/second
- maxDistanceToMoveInMillimeters unsigned maximum distance to move toward home before giving up
- homeLimitSwitchPin pin number of the home switch, switch should be configured to go low when at home
Return: true returned if successful, else false
void moveRelativeInMillimeters(
float distanceToMoveInMillimeters
)
move relative to the current position, units are in millimeters, this function does not return until the move is complete
Parameters:
- distanceToMoveInMillimeters signed distance to move relative to the current position in millimeters
void setTargetPositionRelativeInMillimeters(
float distanceToMoveInMillimeters
)
setup a move relative to the current position, units are in millimeters, no motion occurs until processMove() is called
Parameters:
- distanceToMoveInMillimeters signed distance to move relative to the current position in millimeters
void moveToPositionInMillimeters(
float absolutePositionToMoveToInMillimeters
)
move to the given absolute position, units are in millimeters, this function does not return until the move is complete
Parameters:
- absolutePositionToMoveToInMillimeters signed absolute position to move to in units of millimeters
void setTargetPositionInMillimeters(
float absolutePositionToMoveToInMillimeters
)
setup a move, units are in millimeters, no motion occurs until processMove() is called
Parameters:
- absolutePositionToMoveToInMillimeters signed absolute position to move to in units of millimeters
float getCurrentVelocityInMillimetersPerSecond()
Get the current velocity of the motor in millimeters/second.
Return: float velocity speed in steps per second returned, signed
This functions is updated while it accelerates up and down in speed. This is not the desired speed, but the speed the motor should be moving at the time the function is called. This is a signed value and is negative when the motor is moving backwards. Note: This speed will be incorrect if the desired velocity is set faster than this library can generate steps, or if the load on the motor is too great for the amount of torque that it can generate.
void setStepsPerRevolution(
float motorStepPerRevolution
)
set the number of steps the motor has per revolution
Parameters:
- motorStepPerRevolution
void setCurrentPositionInRevolutions(
float currentPositionInRevolutions
)
set the current position of the motor in revolutions, this does not move the motor
float getCurrentPositionInRevolutions()
get the current position of the motor in revolutions, this functions is updated while the motor moves
Parameters:
- currentPositionInRevolutions a signed motor position in revolutions returned
void setSpeedInRevolutionsPerSecond(
float speedInRevolutionsPerSecond
)
set the maximum speed, units in revolutions/second, this is the maximum speed reached while accelerating
Parameters:
- speedInRevolutionsPerSecond speed to accelerate up to, units in revolutions/second
void setAccelerationInRevolutionsPerSecondPerSecond(
float accelerationInRevolutionsPerSecondPerSecond
)
set the rate of acceleration, units in revolutions/second/second
Parameters:
- accelerationInRevolutionsPerSecondPerSecond rate of acceleration, units in revolutions/second/second
bool moveToHomeInRevolutions(
long directionTowardHome,
float speedInRevolutionsPerSecond,
long maxDistanceToMoveInRevolutions,
int homeLimitSwitchPin
)
home the motor by moving until the homing sensor is activated, then set the position to zero, with units in revolutions
Parameters:
- directionTowardHome 1 to move in a positive direction, -1 to move in a negative directions
- speedInRevolutionsPerSecond speed to accelerate up to while moving toward home, units in revolutions/second
- maxDistanceToMoveInRevolutions unsigned maximum distance to move toward home before giving up
- homeLimitSwitchPin pin number of the home switch, switch should be configured to go low when at home
Return: true returned if successful, else false
void moveRelativeInRevolutions(
float distanceToMoveInRevolutions
)
move relative to the current position, units are in revolutions, this function does not return until the move is complete
Parameters:
- distanceToMoveInRevolutions signed distance to move relative to the current position in revolutions
void setTargetPositionRelativeInRevolutions(
float distanceToMoveInRevolutions
)
setup a move relative to the current position, units are in revolutions, no motion occurs until processMove() is called
Parameters:
- distanceToMoveInRevolutions signed distance to move relative to the currentposition in revolutions
void moveToPositionInRevolutions(
float absolutePositionToMoveToInRevolutions
)
move to the given absolute position, units are in revolutions, this function does not return until the move is complete
Parameters:
- absolutePositionToMoveToInRevolutions signed absolute position to move to in units of revolutions
void setTargetPositionInRevolutions(
float absolutePositionToMoveToInRevolutions
)
setup a move, units are in revolutions, no motion occurs until processMove() is called
Parameters:
- absolutePositionToMoveToInRevolutions signed absolute position to move to in units of revolutions
float getCurrentVelocityInRevolutionsPerSecond()
Get the current velocity of the motor in revolutions/second.
Return: velocity speed in steps per second returned, signed
This functions is updated while it accelerates up and down in speed. This is not the desired speed, but the speed the motor should be moving at the time the function is called. This is a signed value and is negative when the motor is moving backwards. Note: This speed will be incorrect if the desired velocity is set faster than this library can generate steps, or if the load on the motor is too great for the amount of torque that it can generate.
void setCurrentPositionInSteps(
long currentPositionInSteps
)
set the current position of the motor in steps, this does not move the motor
Parameters:
- currentPositionInSteps the new position of the motor in steps
Remark: Note: This function should only be called when the motor is stopped
long getCurrentPositionInSteps()
get the current position of the motor in steps, this functions is updated while the motor moves
Return: a signed motor position in steps returned
void setSpeedInStepsPerSecond(
float speedInStepsPerSecond
)
set the maximum speed, units in steps/second, this is the maximum speed reached while accelerating
Parameters:
- speedInStepsPerSecond speed to accelerate up to, units in steps/second
void setAccelerationInStepsPerSecondPerSecond(
float accelerationInStepsPerSecondPerSecond
)
set the rate of acceleration, units in steps/second/second
Parameters:
- accelerationInStepsPerSecondPerSecond rate of acceleration, units in steps/second/second
bool moveToHomeInSteps(
long directionTowardHome,
float speedInStepsPerSecond,
long maxDistanceToMoveInSteps,
int homeSwitchPin
)
home the motor by moving until the homing sensor is activated, then set the position to zero with units in steps
Parameters:
- directionTowardHome 1 to move in a positive direction, -1 to move in a negative directions
- speedInStepsPerSecond speed to accelerate up to while moving toward home, units in steps/second
- maxDistanceToMoveInSteps unsigned maximum distance to move toward home before giving up
- homeSwitchPin pin number of the home switch, switch should be configured to go low when at home
Return: true returned if successful, else false
void moveRelativeInSteps(
long distanceToMoveInSteps
)
move relative to the current position, units are in steps, this function does not return until the move is complete
Parameters:
- distanceToMoveInSteps signed distance to move relative to the current position in steps
void setTargetPositionRelativeInSteps(
long distanceToMoveInSteps
)
setup a move relative to the current position, units are in steps, no motion occurs until processMove() is called
Parameters:
- distanceToMoveInSteps signed distance to move relative to the current positionin steps
void moveToPositionInSteps(
long absolutePositionToMoveToInSteps
)
move to the given absolute position, units are in steps, this function does not return until the move is complete
Parameters:
- absolutePositionToMoveToInSteps signed absolute position to move to in unitsof steps
void setTargetPositionInSteps(
long absolutePositionToMoveToInSteps
)
setup a move, units are in steps, no motion occurs until processMove() is called
Parameters:
- absolutePositionToMoveToInSteps signed absolute position to move to in units of steps
void setTargetPositionToStop()
setup a "Stop" to begin the process of decelerating from the current velocity to zero, decelerating requires calls to processMove() until the move is complete
Remark: Note: This function can be used to stop a motion initiated in units of steps or revolutions
bool motionComplete()
check if the motor has competed its move to the target position
Return: true returned if the stepper is at the target position
float getCurrentVelocityInStepsPerSecond()
Get the current velocity of the motor in steps/second.
Return: velocity speed in steps per second returned, signed
This functions is updated while it accelerates up and down in speed. This is not the desired speed, but the speed the motor should be moving at the time the function is called. This is a signed value and is negative when the motor is moving backwards. Note: This speed will be incorrect if the desired velocity is set faster than this library can generate steps, or if the load on the motor is too great for the amount of torque that it can generate.
bool processMovement(
void
)
if it is time, move one step
Return: true returned if movement complete, false returned not a final target position yet