Write an assembly language program to interface stepper motor with 8085.
Apparatus:8085 microprocessor kit.
Stepper motor Interfacing/Control using 8085
Stepper MotorA stepper motor is a device that translates electrical pulses into mechanical movement in steps of fixed step angle.
Operation The important parameter of a stepper motor is the step angle. It is the minimum angle through which the motor rotates in response to each excitation pulse. In a four phase motor if there are 200 steps in one complete rotation then then the step angle is 360/200 = 1.8O . So to rotate the stepper motor we have to apply the excitation pulse. For this the controller should send a hexa decimal code through one of its ports. The hex code mainly depends on the construction of the stepper motor. So, all the stepper motors do not have the same Hex code for their rotation.
The flow graph for the process of interfacing is shown as below:
Locate 26 pin connector J3 on DYNA-85LU kit. All the lines of the 8255 PIO are brought out on this connector.
The PIO cards are interfaced through 26 pin FRC flat cable.
a. Copy the program from the specified RAM location as: DYNA-85> C 4700 49FF C000 Enter
b. Enter the program given as below:
Program:The assembly program, when executed will display the message “Stepper mode (0 or 1)”. If 0 is given, the motor will run continuously and if 1 is given, the motor will run for a specified no. of steps, direction and speed.
0 Continuous Mode:In this mode, motor will run continuously at the maximum speed and in the clockwise direction. To stop it, Press ESC key.
1 Step Mode:The program will display message „stepper mode (0 or 1)‟. Enter 1 to switch to step mode. Then the program will display „rP (0 or 1)‟ asking for the Rotational pattern. Here 0 is for clockwise direction and 1 is for anti-clockwise direction. Then „steps‟ will be displayed asking the user to enter the no. of steps (0000-FFFF). Then it will display „Speed‟, asking for the speed (00-FF). After entering the value of rotational motion, steps and speed, the motor will run at the defined rotational motion, no. of steps and speed, and them it will stop. In the program „cts‟ routine controls the motor in continuous Mode and „step‟ routine controls the motor in continuous mode and „step‟ routine controls the Motor in Continuous Mode and „step‟ routine controls the motor in clockwise direction and „anti‟ routine runs it in anticlockwise direction. To display all the different messages corresponding ASCII codes for each message is stored in the lookup table. The program is given below:
Program:
Address | Opcode | Location | Command | Remark |
C000 | 21 00 C1 | MVI A, 80 | 80H → Control word to configure 8255 PA,PB,PC in O/P mode | |
C003 | CD 44 18 | Out | Write control word in CWR of 8255 | |
C006 | CD 1f06 | Up | CWR_Address | Code for the Phase 1 |
C009 | 79 | Out | sent to motor via port A of 8255 | |
C00A | FE 30 | Call Delay | Delay Subroutine | |
C00C | CA 94 C0 | MVI A, BB | Code for the Phase II | |
C00F | FE 31 | Out | Sent to motor via port A of 8255 | |
C011 | CA IC C0 | Call Delay | Delay Subroutine | |
C014 | FE 1B | MVI A, DD | Code for the Phase III | |
C016 | C2 06 C0 | Out | sent to motor via port A of 8255 | |
C019 | CD C4 0F | Call Delay | Delay Subroutine | |
C01C | 21 80 1C | MVI A, EE H | Code for the Phase 1 | |
C01F | CD 44 18 | Out | sent to motor via port A of 8255 | |
C022 | CD 26 06 | Call Delay | Delay subroutine | |
C025 | 79 | JMP up | Keep the motor rotating continuously | |
C029 | 78 | MVI C, FF | Load C with FF -- Change it for the | |
C02A | 32 31 C2 | LOOP1: MVI | speed variation | |
C02D | 21 40 C1 | LOOP2: DCR D | Decrement D | |
C030 | CD 44 18 | JNZ LOOP2 | Continue decrementing till D=0 | |
C033 | CD 26 06 | DCR C | Decrement C | |
C036 | 79 | JNZ LOOP1 | Continue decrementing till C=0 | |
C037 | 32 32 C2 | RET | Return to main program |
Result:
Continuous Mode:Motor will run continuously at the maximum speed and in the clockwise direction
Step Mode:2. The user will be asked to choose the rotation pattern as „rP (0 or 1)‟. Press „0‟ for Clock-wise or „1‟ for anti-clockwise rotation.
Viva Questions:
Get all latest content delivered to your email a few times a month.