5.3 Microprocessors III: 8085 Application Examples Dr. Tarek A. Tutunji Mechatronics Engineering Department Philadelphia University
5.3 Microprocessors III:
8085 Application Examples
Dr. Tarek A. TutunjiMechatronics Engineering Department
Philadelphia University
8085 Application Examples
In the previous sequence, 8085 architecture and instructions set were presented
In this presentation, we will use the 8085 for simple systems which will involve Switches, LED’s, and DC Motor
In each example, a schematic block diagram will be drawn and the assembly code will be provided
Example 1: LEDs
Example: Use the 8085 to turn on LEDs. The 8085 should be connected to eight LEDs at address 01H and the program should turn on LEDs 5,6, and 7
Solution: The 8-bit data lines are connected to the LEDs through an output latch addressed at 01H.
8085
+5V
Decoder
Latch ...
.
.
.
.
.
.
.
.
.
Address LinesA0 A7
Data LinesD0 D7
Control LinesIO/M, WR
D0
D1
D7
LED1
LED2
LED8
Enable
.
.
.
Clock
Example 1: LEDs
Data Bus: D7 D6 D5 D4 D3 D2 D1 D0LEDs: 8 7 6 5 4 3 2 1
Off On On On Off Off Off OffBits sent 0 1 1 1 0 0 0 0
Assembly Code
Mnemonic Machine Code
1000 MVI A,70H 3E % Accumulator A = 70H = 0111 00001001 701002 OUT 01H D3 % Send value in A to port 011003 011004 HLT
Example 2:
Switches & 7-segment DisplayExample: Design system using 8085 interfaced with 2
switches (address F0) and 7-segment display (address F6).
+5V
8085
+5V
Decoder
Latch ...
.
.
.
.
.
.
Address LinesA0 A7
Data LinesD0 D7
Control LinesIO/M, WR, RD
D0
D1
D7
A
B
DP
Enable
.
.
.
Clock
TriStateBuffer
Enable
D0
D1
+5VSW1
SW2
Example 2:
7-segment DisplayWrite an assembly code that continuously displays ‘0’
If switch 1 is closed, program should display ‘1’ and stop
If switch 2 is closed, program should display ‘2’ and stop
DP G F E D C B A
D7 D6 D5 D4 D3 D2 D1 D0
0 0 1 1 1 1 1 1 3F display ‘0’
0 0 0 0 0 1 1 0 06 display ‘1’
0 1 0 1 1 0 1 1 5B display ‘2’
Example 2. Assembly CodeLoop MVI A,3F % Accumulator A = 3F, to display ‘0’
OUT F6 % send result to display address F6IN F0 % Read switches at address F0ANI 01 % Mask with bit 0 first switchSUI 01 % Sub from 1 (i.e. check if closed)JZ xx % If result = 0 go to address xxIN F0 % Read switches at address F0ANI 02 % Mask with bit 1 second switchSUI 02 % Sub from 2 (i.e. check if closed)JZ yy % If result = 0 go to address yyJMP Loop % Jump back to Loop
xx MVI A, 06 % Accumulator A = 06, to display ‘1’OUT F6 % send result to display addressHLT % stop
yy MVI A, 5B % Accumulator A = 5B, to display ‘2’OUT F6HLT % stop
Example 3: DC Motor
Example: Design a mechatronics system that uses the 8085 and Pulse Width Modulation (PWM) to turn a DC Motor at a speed of 60 RPM. Use the following specifications:• Connect the motor with latch at address 88• Microprocessor clock is 4 MHz• Motor maximum speed is 300 RPM
8085
+5V
Decoder
Latch
Address LinesA0 A7
Data Lines, D0
Control LinesIO/M, WR
Enable
Clock
M
+Vcc
Example 3: PWM
Pulse Width Modulation (PWM) is a common method to control the speed of a DC motor
A power transistor (Q) working as a switch is connected to the motor• If Q is always ON Motor will turn at maximum speed
(assuming no load)
• If Q is sometimes ON Motor will turn at %timeON x max speed (i.e. speed = duty cycle x max speed)
In our example, 60 RPM/300 RPM = 0.2 write program to get duty cycle of 20%
Example 3. Assembly Code
Loop MVI A,00 % Bit0 off Q off
OUT 88 % motor address ‘88’MVI C,FF % C = (FF) H
Back1 DCR C % Decrement C by 1JNZ Back1 %Delay for time Q offMVI A,01 % Bit0 ON Q on
OUT 88MVI C, Count % C = (Count) H
Back2 DCR C % Decrement C by 1JNZ Back2 % Delay for time Q onJMP Loop
Time delay calculationsTime delay when Q off, (1/4 MHz) x (14 cycles) x 255 = 892.5 ms Total Time (on + off), T = 892.5/0.8 = 1115.6 msTime delay when Q on, 0.2(1115.6 ms)= (1/4 MHz) x (14 cycles) x N
N =64 Count = (40)H
Summary
Three applications for 8085 were presented
• LED
• Switches and 7-segment display
• DC Motor
For each exam, the block diagram and assembly code were provided