Stepper motor control using microcontroller AT89C51
Various techniques can be used to control the speed of an AC or DC motor, such as using the phase-locked-loop principles, digital inputs, or analog inputs. As we have already published the project “Digital DC motor Speed controller” controls the speed of motor by using of digital input, and “electronics motor control” used to control AC motor. Now, its time to build stepper motor control system. The project stepper motor control illustrates the use of microcontroller and switching circuit to control the speed of stepper motor. This project control the axial rotation in XY plane and to control the rotation of the motor in either XZ or YZ plane similar circuit can be added. The block diagram of stepper motor control using microcontroller AT89C51 is shown in figure 1.
The circuit of stepper motor control system is designed using microcontroller and switching circuit. The power supply is given by pressing switch SW1 which further step down by step down transformer to 7.5V and rectified by bridge rectifier made from diode D1 through D4. The rectified output is further filtered by capacitor C1 and given to pin 1 (input) pin of voltage regulator IC (IC1). The regulated output of 5V is obtained at its output pin 3. Power on-reset is provided by capacitor C3 to the microcontroller connected to pin 9 and across switch SW2.
As we know the stepper motor has four different coils so four motor driver circuits is needed. Each motor driver circuit is build from two NPN transistors (i.e. BC548 and SL100) and configured as darlington pair. The four darlington pair is connected to pin 28 through 25 (i.e. P2.4 through P2.7) as shown in circuit diagram figure 2.
A magnetic field is created around coil when transistors start conduction and as a result motor start to rotate. But when transistor stop conduction a reverse voltage (more than 100V) is produced because of magnetic field energy stored in coil is collapsed which is absorbed by diode connected across the coil.
A crystal of 11.019 MHz is connected to pin 18 and 19 with capacitors C4 and C5 as shown in circuit diagram, which is response for the clock frequency of microcontroller. The speed of stepper motor is directly proportional to frequency of the input pulses.
Formula for calculation time taken by any instruction to get executed is
Time = (C*12)/f
Where C = number of cycle
And f = crystal frequency
Program:- The source code of “Stepper Motor Control Using Microcontroller AT89C51” is written in assembly language.
Resistors (all ¼-watt, ± 5% Carbon)
R1 = 100 Ω
R2 = 100 KΩ
R3, R5, R7, R9 = 1 KΩ
R4, R6, R8, R10, R11 = 470 Ω
C1 = 220 µF/25V
C2 = 100 µF/16V
C3 = 10 µF/16V
C4, C5 = 33 pF
C6 = 100 µF/16V
IC1 = 7805 (5V regulator)
IC2 = AT89C51 (Microcontroller)
T1, T3, T5, T7 = BC548 (NPN transistor)
T2, T4, T6, T8 = SL100 (NPN transistor)
D1 – D8 = 1N4001 (rectifier diode)
LED1 = RED LED (5mm dia.)
X1 = 230V/50Hz or 100V/60Hz primary to 0-7.5V, 1A sec. step down transformer
SW1, SW3 = on/off switch
Sw2 = push to on switch
= 5V DC stepper motor