Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views23 pages

Stepper Control

The project report details the control of a stepper motor using Simulink and a microcontroller, focusing on inputting angle, direction, and speed to achieve precise motor control. It includes a comprehensive analysis of the hybrid stepper motor's construction, driving mechanisms, and simulation results, alongside hardware implementation using Arduino and an LCD display. The report also addresses issues of instability at high RPMs and proposes solutions for enhancing motor performance.

Uploaded by

Anika tabassum
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views23 pages

Stepper Control

The project report details the control of a stepper motor using Simulink and a microcontroller, focusing on inputting angle, direction, and speed to achieve precise motor control. It includes a comprehensive analysis of the hybrid stepper motor's construction, driving mechanisms, and simulation results, alongside hardware implementation using Arduino and an LCD display. The report also addresses issues of instability at high RPMs and proposes solutions for enhancing motor performance.

Uploaded by

Anika tabassum
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

BANGLADESH UNIVERSITY OF ENGINEERING AND TECHNOLOGY

Department of Electrical and Electronic Engineering

Course No. : EEE 316 Section : B1


Course Title: Laboratory on Power Electronics Group No. : 01

Project report on
Stepper-motor Control using Simulink and Microcontroller

Submitted By
Md Awsafur Rahman – 1706066 Level: 3 Term:2
Abdul Mukit Majumdar –1706067 Department: EEE
Nabila Tasnim – 1706068 Submission Date: 25-02-22
Joyita Halder – 1706069
Anika Tabassum Zeba- 1706093
Forwarding Letter

Date: 25/02/22

Arik Subhana
Satyaki Banik

Department of EEE
Bangladesh University of Engineering and Technology .

Subject: Submission of Report on “Stepper-motor Control using


Simulink and Microcontroller”

Dear Sir,
We are glad to present a report entitled “Stepper-motor Control using
Simulink and Microcontroller”. We think this report will help the
readers to clarify their concepts of this project as far as possible.
We would take this occasion to express our humble gratitude for the support and
encouragement that you have always so generously extended towards us in
teaching, which encouraged us to attempt this project.
Thank you for your all consideration.

Sincerely,
Md Awsafur Rahman – 1706066
Abdul Mukit Majumdar – 1706067
Nabila Tasnim – 1706068
Joyita Halder – 1706069
Anika Tabassum Zeba- 1706093

2|Page
Table of Contents

Forwarding letter ….. ………………………………………………………….2


Objectives………….…………………………………………………….. ……...4
Introduction …………………………………………………………………………………………………..4
Hybrid stepper motor-construction and principle of operation……………...5
Driving mechanism for stepper motor…………………………………………6
Simulink Model of Hybrid Stepper Motor………………………….8
Inputs taken for controlling the stepper motor……………………..9
Simulink model of Stepper motor control………………………….10
 Full-Bridge MMC……………………………………………………….................… 12
 Angle input……………………………………………………………….13

Calculations…………………………………………………………..15
Simulation Results…………………………………………………...15
Unstability……………………………………………………………19

 Solution of unstability………………………………………………………................20
Hardware implementation ………………………………………….20
Future plan…………………………………………………………...23
Conclusion……………………………………………………………23
Reference……………………………………………………………..23

3|Page
Objective:
• To control a stepper motor with a PWM signal where you input the angle,
direction and speed to the motor controller.
• To control it at a particular angle
• To rotate it at a particular direction
• To obtain a particular speed

Introduction:
Stepper motor is a synchronous brushless electric motor. It is an
electromechanical converter that the converts control pulses applied to
the motor phases during a rotation. These control pulses consist of
discrete angular displacements of equal size, and they represent the steps
of the motor. In a proper operation, the number of produced steps must
be equal with that of the control pulses applied to the motor phases.
Most of SMs are bidirectional, enabling together acceleration,
interruption and fast reversing without steps loss (i.e. higher precision
operation), with the only condition of being controlled by a frequency
lower than the proper operation regime frequency. To extend the SM
operation at speeds higher than the one corresponding to the top
frequency, and acceleration by a gradual increasing of the control pulses
is needed. SM is used especially in those applications where incremental
movement is necessary, applications that use numerical control systems.

