Microprocessor Based Systems Lab Manualfinal

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 101

FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

MICROPROCESSOR BASED SYSTEMS

LABORATORY MANUAL

Complied and Tested By:

Engr.Muhammad Khalid

Engr.Hamid Saeed Khan

Engr. M. Daud Abbasi

IQRA University, Main Campus, Karachi


FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

STUDENT INFORMATION

Name: _______________________________________________________

Registration No: _______________________________________________

Semester: ____________________________________________________

Program: __________________________________________________

IQRA University, Main Campus, Karachi


FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

List of Experiments
Lab Experiments Remarks Mapping
No.
1. Familiarization with the Organization and the Operating CLO1,
Procedures of the MDA-8086 Trainer PLO2-9
Using 8255A Chip to Interface LED with 8088 microprocessor CLO1,
2. using MDA-8086 Trainer PLO2-9
3. Using 8255A Chip to Interface 7 segment display with 8088 CLO1,
microprocessor using MDA-8086 Trainer PLO2-9
4. Using 8255A Chip to Interface Dot Matrix display with 8088 CLO1,
microprocessor using MDA-8086 Trainer PLO2-9
5. Interfacing Speaker with 8088 microprocessor using MDA-8086 CLO1,
Trainer PLO2-9
6. Interfacing Hex Keyboard with microprocessor using MDA-8086 CLO1,
Trainer PLO2-9
7. Interfacing and programming 16 × 2 Line LCD Module with 8088 CLO1,
microprocessor using MDA-8086 Trainer PLO2-9
8. (Open Ended LAB) CLO1,
PLO2-9
9. Interfacing and Driving Stepper Motor with 8088 microprocessor using CLO1,
MDA-8086 Trainer PLO2-9
10. Interfacing DAC0800 with 8088 microprocessor using MDA-8086 CLO1,
Trainer PLO2-9
11. Interfacing ADC-0804 with 8088 microprocessor using MDA- CLO1,
8086 Trainer PLO2-9
12. Write a program to control fringing angle of SCR to manage input voltage CLO1,
to a tungsten lamp using MDA-8086 Trainer PLO2-9
13. Write a program to control Elevator movement using MDA-8086 CLO1,
Trainer PLO2-9
14. Write a program in Assembly language given that if user press “1”
LEDs from 11 to 14 glow sequentially similarly when user press
CLO1,
“2” hex value of 0 to F should be display on 7-segment display
PLO2-9
while for any keyboard hit microprocessor will remain in no
operation mode.
15. Write a program in Assembly language given that if user presses
“1” “IQRA UNIVERITY” should be displayed on first line of
CLO1,
LCD similarly when user press “2” “KARACHI” should be
PLO2-9
display on second line of LCD while for any keyboard hit
microprocessor will remain in no operation mode.
16. (Open Ended LAB) CLO1,
PLO2-9

IQRA University, Main Campus, Karachi


FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

Rubric for Assessment

Exceeds Meets
Developing Unsatisfactory
Criteria Expectations Expectations
(50%-69%) (<50%)
(>=90%) (70%-89%)
Able to setup Able to setup
experiment experiment Can setup major
Can’t set up the
Experimental independently with independently part of the
experiment even
Setup complete with adequate experiment with
with assistance
understanding of understanding of assistance
each step each step
Able to follow
the procedure Able to follow
Able to follow
completely with major part of the Unable to follow
Procedure the procedure
simplification or procedure with the procedure
completely
develop alternate errors or omissions
procedure
Able to achieve
all the desired Able to achieve
Able to achieve
Experimental results with most of the Unable to achieve
all the desired
Results alternate ways to desired results the desired results
results
improve with errors
measurements
All sections of the
All sections of the All sections of the
report are very Few sections of
Laboratory report are report contain
well written and the report contain
Manual technically multiple technical
technically technical errors.
accurate. errors.
accurate.

IQRA University, Main Campus, Karachi


FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

Lab # Score Allocation


Experimental Procedure: Experimental Laboratory Score:
Setup: Results: Manual:

1 (___) /3 (___) /2 (___) /3: (___) /2 (___) /10

2 (___) /3 (___) /2 (___) /3: (___) /2 (___) /10

3 (___) /3 (___) /2 (___) /3: (___) /2 (___) /10

4 (___) /3 (___) /2 (___) /3: (___) /2 (___) /10

5 (___) /3 (___) /2 (___) /3: (___) /2 (___) /10

6 (___) /3 (___) /2 (___) /3: (___) /2 (___) /10

7 (___) /3 (___) /2 (___) /3: (___) /2 (___) /10

8 (___) /3 (___) /2 (___) /3: (___) /2 (___) /10

9 (___) /3 (___) /2 (___) /3: (___) /2 (___) /10

10 (___) /3 (___) /2 (___) /3: (___) /2 (___) /10

11 (___) /3 (___) /2 (___) /3: (___) /2 (___) /10

12 (___) /3 (___) /2 (___) /3: (___) /2 (___) /10

13 (___) /3 (___) /2 (___) /3: (___) /2 (___) /10

14 (___) /3 (___) /2 (___) /3: (___) /2 (___) /10

15 (___) /3 (___) /2 (___) /3: (___) /2 (___) /10

16 (___) /3 (___) /2 (___) /3: (___) /2 (___) /10

Total Obtained Score (___)160

Formula= (Total Obtained Score / 160) x 15 Examined by: _________________


Score: ___________ out of 15 (Signature of Instructor)

IQRA University, Main Campus, Karachi


FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

Instructor:

Prerequisites: Electronic Devices and Circuit Theory

Objectives:
The goals of the Microprocessor Systems laboratory are;
1. To allow the students to perform experiments that explain the assembly language programming and demonstrate the
working with emu8086.
2. To introduce the students to 8086 microprocessor and its essential circuitry.
3. To familiarize the students with interfacing of 8086 microprocessor with several I/O devices.

Contents:
Assembly language programming, emu8086, 8086 microprocessor and its essential circuitry, with interfacing of 8086
microprocessor with several I/O devices.
Learning Outcomes:

Course Learning Outcomes (CLOs)


*BT
CLOs Domain PLOs
Level
CLO-1:  Implement, Assemble and Manipulate Assembly language code
PLO-2
to have in depth understanding of microprocessor architecture, P P4
PLO-9
programming and peripherals.
*BT = Bloom’s Taxonomy          P= Psychomotor          PLO = Program Learning Outcome

CLO Assessment Mechanism


Assessment tools CLO_1
Lab Manual+ Lab Performance 15%
Project 10%
Midterm Exam 25%
Final Exam 50%

Grading Policy
Marks *GPA Grade
Greater than 88 4 A
Between 81 to 87 3.5 B+
Between 74 to 80 3 B
Between 67 to 73 2.5 C+
Between 60 to 66 2 C
Below 60 0 F
*GPA = Grade Point Average

IQRA University, Main Campus, Karachi


FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

General Laboratory Procedure


While there is no specific document to be submitted at the beginning of the Lab –unless your instructor
advises you otherwise-, you are expected to read the experiment fully before you come to the laboratory?
Interestingly, you can even try parts of the experiment at home. Here is a list of programs that will equip you
with a virtual lab at your home:
Troubleshooting
Things will not always go as expected; this is the nature of the learning process. While conducting the
Experiment think before you do anything. If you do so you will avoid wasting time going down dead-end
streets. Be logical and systematic. First, look for obvious errors that are easy to fix. Is your measuring device
correctly set and connected? Are you looking at the proper scale? Is the power supply set for the correct
voltage? Is the signal generator correctly set and connected? How are the variables in the code set? Is there a
syntax error? And so on. Next, check for obvious misconnections or broken connections, at least in simple
circuits.
As you work through your circuit, use your Lab Manual record tests and changes that you make as you go
along; don't rely on your memory for what you have tried. Identify some test points in the system at which
you know what the signal should be and work your way backwards from the output through the test points
until you find a good signal.
Neatness
When you have finished for the day, return all modules to their proper storage bins, return all test leads and
probes to their storage racks, return all equipment to its correct location, and clean up the lab station. If
appropriate switch off the unneeded equipment. Save your files in the Computer and on any USB device for
your records because you might not get the same PC System again for the next experiment. Also email your
file contents to your email address as a backup.
Laboratory Safety

