Saturday, August 27, 2011

Controlling a Stepper Motor




Purpose: 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.
Description: 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: In this lab, you'll design a program to do the following jobs:
1. Set up the stepper motor and stepper motor driver circuit
2. Interface the PC to the 8051 through a serial communication link. 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:
1. MJE3055T NPN transistors (4)
2. MJE2955T PNP transistors (4)
3. MC3479P Stepper motor driver
4. LB82773-M1 Bipolar Stepper Motor
5. 1k resistors (9)
6. 47K resistor
7. 0.1μF capacitors (6)
8. Serial communication cable, connectors
9. LT1130CN
10. LCD
11. 5V power supply
12. Philips PDS51 development board

Schematic:


_______________________________________________________

Program:
#pragma SMALL DB OE
#include
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 */
}
}


Steps to be followed:
1. Set up the circuit for the stepper motor as shown in the above schematic. Note that the circuit requires two different voltages but you need a common ground. CAUTION: Transistors can get very hot.
2. 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.
3. Set up serial communication between the PC and 8051. (See Lab 3 and make the appropriate changes.)
4. 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.
5. Run your program on the emulator.
• To transmit data go to Neighborhood Network -> Peart -> cs122 -> Serial
• Copy the executable 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.


Steps to be followed:
1. Set up the circuit for the stepper motor as shown in the above schematic. Note that the circuit requires two different voltages but you need a common ground. CAUTION: Transistors can get very hot.
2. 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.
3. Set up serial communication between the PC and 8051. (See Lab 3 and make the appropriate changes.)
4. 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.
5. Run your program on the emulator.
• To transmit data go to Neighborhood Network -> Peart -> cs122 -> Serial
• Copy the executable 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.








No comments:

Popular Posts