Top Banner

Click here to load reader

9

Lab 5 microcontroller

May 06, 2015

Download

Education

mkazree
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lab 5 microcontroller

CENTRE OF DIPLOMA STUDIES

COMPUTER ADDED DESIGN LABORATORY

LABORATORY INSTRUCTION SHEET

Subject Code and Name DEK 3133MICROCONTROLLER

Experiment Code 05

Experiment Title Introduction to Stepper Motor

Course Code DET/DEE/DEX

Page 2: Lab 5 microcontroller

Document ReferenceNo. RPP-05 Page. Number P a g e | 1

Document TitleLABORATORYPRACTICUM

Edition 1

Revision No. 4

Effective Date 12/8/2010

Amendment Date 12/8/2010

SUBJECT INFORMATION

SUBJECT : DEK 3133 MICROCONTROLLER

TOPIC : Lab 5 – Introduction to Stepper Motor.

AIM To apply the knowledge and understanding on theory and applications of Stepper Motor.

1 OBJECTIVES

1.1 To understand the design of keypad.

1.2 To determine and analyze the function of keypad.

1.3 To understand the configuration of LCD.

2 EQUIPMENT

2.1 PIC Development Board – PICDEV

2.2 PIC16F877A

2.3 MPLAB IDE Program

2.4 Mikro C

2.5 Proteus

2.6 The PIC Development Board User manual

2.7 Power supply 9V

3 THEORY

3.1 STEPPER MOTOR

A stepper motor is a widely used device that translates electrical pulses into mechanical movement. Inapplications such as disk drives, dot matrix printers, PCB drilling mill, camera panning system, automatic fishfeeder, and robotic, the stepper motor is used for position control.

Page 3: Lab 5 microcontroller

Document ReferenceNo. RPP-05 Page. Number P a g e | 2

Document TitleLABORATORYPRACTICUM

Edition 1

Revision No. 4

Effective Date 12/8/2010

Amendment Date 12/8/2010

3.2 HOW STEPPER MOTOR WORKS?Stepper motors are very different from a regular DCmotors. Instead of spinning like DC motors do, steppermotor steps at a specific resolution for each pulse. Themotor that we are using needs 48 steps / pulses just tocomplete a single revolution! That should be enough to tellabout its precision.

Another advantage of stepper motors is the fact that theirspeed of rotation can be achieved almost instantly even ifyou change the spinning direction.

Stepper motor consists of a rotor - the permanent magnetthat rotates inside, and stator - four coils (north, east,south, west) that are part of the case, and which don't

move. Rotor can be moved by sequentially applying a pulsed DC voltage to one or two coils at a time.

3.3 STEPPER MOTOR DRIVERIn able to move the rotor you will need a driver. Driver is a circuit that applies a voltage to any of the fourstator coils. Driver can be built with IC such as ULN2003 (pictured on the circuit diagram), four darlingtontransistors or four power transistors such as 2N3055.

3.4 STEPPER MOTOR CONNECTIONSThere are also steppers called variable reluctance stepper motors that do not have permanent magnet rotor. Themost common stepper motors have four stator windings that are paired with a center-tapped common as shownif Figure below.

Unipolar motor should have five or six connections depending on the model. If the motor has six connectionslike the one pictured above, you have to join pins 1 and 2 (red) together and connect them to a (+) 12-24Vvoltage supply. The remaining pins; a1 (yellow), b1 (black), a2 (orange), b2 (brown) should be connected to adriver (ULN2003) as shown on the schematic below.

Page 4: Lab 5 microcontroller

Document ReferenceNo. RPP-05 Page. Number P a g e | 3

Document TitleLABORATORYPRACTICUM

Edition 1

Revision No. 4

Effective Date 12/8/2010

Amendment Date 12/8/2010

Figure of Stepper motor control using ULN2003 driver.

This type of stepper motor is commonly referred to as a four phase or unipolar stepper motor. The center tapallows a change of current direction in each of two coils when a winding is grounded, thereby resulting in apolarity change of the stator. Notice that while a conventional motor shaft runs freely, the stepper motors shaftmoves in a fixed repeatable increment, which allows one to move it to a precise position. This repeatable fixedmovement is possible as a result of basic magnetic theory where poles of the same polarity repel and oppositepoles attract. The direction of the rotation is dictated by the stator poles. The stator poles are determined by thecurrent sent through the wire coils. As the direction of the current is changed, the polarity is also changedcausing the reverse motion of the motor. The stepper motor discussed here has a total of six leads: four leadsrepresenting the four stator windings and two commons for the center-tapped leads. As the sequence of poweris applied to each stator winding, the rotor will rotate. There are several widely used sequences, each of whichhas different degree of precision. Table below shown the finer resolutions that called an 8 –step switchingsequence. The 8 step sequence is also called half-stepping, because in the 8-step sequence each step is half ofthe normal step angle.

Page 5: Lab 5 microcontroller

Document ReferenceNo. RPP-05 Page. Number P a g e | 4

Document TitleLABORATORYPRACTICUM

Edition 1

Revision No. 4

Effective Date 12/8/2010

Amendment Date 12/8/2010