Always pay attention to what you are doing and you’re surrounding during the experiments, notify the
Instructor for any unlikely event or mishap, and leave the Laboratory with the permission of Instructor
immediately.
All students must read and understand the information in this document with regard to laboratory safety and
emergency procedures prior to the first laboratory session.
Your personal laboratory safety depends mostly on YOU. Efforts have been made to address situations
that may pose a hazard in the lab but the information and instructions provided cannot be considered all-
inclusive.
Students must adhere to written and verbal safety instructions throughout the academic term. Since
additional instructions may be given at the beginning of laboratory sessions, it is important that all students
arrive at each session on time. With good judgment, the chance of an accident in this course is very small.
Nevertheless, research and teaching workplaces (labs, shops, etc.) are full of potential hazards that can cause
serious injury and or damage to the equipment. Working alone and unsupervised in laboratories is forbidden
if you are working with hazardous substances or equipment. With prior approval, at least two people should
be present so that one can shut down equipment and call for help in the event of an emergency. Safety
training and/or information should be provided by a faculty member, teaching assistant, lab safety contact,

IQRA University, Main Campus, Karachi


FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

or staff member at the beginning of a new assignment or when a new hazard is introduced into the
workplace.
Emergency Response
1. It is your responsibility to read safety and fire alarm posters and follow the instructions during an
emergency
2. Know the location of the fire extinguisher, eye wash, and safety shower in your lab and know how to
use them.
3. Notify your instructor immediately after any injury, fire or explosion, or spill.
4. Know the building evacuation procedures.
Common Sense
Good common sense is needed for safety in a laboratory. It is expected that each student will work in a
responsible manner and exercise good judgment and common sense. If at any time you are not sure how to
handle a particular situation, ask your Teaching Assistant or Instructor for advice DO NOT TOUCH
ANYTHING WITH WHICH YOU ARE NOT COMPLETELY FAMILIAR!!! It is always better to ask
questions than to risk harm to yourself or damage to the equipment.
Personal and General laboratory safety
1. Never eat, drink, or smoke while working in the laboratory.
2. Read labels carefully.
3. Do not use any equipment unless you are trained and approved as a user by your supervisor.
4. Wear safety glasses or face shields when working with hazardous materials and/or equipment.
5. Wear gloves when using any hazardous or toxic agent.
6. Clothing: When handling dangerous substances, wear gloves, laboratory coats, and safety shield or
glasses. Shorts and sandals should not be worn in the lab at any time. Shoes are required when working in
the machine shops.
7. If you have long hair or loose clothes, make sure it is tied back or confined.
8. Keep the work area clear of all materials except those needed for your work. Coats should be hung in the
hall or placed in a locker. Extra books, purses, etc. should be kept away from equipment that requires air
flow or ventilation to prevent overheating.
9. Disposal - Students are responsible for the proper disposal of used material if any in appropriate
containers.
10. Equipment Failure - If a piece of equipment fails while being used, report it immediately to your lab
assistant or tutor. Never try to fix the problem yourself because you could harm yourself and others.
11. If leaving a lab unattended, turn off all ignition sources and lock the doors.
12. Never pipette anything by mouth.
13. Clean up your work area before leaving.
14. Wash hands before leaving the lab and before eating.
15. Unauthorized person(s) shall not be allowed in a laboratory for any reason

Electrical safety
1. Obtain permission before operating any high voltage equipment.
2. Maintain an unobstructed access to all electrical panels.

IQRA University, Main Campus, Karachi


FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

3. Wiring or other electrical modifications must be referred to the Electronics Shop or the Building
Coordinator.
4. Avoid using extension cords whenever possible. If you must use one, obtain a heavy- duty one that is
electrically grounded, with its own fuse, and install it safely. Extension cords should not go under doors,
across aisles, be hung from the ceiling, or plugged into other extension cords.
5. Never, ever modify, attach or otherwise change any high voltage equipment.
6. Always make sure all capacitors are discharged (using a grounded cable with an insulating handle) before
touching high voltage leads or the "inside" of any equipment even after it has been turned off. Capacitors
can hold charge for many hours after the equipment has been turned off.
7. When you are adjusting any high voltage equipment or a laser which is powered with a high voltage
supply, USE ONLY ONE HAND. Your other hand is best placed in a pocket or behind your back. This
procedure eliminates the possibility of an accident where high voltage current flows up one arm, through
your chest, and down the other arm.
8. Discard damaged cords, cords that become hot, or cords with exposed wiring.
9. Before equipment is energized ensure, (1) circuit connections and layout have been checked by a
Teaching Assistant (TA) and (2) all colleagues in your group give their assent.
10. Know the correct handling, storage and disposal procedures for batteries, cells, capacitors, inductors and
other high energy-storage devices.
11. Experiments left unattended should be isolated from the power supplies. If for a special reason, it must
be left on, a barrier and a warning notice are required.
12. Equipment found to be faulty in any way should be reported to the Lab Engineer immediately and taken
out of service until inspected and declared safe.
13. Voltages above 50 V rms AC and 120 V DC are always dangerous. Extra precautions should be
considered as voltage levels are increased.
14. Never make any changes to circuits or mechanical layout without first isolating the circuit by switching
off and removing connections to power supplies.
15. Know what you must do in an emergency.
16. Emergency Power Off: Every lab is equipped with and Emergency Power Off System.
17. Only authorized personnel are permitted to reset power once the Emergency Power Off system has been
engaged.
Electrical Emergency Response
The following instructions provide guidelines for handling two types of electrical emergencies:
1. When someone suffers serious electrical shock, he or she may be knocked unconscious. If the victim is
still in contact with the electrical current, immediately turn off the electrical power source. If you cannot
disconnect the power source, depress the Emergency Power Off switch.
2. Do not touch a victim that is still in contact with a live power source; you could be electrocuted.
3. Have someone call for emergency medical assistance immediately. Administer first-aid, as appropriate.
4. If an electrical fire occurs, try to disconnect the electrical power source, if possible. If the fire is small and
you are not in immediate danger; and you have been properly trained in fighting fires, use the correct type
of fire extinguisher to extinguish the fire. When in doubt, push in the Emergency Power Off button.
5. NEVER use water to extinguish an electrical fire.
Mechanical safety
1. When using compressed air, use only approved nozzles and never direct the air towards any person.

IQRA University, Main Campus, Karachi


FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

2. Guards on machinery must be in place during operation.


3. Exercise care when working with or near hydraulically- or pneumatically-driven equipment. Sudden or
unexpected motion can inflict serious injury.
Additional Safety Guidelines
1. Never do unauthorized experiments.
2. Never work alone in laboratory.
3. Keep your lab space clean and organized.
4. Do not leave an on-going experiment unattended.
5. Always inform your instructor if you break a thermometer. Do not clean mercury yourself!!
6. Never taste anything. Never pipette by mouth; use a bulb.
7. Never use open flames in laboratory unless instructed by TA.
8. Check your glassware for cracks and chips each time you use it. Cracks could cause the glassware to fail
during use and cause serious injury to you or lab mates.
9. Maintain unobstructed access to all exits, fire extinguishers, electrical panels, emergency showers, and
eye washes.
10. Do not use corridors for storage or work areas.
11. Do not store heavy items above table height. Any overhead storage of supplies on top of cabinets should
be limited to lightweight items only. Also, remember that a 36" diameter area around all fire sprinkler
heads must be kept clear at all times.
12. Areas containing lasers, biohazards, radioisotopes, and carcinogens should be posted accordingly.
However, do not post areas unnecessarily and be sure that the labels are removed when the hazards are no
longer present.
13. Be careful when lifting heavy objects. Only shop staff may operate forklifts or cranes.
14. Clean your lab bench and equipment, and lock the door before you leave the laboratory.
Clothing
1. Dress properly during a laboratory activity.
2. Long hair, dangling jewelry, and loose or baggy clothing are a hazard in the laboratory.
3. Long hair must be tied back, and dangling jewelry and baggy clothing must be secured.
4. Shoes must completely cover the foot.
5. No sandals allowed on lab days.
6. A lab coat or smock should be worn during laboratory
experiments.
Accidents and Injuries
1. Do not panic.
2. Report any accident (spill, breakage, etc.) or injury (cut, burn,
etc.) to the teacher immediately, no matter how trivial it seems.
3. If you or your lab partner is hurt, immediately (and loudly) yell
out the teacher's name to get the teacher's attention.

