Stepper Motor Control Using AVR (Atmega) Microcontroller

An electric machine that converts electrical energy into mechanical energy is called an electric motor. First and foremost electric motor is a simple electrostatic device created by Scottish monk Andrew Gordon in 1740s. But in 1821, Michael Faraday demonstrated the conversion of electrical energy into mechanical energy.


Electric motors are primarily classified into two categories: AC motors and DC motors. Again, each category is subdivided into many types. Many loads such as mixer, grinder, fans, etc., most frequently used home appliances in which we can find different types of motors and these can be operated at different speeds with speed controlling provision of the motors. In this article, we are going to discuss about one of the major types of DC motors, namely Stepper motor and its control using the microcontroller.

Stepper Motor

A synchronous and brushless DC motor  that converts electric pulses into mechanical movements and thus, rotates stepwise with a certain angle between each step for completing a full rotation is called as Stepper Motor. The angle between the steps of rotation of the stepper motor is termed as the stepper angle of the motor.

Stepper Motor
Stepper Motor

Stepper motors are classified into two types according to their winding: Unipolar Stepper Motors and Bipolar Stepper Motors. The unipolar stepper motor is frequently used in many applications due to its ease of operation compared to the bipolar stepper motor. But there are different types of stepper motors such as Permanent Magnet Stepper Motor, Variable Reluctance Stepper Motor, and Hybrid Stepper Motor.

Stepper Motor Control

The stepper motor can be controlled with various techniques, but here we are discussing the stepper motor control using an Atmega microcontroller. The 89C51 is a microcontroller of the 8051 microcontroller family.

Block Diagram of Stepper Motor Control
Block Diagram of Stepper Motor Control

The block diagram of a stepper motor control using an 8051 microcontroller is shown in the figure with power supply, microcontroller, stepper motor and control switch blocks.

PCBWay

2 Methods To Design Stepper Motor Control Circuit

The stepper motor controller is designed using 8051 microcontrollers and switching circuit for controlling the speed of the stepper motor. The control switch circuit can be designed by using transistor switches or by using stepper motor controller IC such as ULN2003 in place of the transistors.

1. Control Circuit Using Stepper Motor Controller IC

The unipolar stepper motor can be rotated by energizing the stator coils in a sequence. The sequence of these voltage signals applied across the motor coils or leads is enough to drive the motor and hence, no driver circuit is required for controlling the direction of the current in the stator coils.

Stepper Motor Control using IC
Stepper Motor Control using IC

The two-phase-stepper motor consists of four end wires connected to the coils and two common wires connected to the two end leads to form two phases. The common points and end points of the two phases are connected to the ground or Vcc and the microcontroller pins, respectively. For rotating the motor, the endpoints of the two phases are to be energized. Primarily a voltage is applied to the first end point of the phase1, and further voltage is applied to the first end point of the phase2, and so on.

The stepper motor can be operated in different modes such as Wave Drive Stepping Mode, Full Drive Stepping Mode and Half Drive Stepping Mode.

Wave Drive Stepping Mode

By repeating the above sequence, the motor can be rotated in wave-drive- stepping mode either in a clockwise or anticlockwise direction based on the selection of end points. The table below shows the signal phase sequence for wave-drive-stepping mode.

Wave Drive Stepping Mode
Wave Drive Stepping Mode

Full Drive Stepping Mode

Energizing the two endpoints of different phases simultaneously achieves a full-drive-stepping mode. The table shows the signal phase sequence for the full-drive -stepping mode.

Full Drive Stepping Mode
Full Drive Stepping Mode

Half Drive Stepping Mode

The combination of the steps of the wave and full-drive-stepping modes achieves a half-drive-stepping mode. Thus, in this mode, the stepping angle is divided into half. The table shows the signal phase sequence of a half-drive-stepping mode.

Half Drive Stepping Mode
Half Drive Stepping Mode

In general, the stepping angle depends on the resolution of the stepper motor. The size of thesteps and the direction of rotation are directly proportional to the number and order of the input sequence. The rotating speed of the shaft depends on the frequency of the input sequence. The torque and the number of magnets magnetized at a time are proportional.

The stepper motor requires 60mA current, but the maximum current rating of the Atmega microcontroller AT89C51 is 50mA. So, a stepper-motor-controller ICisused to interface the stepper motor with the microcontroller for transferring the signals.

2. Control Switch Circuit Using Transistors

The power supply to the circuit can be given by stepping down the voltage from 230V to 7.5V using a step-down transformer, and then rectifying by a bridge rectifier with diodes. This rectified output is fed to a filter capacitor, and then passed through the voltage regulator. The 5V regulated output is obtained from the voltage regulator. The reset pin9 is connected between the capacitor and resistor.

Stepper Motor Control Circuit using Transistor
Stepper Motor Control Circuit using Transistor

In general, the stepper motor consists of four coils as shown in the figure. So, to drive the motor, four motor-driver circuits are required. Instead of using the stepper motor controller IC to drive the motor, four transistors are connected as the driver circuits at 21, 22, 23 and 24 pins of the microcontroller, respectively.

If the transistors start conduction, then a magnetic field will be created around the coil causing rotation of the motor. The stepper motor speed is directly proportional to the input pulse frequency. A crystal oscillator is connected to the pins 18 and 19 to provide microcontroller clock frequency of about 11.019MHz.

The execution time of any instruction can be calculated using the below formula

Time=((C*12))/f

Where C= number of the cycle

And F = crystal frequency

One of the application based circuit that uses a stepper motor for rotating solar panel is described below.

Stepper Motor Control Using Programmed 8051 Microcontroller

Sun Tracking Solar Panel project is intended to generate the maximum amount of energy by automatically adjusting the solar panel. In this project, a stepper motor controlled by a programmed microcontroller of 8051 family is interfaced to the solar panel to maintain the solar panels’ face always perpendicular to the sun.

Stepper Motor Control Using Microcontroller by Edgefxkits.com
Stepper Motor Control Using Microcontroller by Edgefxkits.com

The programmed microcontroller generates stepped electrical pulses at regular intervals to the stepper motor for rotating the solar panel. The driver IC is used to drive the stepper motor as the controller is unable to provide the power requirements of the motor.

Please leave your suggestions, feedback and queries by posting comments in the comment section below. We will do our best to help you technically regarding this article and developing electrical and electronics projects using the stepper motor.