Stepping Motor Control

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

MICROPROCESSOR BASED SYSTEMS (EE-222) Page 1

LAB MANUAL 18

Name
Roll No
Section
Marks

Stepping Motor Control

Stepping Motor Specification


The stepping motor is a device which can transfer the incoming pulses to stepping motion of a
predetermined angular displacement. By using suitable control circuity the angular displacement
can be made proportional to the number of pulses. Using microcomputer, one can have better
control of the angular displacement resolution and angular speed of a stepping motor. In the past
few years the stepping motor has improved in size reduction, speed and precision. Stepping motor
will have wider applications in the future.

Stepping motors are suitable for translating digital inputs into mechanical motion. In general, there
are three types of stepping motor:

1. VR( Variable Reluctance ) stepping motors


2. Hybrid stepping motors
3. PM( Permanent Magnet ) stepping motors

Motor type
PM VR Hybrid
Characteristics

Efficiency
High Low High
Rotor Inertia
High Low Low
Speed
High High Low
Torque
Fair Low High
Power O/P
High Low Low
Damping
Good Poor Poor
Typical Step Angle 1.8°,15°,30° 7.5°,15°,30° 0.18°,0.45°

Table 18.1. Stepping motor characteristics comparison

DEPARTMENT OF ELECTRICAL ENGINEERING UNIVERSITY OF GUJRAT


MICROPROCESSOR BASED SYSTEMS (EE-222) Page 2
LAB MANUAL 18

Figure 18-1 is used to explain the operation of simplified stepping motor (90°/step). Here the A coil
and B coil are perpendicular to each other. If either A or B coil is excited( a condition which is
known as single-phase excitation), the rotor can be moved to 0°, 90°, 180°, 270°degree position
depending on the current's ON/OFF conditions in the coils, see FIGURE 8-1(a). If both coils have
current flowing at the same time, then the rotor positions can be 45°, 135°, 225°, 315°degrees as
shown in FIGURE 8-1(b). This is known as two-phase exception. In FIGURE 8-1(c), the excitation
alternates between 1-phase and 2-phase, then the motor will rotates according to 0°, 45°, 90°, 135°,
180°, 225°, 270°, 315°sequence. This is 1-2 phase excitation, each step distance is only half of step
movement of either 1-phase or 2-phase excitation.

Stepping motor can rotate in clockwise or counter-clockwise direction depending on the current
pulse sequence applied to the excitation coils of the motor. Referring to the truth tables in FIGURE
8-1(a), (b), (c). If signals are applied to coil A and B according to Step 1,2,3,4,5,6,7,8, then counter-
clockwise movement is achieved. And vice-versa is true. If signals are applied according to step
8,7,6,5,4,3,2,1, then clockwise movement is achieved.

Commercial stepping motor uses multimotor rotor, the rotor features two bearlike PM cylinders
that are turned one-half of tooth spacing. One gear is south pole, the other gear is north pole. If a
50-tooth rotor gear is used, the following movement sequences will proceed.

A. Single-Phase Excitation:

The stepping position will be 0°,1.8°, 3.6°, ....... 358.2°, total 200 steps in one round.

B. Two-Phase Excitation:

The stepping positions will be 0.9°, 2.7°, 4.5°, ..... 359.1°, total 200 steps in one round.

C. Single-Phase And Two-Phase Excitations Combined:

The stepping positions will be 0°, 0.9°, 1.8°, 2.7°, 3.6°, 4.5°, ............... 358.2°, 359.1°, total 400 steps in
one round.

Since stepping motor makes step-by-step movement and each step is equidistant, the rotor and
stator magnetic field must be synchronous. During start-up and stopping, the two fields may not be
synchronous, so it is suggested to slowly accelerate and decelerate the stepping motor during the
start-up or stopping period.

DEPARTMENT OF ELECTRICAL ENGINEERING UNIVERSITY OF GUJRAT


MICROPROCESSOR BASED SYSTEMS (EE-222) Page 3
LAB MANUAL 18

FIGURE 8-1. Half-step and full-step rotation

DEPARTMENT OF ELECTRICAL ENGINEERING UNIVERSITY OF GUJRAT