IQRA University, Main Campus, Karachi


FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

General Warning Signs

IQRA University, Main Campus, Karachi


FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

EXPERIMENT # 1
Familiarization with the Organization and the Operating Procedures of the
MDA-8086 Trainer

Name: _______________________________________________________

Registration No._______________________________________________

Program: _________________________________________________

Remarks :
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________

____________________
Lab Instructor Signature

IQRA University, Main Campus, Karachi


FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

Objective:

Familiarization with the Organization and the Operating Procedures of the MDA-8086 Trainer

Familiarization with the Components Layout:

In this task you will be locating and getting familiar with the following functional units of the MDA-8086
trainer. These units are considered as the Building Blocks of a microprocessor based system.

i. 8086 Microprocessor
ii. RAM (Random Access Read and Write Memory)
iii. EPROM (Ultraviolet Erasable and Electrically Programmable Random Access Read Only Memory)
iv. Input Device (The Keyboard)
v. Keyboard Interface Controller
vi. Output Devices:

a. Liquid Crystal Display Unit


b. Common Anode Type 7-Segment Display Device
c. Light Emitting Diodes
d. 8x8 Bicolor Dot Matrix LED. Each dot contains Red and Green LEDs.

vii. Output Device Interface Controllers


viii. Primary Memory Decoder
ix. Primary Port Decoder
x. I/O Controller (8255A)

Procedures:

1. Look at the PCB (Printed Circuit Board) of the trainer and the component layout of Figure-1.
2. Now, on the PCB, locate the circuit designation U1. This is the 8086 microprocessor chip.
3. Look very carefully on the top of the U1-chip and you will find the inscription ‘8086’.
4. Locate the keyboard on the trainer.
5. Locate the following output devices on the PCB of the trainer.

a) The LCD unit. The interface controller of the LCD device is built-in within the LCD panel.
b) The 7-segment display device, which has the circuit designation. This is a common-anode
type display device. Let us agree to call it by the symbolic name CA7SD (Common Anode 7-
Segment Display Device). A CA-type display device is opposite to CC-type display device.
The interface controller for this device is the chip, U29 (8255).
c) The LED assembly, LED11-LED13. The interface controller for these LEDs is the chip, U29.

6. Locate the RAM chips U9, U10 on the PCB. Bit capacity of each RAM is: 32x1024x8.

7. Locate the EPROM chips U7 and U8 on the PCB. These chips contain the Monitor Program of the
MDA-8086 trainer. Bit capacity of each EPROM is: 32x1024x8.

IQRA University, Main Campus, Karachi


FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

Familiarization with the Hardware Block Diagram of MDA-8086

The following hardware block diagram of Figure-1 contains the total I/O scenario of the trainer.

Figure-1: Hardware Block Diagram of MDA-8086 Trainer

IQRA University, Main Campus, Karachi


FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

Function of Keys:

MDA-8086 has high performance 64K-byte monitor program. It is designed for easy function. After power
is on, the monitor begins to work. In addition to all the key function the monitor has a memory
checking routine.

The following is a simple description of the key functions.

IQRA University, Main Campus, Karachi


Basic Operation

On a power-up, following message will be displayed on a LCD.

Figure 2
So as to use serial monitor, move switch P1 which located on the PCB like

Whenever RES is pressed, the display becomes FIGURE 2 and user can operate keyboard only in this
situation.

Serial Monitor

Serial monitor is the basic monitor program to do data communicate between MDA-8086 and computer.
Connecting MDA-8086 to PC:

1. Select MDA software folder.


2. In MDA folder you will find “MASAM.EXE”, “LOD186EXE “ and “COMM.EXE”
3. Select MASAM.EXE. following screen will be displayed.
4. Type source file name e.g LED.ASM and press enter
5. Type source listing e.g. LED.LST and press enter

6. Select LOD186.EXE. following screen will be displayed.


7. Type object file name e.g LED.OBJ and press enter

8. Open COMM software. Connect extended cord of MDA-8086 with PC’s serial port. Press RES
button. Make sure the module is set in serial monitor mode.
9. Write your Code in notepad file and perform operations up to hex file creation.
10. Open another command prompt file.
11. Type LOD186 and press Enter.
12. Go to Comm window and press L. Press Enter. Select desired ABS file from up folder.
13. Type G 0000:1000 and press Enter.

14. Program is successfully run in MDA-8086 module.


EXPERIMENT # 2

Using 8255A Chip to Interface LED with 8088 microprocessor using


MDA-8086 Trainer

Name:___________________________________________________

Registration No.___________________________________________

Program: ______________________________________________

Remarks :
_________________________________________________________
_________________________________________________________
_________________________________________________________

____________________
Lab Instructor Signature
Objective:

Using 8255A Chip to Interface LED with 8088 microprocessor using MDA-8086 Trainer

Interface Diagram:
Sample Program:

Sequentially ON (LED 11 to 14), then (LED 14 to 11) and perform this operation continuously.

CODE SEGMENT
ASSUME CS:CODE,DS:CODE,ES:CODE,SS:CODE
;LED PROGRAM

CW EQU 1FH
PORTC EQU 1DH
PORTB EQU 1BH
PORTA EQU 19H

ORG 1000H
MOV AL,80H
OUT CW,AL
L5: MOV AL,00000001B
L2: OUT PORTB,AL
CALL TIMER
SHL AL,1
TEST AL,00010000B
JNZ L3
JMP L2

L3: MOV AL,00001000B


L4: OUT PORTB,AL
CALL TIMER
ROR AL,1
TEST AL,10000000B
JNZ L5
JMP L4

TIMER: PUSH CX
MOV CX,0
N: NOP
NOP
LOOP N
POP CX
RET

CODE ENDS
END
Exercises:

Exercise 2.1: Write a program to sequentially turn ON four LED’s placed on trainer with 1 sec interval.
Exercise 2.2: Modify your program to limit the sequence for 5 times.

EXPERIMENT # 3
Using 8255A Chip to Interface 7-segment displays with 8088 microprocessor using
MDA-8086 Trainer

Name:___________________________________________________

Registration No.___________________________________________

Program: ______________________________________________

Remarks:
_________________________________________________________
________________________________________________________________
__________________________________________________

____________________
Lab Instructor Signature
Objective:

Using 8255A Chip to Interface 7- segment display with 8088 microprocessor using MDA-8086 Trainer

Interface Diagram:
Sample Program

Generate 4510 sequentially on seven segment using look up table.

CODE SEGMENT
ASSUME CS:CODE; DS:CODE; ES:CODE; SS:CODE

CW EQU 1FH
PORTC EQU 1DH
PORTB EQU 1BH
PORTA EQU 19H

