Microcontroller Stepper Motor (MSM)

OBJECTIVE

  1. Students understand the microcontroller interface circuit with stepper motors
  2. Students understand the ULN2003 stepper motor driver circuit
  3. Students understand assembly language to control the direction of rotation of a stepper motor.
  4. Students understand assembly language to control the direction of rotation of a stepper motor using a switch.


Figure 8.1. Stepper motor interface circuit with ULN2003 driver

Basic theory

In a regular DC motor, it will spin and spin continuously as long as there is power supply. There is no special intelligent circuit required to control the motor, except to slow down the rotation or reverse the rotation, by applying reverse polarity. Stepper motors are very different. If you give power to this motor, then this motor will be in a stationary state, in order for the motor to rotate, you must change the signal that goes into the motor. As an illustration, you can imagine a compass with an electromagnet around it. As depicted in Figure 2.2., if the power given to the electromagnet is changed, it will change the position of the compass needle.


Figure 4.2. Illustration of a compass with an electromagnet.

With four electromagnets, the movement will jump roughly. Now imagine the same arrangement with 100 electromagnets circling a compass. By controlling the energy that flows through each electromagnet in sequence, the needle will need 100 steps to make one rotation. But setting up 100 electromagnets individually would require complex electronics.


Figure 4.3. Illustration of a stepper motor with a compass needle with an electromagnet.

In the illustration, the circular letters represent electromagnets. All magnets with the same letter are in a connected state. When you give current to the circuit, all electromagnets with the same letter will be on at that time, to move the compass, the next electromagnet must be flowed with current, so that it will cause movement.

Table 2.7.1. Full Step Mode

| A | B | C | D | KOMENTAR                |
|---|---|---|---|-------------------------|
| 1 | 0 | 0 | 0 | Take a step clock wise  |
| 0 | 1 | 0 | 0 | another step clock wise |
| 0 | 0 | 1 | 0 | another step clock wise |
| 0 | 0 | 0 | 1 | another step clock wise |
| 0 | 0 | 0 | 1 | No step take            |
| 0 | 0 | 1 | 0 | Take a step back        |

Half Step Mode

By turning on two coils at the same time the motor will be in a position between them.


Figure 2.7.4. Half step mode

Table 2.7.2. Half Step Mode

| A | B | C | D | KOMENTAR                          |
|---|---|---|---|-----------------------------------|
| 1 | 0 | 0 | 0 | Take a step clock wise            |
| 1 | 1 | 0 | 0 | Half a step clock wise            |
| 0 | 1 | 0 | 0 | The complete full step clock wise |
| 0 | 1 | 1 | 0 | another half step clock wise      |
| 0 | 0 | 1 | 0 | The complete full step clock wise |
| 0 | 0 | 1 | 1 | Another half step clock wise      |
| 0 | 0 | 0 | 1 | The complete full step clock wise |
| 1 | 0 | 0 | 1 | another half step clock wise      |
| 1 | 0 | 0 | 0 | Start position                    |


Figure 8.3. Physical form of a 1.2" disk drive stepper motor

Experiment 8.1. Clockwise Rotation Motor Drive

In this experiment, the stepper motor will rotate clockwise, continuously. To do this experiment, do the following steps:

  1. Connect a parallel cable between P0 and the stepper motor.
  2. Connect the Microcontroller Trainer module to the +5V power supply.
  3. Connect the Microcontroller Trainer module to the programmer circuit 
  4. Open the M-IDE Studio for MCS-51 program, as a program editor and compiler.
  5. Type the following program: ( download file prog81a.asm )
    org 0h
    start: call StepCW
               sjmp start
               ;
    StepCW:
               mov P0,#11101111b ; Turn on driver 1
               call delay ; call delay time
               mov P0,#11011111b ; Turn on driver 2
               call delay ; call delay time
               mov P0,#10111111b ; Turn on driver 3
               call delay ; call delay time
               mov P0,#01111111b ; Turn on driver 4
               call delay ; call delay time
               ret
               ;
    StepCCW:
               mov P0,#01111111b ; Turn on driver 1
               call delay ; call delay time
               mov P0,#10111111b ; Turn on driver 2
               call delay ; call delay time
               mov P0,#11011111b ; Turn on driver 3
               call delay ; call delay time
               mov P0,#11101111b ; Turn on driver 4
               call delay ; call delay time
               ret
               ;
    delay: mov R0,#255
     delay1:mov R2,#255
               djnz R2,$
               djnz R0,delay1
               ret
               end
  6. Save the program you typed and name it: prog81a.asm
  7. In the MIDE program, select Build /F9 or to compile the program from *.asm to *.hex.
  8. Program the microcontroller using the ISP Software Program (See Instructions for Use)
  9. Observe the direction of rotation of the stepper motor, is it correct?
  10. Modify the program above, for counterclockwise CCW motor rotation.

Experiment 8.2 Controlling the Direction of Motor Rotation Using a Switch

In this experiment, the stepper motor will rotate clockwise or counterclockwise depending on the position of the push button that is pressed (P2.0 or P2.1) continuously.


Experiment 8.2 Controlling the Direction of Motor Rotation Using a Switch

To do this experiment, do the following steps:

  1. Connect a parallel cable between P0 and the stepper motor.
  2. Connect the Microcontroller Trainer module to the +5V power supply.
  3. Connect the Microcontroller Trainer module to the programmer circuit 
  4. Open the M-IDE Studio for MCS-51 program, as a program editor and compiler.
  5. Type the following program: ( download file prog82a.asm )
    org 0h
    start:
    CW: JB P2.0,CCW ; SW1
               call stepCW
               sjmp start
               ;
    CCW: JB P2.1,CW ;SW2
               Call stepCCW
               Sjmp start
               ;
    StepCW:
               mov P0,#11101111b ; Turn on driver 1
               call delay ; call delay time
               mov P0,#11011111b ; Turn on driver 2
               call delay ; call delay time
               mov P0,#10111111b ; Turn on driver 3
               call delay ; call delay time
               mov P0,#01111111b ; Turn on driver 4
               call delay ; call delay time
               ret
               ;
    StepCCW:
               mov P0,#01111111b ; Turn on driver 1
               call delay ; call delay time
               mov P0,#10111111b ; Turn on driver 2
               call delay ; call delay time
               mov P0,#11011111b ; Turn on driver 3
               call delay ; call delay time
               mov P0,#11101111b ; Turn on driver 4
               call delay ; call delay time
               ret
               ;
    delay: mov R0,#255
    delay1: mov R2,#255
               djnz R2,$
               djnz R0,delay1
               ret
               end
  6. Save the program you typed and name it: prog82a.asm
  7. In the MIDE program, select Build /F9 or to compile the program from *.asm to *.hex.
  8. Program the microcontroller using the ISP Software Program (See Instructions for Use)
  9. Observe the direction of rotation of the stepper motor, is it correct?
  10. Make modifications to the program above, another push button switch.

Post a Comment

Previous Next

نموذج الاتصال