In order their transient performance characteristics to be analyzed


Matlab/Simulink is chosen as simulation tool and motor characteristics
are analyzed under different operating regimes: no-load, rated load and
over load. Advantages of stepper motors are low costs, small
dimensions, possibility to transform the pulses from digital into angular
movement-step, number of steps is equal to the number of control
pulses.

4|Page
Hybrid stepper motor-construction and principle of
operation

Fig. 1 Images at hybrid stepper motor

Hybrid stepper motors have magnetic core which is excited by


combination of electrical windings and permanent magnet. Electrical
windings are placed on stator while rotor is made of permanent magnets.
Number of poles at stator are usually eight and each pole has two to six
teethes. Per pair of poles are placed two excitation windings for example
one winding for pole 1,3,5 and 7 and another for pole 2,4,6 and 8,

Fig. 2 Construction of hybrid stepper motor

5|Page
Length of each step can be calculated if number of rotor teethes are
known-p. For hybrid stepper motor length of one seep is calculated
from:

_
Hybrid steeper motor has small steep, typically 1.8° and larger torque
compared to variable-reluctance stepper motor. These two parameters
can have a decisive advantage when there is an application with limited
operating space.

Driving mechanism for stepper motor:

For this project we have used two types of driving mechanism of the
stepper motor.

 Full step mode:


In this mechanism, two phases are energized at the same time. Like
if we energized two phases AA’ first then A’B, BB’,B’A, it will be
called full step drive method. In this case , the rotor will align with
the middle part of the two energized phases. Here is the phase
energized sequence and rotor location for full step drive
mechanism are shown:

6|Page
Fig 3: Sequence of energized phase and rotor movements for full step

 Half step mode:


In this mechanism the wave and full step mechanism are used,
actually this mechanism is the combination of two mechanism.
Here first A is energized the AA’ A’ A’B B BB’
B’ B’A and the rotor will align with the energized phase
and in the middle position of the both energized phase
respectively. The sequence diagram and rotor’s movement is given
below:

Fig 4: Sequence of energized phase and rotor movements for half


step
7|Page
Simulink Model of Hybrid Stepper Motor:

Hybrid stepper motor is operating due to electronically commutated


magnetic field which enables rotor movement. All excitation windings
are placed at stator while motor rotor is constructed of permanent
magnet or soft magnetic material. Hybrid motor simulation model
constructed of three basic blocks: controller, driver and motor.

Simulink model from Simulink demo library is presented in Fig.5 and it


is consisted of two sections: electrical and mechanical [4]. According to
Simulink model motor input parameters are: phase voltage (A+, A-, B+
and B-) and mechanical load –TL.

Fig.5 Simulink model of hybrid stepper motor

Output parameters from motor model are: phase current-Iph,


electromagnetic torque-Te, rotor speed-w and rotor position-theta.
Electrical part or motor control circuit is consisted of three functions
entities: control block, hystersis comparator and MOSFET PWM
converter.

8|Page
Inputs taken for controlling the stepper motor:

We have to control a stepper motor with PWM signal where the input is
the angle ,direction and speed to the motor controller.
First of all the step mode is chosen for whether the motor will drive in
full step or half step mode. Then the speed of the motor is provided by
the user from which the frequency is calculated for the input step
sequence by which the motor will be drive .The formula that is used for
calculating frequency from the speed is :

Frequency= (6xRPM)/1.8; For Full step


Frequency= (6xRPM)/0.9; For Half step

The step mode and the speed is taken as input by the matlab code below:

Matlab code:

clc;
clear all;
close all;

%%inputs
step_mode=1; % 1=full step; 0=half step
RPM = 5 %RPM from 1 to 100
if (step_mode==1)
f = (6*RPM)/1.8
else
f = (6*RPM)/0.9
end

S= 1/f

if (step_mode==1)
%full step mode
in1=[1 0 0 1] %A+
in2=[0 1 1 0] %A-
9|Page
in3=[1 1 0 0] %B+
in4=[0 0 1 1] %B-
else
%half step mode
in1=[1 1 0 0 0 0 0 1]; %A+
in3=[0 1 1 1 0 0 0 0]; %B+
in2=[0 0 0 1 1 1 0 0]; %A-
in4=[0 0 0 0 0 1 1 1]; %B-
end