ORG 1000H
MOV AL,80H
OUT CW,AL
BACK: MOV CX,4
MOV BX,OFFSET REG
L1: MOV AL,[BX]
OUT PORTA,AL
CALL TIMER
INC BX
LOOP L1
JMP BACK
TIMER:PUSH CX
MOV CX,1
TIMER2: PUSH CX
MOV CX,0
TIMER1: NOP
NOP
NOP
LOOP TIMER1
POP CX
LOOP TIMER2
POP CX
RET

REG: DB 099H
DB 092H
DB 0F9H
DB 0C0H

CODE ENDS
END
Exercises:

Exercise 3.1: Write a program to Sequentially display Hex digits “0” to ” F” on seven segment display such
that each digits remains on display 1 sec.
Exercise 3.2: Re-write program of exercise 3.1 so that seven segment encoded is implemented using look
up table.
EXPERIMENT # 4

Using 8255A Chip to Interface Dot Matrix display with 8088 microprocessor using
MDA-8086 Trainer

Name:_______________________________________________________

Registration No._______________________________________________

Program: __________________________________________________

Remarks :
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________

____________________
Lab Instructor Signature
Object

Using 8255A Chip to Interface Dot Matrix display with 8088 microprocessor using MDA-8086 Trainer

General Description

The KMD D1288C is 1.26 inch height 3mm diameter and 8 × 8 dot matrix LED displays. The
KMD D1288C are dual emitting color type of red, green chips are contained in a dot with
milky and white lens color.
Dot-Matrix LED Interface Diagram
Sample Program

Sequentially ON, the whole line of Dot Matrix from Up to Down and perform this operation
continuously.

CODE SEGMENT
ASSUME CS:CODE; DS:CODE; ES:CODE;
SS:CODE

CW EQU 1EH
PORTC EQU 1CH
PORTB EQU 1AH
PORTA EQU 18H

ORG 1000H
MOV AL,80H
OUT CW,AL
MOV AL,0FFH
OUT PORTC,AL
MOV AL,0FFH
OUT PORTB,AL
MOV AL,7FH
BACK: OUT PORTA,AL
CALL TIMER
ROR AL,1
JMP BACK

TIMER: PUSH CX
MOV CX,1
TIMER2: PUSH CX
MOV CX,0
TIMER1: NOP
NOP
NOP
LOOP TIMER1
POP CX
LOOP TIMER2
POP CX
RET

CODE ENDS
END

Exercises:

Exercise 4.1: Sequentially ON, the whole line of Dot Matrix from Down to Up and perform this operation
5 times.
Exercise 4.2: Put on the diagonal LEDs.
Exercise 4.3: Display “X” on Dot Matrix.
EXPERIMENT # 5

Interfacing Speaker with 8088 microprocessor using MDA-8086 Trainer

Name:_______________________________________________________

Registration No._______________________________________________

Program: __________________________________________________

Remarks :
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________

____________________
Lab Instructor Signature
Object

Interfacing Speaker with 8088 microprocessor using MDA-8086 Trainer

Speaker Interface Diagram

Sample Program

Generate and observe a tone signal on speaker

CODE SEGMENT
ASSUME
CS:CODE,DS:CODE,ES:CODE,SS:CODE

SPK EQU 17H


;TONE
ORG 1000H
MOV AL,0FFH
BACK: OUT SPK,AL
CALL TIMER
NOT AL
JMP BACK

TIMER: PUSH CX
MOV CX,100
N: NOP
NOP
LOOP N
POP CX
RET

CODE ENDS
END

Exercises:

Exercise 5.1: Generate and observe a different tone signal on speaker.


Exercise 5.2: Generate and observe another different tone signal on speaker.
Exercise 5.3: Generate a tune on speaker by using multiple tone signals.
EXPERIMENT # 6

Interfacing Hex Keyboard with 8088 microprocessor using MDA-8086 Trainer

Name:_______________________________________________________

Registration No._______________________________________________

Program: __________________________________________________

Remarks :
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________

____________________
Lab Instructor Signature
Object

Interfacing Hex Keyboard with 8088 microprocessor using MDA-8086 Trainer

General Description

Position Code
Key 0 1 2 3 4 5 6 7
Code 00 01 02 03 04 05 06 07
Key 8 9 A B C D E F
Code 08 09 0A 0B 0C 0D 0E 0F
Key : STP GO REG - + DA AD
Code 10 11 12 13 14 15 16 17

Keyboard Interface Diagram

Sample Program

When any key press, 4510 sequentially display on seven segment.

CODE SEGMENT
ASSUME CS:CODE; DS:CODE; ES:CODE; SS:CODE
CW EQU 1FH
PORTC EQU 1DH
PORTB EQU 1BH
PORTA EQU 19H
KEY EQU 01H
ORG 1000H
MOV AL,80H
OUT CW,AL
BACK: MOV AL,0FFH
OUT PORTA,AL
CALL SCAN
MOV AL,99H
OUT PORTA,AL
CALL TIMER
MOV AL,92H
OUT PORTA,AL
CALL TIMER
MOV AL,0F9H
OUT PORTA,AL
CALL TIMER
MOV AL,0C0H
OUT PORTA,AL
CALL TIMER
JMP BACK
SCAN: IN AL,KEY
TEST AL,10000000B
JNZ SCAN
AND AL,00011111B
OUT KEY,AL
RET
TIMER: PUSH CX
MOV CX,1
TIMER2: PUSH CX
MOV CX,0
TIMER1: NOP
NOP
NOP
LOOP TIMER1
POP CX
LOOP TIMER2
POP CX
RET
CODE ENDS
END

Exercises:

Exercise 6.1: Write a program so that when Key ‘4’, ‘5’, ‘1’, ‘0’, is pressed the corresponding number is
displayed on seven segment.
Exercise 6.2: Write a program so that when Key ‘1’ is pressed 7-segment sequentially displays Hex Digits
from 0 to F.
EXPERIMENT # 7

Interfacing and programming 16 × 2 Line LCD Module with 8088 microprocessor


using MDA-8086 Trainer (Open Ended LAB)

Name:_______________________________________________________

Registration No._______________________________________________

Program: __________________________________________________

Remarks:
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________

____________________
Lab Instructor Signature
Object

Interfacing and programming 16 × 2 Line LCD Module with 8088 microprocessor using MDA-8086 Trainer

1) Physical Data

2) Pin Connections
3) Instruction
4) Initialization Sequence

* 1. Should use this instruction only once in operation.


* 2. ADDR is the setting data cursor position to debug. In data, MSB(D7) should be "1" and
other 7 bits (D0~D6) are cursor position.
* 3. DATA mean the ASCII codes.

5) Character Font Table


LCD Interface

Function Set

0 0 1 DL N F * *

DL = 1; 8-BIT
= 0; 4-BIT

N = 1; 2- Lines
= 0; 1- Line

Size:

F = 1; 5-10 Dots
= 0; 5*7 Dots

0 0 1 1 1 0 0 0
Display ON/OFF Control

0 0 0 0 1 D C B

D = Display ON/OFF
C= Cursor ON/OFF
B= Cursor Blink/Not

0 0 0 0 1 1 1 0

Entry Mode Set

0 0 0 0 0 1 I/D S

Sets Cursor move direction & specifies shift of Display.

I/D = 1 : Increment
Cursor
Move.
0: Decrement

S= 1: Accompanies display shift

0 0 0 0 0 1 1 1

Clear Display

0 0 0 0 0 0 0 1

Set DD RAM (Display Data) Address

D7 D6 D5 D4 D3 D2 D1 D0

1 ADD DATA

1 0 0 0 0 0 0 0
Read Busy Flag and Add

BF AC

BF = 0 : Not Busy
1: Busy

AC: Address counter used for both DD and CG RAM address.

1 X X X X X X X X X

Sample Program

Display “IQRA UNIVERSITY” ON 1st line of LCD.