MICROPROCESSOR BASED SYSTEMS (EE-222) Page 4
LAB MANUAL 18

Stepping Motor Interface

DEPARTMENT OF ELECTRICAL ENGINEERING UNIVERSITY OF GUJRAT


MICROPROCESSOR BASED SYSTEMS (EE-222) Page 5
LAB MANUAL 18

Stepping Motor Experiment

< Sample Program 8-1. Stepping Motor Control >

; FILENAME : STEPMO_1.ASM
; PROCESSOR : I8086

ADDRESS MACHINE CODE MNEMONIC


0000 CODE SEGMENT
ASSUME CS:CODE,DS:CODE,ES:CODE,SS:CODE
;
;
= 0001 KEY EQU 01H
= 0000 LCDC EQU 00H
= 0002 LCDC_ S EQU 02H
= 0004 LCDD EQU 04H
;
;
= 001F PPIC_C EQU 1FH
= 001D PPIC EQU 1DH
= 001B PPIB EQU 1BH
= 0019 PPIA EQU 19H
;
= 000B CTC1 EQU 0BH
= 000F CTCC EQU 0FH
;
= 0010 INTA EQU 10H
= 0012 INTA2 EQU INTA+2
;
= 0100 INT_V EQU 40H*4
;
1000 ORG 1000H
;
1000 33 DB XOR BX,BX
1002 8E C3 MOV ES,BX
1004 8E DB MOV DS,BX
;
1006 B8 11E7 R MOV AX,OFFSET INT_SER
1009 BB 0100 MOV BX,INT_V
100C 26: 89 07 MOV WORD PTR ES:[BX],AX
;
100F 33 C0 XOR AX,AX
1011 26: 89 47 02 MOV WORD PTR ES:[BX+2],AX
;
1015 E8 125B R CALL INIT
1018 E8 124B R CALL P_INIT

DEPARTMENT OF ELECTRICAL ENGINEERING UNIVERSITY OF GUJRAT


MICROPROCESSOR BASED SYSTEMS (EE-222) Page 6
LAB MANUAL 18

;
101B B0 80 MOV AL,10000000B
101D E6 1F OUT PPIC_C,AL
;
101F B0 FF MOV AL,11111111B
1021 E6 19 OUT PPIA,AL
1023 B0 00 MOV AL,00000000B
1025 E6 1D OUT PPIC,AL
;
1027 E8 126C R CALL ALLCLR
;
;
102A BE 11C5 R MOV SI,OFFSET DATA
102D E8 128A R CALL STRING
;
1030 E8 1271 R CALL LN21
1033 BE 11D6 R MOV SI,OFFSET DATA1
1036 E8 128A R CALL STRING
; CLEAR
1039 BB 0000 MOV BX,0
103C 89 1E 12B4 R MOV WORD PTR SPD_BUF,BX
1040 88 1E 12B1 R MOV BYTE PTR P_CONT,BL
1044 88 1E 12B2 R MOV BYTE PTR FULS_STR,BL
;
1048 E6 01 MAIN: OUT KEY,AL
104A FB STI
104B E8 129C R CALL SCAN
104E FA CLI
104F A0 12B0 R MOV AL,BYTE PTR K_BUF
;
1052 3C 00 CMP AL,0
1054 75 03 JNE MAIN1
1056 E9 1122 R JMP L_45
;
1059 3C 01 MAIN1: CMP AL,1
105B 74 23 JE R_45
;
105D 3C 02 MAIN2: CMP AL,2
105F 75 03 JNE MAIN3
1061 E9 114B R JMP L_90
;
1064 3C 03 MAIN3: CMP AL,3
1066 74 40 JE R_90
;
1068 3C 04 MAIN4: CMP AL,4
106A 75 03 JNE MAIN5

DEPARTMENT OF ELECTRICAL ENGINEERING UNIVERSITY OF GUJRAT


MICROPROCESSOR BASED SYSTEMS (EE-222) Page 7
LAB MANUAL 18

106C E9 1174 R JMP L_180


