## Thursday, March 31, 2016

### 8051 Stepper Motor Interfacing

A stepper motor is a widely used device that translates electrical pulses into mechanical movement. Stepper motors commonly have a permanent magnet rotor (also called the shaft) surrounded by a stator. The most common stepper motors have four stator windings that are paired with a center-tapped common. 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. As the sequence of power is applied to each stator winding, the rotor will rotate. There are several widely used sequences where each has a different degree of precision. Following table shows 4-step sequence.

Step Winding A Winding B Winding C Winding D
1 1 0 0 1
2 1 1 0 0
3 0 1 1 0
4 0 0 1 1

It must be noted that although we can start with any of the sequences in Table, once we start we must continue in the proper order. For example, if we start with step 3 (0110), we must continue in the sequence of steps 4, 1,2, etc.

Step Angle Steps Per Revolution
0.72 500
1.8 200
2.0 180
2.5 144
5.0 72
7.5 48
15 24

The four leads of the stator winding are controlled by four bits of the 8051 port (P1.0 - P1.3). However, since the 8051 lacks sufficient current to drive the stepper motor windings, we must use a driver to energize the stator.

``` ORG 0H MOV A, #66H BACK:MOV P1, A RR A ACALL DELAY SJMP BACK DELAY: MOV R2, #100 H1:MOV R3, #255 H2:DJNZ R3, H2 DJNZ R2, H1 RET END ```

``` ;Rotate Motor based on switch status ORG 0H MAIN:SETB P2.7 MOV A, #66H MOV P1, A TURN:JNB P2.7, CW RR A ACALL DELAY MOV P1, A SJMP TURN CW:RL A ACALL DELAY MOV P1, A SJMP TURN DELAY:MOV R2, #100 H1:MOV R3, #255 H2:DJNZ R3, H2 DJNZ R2, H1 RET END ```

Related topics:
8051 External Program Memory Interfacing   |   8051 External Data Memory Interfacing   |   8051 Memory Mapped IO   |   8051 LED Interfacing   |   8051 Switch Interfacing   |   8051 Keyboard Interfacing   |   8051 7-Segment Display Interfacing   |   8051 LCD Interfacing   |   8051 ADC Interfacing   |   8051 DAC Interfacing   |   8051 Relay Interfacing   |   8051 Sensor Interfacing   |   8051 DC Motor Interfacing

List of topics: 8051