CODE SEGMENT
ASSUME CS:CODE;DS:CODE;ES:CODE;SS:CODE
IRWR EQU 00H
IRRD EQU 02H
DTWR EQU 04H
ORG 1000H
START:
CALL TIMER
CALL INITLCD
MOV SI,OFFSET NAMESTR
MOV AL,80H
CALL CMDWR
CALL DSPSTR
START1:
JMP START1
CHKBSY:
PUSH AX
CHKBSY1:
IN AL,IRRD
AND AL,80H
JNZ CHKBSY1
POP AX
RET
CMDWR:
CALL CHKBSY
OUT IRWR,AL
RET
CHARWR:
CALL CHKBSY
OUT DTWR,AL
RET
INITLCD:
PUSH AX
MOV AL,38H
CALL CMDWR
MOV AL,0EH
CALL CMDWR
MOV AL,06H;
CALL CMDWR
MOV AL,01H
CALL CMDWR
POP AX
RET
DSPSTR:
MOV AL,BYTE PTR CS:[SI]
CMP AL,00H
JE DSPSTR1
CALL CHARWR
INC SI
JMP DSPSTR
DSPSTR1:
RET

TIMER:
MOV CX,2
TIMER1:
PUSH CX
MOV CX,0
TIMER2:
NOP
NOP
NOP
NOP
LOOP TIMER2
POP CX
LOOP TIMER1
RET

NAMESTR:
DB 'IQRA UNIVERSITY',00H
CODE ENDS
END

(Open Ended LAB):

Exercise 7.1: Write a program to display string “IQRA UNIVERSITY” on 2nd line of LCD.
Exercise 7.2: Write a program so that LCD displays the Key Number when pressed.
EXPERIMENT # 8

Open Ended Lab

Name:___________________________________________________

Registration No.___________________________________________

Program: ______________________________________________

Remarks:
_________________________________________________________
_________________________________________________________
_________________________________________________________

____________________
Lab Instructor Signature
Objective:_______________________________________________________________
________________________________________________________________________
________________________________________________________________________
____________________________________________

Experimental Setup:
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
______________________________________________________________

Procedure:
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
______________________

Experimental Results:
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
__________________________________________________________
EXPERIMENT # 9

Interfacing and Driving Stepper Motor with 8088 microprocessor using


MDA-8086 Trainer

Name:___________________________________________________

Registration No.___________________________________________

Program: ______________________________________________

Remarks:
_________________________________________________________
_________________________________________________________
_________________________________________________________

____________________
Lab Instructor Signature
Object

Interfacing and Driving Stepper Motor with 8088 microprocessor using MDA-8086 Trainer

Stepping Motor Specification


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
will have wider applications in the future.

Stepping motors are suitable for translating digital inputs into mechanical motion. In general, there are three
types of stepping motor:

i. VR( Variable Reluctance ) stepping motors


ii. Hybrid stepping motors
iii. PM( Permanent Magnet ) stepping motors

Table 9-4. Stepping motor characteristics comparison

Figure 9-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 current's ON/OFF conditions in the coils, see FIGURE 10-1(a). 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 10-1(b). This is known as two-phase exception. In FIGURE 10-1(c), the excitation
alternates between 1-phase and 2-phase, then the motor will rotates 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.

Stepping motor can rotate in clockwise or counter-clockwise direction depending on the current
pulse sequence applied to the excitation coils of the motor. Referring to the truth tables in FIGURE
10-1(a), (b), (c). If signals are applied to coil A and B according to Step 1,2,3,4,5,6,7,8, then counter-
clockwise movement is achieved. And vice-versa is true. If signals are applied according to step
8,7,6,5,4,3,2,1, then clockwise movement is achieved.
Commercial stepping motor uses multi-motor rotor, the rotor features two bearlike 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 sequences will proceed.

Single-phase excitation:

The stepping position will be 0°,1.8°, 3.6°, ....... 358.2°, total 200 steps in one round.

Two-phase excitation:

The stepping positions will be 0.9°, 2.7°, 4.5°, ..... 359.1°, total 200 steps in one round.

Single-phase and two-phase excitations combined:

The stepping positions will be 0°, 0.9°, 1.8°, 2.7°, 3.6°, 4.5°, ...............
358.2°, 359.1°, total 400 steps in one round.

FIGURE 10-1. Half-step and full-step rotation


Since stepping motor makes step-by-step movement and each step is equidistant, the rotor and
stator magnetic field 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.

Stepping Motor Interface


Sample Program
When any key press, motor rotates 1 cycle CCW.

CODE SEGMENT
ASSUME CS:CODE; DS:CODE; ES:CODE; SS:CODE

CW EQU 1FH
PORTC EQU 1DH
PORTB EQU 1BH
PORTA EQU 19H
KEY EQU 01H

ORG 1000H

MOV AL,80H
OUT CW,AL
BACK: CALL SCAN
MOV AL,10011001B
MOV CX,200
B1: OUT PORTB,AL
CALL TIMER
ROR AL,1
LOOP B1
JMP BACK

SCAN: IN AL,KEY
TEST AL,10000000B
JNZ SCAN
AND AL,00011111B
OUT KEY,AL
RET

TIMER: PUSH CX
MOV CX,3FFFH
N: NOP
NOP
LOOP N
POP CX
RET

CODE ENDS
END

Exercises:

Exercise 9.1: Write a program so that when any key is pressed, motor rotates 1 cycle CW.
Exercise 9.2: Write a program to drive motor CCW at the speed of 10 rpm.
EXPERIMENT # 10

Interfacing DAC0800 with 8088 microprocessor using MDA-8086 Trainer

Name:_______________________________________________________

Registration No._______________________________________________

Program: __________________________________________________

Remarks :
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________

____________________
Lab Instructor Signature
Object

Interfacing DAC0800 with 8088 microprocessor using MDA-8086 Trainer


General Description

The DAC08 is a monolithic 8-Bit high-speed current output digital to analog converter (DAC)
featuring typical setting times of 100ns. When used as a multiplying DAC monotonic
performance over a 40 to 1 reference current range is possible. The DAC08 also features high
compliance complementary current outputs to allow differential output voltage of 20 Vpp with
simple resistor loads as shown in FIGURE 8-1.

FIGURE 9-1. DAC0800 Block Diagram


FIGURE 9-2 DAC0800 Block Diagram (continue)
D/A Converter Interface Diagram
Sample Program

Display DAC Led bar moving from down to up.


CODE SEGMENT
ASSUME CS:CODE; DS:CODE; ES:CODE; SS:CODE

CW EQU 1FH
PORTC EQU 1DH
PORTB EQU 1BH
PORTA EQU 19H
;LEVEL METER DOWN TO UP.
ORG 1000H

MOV AL,80H
OUT CW,AL
BACK: MOV AL,00H
B1: OUT PORTC,AL
CALL TIMER
INC AL
CMP AL,64H
JNE B1
JMP BACK

TIMER: PUSH CX
MOV CX,7FFFH
N: NOP
NOP
LOOP N
POP CX
RET

CODE ENDS
END
Exercises:

Exercise 10.1: Display DAC Led bar moving from up to down.


Exercise 10.2: Display DAC Led bar moving from up to down 5 times only.
Exercise 10.3: Display DAC Led bar moving from “up to down” then “down to up” and perform this
operation continuously.
EXPERIMENT # 11

Interfacing ADC-0804 with 8088 microprocessor using MDA-8086 Trainer

Name:_______________________________________________________

Registration No._______________________________________________

Program: __________________________________________________

Remarks :
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________

____________________
Lab Instructor Signature
Object

Interfacing ADC-0804 with 8088 microprocessor using MDA-8086 Trainer

General Description

The ADC0800 is an 8-bit monolithic A/D converter using P-channel ion-implanted MOS
technology. It contains a high input impedance comparator 256 series resistors and analog switches
control logic and output latches. Conversion is performed using a successive approximation
technique where the unknown analog voltage is compared to the resister tie points using analog
switches. When the appropriate tie point voltage matches the unknown voltage, conversion is
complete and the digital outputs contain an 8-bit complementary binary word corresponding to the
unknown. The binary output is TRI-STATE to permit bussing on common data lines.
A/D Converter Interface Diagram

