Control of Stepper Motor by Microcontroller

Ivan Virgala, Michal Kelemen, Alexander Gmiterko, Tomáš Lipták

Journal of Automation and Control

Control of Stepper Motor by Microcontroller

Ivan Virgala1,, Michal Kelemen1, Alexander Gmiterko1, Tomáš Lipták1

1Department of Mechatronics, Technical University of Košice, Faculty of Mechanical Engineering, Košice, Slovakia


The paper deals with stepper motor control using microcontroller ATmega8-16PU. In the paper are mentioned two ways of control, namely full-step mode and half-step mode control. At first, bipolar stepper motor is introduced. For stepper motor control it has to be used H-bridge as well as amplifier in one module. Next, there is created measuring stand consisting of bipolar stepper motor SY28STH32-0674A with one step angle 1.8° and revolute encoder ISC3004 with 360 CPR. During the experiment were measured angular velocities by I/O measuring card MF624 cooperating with Matlab/Simulink. The results show differences between used two stepping modes of stepper motor.

Cite this article:

  • Ivan Virgala, Michal Kelemen, Alexander Gmiterko, Tomáš Lipták. Control of Stepper Motor by Microcontroller. Journal of Automation and Control. Vol. 3, No. 3, 2015, pp 131-134.
  • Virgala, Ivan, et al. "Control of Stepper Motor by Microcontroller." Journal of Automation and Control 3.3 (2015): 131-134.
  • Virgala, I. , Kelemen, M. , Gmiterko, A. , & Lipták, T. (2015). Control of Stepper Motor by Microcontroller. Journal of Automation and Control, 3(3), 131-134.
  • Virgala, Ivan, Michal Kelemen, Alexander Gmiterko, and Tomáš Lipták. "Control of Stepper Motor by Microcontroller." Journal of Automation and Control 3, no. 3 (2015): 131-134.

Import into BibTeX Import into EndNote Import into RefMan Import into RefWorks

At a glance: Figures

1. Introduction

The main utilization of stepper motor is positioning of stepper motor rotor with required precision. Stepper motor is suitable primarily for tasks where the precision is very important factor. Application areas are computer art (hard disks, printers), tool machines, automobile industry, actuators of industry robots and manipulators etc. For stepper motor control it is necessary control unit, which generates steps of motor. [1]

The stepper motor is special type of synchronous motor. Difference between synchronous and stepper motor is that stepper motor can reaches certain amount of defined positions. The step of motor is reached by suitable activity of control unit. The basic principle of motion is very simple. Electric current flowing through the coil generates magnetic field. This magnetic field pulls opposite pole of rotor magnet, see Fig.1. By suitable generating of pulses to coils, the rotor starts to rotate. [2]

The angular velocity of motor is limited because of transient performance magnetic field. By overshooting of maximum motor speed the motor starts to lose its step. [3]

One of the first advantage of stepper motor is effective positioning. For precise positioning can be determined specific step and motor rotates to required position without encoder. The basic relations of stepper motor are following:


where motor step angle, is number of steps per round, is position, n is number of steps, is angular velocity. The difference of stepper motor in comparison with DC motor is that it doesn´t need encoder, because it operates with open loop, while DC motor operates with closed loop. On the other side, stepper motor positioning is limited to step size of rotor. Disadvantages of stepper motor is for example lower torque in comparison with DC motor [4]. Principle of stepper motor can be seen in the Figure 1.

2. Bipolar Stepper Motor

Bipolar stepper motors are composed of two windings and have four wires. Unlike unipolar motors, bipolar motors have no center taps. The advantage to not having center taps is that current runs through an entire winding at a time instead of just half of the winding [5].

The torque of bipolar stepper motor is proportional to the magnetic field intensity of the stator windings, which is proportional to the number of turns and the current in the winding [6, 7, 8]. The motor torque can be increased by increasing of number of turns or by increasing electric current. [9]

For bipolar control it is necessary to ensure changing of voltage polarity so, that coil current can flow to both directions.

Changing voltage polarity can be reached by H-bridge, see Figure 2. By suitable switching of transistors bases T1, T2, T3 and T4 can stepper motor performs rotational motion. As can be seen on the Figure 2, there are necessary two H-bridges. For our purposes will be used circuit L298N which contains two independent H-bridges as well as amplifier. Amplifier is necessary because of microcontroller´s pins can produce electric current roughly 20 - 40 mA. L298 receives control signals from the system’s controller, usually a microcomputer chip, and provides all the necessary drive signals for the power stage. Additionally, it includes two PWM chopper circuits to regulate the current in the motor windings.

3. Control of Stepper Motor

The usual ways of stepper motor control are wave mode, full-step mode, half-step mode and micro-step mode. Ideally stepper motor is controlled by sinusoidal current. Using full-step mode the motor can exhibit vibration, which are in some applications very ineligible. On the other hand, using full-step mode motor can reach higher torque. It depends on particular application what is more important point.

Very frequently used method for stepper motor control are just full-step and half-step mode. This way of control is very simply and easy to realizable by any control unit. However, the problems arise in area of resonant zone and motor can lost step. One way how can be this problem solved is to distribute motor step into micro-steps. This method causes better precise in positioning as well as it limits angular velocity pulsation of rotor in the zone of low step frequencies.

Full-step mode and half-step mode are in the Figure 3 shown.