;
106F 3C 05 MAIN5: CMP AL,5
1071 74 5D JE R_180
;
1073 3C 06 MAIN6: CMP AL,6
1075 75 03 JNE MAIN7
1077 E9 119D R JMP L_REV
;
107A 3C 07 MAIN7: CMP AL,7
107C 74 7B JE R_REV
107E EB C8 JMP MAIN
;
;
1080 FA R_45: CLI
1081 B0 19 MOV AL,25
1083 A2 12B1 R MOV BYTE PTR P_CONT,AL
1086 32 C0 XOR AL,AL
1088 A2 12B3 R MOV BYTE PTR LR_FLAG,AL
;
108B E8 1271 R CALL LN21
108E BE 1097 R MOV SI,OFFSET R_45D
1091 E8 128A R CALL STRING
1094 FB STI
1095 EB B1 JMP MAIN
;
1097 52 69 67 68 74 20 R_45D: DB 'Right 45 degree!',00H
34 35 20 64 65 67
72 65 65 21 00
;
10A8 FA R_90:CLI
10A9 B0 32 MOV AL,50
10AB A2 12B1 R MOV BYTE PTR P_CONT,AL
10AE 32 C0 XOR AL,AL
10B0 A2 12B3 R MOV BYTE PTR LR_FLAG,AL
;
10B3 E8 1271 R CALL LN21
10B6 BE 10BF R MOV SI,OFFSET R_90D
10B9 E8 128A R CALL STRING
10BC FB STI
10BD EB 89 JMP MAIN
;
10BF 52 69 67 68 74 20 R_90D: DB 'Right 90 degree!',00H
39 30 20 64 65 67
72 65 65 21 00

DEPARTMENT OF ELECTRICAL ENGINEERING UNIVERSITY OF GUJRAT


MICROPROCESSOR BASED SYSTEMS (EE-222) Page 8
LAB MANUAL 18

;
10D0 FA R_180: CLI
10D1 B0 64 MOV AL,100
10D3 A2 12B1 R MOV BYTE PTR P_CONT,AL
10D6 32 C0 XOR AL,AL
10D8 A2 12B3 R MOV BYTE PTR LR_FLAG,AL
;
10DB E8 1271 R CALL LN21
10DE BE 10E8 R MOV SI,OFFSET R_180D
10E1 E8 128A R CALL STRING
10E4 FB STI
10E5 9 1048 R JMP MAIN
;
10E8 52 69 67 68 74 20 R_180D: DB 'Right 180 degree',00H
31 38 30 20 64 65
67 72 65 65 00
10F9 FA R_REV:CLI
10FA B0 FF MOV AL,0FFH
10FC A2 12B1 R MOV BYTE PTR P_CONT,AL
10FF 32 C0 XOR AL,AL
1101 A2 12B3 R MOV BYTE PTR LR_FLAG,AL
;
1104 E8 1271 R CALL LN21
;
1107 BE 1111 R MOV SI,OFFSET R_MSG
110A E8 128A R CALL STRING
110D B STI
110E E9 1048 R JMP MAIN
;
1111 52 69 67 68 74 20 R_MSG: DB 'Right Revolution',00H
52 65 76 6F 6C 75
74 69 6F 6E 00
;
;
1122 FA L_45: CLI
1123 B0 19 MOV AL,25
1125 A2 12B1 R MOV BYTE PTR P_CONT,AL
1128 B0 01 MOV AL,1
112A A2 12B3 R MOV BYTE PTR LR_FLAG,AL
;
112D E8 1271 R CALL LN21
1130 BE 113A R MOV SI,OFFSET L_45D
1133 E8 128A R CALL STRING
1136 FB STI
1137 E9 1048 R JMP MAIN
;

DEPARTMENT OF ELECTRICAL ENGINEERING UNIVERSITY OF GUJRAT


MICROPROCESSOR BASED SYSTEMS (EE-222) Page 9
LAB MANUAL 18

113A 4C 65 66 74 20 34 L_45D: DB 'Left 45 degree !',00H