Sample Program
Observe ADC value change on Level meter Led bar.

CODE SEGMENT
ASSUME CS:CODE; DS:CODE; ES:CODE; SS:CODE

CW EQU 1FH
PORTC EQU 1DH
PORTB EQU 1BH
PORTA EQU 19H
ADC EQU 18H
;ADC ANALOG VALUE AT LEVEL METER LEDS
ORG 1000H
MOV AL,80H
OUT CW,AL
BACK: MOV AL,00H
OUT ADC,AL
CALL TIMER
IN AL,ADC
OUT PORTC,AL
JMP BACK
TIMER:
MOV CX,3FFFH
TIMER1:
NOP
NOP
NOP
NOP
LOOP TIMER1
RET
CODE ENDS
END
EXPERIMENT # 12

Write a program to control fringing angle of SCR to manage input voltage to a tungsten lamp
using MDA-8086 Trainer

Name:___________________________________________________

Registration No.___________________________________________

Program: ______________________________________________

Remarks:
_________________________________________________________
_________________________________________________________
_________________________________________________________

____________________
Lab Instructor Signature
Object

Write a program to control fringing angle of SCR to manage input voltage to a tungsten lamp using MDA-8086 Trainer

Voltage Control unit Specification

1. The illumination control of lamp using microcomputer.


2. Control method: Phase control using photo SCR.
3. Changed the illumination control by program.
4. The research of electric power control.
5. Study purpose:
a) Phase control of A.C voltage.
b) The illumination control of lamp by software.
c) The control of photo SCR and photo interrupter.

Sample Program
Generate fix bulb intensity (less than full)

CODE SEGMENT
ASSUME CS:CODE, DS:CODE, ES:CODE, SS:CODE
PPI EQU 26H
CPORT EQU 24H
BPORT EQU 22H
APORT EQU 20H
;FIX BULB INTENSITY DEPEND ON TIMER 1-15
ORG 1000H
MOV AL,98H
OUT PPI,AL
MOV AL,0FFH
OUT CPORT,AL
BACK1: IN AL,CPORT
TEST AL,00010000B
JNZ BACK1
MOV AL,00H
OUT CPORT,AL
CALL TIMER
MOV AL,0FFH
OUT CPORT,AL
JMP BACK1
TIMER: MOV CX,10
DL2: PUSH CX
MOV CX,88H
DL1: LOOP DL1
POP CX
LOOP DL2
RET
CODE ENDS
END
Exercises:

Exercises12.1: Generate different fix bulb intensity (less than full).


Exercises12.2: Generate decreasing bulb intensity output.
EXPERIMENT # 13

Write a program to control Elevator movement using MDA-8086 Trainer

Name:___________________________________________________

Registration No.___________________________________________

Program: ______________________________________________

Remarks:
_________________________________________________________
_________________________________________________________
_________________________________________________________

____________________
Lab Instructor Signature
Object

Write a program to control Elevator movement using MDA-8086 Trainer

Elevator Control Unit specifications

1. DC motor controlled to micro computer.


2. Speed and position control of DC motor.
3. The research of elevator structures.
4. The 1 ~ 4 floor control by program.
5. Study purpose:
a) Control the DC motor.
b) Elevation control by software.
c) Speed and position control of DC motor by program.
d) The control of photo interrupter.

Elevator connected to following addresses:

CW  26H
PORTC  24H
PORTB  22H
PORTA  20H

Sensors connected to PORTA:

4F sensor  PA7
3F sensor  PA6
2F sensor  PA5
1F sensor  PA4

Lift controlled by following bits of PORTC:

PC1 PC0 Lift Operation


0 0 Lift stop
0 1 Lift moves down
1 0 Lift moves up
1 1 Lift stop
Sample Program

Move lift to 3rd floor, initially it should be below 3rd floor.

CODE SEGMENT
ASSUME CS:CODE,DS:CODE,ES:CODE,SS:CODE

CW EQU 26H
PORTC EQU 24H
PORTB EQU 22H
PORTA EQU 20H
;LIFT UP TILL 3FLOOR
ORG 1000H

MOV AL,90H
OUT CW,AL
MOV AL,00000010B
OUT PORTC,AL
L1: IN AL,PORTA
TEST AL,01000000B
JZ L1
MOV AL,00000011B
OUT PORTC,AL
BACK: JMP BACK

CODE ENDS
END
Exercises:

Exercises 13.1: Write a program to move elevator to 4th floor when its placed at 1st floor.
Exercises 13.2: Re-write the program in exercises 12.1 so that elevator moves from 1st floor to 4th floor
when key ‘4’ is pressed and than the elevator moves to 3rd floor when key ‘3’ is pressed.
EXPERIMENT # 14

Write a code in Assembly language given that if user press “1” leds from 11 to 14 glow sequentially
similarly when user press “2” hex value of 0 to F should be display on 7-segment display while for any
keyboard hit microprocessor will remain in no operation mode.

Name:___________________________________________________

Registration No.___________________________________________

Program: ______________________________________________

Remarks:
_________________________________________________________
_________________________________________________________
_________________________________________________________

__________________
Lab Instructor Signature
Object

Write a code in Assembly language given that if user press “1” leds from 11 to 14 glow sequentially
similarly when user press “2” hex value of 0 to F should be display on 7-segment display while for any
keyboard hit microprocessor will remain in no operation mode.

Sample Program

CODE SEGMENT
ASSUME CS:CODE,DS:CODE,ES:CODE,SS:CODE

CW EQU 1FH
PORTC EQU 1DH
PORTB EQU 1BH
PORTA EQU 19H
KEY EQU 01H

ORG 1000H
MOV AL,80H
OUT CW,AL
BACK: MOV AL,0FFH
OUT PORTA,AL
CALL SCAN
CMP AL,01H
JNE L1
JMP LED
L1: CMP AL,02H
JNE L2
JMP SEGG
L2: JMP BACK

LED: MOV AL,00000001B


A1: OUT PORTB,AL
CALL TIMER
SHL AL,1
TEST AL,00010000B
JZ A1
JMP LED

SEGG: MOV BX,OFFSET [REG]


S1: MOV AL,[BX]
CMP AL,0FFH
JE SEGG
OUT PORTA,AL
CALL TIMER
INC BX
JMP S1
REG: DB 11000000B;0
DB 11111001B;1
DB 10100100B;2
DB 10110000B;3
DB 10011001B;4
DB 10010010B;5
DB 10000010B;6
DB 11111000B;7
DB 10000000B;8
DB 10010000B;9
DB 10001000B;A
DB 10000011B;b
DB 11000110B;C
DB 10100001B;d
DB 10000110B;E
DB 10001110B;F
DB 11111111B;OFF

TIMER: PUSH CX
MOV CX,1
TIMER2: PUSH CX
MOV CX,0
TIMER1: NOP
NOP
NOP
LOOP TIMER1
POP CX
LOOP TIMER2
POP CX
RET

SCAN: IN AL,KEY
TEST AL,10000000B
JNZ SCAN
AND AL,00011111B
OUT KEY,AL
RET

CODE ENDS
END
Exercises:

Write a code in Assembly language given that if user press “1” leds from 14 to 11 glow sequentially
similarly when user press “2” hex value of F to 0 should be display on 7-segment display while for any
keyboard hit microprocessor will remain in no operation mode.
EXPERIMENT # 15

Write a code in Assembly language given that if user presses “1” “IQRA UNIVERITY” should be
displayed on first line of LCD similarly when user press “2” “KARACHI” should be display on
second line of LCD while for any keyboard hit microprocessor will remain in no operation mode.
(Open Ended LAB)

Name:___________________________________________________

Registration No.___________________________________________

Program: ______________________________________________