Here the inp1,inp2,inp3 and inp4 are step input according to the energy
sequence for a particular mode .

Simulink model of Stepper motor control:

This is the full Simulink model that has been built for controlling the
stepper motor.

Fig 6: Simulink model of Stepper motor control

10 | P a g e
Motor movement is controlled by two signals: STEP inputs and
Direction inputs. Step inputs are taken by the matlab code and in the
Simulink block it is provided by the repeating sequence stair . The block
is shown below:

Fig7: Repeating Sequence stair block parameter

Here inp1 and Sample time S is taken from the matlab code. For PWM
generation a PWM generator block is used with 540 Hz carrier
frequency and a switching delay if 1e-6 is used so that all the MOSFETs
do not turn on /off at the same time while zero crossing of the step
inputs.

Direction signal controls the direction of motor rotation. Positive value


(value of ‘1’) enables rotation in one direction while value of ‘0’
reverses the direction of rotation.

Fig 8: Direction block input

For this a constant value block is used which provide 0/1 and the
operation will be working accordingly. We have taken A and B two
outputs which will be used for switching direction of the MOSFETs.

11 | P a g e
Here we have used a Special switching device in Simulink.

Full-Bridge MMC:

The Full-Bridge MMC block implements a full-bridge modular


multilevel converter. The converter consists of multiple series-connected
power modules. Each power module consists of one H-bridge and one
capacitor on the DC side.

Fig9: Full bridge block and schematic diagram.

In the Simulink model converter bridges “A’ and “B’ are H bridges
consisted of four MOSFET transistors. Bridges are supplied by 20 V DC
and their outputs supply the motor windings with excitation current and
enable the motor movement.

12 | P a g e
Fig10: Hbridge switching from the direction block

When direction is 1 the A =1 and B=0. The below switches will be turn
on and the motor will be rotate at clockwise direction.

Fig11: Hbridge switching from the direction block when direction is 1

For direction 0 , A=0 and B=1. The opposite operation will be occurred
and the motor will rotate in the opposite direction.

Angle input:
To stop the motor at a particular angle first we have provided a
particular angle as input. We know the motor block gives the output
theta for rotor position. We have implemented a block where the input
13 | P a g e
angle and the motor block’s output angles are compared and the
direction inputs are taken in consideration and make a decision value
which is provided to the Full bridge MMC block’s blocking load input
which stops when it gets a non zero value .

Fig12: The implemented block for stopping the motor at particular angle

Fig13: The implemented block mechanism for stopping the motor at particular
angle
This is the matlab code for the working principle of the implemented
block. This block first check the condition for the directions. Then it
will compare the difference between input angle and output angle of the
motor’s block which is u and will give the output result in y variable.

14 | P a g e
Matlab code:

Calculations:

For Full step mode the outputs were observed at 5 rad/sec RPM and 100
degree step angle. We know, RPM = (step angle)/360*frequency*60
F=(6*RPM)/1.8; for full step
F=(6*RPM)/0.9; for Half step
Formulas for calculating frequencies from RPM

Using the formula for full step the frequency will be


F= 6*5/1.8=16.667Hz
and period is 0.06 sec

When the motor will be stopped can be calculated by the end time.

The end time, T =desired angle/(6*RPM)


Here, T = 3.33 sec

Simulation results:
After all motor parameters are input in motor model simulation is
run.Time for simulation execution in is defined to be 5 seconds. First
simulation is run at no-load operation or motor is running without any
load. For full step mode , 5 rad/sec RPM, direction=1 and at 1000 angle.

15 | P a g e
Fig 14: Output of the PWM generator which are the step inputs

From the angle output of the motor block it can be seen that the motor
has stopped nearly at 1000. The little deviation has occurred because of
the step angle of 1.80 needed to stop the motor fully.

Fig 15: Angle Output of Motor block

16 | P a g e
From the plot it is also can be seen that the ending time is 3.33 sec which
matches the theoretical calculated value.
For the speed output we have also observed the mean value of the speed
at the fundamental frequency f=16.667 Hz . Both the outputs are shown
below:

Fig 16: Speed(RPM(rad/sec)) Output of Motor block

