This document outlines a mini project for students to design software to control a stepper motor. The objectives are to design software that smoothly rotates the motor to specified positions while considering its maximum operating speed. Over two days, students will create programs to move the motor to positions using delays and then interrupts, and investigate how load affects the motor's maximum rotation speed. They will implement a speed profile to move the motor as quickly as possible.
2. Mini Project- Stepper Motor Control
Section 1. Project Introduction
1. Learning Outcomes assessed (as taken from the DMD)
All Learning Outcomes specified in the Definitive Module Documentation are assessed as part of this miniproject. The
specific Learning Outcomes are:
Knowledge and Understanding
Be able to:
• Identify and enhance knowledge gained from other studies in areas relevant to the project topic selected.
Skills and Attributes
Be able to:
• Use relevant measurement instruments to analyse a defined electronic engineering problem relevant to digital
systems or embedded computer systems.
• Synthesise a solution to a defined electronic engineering problem relevant to digital systems or embedded
computer systems.
• Take, and analyse appropriately, test results from that solution.
• Carry out a simple critical evaluation of the results taken.
2. Project Title: Stepper Motor Control
3. Project Objectives: (technical, specific to this project)
Design, develop and test software for an embedded system that will smoothly control the rotation of a stepper motor,
taking into account the physical constraints on the maximum operating speed of the motor.
4. Project Summary: (50 words max)
Each student will be required to design a ‘C’ program can rotate a stepper motor to a number of user-defined positions
as quickly as possible. This will include sensing of the marker pulse, the implementation of an appropriate speed profile
and the use of timer-generated interrupts.
5. Introductory Lecture (2hrs) Content:
• The importance of embedded system design, specifically structure charts and I/O Maps
• The MC68230 PIT board
• Addressing I/O ports
• Bit manipulation and masks
6. Preparation Session (3hrs):
The students will complete a design and programming task to generate specified patterns on the output pins of the
buffered I/O port, controlled by the signals on the input pins. They could, for example, derive and output a parity signal
from the inputs. This session will act primarily as a refresher about:
The programming and development environment for the 68000 system
Debugging (breakpoints, single stepping, watch windows, …)
7. Day 1
Expected Outcomes for the day:
The student will develop a program that will move the stepper motor to a number of positions specified by the facilitator.
The pulses will be generated using delay loops and the program will poll for the marker pulse input. The program should
choose the shortest distance between specified positions.
Assessment criteria: a logical choice of I/O configuration; a methodical design/build/test sequence; well-structured and
legible code including effective breakdown into functions and clear use of #define statements; correct operation of the
programs at each stage.
Key Tasks:
1. Specify an I/O map to show how the stepper motor is to be connected to the input and output ports.
Page 2 of 6
3. Mini Project- Stepper Motor Control
2. Using a structure chart, design a program to generate the appropriate signals to rotate the motor, using delay
loops. Implement and test the program. Perform experiments to choose a reasonable delay length.
3. Modify the design to position the motor at the marker pulse and then to execute a complete revolution, thereby
counting the number of steps per revolution and deriving the angular travel per step.
4. Further modify the design to move the motor to a specified position and then to a sequence of positions
specified by the facilitator, using the shortest distance between positions.
8. Day 2
Expected Outcomes for the day:
The student will build on his or her experience on Day 1 to create an interrupt-driven system that will rotate the motor at
a speed (in r.p.m.) specified on a number of input pins. The student will then investigate the range of speeds at which
the motor can rotate, in the presence of different amounts of inertial load. The student will then be asked to rotate the
motor a given number of times as quickly as possible while maintaining reliable positioning. Ideally the student will
develop the idea of using a speed profile and will implement this.
Assessment criteria; a methodical design/build/test sequence; well-structured and legible code including effective
breakdown into functions and clear use of #define statements; correct implementation of interrupts; correct operation of
the programs at each stage; a well-designed sequence of experiments to determine the best performance of the motor.
Key Tasks:
1. Design, implement, and test a program to control motor revolution speed in terms of Hertz using the delay
function.
2. Determine the maximum speed at which the motor will turn (from a standing start) with and without extra inertial
load.
3. Modify your code so that the motor begins to rotate using the pulse rate, which gradually increases and then
decreases. This is known as implementing a "speed profile".
4. Modify the design to complete a fixed number of revolutions as quickly as possible (using a speed profile).
Demonstrate the performance of the system.
9. Facilitator guidance (key ideas to draw out from students):
Day 1: Need for clear design. Variations in motor positions. Benefits of reusable functions. Limits of open-loop control.
Day 2: Relating processor speed to motor behaviour (e.g. speed). Impact of real-world effects such as inertia. Speed
profiling.
10. Required Resources: Laboratory Facilities and Teaching Support.
Laboratory Resources: LD403
1. PC Workstations with development environment for 68000 Flight boards.
2. Main 68000 development boards, buffered I/O boards, stepper motor boards, detachable discs to attach to
stepper motor dial to vary the inertia.
Teaching Resources:
3. Briefing packs for the preparatory session and both practical days.
Page 3 of 6
4. Mini Project- Stepper Motor Control
Section 2. Tasks for Project Day 1
Write functions to perform each of the tasks listed below. You should demonstrate each task as you complete it. The
code that you submit at the end of the day should include all of these functions.
Initialise the motor by moving it to a standard starting position.
Count the number of steps required for a full rotation of the motor. (Read the result using the debugger.) Perform this
procedure in full-step and half-step mode.
Design, develop and test a diagnostic start-up routine that moves the motor to its starting position, performs enough
steps for a full rotation, and verifies that the motor is back in the starting position. Output a signal to indicate whether the
test was successful.
Move the motor to a position that the user has specified on the input switches.
Move the motor through a sequence of 3 positions (4, 9, 2) that are stored in an array in the program. The motor must
take the shortest route between the specified positions.
Page 4 of 6
5. Mini Project- Stepper Motor Control
Section 3. Tasks for Project Day 2
Perform each of the tasks listed below. You should demonstrate each task as you complete it. The code that you submit
at the end of the day should include all of the changes described below.
Your code includes a "delay loop" to control the rate at which pulses are sent to the motor. Perform experiments to
relate the number of times the loop is executed to the pulse rate (in Hz).
Modify your code to include a variable that represents the desired pulse rate (in Hz). Your code should convert this rate
into an appropriate limit for the delay loop.
Perform experiments to determine the maximum pulse rate that can be used to rotate the wheel.
Attach the extra mass to the wheel.
Repeat step 3 to determine the maximum pulse rate with the extra mass attached.
Modify your code so that the motor begins to rotate using the pulse rate from step 5, and then gradually increases the
pulse rate. This is known as implementing a "speed profile". Experiment to find out the maximum pulse rate that can be
achieved in this way and the maximum rate at which the pulse rate can be increased.
Optional Tasks:
Notice that the motor will overshoot if it is moving at high speed and is stopped suddenly. Modify your code so that the
speed profile includes a gradual increase in speed, followed by a period at constant speed, followed by a gradual
deceleration.
Using your speed profile, make the motor complete exactly 20 revolutions in as short a time as possible.
Page 5 of 6