CENTRE OF DIPLOMA STUDIES



COMPUTER ADDED DESIGN LABORATORY



   LABORATORY INSTRUCTION SHEET



                        DEK 3133
Subject Code and Name
                        MICROCONTROLLER

  Experiment Code       05

   Experiment Title     Introduction to Stepper Motor


    Course Code         DET/DEE/DEX
Document      Reference
                        No.                       RPP-05                  Page. Number              Page |1
                                                                          Edition                     1
                                                    LABORATORY            Revision No.                   4
                           Document Title
                                                     PRACTICUM            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. In
applications such as disk drives, dot matrix printers, PCB drilling mill, camera panning system, automatic fish
feeder, and robotic, the stepper motor is used for position control.
Document       Reference
                       No.                        RPP-05                  Page. Number              Page |2
                                                                          Edition                     1
                                                    LABORATORY            Revision No.                   4
                           Document Title
                                                     PRACTICUM            Effective Date             12/8/2010
                                                                          Amendment Date             12/8/2010

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

                                                   Another advantage of stepper motors is the fact that their
                                                   speed of rotation can be achieved almost instantly even if
                                                   you change the spinning direction.

                                                 Stepper motor consists of a         - the permanent magnet
                                                 that rotates inside, and          - four coils (north, east,
                                                 south, west) that are part of the case, and which
      . Rotor can be moved by sequentially applying a pulsed DC voltage to one or two coils at a time.



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



         3.4 STEPPER MOTOR CONNECTIONS
There are also steppers called variable reluctance stepper motors that do not have permanent magnet rotor. The
most common stepper motors have four stator windings that are paired with a center-tapped common as shown
if Figure below.




Unipolar motor should have five or six connections depending on the model. If the motor has six connections
like the one pictured above, you have to join pins 1 and 2 (red) together and connect them to a (+) 12-24V
voltage supply. The remaining pins; a1 (yellow), b1 (black), a2 (orange), b2 (brown) should be connected to a
driver (ULN2003) as shown on the schematic below.
Document       Reference
                        No.                         RPP-05                   Page. Number                Page |3
                                                                             Edition                       1
                                                       LABORATORY            Revision No.                     4
                             Document Title
                                                        PRACTICUM            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 tap
allows a change of current direction in each of two coils when a winding is grounded, thereby resulting in a
polarity change of the stator. Notice that while a conventional motor shaft runs freely, the stepper motors shaft
moves in a fixed repeatable increment, which allows one to move it to a precise position. This repeatable fixed
movement is possible as a result of basic magnetic theory where poles of the same polarity repel and opposite
poles attract. The direction of the rotation is dictated by the stator poles. The stator poles are determined by the
current sent through the wire coils. As the direction of the current is changed, the polarity is also changed
causing the reverse motion of the motor. The stepper motor discussed here has a total of six leads: four leads
representing the four stator windings and two commons for the center-tapped leads. As the sequence of power
is applied to each stator winding, the rotor will rotate. There are several widely used sequences, each of which
has different degree of precision. Table below shown the finer resolutions that called an 8 –step switching
sequence. The 8 step sequence is also called half-stepping, because in the 8-step sequence each step is half of
the normal step angle.
Document     Reference
                        No.                          RPP-05               Page. Number             Page |4
                                                                          Edition                    1
                                                      LABORATORY          Revision No.                 4
                           Document Title
                                                       PRACTICUM          Effective Date           12/8/2010
                                                                          Amendment Date           12/8/2010




Clockwise      Step #          Winding A         Winding B     Winding C        Winding D      Counter
                                                                                               Clockwise
               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 of
the time delay loop, we can achieve various rotation speeds. Decreasing the delay time will increase the
rotation speed and vice versa.
Document      Reference
                     No.                       RPP-05                  Page. Number              Page |5
                                                                       Edition                     1
                                                 LABORATORY            Revision No.                   4
                          Document Title
                                                  PRACTICUM            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.1    Before test the source code on the PIC development board, the connection of PORTC must
     5.1     STEPPER MOTOR (See Circuit 1)


              be connected to the steeper motor driver (ULN2003A) using jumper wires. The
              connections are shown below:
              M1     C0
              M2     C1
              M3     C2
              M4     C3

     5.1.2    The code below is show how the stepper motor is rotate in clockwise and counter
              clockwise for about 20 seconds. Type the code and test on the development board. Write
              your observation.
Document    Reference
No.                     RPP-05        Page. Number     Page |6
                                      Edition            1
                         LABORATORY   Revision No.        4
   Document Title
                          PRACTICUM   Effective Date   12/8/2010
                                      Amendment Date   12/8/2010
Document       Reference
                        No.                         RPP-05             Page. Number             Page |7
                                                                       Edition                    1
                                                      LABORATORY       Revision No.                  4
                             Document Title
                                                       PRACTICUM       Effective Date           12/8/2010
                                                                       Amendment Date           12/8/2010




        5.2.1    Base on the code above; modify the program, so that the motor rotation speed is increase.
        5.2     Exercise 1



        5.2.2    Write you observations.



        5.3.1    Base on the circuit 1, develop a program, so that the stepper motor will rotate if the
        5.3     Exercise 2


                 button is pressed and stop if the button is not pressed.

        5.3.2    Draw a flow chart for the complete program.



        5.4.1    Base on circuit 1, develop a program to toggle the direction of stepper motor rotation if
        5.4     Exercise 3


                 button 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)                 (5M)
       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)
Document    Reference
                         No.                     RPP-05                  Page. Number     Page |8
                                                                         Edition            1
                                                   LABORATORY            Revision No.        4
                            Document Title
                                                    PRACTICUM            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