Remarks:
_________________________________________________________
_________________________________________________________
_________________________________________________________

___________________
Lab Instructor Signature
Object

Write a code in Assembly language given that if user presses “1” “IQRA UNIVERITY” should be displayed
on first line of LCD similarly when user press “2” “KARACHI” should be display on second line of LCD
while for any keyboard hit microprocessor will remain in no operation mode.

Sample Program

CODE SEGMENT
ASSUME CS:CODE,DS:CODE,ES:CODE,SS:CODE

IRWR EQU 00H


IRRD EQU 02H
DTWR EQU 04H
KEY EQU 01H

ORG 1000H

START:
CALL TIMER
CALL INITLCD
BACK: CALL SCAN
CMP AL,01H
JNE L1
MOV AL,01H
CALL CMDWR
MOV SI,OFFSET NAMESTR1
MOV AL,80H
CALL CMDWR
CALL DSPSTR
JMP BACK

L1: CMP AL,02H


JNE BACK
MOV AL,01H
CALL CMDWR
MOV SI,OFFSET NAMESTR2
MOV AL,0C0H
CALL CMDWR
CALL DSPSTR
JMP BACK

CHKBSY:
PUSH AX

CHKBSY1:
IN AL,IRRD
AND AL,80H
JNZ CHKBSY1
POP AX
RET

CMDWR:
CALL CHKBSY
OUT IRWR,AL
RET

CHARWR:
CALL CHKBSY
OUT DTWR,AL
RET

INITLCD:
PUSH AX
MOV AL,38H
CALL CMDWR
MOV AL,0EH
CALL CMDWR
MOV AL,06H;
CALL CMDWR
MOV AL,01H
CALL CMDWR
POP AX
RET

DSPSTR:

MOV AL,BYTE PTR CS:[SI]


CMP AL,00H
JE DSPSTR1
CALL CHARWR
INC SI
JMP DSPSTR

DSPSTR1:
RET

TIMER:
MOV CX,2

TIMER1:
PUSH CX
MOV CX,0

TIMER2:
NOP
NOP
NOP
NOP
LOOP TIMER2
POP CX
LOOP TIMER1
RET

NAMESTR1:
DB 'IQRA UNIVERSITY',00H
NAMESTR2:
DB 'MAIN CAMPUS',00H

SCAN: IN AL,KEY
TEST AL,10000000B
JNZ SCAN
AND AL,00011111B
OUT KEY,AL
RET

CODE ENDS
END
Exercise 15
Write a code in Assembly language given that if user presses “1” “IQRA UNIVERITY” should be displayed
as blinking text on first line of LCD similarly when user press “2” “KARACHI” should be display as
blinking text on second line of LCD while for any keyboard hit microprocessor will remain in no operation
mode.
EXPERIMENT # 16

Open Ended Lab

Name:___________________________________________________

Registration No.___________________________________________

Program: ______________________________________________

Remarks:
_________________________________________________________
_________________________________________________________
_________________________________________________________

____________________
Lab Instructor Signature
Objective:_______________________________________________________________
________________________________________________________________________
________________________________________________________________________
____________________________________________

Experimental Setup:
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
______________________________________________________________

Procedure:
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
______________________

Experimental Results:
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
__________________________________________________________
Appendix
MDA-8086 Memory Circuit
Mda-8086 Connector Circuit

If control 8255A, Address map is follow

PORT 8255A ADDRESS


A PORT 20H
B PORT1 22H
C PORT2 24H
CONTROL 26H
REGISTER

I/O connector (con10,l) circuit


8086 Pin Configuration

(a) 8086

(b) 8088
8086 Instruction Set Summary

8086
REGISTER MODEL

AF : AUXILIARY CARRY - BCD CF : CARRY FLAG


PF : PARITY FLAG SF : SIGN FLAG
ZF : ZERO FLAG

DF : DIRECTION FLAG [STRINGS] IF : INTERRUPT


ENABLE FLAG
OF : OVERFLOW FLAG [DF & SF]
TF : TRAP - SINGLE STEP FLAG
Operand Summary
"reg" fleld bit assignments :

SECOND INSTRUCTION BYTE SUMMARY

mod xxx r/m

mod Displacement
00 DISP : 0". disp-low and disp-high are absent
01 DISP : disp-low sign-extended to 16-bits. disp-high is absent
10 DISP = disp-high ; disp-low
11 r/w is treated as a "reg" field

r/m Operand Address


000 (BX) + (SI) + DISP
011 (BX) + (DI) + DISP
010 (BP) + (SI) + DISP
011 (BP) + (DI) + DISP
100 (SI) + DISP
101 (DI) + DISP
110 (BP) + DISP
111 (BX) + DISP

DISP follows 2nd byte of instruction (before data if required)


* except if mod = 00 and r/m = 110 then EA = disp-high; disp-row

Operand address (EA) Timing (clocks):


Add 4 clocks for word operands at ODD ADDRESSES
immed offset = 6
Base(BX, BP, SI, DI) = 5
Base +DISP = 9
Base + Index (BP + DI, BX + SI) = 7
Base + Index (BP + SI, BX + DI) = 8
Base + Index (BP + DI, BX + SI) + DISP = 11
Base + Index (BP + SI, BX + DI) + DISP = 12
MDA - 8086 Address MAP

Memory address Map

00000H~0FFFFH RAM

10000H~FFFFFH USER AREA


F0000H~FFFFFH ROM MONITOR
PROGRAM
I/O Address Map

00H 02H 03H 04H LCD Even address

01H Key Odd address


08H, 0AH 8251 Serial
Communication
09H 0BH 0DH, 0FH 8253 Programerable Timer

10H, 12H 8259 Interrupt Controller

11H Speaker

18H 1AH 1CH 1EH 8255 IO

19H 1BH 1DH 1FH 8255 DOT LED


Extern 8255 BUS

DO -- D7 : Data Bus from 8086


RESET : Reset Active 'H' RD : Read Active 'L'
WR : Write Active 'L' A1 : Address Bus
A2 : Address Bus
CS : Chip Select ( 20H, 22H, 24H, 26H)
8255 Connect

PA0 -- PA7 : 8255 Port A PB0 -- PA7 : 8255


