Search
Close this search box.

Home

Stepper Motor Control using 8051 Microcontroller

A stepper motor is a brushless and synchronous motor which divides the complete rotation into number of steps. Each stepper motor will have some fixed step angle and motor rotates at this angle. Here in this article, I’ll show you how to interface a Stepper Motor with 8051 using two different drivers: L293D and ULN 2003. Also, the Stepper Motor Control using 8051 Microcontroller is explained here. 

Stepper Motor Control using 8051 Microcontroller Principle

 The main principle of these circuits is to rotate the stepper motor step wise at a particular step angle. The ULN2003 IC and the L293D Motor Driver are used to drive the  stepper motor  as the controller cannot provide current required by the motor.

Also Read the Related Post – PWM Based DC Motor Speed Control using Microcontroller

Circuit 1: Stepper Motor Control using 8051 Microcontroller & L293D

The first circuit in this project is implemented using an L293D Motor Driver IC. Since the L293D Motor Driver has option for four output pins, only a Bipolar Stepper Motor can be driven using it. 

Circuit Diagram

The circuit diagram of interfacing a Bipolar Stepper Motor with 8051 Microcontroller and L293D Motor Driver is shown in the image below. 

Stepper Motor Control using 8051 Microcontroller L293D Circuit Diagram

Components Required 

  • AT89C51 (8051 Microcontroller) 
  • L293D Motor Driver 
  • 5V Bipolar Stepper Motor 
  • 16X2 LCD Diaplay 
  • 11.0592 MHz Quartz Crystal 
  • 10KΩ Resistors X 2 
  • 10KΩ POT 
  • 8x 1KΩ Resistor Pack 
  • 33pF Ceramic Capacitors X 2  
  • 10μF/16V Capacitor 
  • Push Buttons X 4 
  • 330Ω Resistor 
  • 5V Power Supply

Circuit Design 

First, the data pins of the LCD are connected to the PORT0 Pins of 8051. Since PORT0 doesn’t have any internal pull-up, a resistor pack is used to pull the PORT0 up. The RS and E Pins of LCD are connected to P2.0 and P2.1 of 8051. 

The RST Pin is pulled-down using a 10KΩ resistor. The combination of a Push Button and a 10μF Capacitor will be used to reset the microcontroller. Also, the EA Pin is pulled-up using a 10KΩ resistor. 

Next, the oscillator. It consists of two 33pF Capacitors and an 11.0592 MHz Crystal connected between XTAL1 and XTAL2 Pins of 8051.

Coming to the Motor Driver, the two enable pins and two supply pins are connected to +5V supply. The four inputs are connected to PORT1 pins of 8051 i.e. P1.0, P1.1, P1.2 and P1.3. The four pins of the Bipolar Stepper Motor are connected to the four out pins of L293D. 

In order to control the direction of the Stepper Motor, three buttons are connected to PORT3 pins i.e. P3.0, P3.1 and P3.2. 

CODE 

Working 

The working of this circuit is very simple. A method called as Half-Stepping is implemented in the program to rotate the Stepper Motor. When the forward button is pushed, the stepper motor rotates in clockwise direction. 

Stepper Motor Control using 8051 Microcontroller Image 1
Stepper Motor Control using 8051 Microcontroller Image 2

Similarly, when the backward button is pushed, it starts rotating in anti-clockwise direction. To stop the rotation completely, you can press the stop button. 

Circuit 2: Stepper Motor Control using 8051 Microcontroller & ULN2003

The second circuit in the project is to implement a Stepper Motor Control using 8051 Microcontroller and ULN2003. Since the ULN2003 Transistor Array consists of 7 outputs, you can control both the Unipolar and Bipolar Stepper Motors. 

In this project, I’ll show you how to control a 5-Wire Unipolar Stepper Motor using 8051 Microcontroller and ULN2003 Transistor Array. 

Circuit Diagram

Following image shows the circuit diagram of interfacing a Stepper Motor with 8051 Microcontroller and ULN2003. 

