Stepper Motor
Introduction
The purpose of this lab is to control a stepper motor, with instructions
received from the PC via a serial communication link to the 8051.
Stepper motors are often used in conjunction with microcontrollers to
provide precisely controlled motor power. Stepper motors are devices that
rotate a precise number of degrees for each "step" applied, as opposed
to regular motors, which simply rotate continuously when power is applied.
Driving a stepper motor involves applying a series of voltages to the
four(typically) coils of the stepper motor. The coils are energized one or
two at a time to cause the motor to rotate one step.
Assignment:
- Set up the stepper motor and stepper motor driver circuit
- Interface the PC to the 8051 through a serial communication link.
Refer to the Serial
Communication lab for details.
- Control the movement of the stepper motor by characters received
from the PC.
- When the character 'l' is received from the PC, make the
stepper motor turn left. Also display the message
"Moving left" on an LCD interfaced to the 8051.
- When the character 'r' is received from the PC, make the
stepper motor turn in the opposite direction and the
mesasge "Moving Right" should be displayed on the LCD.
Apparatus Required:
- MJE3055T NPN transistors (4)
- MJE2955T PNP transistors (4)
- MC3479P Stepper motor driver
- LB82773-M1 Bipolar Stepper Motor
- 1k resistors (9)
- 47K resistor
- 0.1mF capacitors (6)
- Serial communication cable, connectors
- LT1130CN
- LCD
- 5V power supply
- Philips PDS51 development board
Schematic:

Figure 1. Pinout for transistors

Figure 2. Stepper Motor Schematic
Program:
#pragma SMALL DB OE
#include <reg51.h>
unsigned char ReceiveSerial() {
unsigned char c;
TMOD = 0x20; /* configure timer for the correct baud rate */
TH1 = 0xe6; /* 1200 bps for 12 MHz clock */
TCON = 0x00; /* Set timer to not running */
SCON = 0x50; /* Set Serial IO to receive and normal mode */
TR1 = 1; /* start timer to Receive */
while( (SCON & 0x01) == 0 ) /* wait for receive data */;
c = SBUF;
return c;
}
void SendSerial(unsigned char c) {
/* initialize..set values for TMOD, TH1 and TCON */
/* set the Tx interrupt in SCON to indicate sending data */
/* start timer */
/* write character to SBUF */
/* wait for completion of sent data */
}
void main(void) {
unsigned char c;
while( 1 ) {
/* Use ReceiveSerial to read in a character */
/* Depending on character make the motor move left or right */
/* and display the direction on the LCD */
}
}
Procedure:
- Set up the circuit for the stepper motor as
shown in the above schematic.
Note: The circuit requires two different voltages
but you need a common ground.
CAUTION: Transistors can get very hot.
- Interface the LCD and 8051 as was done in earlier labs.
Pins 3 and 5 of the LCD are connected to different pins on
the 8051. You will need to make the appropriate changes to the
io.c file.
- Set up serial communication between the PC and 8051. (See Lab 3
and make the appropriate changes.)
- The stepper motor moves when Clk (pin 7 on the MC3479P chip)
is toggled. It's direction depends on whether CW/CCW
(pin 10 on the MC3479P chip) is set to 0 or 1.
- Run your program on the emulator.
- To transmit data copy the executable serial.exe onto your
desktop
- Enter the letter you wish to transmit and click
"Transmit" several times. If everything is done
correctly, your stepper motor should be moving.