Port B PC0 -- PC7 : 8255 Port C
* Reference : 8255.PDF
MDA-8086 Schematic
;*****************************************
;* MDA-IO APPLICATION PROGRAM *
;* ELEVATOR CONTROL(MDA-007) *
;* PROGRAM BY MiDAS ENGINEERING *
;*****************************************
;
; FILENAME : ELEV1.ASM
; PROCESSOR : I8086
; VER. : V2.0
;
CODE SEGMENT
ASSUME CS:CODE,DS:CODE,ES:CODE,SS:CODE
;
;
PPI EQU 26H ; 8255A control register
CPORT EQU 24H ; c port
BPORT EQU 22H ; b port
APORT EQU 20H ; a port
;
STACK EQU 0540H
;
ORG 1000H
;
;
START: XOR AX,AX
MOV DS,AX
MOV ES,AX
MOV SS,AX
MOV SP,STACK
;
MOV AL,90H ; A port - IN
OUT PPI,AL ; B,C port - OUT
;
;
MOV DL,0EFH ; first floor LED ON, motor STOP
MOV AL,DL
OUT CPORT,AL
;
INIT0: IN AL,APORT
CMP AL,01FH ; first floor ?
JZ INIT1
MOV DL,0ECH ; first floor LED ON
CALL DISP1
CALL LEFT
JMP INIT0
;
INIT1: CALL STOP
IN AL,APORT ; switch input
OR AL,0F0H
CMP AL,0FEH ; 1st floor
JZ FL1
CMP AL,0FDH ; 2nd floor
JZ FL2
CMP AL,0FBH ; 3rd floor
JZ FL3
CMP AL,0F7H ; 4th floor
JZ FL4_F
JMP INIT1
;
FL1: MOV DL,0ECH ; first floor LED ON
FL1_1: IN AL,APORT ; move 1'st floor
OR AL,0FH
CALL SEG_MENT ; floor display
CMP AL,1FH
JZ INIT1
CALL LEFT
JMP FL1_1
;
FL2: MOV DL,0DCH ; 2'nd floor LED ON
FL2_1: IN AL,APORT ; move 2'nd floor
OR AL,0FH
CALL SEG_MENT ; floor display
CMP AL,8FH ; 4'th ?
JZ FL2_DN
CMP AL,4FH ; 3'rd ?
JZ FL2_DN
CMP AL,2FH ; 2'nd ?
JZ INIT1
CMP AL,1FH
JZ FL2_UP ; 1'st ?
CALL LEFT
JMP FL2_1
;
FL2_DN: IN AL,APORT
OR AL,0FH
CALL SEG_MENT ; floor display
CMP AL,2FH
JZ INIT1
CALL LEFT
JMP FL2_DN
;
FL2_UP: IN AL,APORT
OR AL,0FH
CALL SEG_MENT ; floor display
CMP AL,2FH
JZ INIT1
CALL RIGHT
JMP FL2_UP
;
INIT2: JMP INIT1
FL4_F: JMP FL4
FL3: MOV DL,0BCH ; 3'rd LED ON
FL3_1: IN AL,APORT ; move 3'rd floor
OR AL,0FH
CALL SEG_MENT ; floor display
CMP AL,8FH ; 4'th ?
JZ FL3_DN
CMP AL,4FH ; 3'rd ?
JZ INIT2
CMP AL,2FH ; 2'nd ?
JZ FL3_UP
CMP AL,1FH
JZ FL3_UP ; 1'st ?
CALL LEFT
JMP FL3_1
;
FL3_DN: IN AL,APORT
OR AL,0FH
CALL SEG_MENT ; floor display
CMP AL,4FH
JZ INIT2
CALL LEFT
JMP FL3_DN
;
FL3_UP: IN AL,APORT
OR AL,0FH
CALL SEG_MENT ; floor display
CMP AL,4FH
JZ INIT2
CALL RIGHT
JMP FL3_UP
;
FL4: MOV DL,7CH ; 4'th LED ON
FL4_1: IN AL,APORT ; move 4'th floor
OR AL,0FH
CALL SEG_MENT ; floor display
CMP AL,8FH
JZ INIT2
CALL RIGHT
JMP FL4_1
;
;
LEFT: MOV AL,DL
OR AL,09H ; motor left
AND AL,0FBH ; DOWN LAMP ON
OUT CPORT,AL
RET
;
RIGHT: MOV AL,DL
OR AL,06H ; motor right
AND AL,0F7H ; UP LAMP ON
OUT CPORT,AL
RET
;
STOP: MOV AL,DL
OR AL,0FH
OUT CPORT,AL
RET
;
SEG_MENT:
TEST AL,00010000B
JNZ DISP1
TEST AL,00100000B
JNZ DISP2
TEST AL,01000000B
JNZ DISP3
TEST AL,10000000B
JNZ DISP4
RET
;
DISP1: PUSH AX
MOV AL,11111001B ; "1"
OUT BPORT,AL
POP AX
RET
;
DISP2: PUSH AX
MOV AL,10100100B ; "2"
OUT BPORT,AL
POP AX
RET
;
DISP3: PUSH AX
MOV AL,10110000B ; "3"
OUT BPORT,AL
POP AX
RET
;
DISP4: PUSH AX
MOV AL,10011001B ; "4"
OUT BPORT,AL
POP AX
RET
;
CODE ENDS
END
;*****************************************
;* MDE-IO APPLICATION PROGRAM *
;* VOLTAGE CONTROL (MDE-I95002) *
;* PROGRAM BY MiDAS ENGINEERING *
;*****************************************
;
; FILENAME : VOLTAGE.ASM
; PROCESSOR : I8086
; VER. : V1.1
;
CODE SEGMENT
ASSUME CS:CODE,DS:CODE,ES:CODE,SS:CODE
;
KEY EQU 01H
;
PPI EQU 26H ; control regisster
CPORT EQU 24H ; c port
BPORT EQU 22H
APORT EQU 20H
;
STACK EQU 0540H
;
ORG 1000H
;
;
START: XOR AX,AX
MOV DS,AX
MOV ES,AX
MOV SS,AX
MOV SP,STACK
;
MOV AL,98H
OUT PPI,AL ;A,C(high)-IN , B,C(low)-OUT
;
MOV AL,0F0H
OUT CPORT,AL ; lamp off
;
MOV DX,14 ; pulse width initial
;
L: CALL ZERO ; zero volt scan
CALL SCAN ; key input ?
JMP L
;
ZERO: IN AL,CPORT
TEST AL,00010000B
JZ ZERO_1 ; zero volt
RET
;
; zero volt service routine
;
ZERO_1: MOV CX,DX
CALL DELAY1 ; key delay dataa
MOV AL,0FFH ; lamp on
OUT CPORT,AL
CALL DELAY2
MOV AL,0F0H
OUT CPORT,AL ; lamp off
RET
;
DELAY1: PUSH CX
MOV CX,88H
DL1: LOOP DL1
POP CX
LOOP DELAY1
RET
;
DELAY2: MOV CX,08H
DL2: LOOP DL2
DL3: RET
;
SCAN: IN AL,KEY ; Key input
TEST AL,10000000B
JNZ DL3
;
AND AL,00011111B
MOV BX,0
MOV DS,BX
OUT KEY,AL ; key clear
;
TEST AL,00010000B ; function key ?
JNZ DL3
;
SW0: CMP AL,00H
JNE SW1
MOV DX,14
RET
SW1: CMP AL,01H
JNE SW2
MOV DX,14
RET
SW2: CMP AL,02H
JNE SW3
MOV DX,14
RET
SW3: CMP AL,03H
JNE SW4
MOV DX,13
RET
SW4: CMP AL,04H
JNE SW5
MOV DX,12
RET
SW5: CMP AL,05H
JNE SW6
MOV DX,11
RET
SW6: CMP AL,06H
JNE SW7
MOV DX,10
RET
SW7: CMP AL,07H
JNE SW8
MOV DX,9
RET
SW8: CMP AL,08H
JNE SW9
MOV DX,8
RET
SW9: CMP AL,09H
JNE SWA
MOV DX,7
RET
SWA: CMP AL,0AH
JNE SWB
MOV DX,6
RET
SWB: CMP AL,0BH
JNE SWC
MOV DX,5
RET
SWC: CMP AL,0CH
JNE SWD
MOV DX,4
RET
SWD: CMP AL,0DH
JNE SWE
MOV DX,3
RET
SWE: CMP AL,0EH
JNE SWF
MOV DX,2
RET
SWF: CMP AL,0FH
JNE SW_NO
MOV DX,1
SW_NO: RET
;
CODE ENDS
END
;*****************************************
;* MDE-8086 EXPERIMENT PROGRAM *
;* Chapter 12-4 (Example 1) *
;* PROGRAM BY MiDAS ENGINEERING
;* Stepper Motor Steper Motor
;*****************************************
;
; FILENAME : step1.ASM
; PROCESSOR : I8086
; VER. : V1.1
;
CODE SEGMENT
ASSUME CS:CODE,DS:CODE,ES:CODE,SS:CODE
;
PPIC_CEQU 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,0
TIMER1: NOP
NOP
NOP
NOP
LOOP TIMER1
RET
;
CODE ENDS
END
References:

a) MDA-8086 Official User Manual

b) Project Book 8088 by Robert Gross Blate

c) Intel Microprocessors 8086 8088, 80186 80188, 80286, 80386, 80486, Pentium, and Pentium Pro Proc: Architecture,
Programming and Interfacing 4th Edition by Barry B Brey

You might also like