Professional Documents
Culture Documents
MICROPROCESSOR/MICROCONTROLLER-BASED
INDUSTRIAL PRODUCTION
TOPICS INCLUDED:
INTRODUCTION TO STEPPER MOTORS &
ROTATION SEQUENCES
INTERFACING AND ISOLATING CIRCUITRY
INDUSTRIAL APPLICATIONS
EXPERIMENTS
EXERCISES
INTRODUCTION TO STEPPER MOTORS:
The stepping motor is a device which can transfer the incoming pulses to stepping motion
of a predetermined angular displacement. By using suitable control circuitry 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 already have and will continue to have wide
applications in industry.
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
Figure 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 currents ON/OFF conditions in the coils
(Figure 8-1(a)).
Figure 1. Rotation Sequences
(a) 1-phase excitation
A B A B
Step 1 1 0 0 0
2 0 1 0 0
3 0 0 1 0
4 0 0 0 1
5 1 0 0 0
6 0 1 0 0
7 0 0 1 0
8 0 0 0 1
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 1(b). This is known as two-phase exception.
In figure 1(c), the excitation alternates between 1-phase and 2-phase, then the motor will
rotate 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.
Commercial stepping motor uses multimotor rotor, the rotor features two gearlike 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 sequence 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 position 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 position 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 fields 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.
The 8255 IC#1 on the MDA-8086 is connected via its port B upper nibble to the stepper
motor interface. This part is the digital communication interface for any peripherals.
The connections shown in Figure 3 are for unipolar-type stepper motors, we can
externally modify this circuit to drive bipolar stepper motors too. This interfacing circuit
is shown below in Figure 4.
For isolation, we used optocouplers so that the boards circuitry does not get damaged.
Figure 4. External interface connected to Kits motor outlet (pin 1, 3, 4, 6 for data and pin 2 for
supply) for a bipolar stepper motor.
The coil schematic of a bipolar stepper motor is shown below:
However, commercial motors have more than two teeth, and they turn by steps of
typically 1.8 instead of 90.
INDUSTRIAL APPLICATIONS:
Robotic Arm. In a motor-car assembly industry, robotic arms are constructed with stepper
motors. We can use 3 motors to move the arm along 3 axes. Programs are written with
particular number of steps and the time for turning for each direction movement stored in
the memory. Time delay has to be accurately calculated, otherwise, after a long time has
passed, the arm will lag behind the assemblage line by a large amount of time.
Satellite or Solar Tracking. A satellite or solar tracking device may be made with
stepper motors moving the shafts of an antenna or a solar panel. According to measured
signal or light intensity, the microcomputer will decide if to turn the panel/antenna in a
certain direction, and if so, by how many steps.
EXPERIMENTS:
Bipolar Motors:
Connect the external interface to the MDA-8086 board, turn it on from the external
power supply and execute the following programs.
1. This program rotates the stepper motor in a given direction with a given speed,
which are defined in the program.
CODE SEGMENT
ASSUME CS:CODE,DS:CODE,ES:CODE,SS:CODE
;
PPIC_C EQU 1FH
PPIC EQU 1DH
PPIB EQU 1BH
PPIA EQU 19H
;
ORG 1000H
;
;
MOV AL,10000000B
OUT PPIC_C,AL
;
MOV AL,11111111B
OUT PPIA,AL
MOV AL,00000000B
OUT PPIC,AL
ROL AL,1
;ROR AL,1 ;REMOVE ; FROM THIS LINE AND
; PUT ON PREVIOUS LINE
;FOR REVERSING DIRECTION
CALL TIMER
JMP L3
;
TIMER: MOV CX,3 ;CHANGE CX VALUE TO
CONTROL
;SPEED
TIMER2: PUSH CX
MOV CX,0ffh ;CHANGE CX VALUE TO ADJUST
;SPEED
TIMER1: NOP
NOP
NOP
NOP
LOOP TIMER1
POP CX
LOOP TIMER2
RET
;
CODE ENDS
END
2. This program also rotates the stepper motor in a given direction with a given
speed, which are defined in the program. We can modify the data table, to make
the stepper motor move in one direction first, then in the opposite direction.
CODE SEGMENT
ASSUME CS:CODE,DS:CODE,ES:CODE,SS:CODE
;
PPIC_C EQU 1FH
PPIC EQU 1DH
PPIB EQU 1BH
PPIA EQU 19H
;
ORG 1000H
;
;
MOV AL,10000000B
OUT PPIC_C,AL
;
MOV AL,11111111B
OUT PPIA,AL
MOV AL,00000000B
OUT PPIC,AL
ROT: DB 11101110B
DB 10111011B
DB 11011101B
DB 01110111B
DB 0FFH
;
CODE ENDS
END
3. This program checks key input from the key matrix, and according to the key
pressed, increases/decreases its speed accordingly. If no key is pressed, it moves
with the least speed, by default. We can modify it not to run at all.
;PROGRAM FOR CONTROLLING A UNIPOLAR STEPPER MOTOR
;(CAN BE MODIFIED FOR BIPOLAR STEPPER MOTOR)
;(SEPARATE INTERFACE CIRCUITRY IS USED DURING
;EXPERIMENTATION)
;DECREASE THE SPEED OF THE STEPPER MOTOR
;BY KEEPING ANY LOWER NUMBER KEY ON THE KEYPAD
;INCREASE THE SPEED OF THE STEPPER MOTOR
;BY KEEPING ANY HIGHER NUMBER KEY ON THE KEYPAD
;CHANGE THE CX VALUES TO ADJUST YOUR OWN SPEEDS
CODE SEGMENT
ASSUME CS:CODE,DS:CODE,ES:CODE,SS:CODE
;
PPIC_C EQU 1FH
PPIC EQU 1DH
PPIB EQU 1BH
PPIA EQU 19H
KEY EQU 01H
;
ORG 1000H
;
MOV AL,10000000B
OUT PPIC_C,AL
;
MOV AL,11111111B
OUT PPIA,AL
MOV AL,00000000B
OUT PPIC,AL
MOV AL,80H
OUT KEY,AL
CMP AL,80H
JE NONE
CMP AL,40H
JE ZERO
CMP AL,41H
JE ONE
CMP AL,42H
JE TWO
CMP AL,43H
JE THREE
CMP AL,44H
JE FOUR
CMP AL,45H
JE FIVE
CMP AL,46H
JE SIX
CMP AL,47H
JE SEVEN
CMP AL,48H
JE EIGHT
CMP AL,49H
JE NINE
RET
;
CODE ENDS
END
Unipolar Motors:
Connect a unipolar motor to the board interface (we will not perform this experiment,
because if boards driver circuitry gets burned, it is very difficult to replace them).
4. This program rotates the stepper motor in a given direction with a given speed,
which are defined in the program.
CODE SEGMENT
ASSUME CS:CODE,DS:CODE,ES:CODE,SS:CODE
;
PPIC_C EQU 1FH
PPIC EQU 1DH
PPIB EQU 1BH
PPIA EQU 19H
;
ORG 1000H
;
MOV AX,0
MOV DS,AX
;
MOV AL,10000000B
OUT PPIC_C,AL
;
MOV AL,11111111B
OUT PPIA,AL
MOV AL,00000000B
OUT PPIC,AL
;
MOV AL,11101110B
L1: OUT PPIB,AL
CALL TIMER
ROL AL,1
JMP L1
;
TIMER: MOV CX,0FFH
PUSH CX
TIM: MOV CX,2H
TIMER1: NOP
NOP
NOP
NOP
LOOP TIMER1
POP CX
LOOP TIM
RET
;
CODE ENDS
END
5. This program rotates the stepper motor with corresponding key inputs from the
kits key matrix, and also shows on the LCD how many degrees the motor rotated
in which direction.
CODE SEGMENT
ASSUME CS:CODE,DS:CODE,ES:CODE,SS:CODE
;
;
KEY EQU 01H
LCDC EQU 00H
LCDC_S EQU 02H
LCDD EQU 04H
;
;
PPIC_C EQU 1FH
PPIC EQU 1DH
PPIB EQU 1BH
PPIA EQU 19H
;
CTC1 EQU 0BH
CTCC EQU 0FH
;
INTA EQU 10H
INTA2 EQU INTA+2
;
INT_V EQU 40H*4
;
ORG 1000H
;
XOR BX,BX
MOV ES,BX
MOV DS,BX
;
MOV AX,OFFSET INT_SER
MOV BX,INT_V
MOV WORD PTR ES:[BX],AX
;
XOR AX,AX
MOV WORD PTR ES:[BX+2],AX
;
CALL INIT
CALL P_INIT
;
MOV AL,10000000B
OUT PPIC_C,AL
;
MOV AL,11111111B
OUT PPIA,AL
MOV AL,00000000B
OUT PPIC,AL
;
CALL ALLCLR
;
;
MOV SI,OFFSET DATA
CALL STRING
;
CALL LN21
MOV SI,OFFSET DATA1
CALL STRING
; CLEAR
MOV BX,0
MOV WORD PTR SPD_BUF,BX
MOV BYTE PTR P_CONT,BL
MOV BYTE PTR FULS_STR,BL
;
MAIN: OUT KEY,AL
STI
CALL SCAN
MOV AL,BYTE PTR K_BUF
;
CMP AL,0
JNE MAIN1
JMP L_45
;
MAIN1: CMP AL,1
JNE MAIN2
JMP R_45
;
MAIN2: CMP AL,2
JNE MAIN3
JMP L_90
;
MAIN3: CMP AL,3
JNE MAIN4
JMP R_90
;
MAIN4: CMP AL,4
JNE MAIN5
JMP L_180
;
MAIN5: CMP AL,5
JNE MAIN6
JMP R_180
;
MAIN6: CMP AL,6
JNE MAIN7
JMP L_REV
;
MAIN7: CMP AL,7
JNE MAIN
JMP R_REV
;
;
R_45: CLI
MOV AL,25
MOV BYTE PTR P_CONT,AL
XOR AL,AL
MOV BYTE PTR LR_FLAG,AL
;
CALL LN21
MOV SI,OFFSET R_45D
CALL STRING
STI
JMP MAIN
;
R_45D: DB 'Right 45 degree!',00H
;
R_90: CLI
MOV AL,50
MOV BYTE PTR P_CONT,AL
XOR AL,AL
MOV BYTE PTR LR_FLAG,AL
;
CALL LN21
MOV SI,OFFSET R_90D
CALL STRING
STI
JMP MAIN
;
R_90D: DB 'Right 90 degree!',00H
;
R_180: CLI
MOV AL,100
MOV BYTE PTR P_CONT,AL
XOR AL,AL
MOV BYTE PTR LR_FLAG,AL
;
CALL LN21
MOV SI,OFFSET R_180D
CALL STRING
STI
JMP MAIN
;
R_180D: DB 'Right 180 degree',00H
R_REV: CLI
MOV AL,0FFH
MOV BYTE PTR P_CONT,AL
XOR AL,AL
MOV BYTE PTR LR_FLAG,AL
;
CALL LN21
;
MOV SI,OFFSET R_MSG
CALL STRING
STI
JMP MAIN
;
R_MSG: DB 'Right Revolution',00H
;
;
L_45: CLI
MOV AL,25
MOV BYTE PTR P_CONT,AL
MOV AL,1
MOV BYTE PTR LR_FLAG,AL
;
CALL LN21
MOV SI,OFFSET L_45D
CALL STRING
STI
JMP MAIN
;
L_45D: DB 'Left 45 degree !',00H
;
L_90: CLI
MOV AL,50
MOV BYTE PTR P_CONT,AL
MOV AL,1
MOV BYTE PTR LR_FLAG,AL
;
CALL LN21
MOV SI,OFFSET L_90D
CALL STRING
STI
JMP MAIN
;
L_90D: DB 'Left 90 degree !',00H
;
L_180: CLI
MOV AL,100
MOV BYTE PTR P_CONT,AL
MOV AL,1
MOV BYTE PTR LR_FLAG,AL
;
CALL LN21
MOV SI,OFFSET L_180D
CALL STRING
STI
JMP MAIN
;
L_180D: DB 'Left 180 degree!',00H
;
L_REV: CLI
MOV AL,0FFH
MOV BYTE PTR P_CONT,AL
MOV AL,1
MOV BYTE PTR LR_FLAG,AL
;
CALL LN21
;
MOV SI,OFFSET L_MSG
CALL STRING
STI
JMP MAIN
;
L_MSG: DB 'Left Revolution',00H
;
DATA DB 'Stepping Control',00H
DATA1: DB 'Press 0 - 7 Key ',00H
;