From the plot it can be seen that the period is 0.36-0.3=0.06 sec, which
is matches the calculated value. From the plot , it can be observed that in
every step the motor gives a high amount of speed and then become stale
which is the main characteristics of the stepper motor.
If we plot the mean value we can see it will give a 5 rad/sec RPM

17 | P a g e
Fig 17: Mean value of Speed(RPM(rad/sec)) Output of Motor block

As the mean value is calculated at the fundamental frequency ,there is


some distortion because of other harmonics. The motor gives a high
amount of speed before stopping can also be observed from the graph.

If we change the direction to 0 the observed outputs are given below:

Fig 18: Angle and Speed(RPM(rad/sec)) Output of Motor block

18 | P a g e
Fig 19: Mean value of Speed(RPM(rad/sec)) Output of Motor block

It can be observed that if the direction is changed the angle and speed
gives the negative values.

Unstability:
• Unstability occurs when we run the motor at more than 100 rpm
We have ovserved this at half step mode and at 100 rpm , the
outputs are given below:

Fig 20: Speed(RPM(rad/sec)) Output of Motor block

19 | P a g e
Solution of unstability:
By upgrading the motor ratings like friction constant, Load rating,
linkage flux and coil inductance.

Hardware implementation :

Fig 21: Arduino,LCD,Stepper motor

Here are the hardware components that are used for the project
implementation. Arduino uno has been used for microcontroller as it an
open source controller and easy to use. Also the code has similarity with
c language. A 16x2 LCD display is used to show the outputs. The motor
can be run in two methods, here we have used 4 bit mode. The nema-17
bypolar motor has been used here. It is a 4 wire stepper motor witj step
angle of 1.80. As it is not a unipolar motor it has no center tap
connection

Fig 22: Hardware implementation of the circuit


20 | P a g e
The direction of the motor can be changed by changing its current
direction.

In the above picture the hardware model is shown. The motor driver has
been used to run the nema-17 motor which has two built in half bridge.
We can interface LCD with arduino and a potentiometer is used to adjust
the brightness of the display. Finally a 9 volt battery was used to power
the motor.

Arduino Code:
#include<LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 7, 6, 5, 4);

const int angle = 180, g_direction = 1, rpm = 100; //inputs


const int step_len = angle/1.8; //counting number of steps
const int pulse_width = (1.8/(rpm*6*2))* 1000000; //determining frequncy
required to achieve given rpm

const int dirPin = 2;


const int stepPin = 3;

void setup () {
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
lcd.begin(16, 2);
}

void loop() {

//giving rotation direction


if(g_direction == 1) {
digitalWrite(dirPin, HIGH);
}
else {
digitalWrite(dirPin, LOW);
}

21 | P a g e
//operation until required angle
for(int x = 0; x < step_len; x++) {
digitalWrite(stepPin, HIGH);
delayMicroseconds(pulse_width);
digitalWrite(stepPin, LOW);
delayMicroseconds(pulse_width);
}

//show the result in lcd


lcd.setCursor(0,0);
lcd.print(angle);

lcd.setCursor(5,0);
if(g_direction == 1) {
lcd.print("CW");
}
else {
lcd.print("CCW");
}

lcd.setCursor(3,1);
lcd.print(rpm);

delay(2000);
}

This is the code for LCD display and motor. The angle, direction and
rpm are taken as input. Using the for loop we increased the angle
achieved by each step size until the motor has reached the desired value
and stopped. RPM is proportional to pulse frequency for higher RPM.

22 | P a g e
Future plan:
 Improve the stability of the stepper motor
 Implement different types of stepper motor such as Permanent
Magnet and variable reluctance stepper motor
 Implement different stepping mechanism such as Quarter and
Micro-stepping stepping mechanism.

Conclusion:

 Implemented a system to control stepper motor with a PWM signal


in both hardware and software.
 System can be used to control speed ,direction, angle of the stepper
motor
 Discussed Stability, Maximum stable speed and solution to
improve stability
of the stepper motor.

Reference:
https://drive.google.com/drive/folders/1C8oh0oPdPOX0yBpAYSCUYZ
TTwN96Pmy1?usp=sharing

23 | P a g e

You might also like