Microprocessor 8086 program File

Document Sample
Microprocessor 8086 program File Powered By Docstoc
					           MICROPROCESSOR
                BASED
          INSTRUMENTATION
                 LAB
                         USING


                         8086

SUBMITTED TO:                    SUBMITTED BY:
Mr. BHANU PARTAP SINGH           SALMAN KHAN
LECTURER                         ROLL NO. 10
                                 B. TECH 3RD YEAR




   INSTITUTE OF INSTRUMENTATION ENGINEERING
                  KURUKSHETRA
PROGRAM 1: COMPLETE 8086 INSTRUCTION SET


  1. Data Transfer Instructions
MOV Move byte or word to register or memory
IN, OUT Input byte or word from port, output word to port
LEA Load effective address
LDS, LES Load pointer using data segment, extra segment
PUSH, POP Push word onto stack, pop word off stack
XCHG Exchange byte or word
XLAT Translate byte using look-up table


  2. Logical Instructions
NOT Logical NOT of byte or word (one's complement)
AND Logical AND of byte or word
OR Logical OR of byte or word
XOR Logical exclusive-OR of byte or word
TEST Test byte or word (AND without storing)


  3. Shift and Rotate Instructions
SHL,   SHR   Logical shift left, right byte or word by 1 or CL
SAL,   SAR   Arithmetic shift left, right byte or word by 1 or CL
ROL,   ROR   Rotate left, right byte or word by 1 or CL
RCL,   RCR   Rotate left, right through carry byte or word by 1 or
CL


  4. Arithmetic Instructions
ADD, SUB Add, subtract byte or word
ADC, SBB Add, subtract byte or word and carry (borrow)
INC, DEC Increment, decrement byte or word
NEG Negate byte or word (two's complement)
CMP Compare byte or word (subtract without storing)
MUL, DIV Multiply, divide byte or word (unsigned)
IMUL, IDIV Integer multiply, divide byte or word (signed)
CBW, CWD Convert byte to word, word to double word (useful
before multiply/divide)

Adjustments after arithmetic operations:
AAA, AAS, AAM, AAD ASCII adjust for addition, subtraction,
multiplication, division (ASCII codes 30-39)
DAA, DAS Decimal adjust for addition, subtraction (binary
coded decimal numbers)
  5. Transfer Instructions
JMP Unconditional jump (short 127/8, near 32K, far between
segments)

Conditional jumps:
JA (JNBE) Jump if above (not below or equal) +127, -128 range
only
JAE (JNB) Jump if above or equal(not below) +127, -128 range
only
JB (JNAE) Jump if below (not above or equal) +127, -128 range
only
JBE (JNA) Jump if below or equal (not above) +127, -128 range
only
JE (JZ) Jump if equal (zero) +127, -128 range only
JG (JNLE) Jump if greater (not less or equal) +127, -128 range
only
JGE (JNL) Jump if greater or equal (not less) +127, -128 range
only
JL (JNGE) Jump if less (not greater nor equal) +127, -128
range only
JLE (JNG) Jump if less or equal (not greater) +127, -128 range
only
JC, JNC Jump if carry set, carry not set +127, -128 range only
JO, JNO Jump if overflow, no overflow +127, -128 range only
JS, JNS Jump if sign, no sign +127, -128 range only
JNP (JPO) Jump if no parity (parity odd) +127, -128 range only
JP (JPE) Jump if parity (parity even) +127, -128 range only

Loop control:
LOOP Loop unconditional, count in CX, short jump to target
address
LOOPE (LOOPZ) Loop if equal (zero), count in CX, short jump to
target address
LOOPNE (LOOPNZ) Loop if not equal (not zero), count in CX,
short jump to target address
JCXZ Jump if CX equals zero (used to skip code in loop)


  6. Subroutine and Interrupt Instructions
CALL, RET Call, return from procedure (inside or outside
current segment)
INT, INTO Software interrupt, interrupt if overflow
IRET Return from interrupt
  7. String Instructions
MOVS Move byte or word string
MOVSB, MOVSW Move byte, word string
CMPS Compare byte or word string
SCAS Scan byte or word string (comparing to A or AX)
LODS, STOS Load, store byte or word string to AL or AX

Repeat instructions (placed in front of other string
operations):
REP Repeat
REPE, REPZ Repeat while equal, zero
REPNE, REPNZ Repeat while not equal (zero)



  8. Processor Control Instructions
Flag manipulation:
STC, CLC, CMC Set, clear, complement carry flag
STD, CLD Set, clear direction flag
STI, CLI Set, clear interrupt enable flag
LAHF, SAHF Load AH from flags, store AH into flags
PUSHF, POPF Push flags onto stack, pop flags off stack

Coprocessor, multiprocessor interface:
ESC Escape to external processor interface
LOCK Lock bus during next instruction

Inactive states:
NOP No operation
WAIT Wait for TEST pin activity
HLT Halt processor
PROGRAM 2: - ARITHMETIC PROGRAMS USING 8086

 2.1.      PROGRAM TO ADD TWO 16-BIT NUMBERS

 2.2.      PROGRAM TO SUBTRACT TWO 16-BIT NUMBERS

 2.3.      PROGRAM TO MULTIPLY TWO 16-BIT NUMBERS

 2.4.      PROGRAM TO DIVIDE 32-BIT NUMBER BY A
           16-BIT NUMBER
====================================================================
               2.1. PROGRAM TO ADD TWO 16-BIT NUMBERS
====================================================================

MOV AX, 5000H
MOV DS, AX
MOV AX, 0000H
MOV SI, 2000H
MOV DI, 4000H
MOV   AX, [SI]
MOV   BX, [SI+2]
ADD   AX, BX
MOV   [DI], AX
MOV   AX, 0000H
ADC   AX, AX
MOV   [DI+2], AX

HLT
====================================================================

PROGRAM OUTPUT:
NUMBER1 = 8484H, NUMBER2 = 9595H

[5000:2000]   -->   84H
[5000:2001]   -->   84H
[5000:2002]   -->   95H
[5000:2003]   -->   95H
[5000:4000]   -->   19H
[5000:4001]   -->   1AH
[5000:4002]   -->   01H
[5000:4003]   -->   00H
RESULT NUMBER3 = 00011A19H

====================================================================
====================================================================
            2.2. PROGRAM TO SUBTRACT TWO 16-BIT NUMBERS
====================================================================

MOV AX, 5000H
MOV DS, AX
MOV AX, 0000H
MOV SI, 2000H
MOV DI, 4000H
MOV   AX, [SI]
MOV   BX, [SI+2]
SUB   AX, BX
MOV   [DI], AX

HLT
====================================================================

PROGRAM OUTPUT:
INPUT
NUMBER1 = 8765H, NUMBER2 = 1234H
[5000:2000]   -->   65H
[5000:2001]   -->   87H
[5000:2002]   -->   34H
[5000:2003]   -->   12H
OUTPUT
NUMBER3 = 7531H
[5000:4000] --> 31H
[5000:4001] --> 75H

====================================================================
====================================================================
            2.3. PROGRAM TO MULTIPLY TWO 16-BIT NUMBERS
====================================================================

MOV AX, 5000H
MOV DS, AX
MOV AX, 0000H
MOV SI, 2000H
MOV DI, 4000H
MOV AX, [SI]
MOV CX, [SI+2]
MUL CX
MOV [DI], AX
MOV [DI+2], DX
HLT
====================================================================

PROGRAM OUTPUT:
INPUT
NUMBER1 = 4545H, NUMBER2 = 7878H

[5000:2000]   -->   45H
[5000:2001]   -->   45H
[5000:2002]   -->   78H
[5000:2003]   -->   78H
OUTPUT
NUMBER3 = 2098D058H
[5000:4000]   -->   58H
[5000:4001]   -->   D0H
[5000:4002]   -->   98H
[5000:4003]   -->   20H

====================================================================
====================================================================
      2.4. PROGRAM TO DIVIDE 32-BIT NUMBER BY A 16-BIT NUMBER
====================================================================

MOV AX, 5000H
MOV DS, AX
MOV AX, 0000H
MOV SI, 2000H
MOV DI, 4000H
MOV   AX, [SI]
MOV   DX, [SI+2]
MOV   CX, [SI+4]
DIV   CX

MOV [DI], AX
MOV [DI+2], DX

HLT
====================================================================

PROGRAM OUTPUT:
INPUT
DIVIDEND = 12345678H, DIVISOR = 9ABCH
[5000:2000]   -->   78H
[5000:2001]   -->   56H
[5000:2002]   -->   34H
[5000:2003]   -->   12H
[5000:2004]   -->   BCH
[5000:2005]   -->   9AH
OUTPUT
QUOTIENT = 1E1EH, REMAINDER = 2C70H
[5000:4000]   -->   1EH
[5000:4001]   -->   1EH
[5000:4002]   -->   70H
[5000:4003]   -->   2CH

====================================================================
PROGRAM 3: - LOGICAL PROGRAMS USING 8086


   3.1.    PROGRAM TO PERFORM AND OPERATION ON TWO
           16-BIT NUMBERS

   3.2.    PROGRAM TO PERFORM OR OPERATION ON TWO
           16-BIT NUMBERS

   3.3.    PROGRAM TO PERFORM NOT OPERATION ON A
           16-BIT NUMBER
====================================================================
    3.1. PROGRAM TO PERFORM AND OPERATION ON TWO 16-BIT NUMBERS
====================================================================

MOV AX, 5000H
MOV DS, AX
MOV AX, 0000H
MOV SI, 2000H
MOV DI, 4000H
MOV AX, [SI]
MOV BX, [SI+2]
AND AX, BX
MOV [DI], AX
HLT

====================================================================

PROGRAM OUTPUT:
NUMBER1 = 1515H, NUMBER2 = 2626H
[5000:2000]   -->   15H
[5000:2001]   -->   15H
[5000:2002]   -->   26H
[5000:2003]   -->   26H
[5000:4000] --> 04H
[5000:4001] --> 04H
RESULT NUMBER3 = 0404H

====================================================================
====================================================================
     3.2. PROGRAM TO PERFORM OR OPERATION ON TWO 16-BIT NUMBERS
====================================================================

MOV AX, 5000H
MOV DS, AX
MOV AX, 0000H
MOV SI, 2000H
MOV DI, 4000H
MOV AX, [SI]
MOV BX, [SI+2]
OR AX, BX
MOV [DI], AX
HLT

====================================================================

PROGRAM OUTPUT:
INPUT
NUMBER1 = 1234H, NUMBER2 = 5678H
[5000:2000]   -->   34H
[5000:2001]   -->   12H
[5000:2002]   -->   78H
[5000:2003]   -->   56H
OUTPUT
NUMBER3 = 567CH
[5000:4000] --> 7CH
[5000:4001] --> 56H

====================================================================
====================================================================
      3.3. PROGRAM TO PERFORM NOT OPERATION ON A 16-BIT NUMBER
====================================================================

MOV AX, 5000H
MOV DS, AX
MOV AX, 0000H
MOV SI, 2000H
MOV DI, 4000H
MOV AX, [SI]
NOT AX
MOV [DI], AX

HLT
====================================================================

PROGRAM OUTPUT:
INPUT
NUMBER1 = 1234H
[5000:2000] --> 34H
[5000:2001] --> 12H
OUTPUT
NUMBER2 = EDCBH
[5000:4000] --> CBH
[5000:4001] --> EDH

====================================================================
PROGRAM 4: - DATA BLOCK MOVEMENT USING 8086
====================================================================
    PROGRAM FOR DATA BLOCK MOVEMENT FROM ONE LOCATION TO ANOTHER
====================================================================

MOV AX, 5000H
MOV DS, AX
MOV AX, 0000H
MOV SI, 2000H
MOV DI, 4000H
MOV AX, [SI]
MOV BX, [SI+2]
AND AX, BX
MOV [DI], AX
HLT

====================================================================

PROGRAM OUTPUT:
INPUT DATA BLOCK. 1ST LOCATION INDICATES HOW MANY DATA BYTES TO MOVE
[5000:2000]   -->   05H
[5000:2001]   -->   32H
[5000:2002]   -->   15H
[5000:2003]   -->   4FH
[5000:2004]   -->   6BH
[5000:2005]   -->   A5H
OUTPUT DATA BLOCK
[5000:4000]   -->   32H
[5000:4001]   -->   15H
[5000:4002]   -->   4FH
[5000:4003]   -->   6BH
[5000:4004]   -->   A5H

====================================================================
PROGRAM 5: - TO FIND LARGEST NUMBER USING 8086
====================================================================
     PROGRAM TO FIND THE LARGEST NUMBER FROM A GIVEN DATA ARRAY
====================================================================

MOV AX, 5000H
MOV DS, AX
MOV AX, 0000H
MOV SI, 2000H
MOV DI, 4000H
MOV CL, [SI]
INC SI
MOV AL, [SI]

BACK: INC SI
CMP AL, [SI]
JNC NEXT
MOV AL, [SI]
NEXT: LOOP BACK
MOV [DI], AL

HLT
====================================================================

PROGRAM OUTPUT:
INPUT
DATA ARRAY. 1ST LOCATION INDICATE HOW MANY BYTES OF DATA
[5000:2000]   -->   05H
[5000:2001]   -->   67H
[5000:2002]   -->   89H
[5000:2003]   -->   ABH
[5000:2004]   -->   CDH
[5000:2005]   -->   EFH
OUTPUT
LARGEST NUMBER = EFH
[5000:4000] --> EFH

====================================================================
PROGRAM 6:- To Interface Digital -to-Analog
converter to 8086 using 8255 and write
Assembly Language Program to generate Square
Wave, Ramp Wave, Triangular Wave, and
Staircase Waveform.
APPARATUS: - Microprocessor trainer kit, ADC kit,
power            supply, data cable, CRO etc
THEORY: -
The DAC 0800 is a monolithic 8 bit high speed current output
digital to analog converters featuring setting time of
100nSEC. It also features high compliance complementary
current outputs to allow differential output voltage of 20 Vp-
p with simple resistor load and it can be operated both in
unipolar and bipolar mode.

FEATURES: -
  1. Fast setting output current 100nS
  2. Full scale error +/- 1 LSB
  3. Complementary current outputs
  4. easy interface to all microprocessor
  5. Wide power supply range +/- 4.5 to +/- 18V
  6. low power consumption

WORKING: -
When chip select of DAC is enabled then DAC will convert
digital input value given through portliness PB0-PB7 to analog
value. The analog output from DAC is a current quantity. This
current is converted to voltage using OPAMP based current-to-
voltage converter. The voltage outputs (+/- 5V for bipolar 0
to 5V for unipolar mode) of OPAMP are connected to CRO to see
the wave form.


PROCEDURE: -
  1. Connect power supply 5V & GND to both microprocessor
     trainer kit & DAC interfacing kit.
  2. Connect data bus between microprocessor trainer kit & DAC
     interfacing kit.
  3. Enter the program to generate Ramp, Square, Triangular,
     and Staircase Wave.
  4. Execute the program.
  5. Observe the waveforms on CRO.
====================================================================
    6.1. PROGRAM FOR SQUARE WAVE GENERATOR WITH 8086 USING 8255
====================================================================

;CONTROL   ADDRESS   =   0FFC6H
;PORT A    ADDRESS   =   0FFC0H
;PORT B    ADDRESS   =   0FFC2H
;PORT C    ADDRESS   =   0FFC4H
START:
MOV AX, 5000H
MOV DS, AX
MOV AX, 0000H
MOV DX, 0FFC6H
MOV AL, 80H
OUT DX, AL
UP: MOV DX, 0FFC2H
MOV AL, 00H
CALL OUTPUT
MOV AL, 0FFH
CALL OUTPUT
JMP UP
OUTPUT:
OUT DX, AL
CALL DELAY
INT 21H
DELAY:
MOV CX, 0FFH
LOOP1: LOOP LOOP1
INT 21H
END START
====================================================================
====================================================================
     6.2. PROGRAM FOR RAMP WAVE GENERATOR WITH 8086 USING 8255
====================================================================

;CONTROL   ADDRESS   =   0FFC6H
;PORT A    ADDRESS   =   0FFC0H
;PORT B    ADDRESS   =   0FFC2H
;PORT C    ADDRESS   =   0FFC4H
START:
MOV AX, 5000H
MOV DS, AX
MOV AX, 0000H
MOV DX, 0FFC6H
MOV AL, 80H
OUT DX, AL
MOV BL, 0FFH
RAMP: MOV DX, 0FFC2H
MOV AL, BL
OUT DX, AL
DEC BL
JNZ RAMP
MOV BL, 0FFH
JMP RAMP
INT 03H
END START
====================================================================
====================================================================
  6.3. PROGRAM FOR TRIANGULAR WAVE GENERATOR WITH 8086 USING 8255
====================================================================

;CONTROL   ADDRESS   =   0FFC6H
;PORT A    ADDRESS   =   0FFC0H
;PORT B    ADDRESS   =   0FFC2H
;PORT C    ADDRESS   =   0FFC4H
START:
MOV AX, 5000H
MOV DS, AX
MOV AX, 0000H
MOV DX, 0FFC6H
MOV AL, 80H
OUT DX, AL
BEGIN:
MOV DX, 0FFC2H
MOV AL, 00H
UP: CALL OUTPUT
INC AL
CMP AL, 00H
JNZ UP
MOV AL, 0FFH
UP1: CALL OUTPUT
DEC AL
CMP AL. 0FFH
JNZ UP1
JMP BEGIN
OUTPUT:
OUT DX, AL
CALL DELAY
INT 21H
DELAY:
MOV CX, 10H
LOOP1: LOOP LOOP1
INT 21H

END START
====================================================================
====================================================================
   6.4. PROGRAM FOR STAIRCASE WAVE GENERATOR WITH 8086 USING 8255
====================================================================

;CONTROL   ADDRESS   =   0FFC6H
;PORT A    ADDRESS   =   0FFC0H
;PORT B    ADDRESS   =   0FFC2H
;PORT C    ADDRESS   =   0FFC4H
START:
MOV AX, 5000H
MOV DS, AX
MOV AX, 0000H
MOV DX, 0FFC6H
MOV AL, 80H
OUT DX, AL
UP: MOV DX, 0FFC2H
MOV AL, 00H
CALL OUTPUT
MOV AL, 0FFH
CALL OUTPUT
MOV AL, 07FH
CALL OUTPUT
JMP UP
OUTPUT:
OUT DX, AL
MOV CX, 0FFH
DELAY:
LOOP DELAY
INT 03H
END START
====================================================================
PROGRAM 7: - ARRANGING 10 BYTE DATA IN
ASCENDING          ORDER
====================================================================
        PROGRAM 7: ARRANGING 10 BYTE DATA IN ASCENDING ORDER
====================================================================
MOV AX, 5000H
MOV DS, AX
MOV AX, 0000H

MOV CL, 09H
START:
MOV SI, 2000H
MOV CH, 09H

BACK:
MOV AL, [SI]
INC SI
CMP AL, [SI]
JC SKIP
JZ SKIP
MOV DL, [SI]
MOV [SI], AL
DEC SI
MOV [SI], DL
INC SI
SKIP:
DEC CH
JNZ BACK
DEC CL
JNZ START
HLT
====================================================================

INPUT DATA ARRAY
[5000:2000]   -->   12H    [5000:2005]   -->   2CH
[5000:2001]   -->   65H    [5000:2006]   -->   64H
[5000:2002]   -->   78H    [5000:2007]   -->   9AH
[5000:2003]   -->   92H    [5000:2008]   -->   38H
[5000:2004]   -->   F6H    [5000:2009]   -->   A9H
OUTPUT DATA ARRAY
[5000:2000]   -->   12H    [5000:2005]   -->   78H
[5000:2001]   -->   2CH    [5000:2006]   -->   92H
[5000:2002]   -->   38H    [5000:2007]   -->   9AH
[5000:2003]   -->   64H    [5000:2008]   -->   A9H
[5000:2004]   -->   65H    [5000:2009]   -->   F6H

====================================================================
PROGRAM 8: - TO DEVELOP TRAFFIC LIGHT CONTROL
               SYSTEM USING 8086

APPARATUS: - Microprocessor trainer kit, Traffic
light                controller kit, power supply,
data cable

THEORY: -
Traffic light controller interface module is designed to
simulate the function of four way traffic light controller.
Combinations of red, yellow and green LED’s are provided to
indicate Halt, Wait and Go signals for vehicles. SEE FIG.

WORKING:-
8255 is interfaced with 8086 in I/O mapped I/O and all ports
are output ports. The basic operation of the interface is
explained with the help of the enclosed program.


PROCEDURE:-
1. Connect power supply 5V & GND
     to both microprocessor trainer
     kit & Traffic light controller
     interfacing kit.

2. Connect data bus between
     microprocessor trainer kit
     & Traffic light controller
     interfacing kit.

3. Enter the program to control
     Traffic light.

4. Execute the program by typing
     GO E000:0B80 ENTER.

5. Observe the LED’s on traffic
     light controller PCB.             PORT 4 (WORD – 16
BITS)
====================================================================
         PROGRAM 8: TRAFFIC LIGHT CONTROL SYSTEM USING 8086
====================================================================

; DATA SENT TO PORT[04H]
;               |
;               |
;     MSB       |         LSB
;     +---------------------+
;     | FEDC_BA98_7654_3210 |
;     +---------------------+
MOV AX, 0000_0010_0100_1001B    ; ALL_RED
OUT 04, AX
START:
MOV AX, 0000_0011_0000_1100B    ; NORTH SOUTH
OUT 04, AX
CALL DELAY
MOV AX, 0000_0011_0000_1100B
OUT 04, AX
CALL DELAY
MOV AX, 0000_0110_1001_1010B    ; ALL_WAIT
OUT 04, AX
CALL DELAY
MOV AX, 0000_1000_0110_0001B    ; WEST EAST
OUT 04, AX
CALL DELAY
MOV AX, 0000_1000_0110_0001B
OUT 04, AX
CALL DELAY
MOV AX, 0000_0100_1101_0011B    ; ALL_WAIT
OUT 04, AX
CALL DELAY
JMP START

DELAY:
MOV DX, 0098H         ;00989680H = 10,000,000D
L1:
MOV CX, 9680H         ; HENCE, 10 SEC DELAY
REPEAT: LOOP REPEAT   ; USING 1 MICROSECOND
DEC DL                ; CLOCK FREQUENCY
JNZ L1
RET
====================================================================
PROGRAM 9: - TO DEVELOP TEMPERATURE CONTROL
               SYSTEM USING 8086

APPARATUS: - Microprocessor trainer kit, Temperature
                 controller kit, power supply, data
cable

THEORY: -
Temperature control system involved interfacing successive
approximation ADC and typical method of measuring and
controlling the temperature using microprocessor. ADC is among
the most widely used devices for data acquisition. To enable
easy equivalence between the transducers O/P in volts and the
measured temperature a calibration procedure needs to be done.

PROGRAM 9. shows how to keep
constant temperature using heater
 and thermometer
(between 60° to 80°), it is
assumed that air temperature
is lower 60°.

WORKING: -
This program gets input
temperature from PORT 125, which
is the input port. Temperature is
 inputted in microprocessor
register AL in binary form with
the help of ADC converter. Here,
 calibration constant is taken as
 unity, to develop clear idea of
 program working.
The temp is then compared with the
 range at which the temperature is
 to be controlled. Here, this
range is 60 degree to 80 degree.
The microprocessor, then turn on
the heater, if the temp is below
60 degree and turn off the heater
 if temp is above 80 degree.
The whole procedure of input,
comparing, and output is repeated.
 Hence, we control the temperature
 of the system.
====================================================================
     PROGRAM 9. TO DEVELOP TEMPERATURE CONTROL SYSTEM USING 8086
====================================================================

; PORTS = 125, 127
MOV AX, CS
MOV DS, AX
START:
IN AL, 125D

CMP AL, 60D
JL LOW

CMP AL, 80D
JLE OK
JG HIGH
LOW:
MOV AL, 01H
OUT 127D, AL
JMP OK
HIGH:
MOV AL, 00H
OUT 127D, AL
OK:
JMP START
====================================================================
PROGRAM 10: - INTERFACING STEPPER MOTOR TO
8086 USING 8255

APPARATUS: - Microprocessor trainer kit, ADC kit,
power supply, data cable etc

THEORY: -
Stepper motor is a device used to obtain
an accurate position control of rotating
shafts. A stepper motor employs rotation
of its shaft in terms of steps. To
rotate the shaft of the stepper motor, a
sequence of pulses is needed to be
applied to the windings of the stepper
motor, in proper sequence. The numbers of
pulses required for complete rotation of
shaft of the stepper motor are equal to
number of internal teeth on its rotor.
The stator teeth and rotor teeth lock
with each other to fix a position of the
shaft. With a pulse applied to winding
input, the rotor rotates by one teeth
position or an angle x. the angle x may
be calculated as.
x = 3600 / no. of rotor teeth
after the rotation of the shaft through angle x, the rotor locks
itself with the next tooth in the sequence on the internal surface
of the stator. The typical schematic of a typical stepper motor with
four windings is as shown below.


WORKING: -
8255 is interfaced with 8086 in I/O
mapped I/O. port C (PC0, PC1, PC2, PC3)
is used to give pulse sequence to
stepper motor.
Output the sequence in correct order
to have the desired direction to
rotate the motor.


PROCEDURE: -
1. Connect power supply 5V & GND to both
microprocessor trainer kit & Stepper
motor interfacing kit.
2. Connect data bus between microprocessor trainer kit & Stepper
motor interfacing kit.
3. Enter the program to rotate Stepper motor in clockwise &
anticlockwise.
4. Execute the program.
5. Observe the rotation of stepper motor.
====================================================================
     PROGRAM 10.1. STEPPER MOTOR PROGRAM FOR CLOCKWISE ROTATION
====================================================================

;        PORTA   ADDRESS   0FFC0H
;        PORTB   ADDRESS   0FFC2H
;        PORTC   ADDRESS   0FFC4H
; CONTROL PORT   ADDRESS   0FFC6H
START:
MOV DX, 0FFC6H
MOV AL, 80H
OUT DX, AL
AGAIN:
MOV AL, 03H
MOV DX, 0FFC4H
OUT DX, AL
CALL DELAY
MOV AL, 06H
MOV DX, 0FFC4H
OUT DX, AL
CALL DELAY
MOV AL, 0CH
MOV DX, 0FFC4H
OUT DX, AL
CALL DELAY
MOV AL, 09H
MOV DX, 0FFC4H
OUT DX, AL
CALL DELAY
JMP AGAIN
DELAY:                 ; 1 SEC DELAY SUBROUTINE
MOV BX, 000FH          ; USING 1 MICROSEC CLOCK
L1: MOV CX, 4240H
L2: LOOP L2
DEC BX
JNZ L1
RET
====================================================================
====================================================================
  PROGRAM 10.1. STEPPER MOTOR PROGRAM FOR COUNTERCLOCKWISE ROTATION
====================================================================

;        PORTA   ADDRESS   0FFC0H
;        PORTB   ADDRESS   0FFC2H
;        PORTC   ADDRESS   0FFC4H
; CONTROL PORT   ADDRESS   0FFC6H
START:
MOV DX, 0FFC6H
MOV AL, 80H
OUT DX, AL
AGAIN:
MOV AL, 03H
MOV DX, 0FFC4H
OUT DX, AL
CALL DELAY
MOV AL, 09H
MOV DX, 0FFC4H
OUT DX, AL
CALL DELAY
MOV AL, 0CH
MOV DX, 0FFC4H
OUT DX, AL
CALL DELAY
MOV AL, 06H
MOV DX, 0FFC4H
OUT DX, AL
CALL DELAY
JMP AGAIN
DELAY:                 ; 1 SEC DELAY SUBROUTINE
MOV BX, 000FH          ; USING 1 MICROSEC CLOCK
L1: MOV CX, 4240H
L2: LOOP L2
DEC BX
JNZ L1
RET
====================================================================

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:6205
posted:2/27/2010
language:English
pages:28
Description: 8086 lab file 8086 programs