Stepper Motor Control using 8051 Microcontroller Circuit Diagram
Circuit Diagram of Stepper Motor Control using AT89C51 Microcontroller

Circuit Components

  • AT89C51 Microcontroller
  • ULN2003A
  • Stepper Motor
  • Crystal
  • Resistor
  • Capacitor

Circuit Design

The circuit consists of AT89C51 microcontroller, ULN2003A, Motor. AT89c51 is low power, high-performance, CMOS 8bit, 8051 family microcontroller. It has 32 programmable I/O lines. It has 4K bytes of Flash programmable and erasable memory. An external crystal oscillator is connected at the 18 and 19 pins of the microcontroller. Motor is connected to the port2 of the microcontroller through a driver IC.

The  ULN2003A is a current driver IC. It is used to drive the current of the stepper motor as it requires more than 60mA of current. It is an array of Darlington pairs. It consists of seven pairs of Darlington arrays with common emitter. The IC consists of 16 pins in which 7 are input pins, 7 are output pins and remaining are VCC and Ground. The first four input pins are connected to the microcontroller. In the same way, four output pins are connected to the stepper motor.

Stepper motor has 6 pins. In these six pins, 2 pins are connected to the supply of 12V and the remaining are connected to the output of the stepper motor. Stepper rotates at a given step angle. Each step in rotation is a fraction of full cycle. This depends on the mechanical parts and the driving method.

Similar to all the motors, stepper motors will have stator and rotor. Rotor has permanent magnet and stator has coil. The basic stepper motor has 4 coils with 90 degrees rotation step. These four coils are activated in the cyclic order. The below figure shows you the direction of rotation of the shaft. There are different methods to drive a stepper motor. Some of these are explained below.

Full Step Drive: In this method two coils are energized at a time. Thus, here two opposite coils are excited at a time. 

Half Step Drive: In this method coils are energized alternatively. Thus it rotates with half step angle. In this method, two coils can be energized at a time or single coil can be energized. Thus it increases the number of rotations per cycle. It is shown in the below figure.

Do you know How Temperature Controlled DC Fan Works using AVR Microcontroller?

Circuit Simulation Video of Interfacing Stepper Motor with 8051 & ULN2003

How to Operate this Stepper Motor Driver Circuit?

  • Initially , switch on the circuit.
  • Microcontroller  starts driving the stepper motor.
  • One can observe the rotation of the stepper motor
  • The stepper motor has four wires. They are yellow, blue, red and white. These are energized alternatively as given below.
  • In full step driving, use the following sequence

Full Step Driving

  • To drive the motor in half step angle, use the following sequence

Half Step Angle

Stepper Motor Controller Circuit Advantages

  • It consumes less power.
  • It requires low operating voltage

Stepper Motor Control Applications

  • This circuit can be used in the robotic applications.
  •  This can also be used in mechantronics applications.
  • The stepper motors can be used in disk drives, matrix printers, etc.

20 Responses

  1. thankyou for sharing me you knowledge.. how i rotate the stepper motor 90 degree at a time… pls help me thank you in advance

  2. How much speed of the stepper motor is controlled ?? What is the speed of the stepper motor after controlling the speed??

  3. Thanks very much for sharing this.

    Can you please show how to control 3 motor in this system ie. moto 1 x axis, motor 2 y axis and motor 3 z axis with input from computer serial port or parallel port
    and interfacing it to computer

    i need for my sisters project for final year electronics

    Thanks

    1. Very dificult to make that. You need an 3 axis circuit and program. Same on cnc program. No one share that friend. We are the manufactures of cutting plktter and cnc machines. Technically you are asking thr 3 axis program. Already we have. But we cant share.

  4. Give me hex code of this project .. if u cant then share a link i will find it or email me …pls nd thanks

  5. which simulation software have u used for the circuit simulation and also which platform for writing and running the code ?? please reply as soon as possible and if possible within the same day !!!

Leave a Reply

Your email address will not be published. Required fields are marked *