35 20 64 65 67 72
65 65 20 21 00
;
114B FA L_90: CLI
114C B0 32 MOV AL,50
114E A2 12B1 R MOV BYTE PTR P_CONT,AL
1151 B0 01 MOV AL,1
1153 A2 12B3 R MOV BYTE PTR LR_FLAG,AL
;
1156 E8 1271 R CALL LN21
1159 BE 1163 R MOV SI,OFFSET L_90D
115C E8 128A R CALL STRING
115F FB STI
1160 E9 1048 R JMP MAIN
;
1163 4C 65 66 74 20 39 L_90D: DB 'Left 90 degree !',00H
30 20 64 65 67 72
65 65 20 21 00
;
1174 FA L_180: CLI
1175 B0 64 MOV AL,100
1177 A2 12B1 R MOV BYTE PTR P_CONT,AL
117A B0 01 MOV AL,1
117C A2 12B3 R MOV BYTE PTR LR_FLAG,AL
;
117F E8 1271 R CALL LN21
1182 BE 118C R MOV SI,OFFSET L_180D
1185 E8 128A R CALL STRING
1188 FB STI
1189 E9 1048 R JMP MAIN
;
118C 4C 65 66 74 20 31 L_180D: DB 'Left 180 degree!',00H
38 30 20 64 65 67
72 65 65 21 00
;
119D FA L_REV: CLI
119E B0FF MOV AL,0FFH
11A0 A2 12B1 R MOV BYTE PTR P_CONT,AL
11A3 B0 01 MOV AL,1
11A5 A2 12B3 R MOV BYTE PTR LR_FLAG,AL
;
11A8 E8 1271 R CALL LN21
;
11AB BE 11B5 R MOV SI,OFFSET L_MSG
11AE E8 128A R CALL STRING

DEPARTMENT OF ELECTRICAL ENGINEERING UNIVERSITY OF GUJRAT


MICROPROCESSOR BASED SYSTEMS (EE-222) Page 10
LAB MANUAL 18

11B1 FB STI
11B2 E9 1048 R JMP MAIN
;
11B5 4C 65 66 74 20 52 L_MSG: DB 'Left Revolution',00H
65 76 6F 6C 75 74
69 6F 6E 00
;
11C5 53 74 65 70 70 69 DATA DB 'Stepping Control',00H
6E 67 20 43 6F 6E
74 72 6F 6C 00
11D6 50 72 65 73 73 20 DATA1: DB 'Press 0 - 7 Key ',00H
30 20 2D 20 37 20
4B 65 79 20 00
;
11E7 50 INT_SER:PUSH AX
11E8 BE 12B1 R MOV SI,OFFSET P_CONT
11EB 2E: 8A 24 MOV AH,BYTE PTR CS:[SI]
11EE 0A E4 OR AH,AH
11F0 74 45 JZ OUT_INT
;
11F2 80 FC FF CMP AH,0FFH
11F5 74 03 JE CHK_RL
11F7 2E: FE 0C DEC BYTE PTR CS:[SI]
;
11FA A0 12B3 R CHK_RL: MOV AL,BYTE PTR LR_FLAG
11FD 3C 01 CMP AL,1
11FF 74 15 JE LEFT
;
1201 BF 12B2 R MOV DI,OFFSET FULS_STR
1204 2E: 8A 05 MOV AL,BYTE PTR CS:[DI]
1207 3C 04 CMP AL,4
1209 75 05 JNE STEP0
120B 32 C0 XOR AL,AL
120D 2E: 88 05 MOV BYTE PTR CS:[DI],AL
;
1210 2E: FE 05 STEP0: INC BYTE PTR CS:[DI]
1213 EB 13 90 JMP OUT_PULSE
;
1216 BF 12B2 R LEFT: MOV DI,OFFSET FULS_STR
1219 2E: 8A 05 MOV AL,BYTE PTR CS:[DI]
121C 3C FF CMP AL,-1
121E 75 05 JNE STEP1
1220 B0 04 MOV AL,4
1222 2E: 88 05 MOV BYTE PTR CS:[DI],AL
;
1225 2E: FE 0D STEP1:DEC BYTE PTR CS:[DI]

DEPARTMENT OF ELECTRICAL ENGINEERING UNIVERSITY OF GUJRAT


MICROPROCESSOR BASED SYSTEMS (EE-222) Page 11
LAB MANUAL 18