Thick lines in the Figure 3 denote difference in voltage polarity. By considering Figure 2 and Figure 3, the stepper motor control is following: the signal above the thick line (Figure 3) represents switching of transistor bases T1 and T4 while T2 and T3 are grounded (Figure 2). When the signal falls below thick line (Figure 3) the transistor bases T2 and T3 are switched on, while T1 and T3 are grounded.

In the Figure 4 and Figure 5 the full step and half-step mode are shown with clockwise rotation.

4. Experiment and Results

The aim of the experiment is to compare full-step mode and half-step mode of stepper motor control. For experiment is used bipolar stepper motor SY28STH32-0674A with 200 steps per revolution, what is 1.8° to one step. For measuring of angular velocity as well as position of motor is used encoder ISC3004 with 360 count per revolution. The measuring stand for experiment in the Figure 6 is shown.

The motion of stepper motor is controlled by 8-bit microcontroller ATmega8 with frequency of CPU 16 MHz. ATmega8-16PU controls the motor using dual full bridge driver L298. This circuit was working on DC voltage of 7 V. The measuring of angular velocity as well as position of stepper motor is measured by I/O measuring card MF624 which cooperates with Matlab / Simulink. Frequency of angular velocity measuring is 1 kHz. The measuring chain in the following figure is shown.

Example of measured angular velocity is shown in the following figure.

Figure 8. Example of measured angular velocity using time of phase 1500 µs

From all measured data was removed extreme peak values. Also for all velocities was determined average values. Then analysis were done from these average values.

In the following figures there are shown results of measurements.

Figure 9. Angular velocity of stepper motor depending on control phase

As can be seen from the Figure 9 using half-step mode motor could start with lower value of phase time. Some problems occurred using phase time 1400 – 1900 µs and motor couldn´t work. On the other hand, using full-step mode motor worked using all phase times between 780 – 3400 µs. Step of phase time was 20 µs. Also the angular velocity of motor was higher using full-step mode in comparison with half-step mode.

During measuring of angular velocities there was also measured electric current. The electric power for both modes is shown in the Figure 10.

Figure 10. Electric power of stepper motor depending on control phase

Using full-step mode there was used higher amount of electric power. So the motor torque was higher using full-step mode. At the end there is also shown positioning of stepper motor rotor to one round.

Figure 11. Positioning of stepper motor to one round

5. Conclusion

In the paper was experimentally analyzed bipolar stepper motor SY28STH32-0674A connected to encoder ISC3004 with 360 CPR. Motion was controlled by microcontroller ATmega8-16PU and dual full bridge driver L298 working on 7V. As control method were used full-step mode and half-step mode. Using full-step mode were reached higher angular velocities. Also, rotor was able to rotate using full range of phase time from value 780 up to 3400 µs. Using half-step mode there were occurred some problems using certain phase times from the value 1400 up to 1900 µs and motor was unusable. By measuring of electric current was found out that using full-step mode there is higher electric energy consumption and torque is higher like torque of half-step mode.


The authors would like to thank to Slovak Grant Agency KEGA project no. 048TUKE-4/2014 “Increasing of knowledge base of students in area of application of embedded systems in mechatronic systems”.


[1]  M. Kelemen, I. Virgala, Ľ. Miková, P. Frankovský, Experimental Identification of Linear Actuator Properties, Acta Mechanica Slovaca (2015), Vol. 19, No. 1, pp. 42-47.
In article      
[2]  M. Dababneh, W. Emar, I. TTrad, Chopper Control of a Bipolar Stepper Motor, International Journal of Engineering, Vol. 7, No. 2, pp. 61-73, 2013.
In article      
[3]  F. Duchoň, M. Dekan, A. Babinec, L. Chovanec, A. Vitko, Detection of Welds in Automated Welding, Applied Mechanics and Materials, Vol. 611 (2014), pp. 519-528.
In article      
[4]  A. Morar, The modelling and simulation of bipolar hybrid stepping motor by Matlab/Simulink, Procedia Technology, 8th International Conference Interdisciplinarity in Engineering (2015), pp. 576-583.
In article      
[5]  R. Condit, Stepping Motors Fundamentals, Microchip Technology Inc., (2004).
In article      
[6]  T. Hopkins, Stepper motor driving, Application note (2012).
In article      
[7]  Stepanov P., Lagutkin S., Nikitin Y., Development of the Algorithm for Definition of Residual Service Life by a Comprehensive Diagnosis of the Electromechanical Drive, Acta Mechanica Slovaca. Volume 19, Issue 2, Pages 52-56.
In article      
[8]  P. Stepanov, S. Lagutkin, P. Božek, Y. Nikitin: Comprehensive Approach to Technical Conditions of Electromechanical Units in Mechatronic Systems, American Journal of Mechanical Engineering (2014).
In article      
[9]  Kollár, P., Nikitin, Y., Straka, M.: The determination of the shelf mass in the universal shelving stacker by measuring the frequency converter torque generating current of the main drive, Manufacturing technology, Vol. 15, No. 3, p. 363-366.
In article      
  • CiteULikeCiteULike
  • MendeleyMendeley
  • StumbleUponStumbleUpon
  • Add to DeliciousDelicious
  • FacebookFacebook
  • TwitterTwitter
  • LinkedInLinkedIn