How to program stepper motor in microprocessor 8086 assembly language

How to Control stepper motor using Microprocessor 8086 by assembly language program? As we all know that stepper motor driver plays an important role in automatic control system.We can create a stepper motor controller using 8086 microprocessor and 8255 Programmable Peripheral Interface IC. Here is the assembly language program for 8086 microprocessor.

This stepper motor assembly language program is quite simple and easy. Here we had described the functions of each code for better understanding.
Basically this assembly program is a beginner guide to those who like to study 8086 programming.
Read Also: Check Prime number is Assembly language

8086 Microprocessor Assembly language

Notations used For representing different types of numbers

We are using some notations here.
B: – used to indicate Binary Number
H: – used to represent Hexa Decimal Number
CW used to represent Control Word register

You must know!

  • Stepper motor is interfaced to 8086 with the help of 8255 IC (Programmable Peripheral Interface).
  • 8255 has two modes of operation BSR (Bit Set Reset) mode & IO (Input Output) mode.
  • The mode is determined by the Control Word (CW) register; (here the CW address is 26).
  • Initialize the CW with (0000 0000)B=(00)H for BSR mode & (1000 0000)B=(80)H for IO mode
  • Stepper motor is IO device so CW should be (80)H There are 4 poles in a typical stepper motor A1, A2, B1, B2
  • Energize the poles for anticlockwise rotation we have to apply the following to the poles
8255 Progammable Periferal Interface

So we, out these set of values to the IO port of 8255

8086 assembly language programming code for beginners

The below program shows the interfacing of Stepper motor [cc lang=”C”]1000 MOV AL,80 /*Move 80(hex) to AL*/
1002 OUT 26,AL /*Move 80(Hex) to PPI, 26 is the CW of PPI*/
1004 MOV AL,0A /*Energizing the poles*/
1006 OUT 20,AL
1008 CALL 2000 /*Give some delay to rotate Motor*/
1010 MOV AL,06
1012 OUT 20,AL
1014 CALL 2000
1016 MOV AL,05
1018 OUT 20,AL
1020 CALL 2000
1022 MOV AL,09
1024 OUT 20,AL
1026 CALL 2000
1028 JMP 1004 /*Repeat the steps*/
1030 HLT
In the memory location 2000, we should give Delay program. You can choose any memory location other than 2000 as you like.

The delay Program is shown below [cc lang=”C”]2000 MOV BX,1000 /*Move a value to BX*/
2002 DEC BX /*Decrementing the value*/s
2004 MP BX,0000 /*Check whether the value reach 0000*/
2006 JNZ 2002 /*If not 0000, Decrement again*/
2008 RET /*Return to the Motor program*/[/cc]

7 thoughts on “How to program stepper motor in microprocessor 8086 assembly language

  1. Thanks a lot for the tutorial. I would however like to know if you have step by step tutorials on how to program the stepper motor in proteus with diagrams illustrating the connections and where you place the codes. I would also like to know how to connect more than one stepper motor to an 8086 through 8255 with each motor having a delay of 5s from the preceding motor. Thank you.

    • In robotics,CNC machines and many more machines where required amount of rotation of the motor is required rather than complete rotation.

Leave a Reply

Your email address will not be published. Required fields are marked *