;
1228 OUT_PULSE:
1228 BE 1247 R MOV SI,OFFSET PULSE_TBL
122B 25 00FF AND AX,00FFH
122E 03 F0 ADD SI,AX
;
1230 2E: 8A 04 MOV AL,BYTE PTR CS:[SI]
1233 24 F0 AND AL,0F0H
1235 E6 1B OUT PPIB,AL
;
1237 OUT_INT:
1237 A1 12B4 R MOV AX,WORD PTR SPD_BUF
123A E6 0B OUT CTC1,AL
123C 8A C4 MOV AL,AH
123E E6 0B OUT CTC1,AL
;
1240 B0 20 MOV AL,00100000B
1242 E6 10 OUT INTA,AL
1244 FB STI
1245 58 POP AX
1246 CF IRET
;
1247 PULSE_TBL:
1247 66 DB 01100110B
1248 33 DB 00110011B
1249 99 DB 10011001B
124A CC DB 11001100B
;
124B P_INIT PROC NEAR
124B 50 PUSH AX
124C B0 70 MOV AL,01110000B
124E E6 0F OUT CTCC,AL
;
1250 A1 12B4 R P_INIT1: MOV AX,WORD PTR SPD_BUF
1253 E6 0B OUT CTC1,AL
1255 8A C4 MOV AL,AH
1257 E6 0B OUT CTC1,AL
1259 58 POP AX
125A C3 RET
125B P_INIT ENDP
;
125B INIT PROC NEAR
; ICW1
125B B0 13 MOV AL,00010011B
125D E6 10 OUT INTA,AL
;ICW2 interrupt vector

DEPARTMENT OF ELECTRICAL ENGINEERING UNIVERSITY OF GUJRAT


MICROPROCESSOR BASED SYSTEMS (EE-222) Page 12
LAB MANUAL 18

125F B0 40 MOV AL,40H


1261 E6 12 OUT INTA2,AL
;ICW4
1263 B0 01 MOV AL,00000001B
1265 E6 12 OUT INTA2,AL
;
1267 B0 FE MOV AL,11111110B
1269 E6 12 OUT INTA2,AL
126B C3 RET
126C INIT ENDP
;
126C B4 01 ALLCLR: MOV AH,01H
126E EB 03 90 JMP LNXX
;
1271 B4 C0 LN21: MOV AH,0C0H
;
1273 E8 127B R LNXX: CALL BUSY
1276 8A C4 MOV AL,AH
1278 E6 00 OUT LCDC,AL
127A C3 RET
;
127B E4 02 BUSY: IN AL,LCDC_S
127D 24 80 AND AL,10000000B
127F 75 FA JNZ BUSY
1281 C3 RET
;
; 1 char. LCD OUT
; AH = out data
1282 CHAROUT:
1282 E8 127B R CALL BUSY
;
1285 8A C4 MOV AL,AH
1287 E6 04 OUT LCDD,AL
1289 C3 RET
;
128A 2E: 8A 24 STRING: MOV AH,BYTE PTR CS:[SI]
128D 80 FC 00 CMP AH,00H
1290 74 09 JE STRING1
;
1292 E8 127B R CALL BUSY
1295 E8 1282 R CALL CHAROUT
1298 46 INC SI
1299 EB EF JMP STRING
129B STRING1:
129B C3 RET
;

DEPARTMENT OF ELECTRICAL ENGINEERING UNIVERSITY OF GUJRAT


MICROPROCESSOR BASED SYSTEMS (EE-222) Page 13
LAB MANUAL 18

129C E4 01 SCAN PROC NEAR


IN AL,KEY
129E A8 80 TEST AL,10000000B
12A0 75 FA JNZ SCAN
;
12A2 E6 01 AND AL,00000111B
12A4 A8 18 MOV BYTE PTR K_BUF,AL
;
12A6 75 F4 OUT KEY,AL
12A8 24 07 RET
12AA A2 12B0 R
12AD E6 01
12AF C3
;
SCAN ENDP
12B0 0001 K_BUF DB 1
12B1 0001 P_CONT: DB 1
12B2 0001 FULS_STR: DB 1
12B3 0001 LR_FLAG: DB 1
12B4 0002 SPD_BUF: DW 1
;
12B8 CODE ENDS
END

DEPARTMENT OF ELECTRICAL ENGINEERING UNIVERSITY OF GUJRAT

You might also like