LAB: Stepper Motor
Date: 2023-09-26
Author/Partner:
Github: repository link
Demo Video: Youtube link
PDF version:
Introduction
In this lab, we will learn how to drive a stepper motor with digital output of GPIOs of MCU. You will use a FSM to design the algorithm for stepper motor control.
You must submit
LAB Report (*.pdf & *.md)
Zip source files(main*.c, ecRCC.h, ecGPIO.h, ecSysTick.c etc...).
Only the source files. Do not submit project files
Requirement
Hardware
MCU
NUCLEO-F411RE
Actuator/Sensor/Others:
3Stepper Motor 28BYJ-48
Motor Driver ULN2003
breadboard
Software
Keil uVision, CMSIS, EC_HAL library
Problem 1: Stepper Motor
Hardware Connection
Read specification sheet of the motor and the motor driver for wiring and min/max input voltage/current.
Stepper Motor Sequence
We will use unipolar stepper motor for this lab
Fill in the blanks of each output data depending on the below sequence.
Full-stepping sequence
Half-stepping sequence
Finite State Machine
Draw a State Table for Full-Step Sequence. Use Moore FSM for this case. If you want, you may use Mealy FSM.
See ‘Programming FSM’ for hints
Full-Stepping Sequence
Half-Stepping Sequence
Problem 2: Firmware Programming
Create HAL library
Download files:
Then, change the library files as ecStepper.h, ecStepper.c
Declare and define the following functions in your library.
You must update your header files located in the directory EC \lib\
.
ecStepper.h
Note that these are blocking stepper controllers. While the stepper is running, the MCU cannot process other polling commands. If you can, modify it to be the non-blocking controller.
You can also create your own functions different from the given instructions.
Procedure
Create a new project under the directory
\repos\EC\LAB\LAB_Stepper_Motor
The project name is “LAB_Stepper_Motor”.
Create a new source file named as “LAB_Stepper_Motor.c”
You MUST write your name on the source file inside the comment section.
Include your updated library in
\repos\EC\lib\
to your project.ecGPIO.h, ecGPIO.c
ecRCC.h, ecRCC.c
ecEXTI.h, ecEXTI.c
ecSysTick.h, ecSysTick.c
ecStepper.h ecStepper.h
Connect the MCU to the motor driver and the stepper motor.
Find out the number of steps required to rotate 1 revolution using Full-steppping.
Then, rotate the stepper motor 10 revolutions with 2 rpm. Measure if the motor rotates one revolution per second.
Repeat the above process in the opposite direction.
Increase and decrease the speed of the motor as fast as it can rotate to find the maximum and minimum speed of the motor.
Apply the half-stepping and repeat the above.
Configuration
Requirement
You have to program the stepping sequence using the state table. You can define the states using structures. Refer to ‘Programming FSM’ for hints.
Discussion
Find out the trapezoid-shape velocity profile for a stepper motor. When is this profile necessary?
Answer discussion questions
How would you change the code more efficiently for micro-stepping control? You don’t have to code this but need to explain your strategy.
Answer discussion questions
Code
Your code goes here: ADD Code LINK such as github
Explain your source code with necessary comments.
Sample Code : Stepper Motor
Results
Experiment images and results
Show experiment images /results
Add demo video link
Reference
Complete list of all references used (github, blog, paper, etc)
Troubleshooting
(Option) You can write Troubleshooting section
Last updated