Lab 5 microcontroller

  • 1.
    CENTRE OF DIPLOMASTUDIES COMPUTER ADDED DESIGN LABORATORY LABORATORY INSTRUCTION SHEET DEK 3133 Subject Code and Name MICROCONTROLLER Experiment Code 05 Experiment Title Introduction to Stepper Motor Course Code DET/DEE/DEX
  • 2.
    Document Reference No. RPP-05 Page. Number Page |1 Edition 1 LABORATORY Revision No. 4 Document Title PRACTICUM 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. In applications such as disk drives, dot matrix printers, PCB drilling mill, camera panning system, automatic fish feeder, and robotic, the stepper motor is used for position control.
  • 3.
    Document Reference No. RPP-05 Page. Number Page |2 Edition 1 LABORATORY Revision No. 4 Document Title PRACTICUM Effective Date 12/8/2010 Amendment Date 12/8/2010 3.2 HOW STEPPER MOTOR WORKS? Stepper motors are very different from a regular DC motors. Instead of spinning like DC motors do, stepper motor steps at a specific resolution for each pulse. The motor that we are using needs 48 steps / pulses just to complete a single revolution! That should be enough to tell about its precision. Another advantage of stepper motors is the fact that their speed of rotation can be achieved almost instantly even if you change the spinning direction. Stepper motor consists of a - the permanent magnet that rotates inside, and - four coils (north, east, south, west) that are part of the case, and which . Rotor can be moved by sequentially applying a pulsed DC voltage to one or two coils at a time. 3.3 STEPPER MOTOR DRIVER In able to move the rotor you will need a driver. Driver is a circuit that applies a voltage to any of the four stator coils. Driver can be built with IC such as ULN2003 (pictured on the circuit diagram), four darlington transistors or four power transistors such as 2N3055. 3.4 STEPPER MOTOR CONNECTIONS There are also steppers called variable reluctance stepper motors that do not have permanent magnet rotor. The most common stepper motors have four stator windings that are paired with a center-tapped common as shown if Figure below. Unipolar motor should have five or six connections depending on the model. If the motor has six connections like the one pictured above, you have to join pins 1 and 2 (red) together and connect them to a (+) 12-24V voltage supply. The remaining pins; a1 (yellow), b1 (black), a2 (orange), b2 (brown) should be connected to a driver (ULN2003) as shown on the schematic below.
  • 4.
    Document Reference No. RPP-05 Page. Number Page |3 Edition 1 LABORATORY Revision No. 4 Document Title PRACTICUM 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 tap allows a change of current direction in each of two coils when a winding is grounded, thereby resulting in a polarity change of the stator. Notice that while a conventional motor shaft runs freely, the stepper motors shaft moves in a fixed repeatable increment, which allows one to move it to a precise position. This repeatable fixed movement is possible as a result of basic magnetic theory where poles of the same polarity repel and opposite poles attract. The direction of the rotation is dictated by the stator poles. The stator poles are determined by the current sent through the wire coils. As the direction of the current is changed, the polarity is also changed causing the reverse motion of the motor. The stepper motor discussed here has a total of six leads: four leads representing the four stator windings and two commons for the center-tapped leads. As the sequence of power is applied to each stator winding, the rotor will rotate. There are several widely used sequences, each of which has different degree of precision. Table below shown the finer resolutions that called an 8 –step switching sequence. The 8 step sequence is also called half-stepping, because in the 8-step sequence each step is half of the normal step angle.
  • 5.
    Document Reference No. RPP-05 Page. Number Page |4 Edition 1 LABORATORY Revision No. 4 Document Title PRACTICUM Effective Date 12/8/2010 Amendment Date 12/8/2010 Clockwise Step # Winding A Winding B Winding C Winding D Counter Clockwise 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 of the time delay loop, we can achieve various rotation speeds. Decreasing the delay time will increase the rotation speed and vice versa.
  • 6.
    Document Reference No. RPP-05 Page. Number Page |5 Edition 1 LABORATORY Revision No. 4 Document Title PRACTICUM 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.1 Before test the source code on the PIC development board, the connection of PORTC must 5.1 STEPPER MOTOR (See Circuit 1) be connected to the steeper motor driver (ULN2003A) using jumper wires. The connections are shown below: M1 C0 M2 C1 M3 C2 M4 C3 5.1.2 The code below is show how the stepper motor is rotate in clockwise and counter clockwise for about 20 seconds. Type the code and test on the development board. Write your observation.
  • 7.
    Document Reference No. RPP-05 Page. Number Page |6 Edition 1 LABORATORY Revision No. 4 Document Title PRACTICUM Effective Date 12/8/2010 Amendment Date 12/8/2010
  • 8.
    Document Reference No. RPP-05 Page. Number Page |7 Edition 1 LABORATORY Revision No. 4 Document Title PRACTICUM Effective Date 12/8/2010 Amendment Date 12/8/2010 5.2.1 Base on the code above; modify the program, so that the motor rotation speed is increase. 5.2 Exercise 1 5.2.2 Write you observations. 5.3.1 Base on the circuit 1, develop a program, so that the stepper motor will rotate if the 5.3 Exercise 2 button is pressed and stop if the button is not pressed. 5.3.2 Draw a flow chart for the complete program. 5.4.1 Base on circuit 1, develop a program to toggle the direction of stepper motor rotation if 5.4 Exercise 3 button 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) (5M) 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)
  • 9.
    Document Reference No. RPP-05 Page. Number Page |8 Edition 1 LABORATORY Revision No. 4 Document Title PRACTICUM 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