Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Stepper_Motor_X27168 by
StepperMotor_X27168 Class Reference
Stepper Motor control class. More...
#include <StepperMotor_X27168.h>
Public Types | |
| enum | Polarity |
Constants for motor rotate control. More... | |
Public Member Functions | |
| StepperMotor_X27168 (PinName A_f, PinName A_r, PinName B_f, PinName B_r) | |
| Create a stepper motor object connected to specified DigitalOut pins. | |
| StepperMotor_X27168 (PinName A_f, PinName A_r, PinName B_f, PinName B_r, int init_step_position) | |
| Create a stepper motor object connected to specified DigitalOut pins starting at specified position. | |
| void | set_speed (float s) |
| Set the motor speed (i.e. | |
| int | get_speed () |
| Get the motor speed (i.e. | |
| void | set_max_position (int p) |
| Set the maximum steps the motor should take (not degrees) | |
| int | get_max_position () |
| Get the motor maximum position (int steps not degress) | |
| int | step (int dir) |
| Turn the motor one step (1/2 Degree) | |
| void | step_position (int pos) |
| Turn the motor to a specific step. | |
| void | angle_position (float angle) |
| Turn the motor to a specific degree angle with a resolution of 0.5 degrees. | |
| void | init () |
| Initialize the motor by rotating CW for full range and CCW for full range. | |
Detailed Description
Stepper Motor control class.
Stepper Motor control library.
Example:
#include "mbed.h" #include "StepperMotor_X27168.h" StepperMotor_X27168 smotor(p25, p26, p23, p22); int main() { smotor.step_position(180); wait(0.5); smotor.step_position(100); wait(0.5); smotor.angle_position(270); wait(0.5); smotor.step_position(0); wait(0.5); }
- Version:
- 1.0 (Oct-19-2015)
This is the driver for Automotive Gauge Stepper Motor X27168
----------------------IMPORTANT-------------------- The API assumes motor is postioned at zero as there is no way to detect or control that in software ---------------------------------------------------
Definition at line 49 of file StepperMotor_X27168.h.
Member Enumeration Documentation
| enum Polarity |
Constants for motor rotate control.
Definition at line 54 of file StepperMotor_X27168.h.
Constructor & Destructor Documentation
| StepperMotor_X27168 | ( | PinName | A_f, |
| PinName | A_r, | ||
| PinName | B_f, | ||
| PinName | B_r | ||
| ) |
Create a stepper motor object connected to specified DigitalOut pins.
- Parameters:
-
A_f DigitalOut pin for Forward Control of H-Brigde Port A (AIN1) A_r DigitalOut pin for Reverse Control of H-Brigde Port A (AIN2) B_f DigitalOut pin for Forward Control of H-Brigde Port B (BIN1) B_r DigitalOut pin for Reverse Control of H-Brigde Port B (BIN2)
Definition at line 3 of file Stepper_Motor_X27168.cpp.
| StepperMotor_X27168 | ( | PinName | A_f, |
| PinName | A_r, | ||
| PinName | B_f, | ||
| PinName | B_r, | ||
| int | init_step_position | ||
| ) |
Create a stepper motor object connected to specified DigitalOut pins starting at specified position.
- Parameters:
-
A_f DigitalOut pin for Forward Control of H-Brigde Port A (AIN1) A_r DigitalOut pin for Reverse Control of H-Brigde Port A (AIN2) B_f DigitalOut pin for Forward Control of H-Brigde Port B (BIN1) B_r DigitalOut pin for Reverse Control of H-Brigde Port B (BIN2) init_step_position Rotate of given initial step position
Definition at line 13 of file Stepper_Motor_X27168.cpp.
Member Function Documentation
| void angle_position | ( | float | angle ) |
Turn the motor to a specific degree angle with a resolution of 0.5 degrees.
- Parameters:
-
angle desired angle (0-(max_positon/2))
Definition at line 96 of file Stepper_Motor_X27168.cpp.
| int get_max_position | ( | ) |
Get the motor maximum position (int steps not degress)
- Returns:
- maximum position
Definition at line 34 of file Stepper_Motor_X27168.cpp.
| int get_speed | ( | ) |
Get the motor speed (i.e.
number of steps per second)
- Returns:
- steps per second
Definition at line 24 of file Stepper_Motor_X27168.cpp.
| void init | ( | ) |
Initialize the motor by rotating CW for full range and CCW for full range.
Definition at line 100 of file Stepper_Motor_X27168.cpp.
| void set_max_position | ( | int | p ) |
Set the maximum steps the motor should take (not degrees)
- Parameters:
-
p maximum_steps :(ignored if parameter is greater than 629, the physical limit of the motor)
Definition at line 28 of file Stepper_Motor_X27168.cpp.
| void set_speed | ( | float | s ) |
Set the motor speed (i.e.
number of steps per second) Motor will malfuntion is speed is faster than the the maximum capability if the motor.
- Parameters:
-
s steps per second : lower number makes the turn slower (default = 1000)
Definition at line 20 of file Stepper_Motor_X27168.cpp.
| int step | ( | int | dir ) |
Turn the motor one step (1/2 Degree)
- Parameters:
-
dir 0 CLOCKWISE/FORWARD 1 ANTI-CLOCKWISE/REVERSE 2 STOP
- Returns:
- current_position of the motor
Definition at line 38 of file Stepper_Motor_X27168.cpp.
| void step_position | ( | int | pos ) |
Turn the motor to a specific step.
- Parameters:
-
pos desired position in steps (0-max_position)
Definition at line 80 of file Stepper_Motor_X27168.cpp.
Generated on Thu Jul 14 2022 23:34:00 by
1.7.2