Clockwise Step # Winding A Winding B Winding C Winding D CounterClockwise

1 1 0 0 1

2 1 0 0 0

3 1 1 0 0

4 0 1 0 0

5 0 1 1 0

6 0 0 1 0

7 0 0 1 1

8 0 0 0 1

Table 1: Half-Step 8 –Step Sequence

3.5 MOTOR SPEED

The motor speed, measured in steps per second, is a function of the switching rate. By changing the length ofthe time delay loop, we can achieve various rotation speeds. Decreasing the delay time will increase therotation speed and vice versa.

Prepared By:

Signature :Name: Mohamad Bin Md. SomDate: 12 August 2010

Approved by:

Signature:Name: Shamsul B. MohamadDate: 12 August 2010

Page 6: Lab 5 microcontroller

Document ReferenceNo. RPP-05 Page. Number P a g e | 5

Document TitleLABORATORYPRACTICUM

Edition 1

Revision No. 4

Effective Date 12/8/2010

Amendment Date 12/8/2010

4 ATTENTION

4.1 Do not move any IC or device inside the board without any order from your instructor.

5 EXPERIMENT PROCEDURE

5.1 STEPPER MOTOR (See Circuit 1)5.1.1 Before test the source code on the PIC development board, the connection of PORTC mustbe connected to the steeper motor driver (ULN2003A) using jumper wires. Theconnections are shown below:M1 C0M2 C1M3 C2M4 C35.1.2 The code below is show how the stepper motor is rotate in clockwise and counterclockwise for about 20 seconds. Type the code and test on the development board. Writeyour observation.

//####################################START##########################// DCBA#define STEP1 0b00001001#define STEP2 0b00000001#define STEP3 0b00000011#define STEP4 0b00000010#define STEP5 0b00000110#define STEP6 0b00000100#define STEP7 0b00001100#define STEP8 0b00001000

void Delay(unsigned int ms){

switch (ms) {case 500:

Delay_ms(500);break;

case 200:Delay_ms(200);break;

default:Delay_ms(1000);

}

Page 7: Lab 5 microcontroller

Document ReferenceNo. RPP-05 Page. Number P a g e | 6

Document TitleLABORATORYPRACTICUM

Edition 1

Revision No. 4

Effective Date 12/8/2010

Amendment Date 12/8/2010

}

void main(void){

unsigned int i;TRISC = 0x00;PORTC = 0;

while(1){

//Forwardfor (i=1;i<=5;i++){

PORTC = STEP1;Delay(500);PORTC = STEP2;Delay(500);PORTC = STEP3;Delay(500);PORTC = STEP4;Delay(500);PORTC = STEP5;Delay(500);PORTC = STEP6;Delay(500);PORTC = STEP7;Delay(500);PORTC = STEP8;Delay(500);

}

for (i=1;i<=5;i++){//ReversePORTC = STEP8;Delay(500);PORTC = STEP7;Delay(500);PORTC = STEP6;Delay(500);PORTC = STEP5;Delay(500);PORTC = STEP4;Delay(500);PORTC = STEP3;Delay(500);PORTC = STEP2;Delay(500);PORTC = STEP1;Delay(500);

}}

Page 8: Lab 5 microcontroller

Document ReferenceNo. RPP-05 Page. Number P a g e | 7

Document TitleLABORATORYPRACTICUM

Edition 1

Revision No. 4

Effective Date 12/8/2010

Amendment Date 12/8/2010

}//####################################END##########################

5.2 Exercise 15.2.1 Base on the code above; modify the program, so that the motor rotation speed is increase.5.2.2 Write you observations.5.3 Exercise 25.3.1 Base on the circuit 1, develop a program, so that the stepper motor will rotate if thebutton is pressed and stop if the button is not pressed.5.3.2 Draw a flow chart for the complete program.5.4 Exercise 35.4.1 Base on circuit 1, develop a program to toggle the direction of stepper motor rotation ifbutton is pressed.5.4.2 Draw a flow chart for the complete program.

6 REPORT PREPARATION AND SCHEMA.

(1) 2 persons for 1 report.

(2) Due date to send report is 1 weeks after lab date.

(3) Report schema following below requirements:

Lab report cover sheet for 1st page.

Objective, theory, equipments for the 2nd page. (5) ( 5 M )

Observations. (10)

1.Motor rotation observation from 5.1.2 (5 M)

2.Motor Speed observation from 5.2.2 (5 M )

Result. (65)

1. Exercise 1 source code (15 M)

2. Exercise 2 source code & Flow Chart (25 M)

Page 9: Lab 5 microcontroller

Document ReferenceNo. RPP-05 Page. Number P a g e | 8

Document TitleLABORATORYPRACTICUM

Edition 1

Revision No. 4

Effective Date 12/8/2010

Amendment Date 12/8/2010

3. Exercise 3 source code & Flow chart (25M )

Discussion. (10)

1. What is the function of ULN2003A device? (5 M)

2. How to increase and reduce the rotation speed of stepper motor? (5 M)

Conclusions. (10)

7 CIRCUIT ATTACMENT

Circuit 1: STEPPER MOTOR