Stepper Motor
Description
The redaction of this page is under progress.
Characteristics
Code examples
Software API
-
class MotorStepper : public Motor
Public Static Functions
-
static void attachLimitSwitch(MotorNum_t motor, DigitalInputNum_t din, DigitalInputLogic_t logic = ACTIVE_HIGH)
Attach a limit switch to the specified motor The first limit switch attached will be used for homing. Limit switches will be used for stopping motor when they will be reached.
- Parameters:
motor –
din –
logic –
-
static void detachLimitSwitch(MotorNum_t motor, DigitalInputNum_t din)
Detach a limit switch to the specified motor.
- Parameters:
motor –
din –
-
static void setStepResolution(MotorNum_t motor, MotorStepResolution_t res)
Set the Step Resolution. Default resolution is 1/16 step.
- Parameters:
motor –
res –
-
static void setAcceleration(MotorNum_t motor, float acc)
Set acceleration speed.
- Parameters:
motor –
acc – step/s
-
static void setDeceleration(MotorNum_t motor, float dec)
Set deceleration speed.
- Parameters:
motor –
dec – step/s
-
static void setMaxSpeed(MotorNum_t motor, float speed)
Set max speed.
- Parameters:
motor –
speed – step/s
-
static void setMinSpeed(MotorNum_t motor, float speed)
Set min speed.
- Parameters:
motor –
speed – step/s
-
static void setFullStepSpeed(MotorNum_t motor, float speed)
Set full step speed. Above this speed, the motor will run in full step.
- Parameters:
motor –
speed – step/s
-
static int32_t getPosition(MotorNum_t motor)
Get the current position.
- Parameters:
motor – Motor num
- Returns:
int32_t position in step
-
static float getSpeed(MotorNum_t motor)
Get the current speed.
- Parameters:
motor – Motor num
- Returns:
float speed in step/s
-
static void resetHomePosition(MotorNum_t motor)
Reset home position without perform homing.
- Parameters:
motor –
-
static void stop(MotorNum_t motor, MotorStopMode_t mode = SOFT_HIZ)
Stop the motor.
- Parameters:
motor – Motor num
mode – Mode [SOFT_STOP, HARD_STOP, SOFT_HIZ, HARD_HIZ]
-
static void moveAbsolute(MotorNum_t motor, uint32_t position, bool microStep = false)
Go to position.
- Parameters:
motor –
position – Absolute position
microStep – Default to false. If true, position will be read as microstep position
-
static void moveRelative(MotorNum_t motor, int32_t position, bool microStep = false)
Move.
- Parameters:
motor –
position – Absolute position, can be positive or negative
microStep – Default to false. If true, position will be read as microstep position
-
static void run(MotorNum_t motor, MotorDirection_t direction, float speed)
Stepper Run command.
- Parameters:
motor – [in] Motor num
direction – [in] Movement direction (FORWARD, BACKWARD)
speed – [in] in step/s
- Returns:
None
-
static void wait(MotorNum_t motor)
Wait for motor to finish is action If motor is moving with a ‘run’ command, wait will return as soon as the required speed is reach.
- Parameters:
motor –
-
static void homing(MotorNum_t motor, float speed)
Run task to perform homing. Please set a limit switch before performing a homing. The motor will run in reverse until it reach the limit switch. Then it will move at min speed until it move out of the sensor. The position will be set at the home position.
- Parameters:
motor –
speed –
-
static void attachLimitSwitch(MotorNum_t motor, DigitalInputNum_t din, DigitalInputLogic_t logic = ACTIVE_HIGH)