Unipolar Stepper Motor Interfacing To 8051

Description

It’s an example of Unipolar Stepper Motor Interfacing To 8051 microcontroller.

Circuit Diagram

Detail

It is simplest stepper motor interfacing example with 8051. In this project 8051 microcontroller controls unipolar stepper motor.

Stepper Motor

Stepper or stepping motors rotate through a fixed (pre-determined) angular step in response to input command provided by controller. On every next command motor advances one angular step. It means motor rotates in a series of angular intervals/steps with each step of same distance. If we reverse the order of input commands the direction of stepper motor also reverses.

Stepper.jpg
Click to Enlarge
Stepper Internal Circuit Diagram
Stepper-Internal-Circuit.jpg
Click to Enlarge

Above is the circuit diagram of 5 or 6 pin unipolar stepper motor. There are 2 main coils A and B. Each is further sub divided into 2 more coils resulting A0, A1, B0 and B1. Center tapped are usually connected to common supply source and command or command pattern is provided by its controller on inputs A0, A1, B0 and B1. For full step command sequence is given by

b1 b0 a1 a0 Hex Decimal
0 0 0 1 0x01 1
0 1 0 0 0x04 4
0 0 1 0 0x02 2
1 0 0 0 0x08 8

We can make software interface simple by interchanging pin a1 with b0. Now commands sequence will become

b1 a1 b0 a0 Hex Dec
0 0 0 1 0x01 1
0 0 1 0 0x02 2
0 1 0 0 0x04 4
1 0 0 0 0x08 8

We can use this unipolar stepper motor as bipolar stepper motor by ignoring center tapped input.

In the controller circuit diagram Port0 4 LSBs are connected to the inputs of 2 ULN2003A coil driver IC. Each ULN2003A contains 7 darling-ton pairs to provide interface between 8051 microcontroller and stepper motor. As microcontroller cannot drive stepper motors or coils directly. We know that coils produce back emf when these are switched from “on” to “off” or “off” to “on” state. ULN2003A also provides back emf protection diodes to remove back emf produce by coils. Each driver of ULN2003A can sink 500mA current maximum. We can parallel these drivers to handle more current according to stepper motor needs. In the above controller circuit diagram we have paralleled 3 drivers. We have connected 3 inputs together. Similarly 3 outputs of driver together. Each pair of 3 drivers is driving a single coils of stepper motor. We have used separate power supplies for controller and stepper motor.

For basic operation & components used in an 8051 based microcontroller based systems see
8051 Basic LED Flasher.

Code

Below is the simplest code of stepper motor demonstration.

// Start of code.


///////////////////////////////////////////////////////////
// Company         : Micro Digital                       //
// Address         : Office # C7 Raza Plaza              //
//                   DAV College Road                    //
//                   Rawalpindi,                         //
//                   Pakistan.                           //
// Programmed By   : Rashid Mehmood                      //
// Project Name    : Unipolar Stepper Motor Interfacing  //
//                   To 8051                             //
// Crystal         : 24.000000 MHz                       //
// Microcontroller : AT89C2051-C51-C52-C55-S2051-S51-S52 //
///////////////////////////////////////////////////////////

#include <AT89x051.h>

void delay(unsigned int del)
{
	while(del --);
}

void main()
{
	char i;
	while(1)
	{
		for(i = 0; i < 4; i ++)
		{
			// Output pattern for next step.
			P0 = 0x01 << i;
			// Give some suitable delay.
			// You can change this delay
			// depending on your motor 
			// maximum speed.
			delay(10000);
		}	
	}
}

// End of code.

This code can also be executed with little or no change on AT89C2051 microcontroller a small brother of AT89C51.

Related Projects

8051 Basic LED Flasher

More Projects