STM32 library to use the stepper motor drivers
Download Normal Version : StepMotor
-
+ ARM STM32 Series
void Init(GPIO_TypeDef *enGPIO, uint32_t enPIN, GPIO_TypeDef *dirGPIO, uint32_t dirPIN, GPIO_TypeDef *clkGPIO, uint32_t clkPIN, uint16_t numberOfSteps, uint16_t rpm);
void SetSpeed(uint16_t rpm);
void Step(int16_t step);
void Step(int16_t step, StepperRun_T func);
void StepAngle(float ang);
void StepAngle(float ang, StepperRun_T func);
non
-
-
Initializer:
Stepper(GPIO_TypeDef *enGPIO, uint32_t enPIN, GPIO_TypeDef *dirGPIO, uint32_t dirPIN, GPIO_TypeDef *clkGPIO, uint32_t clkPIN, uint16_t numberOfSteps, uint16_t rpm);
-
Parameters:
- enGPIO : 'enable pin' GPIO
- enPIN : enable pin
- dirGPIO : 'direction pin' GPIO
- dirPIN : direction pin
- clkGPIO : 'pulse pin' GPIO
- clkPIN : pulse pin
- numberOfSteps : number of stepper motor steps
- rpm : speed of stepper motor
-
Example:
Stepper myMotor(&GPIOA, GPIO_PIN_0, &GPIOA, GPIO_PIN_1, &GPIOA, GPIO_PIN_2, 400, 30);
-
-
-
Initializer:
Stepper::Init(GPIO_TypeDef *enGPIO, uint32_t enPIN, GPIO_TypeDef *dirGPIO, uint32_t dirPIN, GPIO_TypeDef *clkGPIO, uint32_t clkPIN, uint16_t numberOfSteps, uint16_t rpm);
-
Parameters:
- enGPIO : 'enable pin' GPIO
- enPIN : enable pin
- dirGPIO : 'direction pin' GPIO
- dirPIN : direction pin
- clkGPIO : 'pulse pin' GPIO
- clkPIN : pulse pin
- numberOfSteps : number of stepper motor steps
- rpm : speed of stepper motor
-
Example:
Stepper myMotor; myMotor.Init(&GPIOA, GPIO_PIN_0, &GPIOA, GPIO_PIN_1, &GPIOA, GPIO_PIN_2, 400, 30);
-
myMotor.Step(10);
myMotor.StepAngle(-50);
int main()
{
//Your codes
GPIO_Init(); // Initialize gpio for connect to driver
Stepper myMotor;
myMotor.Init(&GPIOA, GPIO_PIN_0, &GPIOA, GPIO_PIN_1, &GPIOA, GPIO_PIN_2, 400, 30);
while(1)
{
myMotor.StepAngle(60);
HAL_Delay(100);
myMotor.StepAngle(-50);
HAL_Delay(100);
}
}
void stepperEvent(uint16_t currentStep)
{
print(currentStep);
}
int main()
{
//Your codes
GPIO_Init(); // Initialize gpio for connect to driver
Stepper myMotor;
myMotor.Init(&GPIOA, GPIO_PIN_0, &GPIOA, GPIO_PIN_1, &GPIOA, GPIO_PIN_2, 400, 30);
while(1)
{
myMotor.Step(10, stepperEvent);
HAL_Delay(100);
myMotor.StepAngle(-9, stepperEvent);
HAL_Delay(100);
}
}
- Run on STM32 Fx cores