Documente Academic
Documente Profesional
Documente Cultură
Objective:
Description:
The BGC Micro-engineer V3.4 is a 8088 microprocessor training system. It contains hardware
and software to expand its functions and applications. It provides user an inexpensive and useful
learning tool for the 8088 microprocessor.
Hardware:
8088-2 CPU, 4.77 MHz clock, with 8 MHz option.8K SRAM and 16K EPROM
with wired socket for additional 24K SRAM and 16K EPROM. 1MB RAM is
optional.
Keyboard: Large size, 56 alphanumeric and ASCII symbol keys. On-board LCD
display. An external 80 x 24 monochrome monitor can be used with a Hercules card.
RS-232 interface.
Status ports to display keyboard status as Caps Lock, Ins, and Ctrl-P. In addition,
a speaker is built in for user application.
Parallel control interfaces: Three 8-bit I/O ports(8255), three timers(8254), and
five interrupt signals (8259A).
(ii)
An area on the main board is reserved for circuit designs and experiments.
Software:
CPU: 8088-2 CPU runs at 4.77 MHz. However, a clock rate of 8 MHz can be achieved
by using a 24 MHz crystal oscillator.
RAM: The system provides 32K RAM, addresses from 00000H to 07FFFH, with
00000H to 00FFFH for system program and 0100H to 07FFFH for user applications.
ROM: The system provides ROM, addresses from F8000H to FFFFFH, with
FC000H to FFFFFH for BIOS and F8000H to FBFFFH for user applications.
Keyboard: It has 56 keys which include alphanumeric A-Z and 0-9 special ASCII
symbols.
RS-232 interface. The 8250 controls the RS-232 interface. It can be programmed for
baud rate, data bit, and stop bit.
I/O expansion slot: The signals are compatible with the IBM PC expansion slot, but
no DMA function is provided.
Status port: The status port is used to display keyboard statuses such as Caps Lock,
Ins, and Ctrl-P. A correspondent LED is lighted when the function is enabled. In
addition, it provides the speaker interface to generate sound.
Parallel control interface: Three IC s are used to provide parallel controls. They are
8255- three 8-bit I/O ports, 8254, - three timers, and 8259A five interrupt signals.
Power supply: +5V, -5V, +12V, -12V and GND are used in this system.
User Program
I/O Drivers
Hardware
System Commands:
The system commands provide
Memory management
Program control
I/O control.
Communication.
I/O Drivers:
The I/O drivers of BGC-8088 provide the software interface between the system and I/O devices.
RS-232 driver.
Keyboard driver
Printer driver
Assignment:
Description:
The system commands can be divided into the following groups according to their functions.
Note:
Each command begins with a command letter followed by 1 to 3 operand parameters. The
parameters of system commands are described below.
<Address>
<Range>
<Number>
<Byte>
<String>
<Series>
It move the contents of a block of memory specified in <Range> from one place to another.
The starting address of the destination is specified in <Address>.
There are two different procedures for moving memory.
1. The first is used when the <Range> block occurs before the destination address.
2. The second is used when the destination start address is less than the source start address.
NOTE:
.
Assembler Commands
A
U
I
Assemble a program.
Disassemble a program
Insert an instruction in a program.
The I and A command can both be used to enter 8088 assembly language instructions.
However, these two commands differ in how memory is handled.
The A command overwrites the contents (machine codes) of the specified memory,
While I command only pushes the contents back one location without erasing them.
The INS key is used in toggle mode.i.e by pressing it will insert instructions into memory. As long
as the INS LED is ON, the only way to leave insert mode is to press the INS key once again.
The range of decimal numbers on the BGC-8088 is 0 to 4294967295 (i.e. 65535 x 65535)
Negative numbers are not considered.
The binary representation for numbers in this range requires up to 32 bits.
When the binary values is displayed, the leading zeroes are omitted, and B is appended to denote
that the number is binary.
If the decimal number is greater than 4294967295, it can not be converted into binary.
The range of decimal numbers is from 0 to 4294967295 , up to 8 digits are needed in the
hexadecimal representation of a decimal number.
As with the B command, the leading zeros or the result are not displayed and an H is suffixed to
denote that the number is in hexadecimal.
The range of decimal numbers is from 0 to FFFFFFFF, and no negative numbers are
considered.
Therefore, the maximum decimal number is 4294967295.
In the result, the leading zeros are not displayed and a D appended to denote
decimal representation.
If the input value is non-hexadecimal or greater than FFFFFFFF, no conversion is executed and
an error message is issued.
Execute program
Display or modify the contents of registers.
Trace program execution.
The = sign in the above syntax indicates that a <Start address> parameter will be given.
If this symbol is not used , then the system assumes that any parameters are break points.
<Start address> specifies the beginning address of the program to be executed.
f it is not present, execution will start at the default value, which is the current CS: IP.
<Break point> tells the program results to determine whether the program runs as expected.
The R command is used to check or change the contents of the 14 register in the BGC-8088 .
It can be used to dump the register contents, or to display and modify the register contents.
These functions can be described in the following ways.
R: Display the register contents
If there is no <Register> specified, the R command is used to dump all the register contents
to the screen.
The registers are displayed in the following order:
AX, CX, DX, BX, SP, BP, SI, DI, ES, CS, SS, DS, IP and FG.
9
IF
8
TF
7
SF
6
ZF
5
XX
4
AF
3
XX
2
PF
1
XX
0
CY
Name
Overflow
Direction
Interrupt
Trap (Single step)
Sign
Zero
Auxiliary Carry
Parity
Carry
Bit = 1
OV
DN
EI
Bit = 0
NV
UP
DI
NG
ZR
AC
PE
CY
PL
NZ
NA
PO
NC
Assignment:
Write atleast first 8-bytes of each Memory Management Command.
Assemble the following code and fill the table.
Logical Address
Opcode
Assembly code
comments
;
;
;
10
Laboratory Exercise 2
Objective:
To understand the basic assembly language instructions and performing basic arithmetic
operations.
To understand how the Half-Adder, Full Adder, Half-Subtractor, Full Subtractor, Multiplier
and Divisor circuits are implemented as assembly instructions.
Theory:
Addition:
Half-Adder is implemented using the instruction ADD. No carry-in but carry-out may occur.
Full Adder is implemented using the instruction ADC. Both carry-in and carry-out may
occur.
(a) Program to add two 32 bit numbers using ADC (add with carry) command.
Assembly Language Program:
Address
-------:0100
-------:
-------:
-------:
-------:
-------:
Data/Code
Mnemonics
MOV
MOV
MOV
MOV
ADD
ADC
Comments
AX,1111
BX,2000
CX,3000
DX,4000
AX,CX
BX,DX
Result :____________________________________________________________
Also write the flags affected.
11
Subtraction:
Data/Code
Mnemonics
MOV
MOV
MOV
MOV
SUB
SBB
Comments
AX,3000
BX,2000
CX,1000
DX,4000
AX,DX
BX,CX
Result :____________________________________________________________
Also write the flags affected.
12
Multiplication:
Multiplication
Byte x byte
Word x word
Word x byte
Operand 1
AL
AX
AL=byte, AH=0
Operand 2
Register or memory
Register or memory
Register or memory
Result
AX
DX AX
DX AX
(c) Program to multiply two numbers store in registers BL and CL, and store the
result in register DX.
Assembly Language Program:
Address
-------:0100
-------:
-------:
-------:
-------:
Data/Code
Mnemonics
MOV
MOV
MOV
MUL
MOV
Comments
BL, 05
CL, 10
AL, CL
BL
DX, AX
Result :____________________________________________________________
Also write the flags affecred.
13
Division:
Division
Byte / byte
Word / word
Word / byte
DW / word
Numerator
AL=byte, AH=0
AX=word,DX=0
AX=word
DXAX=DW
Denominator
Register or memory
Register or memory
Register or memory
Register or memory
Quotient
AL
AX
AL
AX
Remainder
AH
DX
AH
DX
Data/Code
Mnemonics
Comments
MOV BL, 05
MOV CL, 10
MOV AH, 00
MOV AL, CL
DIV BL
Result :____________________________________________________________
Also write the flags affecred.
14
Description:
DEBUG is a program included in the MS-DOS and PC-DOS operating systems that allows
the programmer to monitor a programs execution closely for debugging purposes.
Specifically, it can be used to examine and alter the contents of memory, to enter and run
programs, and to stop programs at certain points in order to check or even change data.
Student will learn
Data/Code
Mnemonics
MOV BL, 05
MOV CL, 10
MOV AL, CL
MUL BL
MOV DX, AX
Comments
;Load data 05 in register BL
;Load data 10 in register CL
; Position data
;Multiplying
; Storing product in register DX
15
16
Description:
The three steps to be followed to create an executable assembly language program are listed
as under
Steps
Input
Program
Output
1. Edit the program
Keyboard
Editor
myfile.asm
2. Assemble the program
myfile.asm
TASM or MASM
myfile.obj
3. Link the program
myfile.obj
TLINK or LINK
myfile.exe
Where, .asm, .obj, and .exe are the extension meaning assembler, object and executable file
respectively.
Directives:
.model (memory models)
Memory Models
Small
Medium
Compact
Large
Huge
64kb
64kb
Can exceed 64kb
64kb
64kb
Can exceed 64kb
Both can exceed 64kb (single data array cant exceed 64kb)
Both can exceed 64kb (single data array can exceed 64kb)
.stack 100h
Stack memory reserved 100 bytes
.data
Data segment starts
.code
Code segment starts
As it is obvious from the above description that a program is to be typed in by using an editor,
like Notepad (in windows) or Edit (in DOS) with the extension .asm, it is then presented to
an assembler program such as TASM (Turbo Assembler) or MASM (Microsofts Macro
Assembler) in the following manner, (assuming that you are working on the COMMAND
PROMPT)
C:\> MASM myfile.asm < return >
If no errors found in the program, MASM will generate an object file. This object file is to be
presented to the TLINK (Turbo Linker) or LINK as
C:\> LINK myfile.obj < return >
If no errors occur, this will generate an executable file ready to be run stand-alone.
Telecommunication Engineering Department
Sir Syed University of Engineering & Technology
17
18
Laboratory Exercise 4
Objective:
To learn how to implement loop in assembly language.
To learn how a software program affects the hardware signals and their connections.
Theory:
LOOP Command:
The Loop is implemented by using the command LOOP followed by the lable of the instruction
where to jump to. The maximum number of iterations (repetitions) is defined in the register CX.
The LOOP instruction first decrements the value of count defined in register CX and checks the
value of CX register. If the CX register contains a non-zero value the loop continues otherwise the
loop stops. For example, following code will add 1 in the value contained in register AL for 10
times.
MOV CX, 10
;CX=max. count value i.e.; 10
MOV AL, 0
;Initializing AL with zero
SUM: ADD AL, 1
;Add 1 to AL
LOOP SUM
;DEC CX and JNZ SUM
The alternate of the LOOP instruction can be a combination of two commands DEC and JNZ. To
demonstrate this the above code can be written as:
MOV CX, 10
MOV AL, 0
SUM: ADD AL, 1
DEC CX
JNZ SUM
It is also to be noted that the count initialization for the CX value is done outside the loop.
Loops can also be used to insert delays in a Program. In this lab exercise we will require to turn
on/off sequentially the LEDs interfaced on the BGC-trainer. To make the sequence visible we need
to put a delay in between.
19
Description:
The program controls the input signals SD0, SD1 and SD2.
When one of these signals is low (L) or logic 0 the corresponding LED is turn ON.
By adjusting the level of the input signals, the program can turn each LED OFF or ON at any
time.
In this program, the LEDs are turned ON and OFF in sequence to make them blink.
The frequency of blinking cycle is determined by the contents of the CX register.
Changing the value in the CX register changes the blinking frequency.
Assembly Language Program:
Address
-U0,1b
0100:0000
0100:0003
0100:0005
0100:0006
0100:0009
0100:000B
0100:000D
0100:000E
0100:0011
0100:0013
01000015
0100:0016
0100:0019
0100:001B
-g
Data/Code
BA70FF
BOFE
EE
B9401F
E2FE
B0FD
EE
B9401F
E2FE
B0FB
EE
B9401F
E2FE
EBE3
Mnemonics
Comments
MOV DX,FF70
MOV AL,FE
OUT DX,AL
MOV CX,1F40
LOOP 0009
MOV AL,FD
OUT DX,AL
MOV CX,1F40
LOOP 0011
MOV AL,FB
OUT DX,AL
MOV CX,1F40
LOOP 0019
JMP 0000
20
Description:
There are some extremely useful subroutines within BIOS and DOS that are available to the user
through the INT (Interrupt) instructions. The INT instruction is somewhat like a FAR CALL.
When it is invoked, it saves the value of CS:IP for the next instruction to be executed and flags on
the stack and load the value of the CS:IP of the ISR (Interrupt Service Routine), associated with
the interrupt, from the IVT (Interrupt Vector Table). The INT instruction has the following format
INT xx
This makes 256 interrupts in 80x86 microprocessors. Of these 256 interrupts, two are widely used
namely, INT 21H (DOS) and INT 10H (BIOS). Each of them can perform number of functions.
Various functions of INT 21H and INT 10H are selected by the value put in the AH register,
Download the documents regarding int 10h and int 21h from the course website.
http://www.ee322.tk.
Activity 1:
Write and run an Assembly language program to display Hello World!
Activity 2:
Write and run an Assembly language program to clear the screen and then set the cursor at desired
location on the screen and display Hello World!
Activity 3:
Write and run an Assembly language program to clear the screen and then set the cursor at desired
location on the screen and display the table of any number from 2 to 10.
21
Description:
String: A series of data words (or bytes) that reside in consecutive memory
locations
Examples: move, scan, compare
Some commands use for string handling
22
Activity 1:
Write and assemble a program in assembly language that scans the name Mr. Gones and
replaces the G with the letter J.
Activity 2:
Write and assemble a program in assembly language that scan the input string and determine if it
has letter O in it.
Activity 3:
Write and assemble a program in assembly language which compare the input string with a pre
defined string (password) and displays Access Granted on matching and displays Access
Denied if both the strings do not match.
23
Objective:
Materials:
Emulator (EMU8086)
Web Site:
www.emu8086.com
Description:
Emulator:
Emulator runs programs on a Virtual PC, this completely blocks your program from accessing real
hardware, such as hard-drives and memory, since your assembly code runs on a virtual machine,
this makes debugging much easier.
Everything for learning assembly language in one pack! Emu8086 combines an advanced source
editor, assembler, disassembler, software emulator (Virtual PC) with debugger, and step by step
tutorials. This program is extremely helpful for those who just begin to study assembly language.
It compiles the source code and executes it on emulator step by step.
Visual interface is very easy to work with. You can watch registers, flags and memory while your
program executes. Arithmetic & Logical Unit (ALU) shows the internal work of the central
processor unit (CPU).
Virtual Devices
Traffic Lights - Port 4 (word)
The traffic lights are controlled by sending data to I/O Port 4.
There are 12 lamps: 4 green, 4 yellow, and 4 red.
You can set the state of each lamp by setting its bit:
1 - the lamp is turned on.
0 - the lamp is turned off.
Only 12 low bits of a word are used (0 to 11), last bits (12 to 15) are unused.
For example:
MOV AX, 0000001011110100b
OUT 4, AX
24
We use yellow hexadecimal digits in caption (to achieve compact view), here's a conversion:
Hex - Decimal
A
B
C
D
E
F
10
11
12
13
14
15
(unused)
(unused)
(unused)
(unused)
First operand for OUT instruction is a port number (4), second operand is a word (AX)
that is written to the port. First operand must be an immediate byte value (0..255) or DX
register. Second operand must be AX or AL only.
If required you can read the data from port using IN instruction, for example:
IN AX, 4
First operand of IN instruction (AX) receives the value from port, second operand (4) is a
port number. First operand must be AX or AL only. Second operand must be an
immediate byte value (0,255) or DX register.
25
26
Activity 1:
Rotate the Stepper Motor one complete revolution clockwise.
Activity 2:
Rotate the stepper motor N times clockwise and M times counter clockwise, where N & M
represents last two digits of your roll number.
Activity 3:
Write and assemble a program to run traffic lights module.
27
Description:
The Fibonacci Series is a sequence of numbers first created by Leonardo Fibonacci (fi-bona-chee) in 1202. It is a deceptively simple series, but its ramifications and applications are nearly
limitless. It has fascinated and perplexed mathematicians for over 700 years, and nearly everyone
who has worked with it has added a new piece to the Fibonacci puzzle, a new tidbit of information
about the series and how it works. Fibonacci mathematics is a constantly expanding branch of
number theory, with more and more people being drawn into the complex subtleties of Fibonacci's
legacy. (do visit http://en.wikipedia.org/wiki/Fibonacci_number)
The series is like
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946,
17711, 28657, 46368, 75025, 121393,
In computing and electronic systems, binary-coded decimal (BCD) is an encoding for
decimal numbers in which each digit is represented by its own binary sequence. Its main virtue is
that it allows easy conversion to decimal digits for printing or display and faster decimal
calculations. Its drawbacks are the increased complexity of circuits needed to implement
mathematical operations and a relatively inefficient encoding it occupies more space than a pure
binary representation. In BCD, a digit is usually represented by four bits which, in general,
represent the values/digits/characters 0-9.
Activity 1:
Write and run an Assembly language program to generate the Fibonacci series upto 233.
Activity 2:
Write and run an Assembly language program to generate two digit BCD up/down counts
(00 999).
28
Reference:
Mazidi and McKinlay, The 8051 Microcontroller and Embedded Systems, Chapter 2.
Materials:
8051 assembler and simulator from Franklin Software Inc., Keil Corporation, or the assembler
of your choice.
Web Sites:
www.keil.com
Activity 1
Write and assemble a program to move value 99H to register A. Then from register A move it to
all registers R0 - R7. Use the simulator to single-step the program and examine the registers.
Activity 2
Write and assemble a program to add all the single digits of your ID number and save the result in
R2. Pick 7 random numbers (all single digit) if you do not want to use your ID number. Then use
the simulator to single-step the program and examine the registers.
Activity 3
Write and assemble a program that Sequentially and repeatedly turn on/off the 8 LEDs from the
leftmost LED to the rightmost LED.
Activity 4
Write and assemble a program to add the following data and then use the simulator to examine
the CY flag. 92H, 23H, 66H, 87H, F5H
Activity 5
Write and assemble a program to load values into each of registers R0 - R4 and then push each of
these registers onto the stack. Single-step the program, and examine the stack and the SP register
after the execution of each instruction.
Telecommunication Engineering Department
Sir Syed University of Engineering & Technology
29
Activity 6
Write and assemble a program to:
(a) Set SP = 0D,
(b) Put a different value in each of RAM locations 0D, 0C, 0B, 0A, 09, and 08,
(c) POP each stack location into registers R0 - R4.
Use the simulator to single-step and examine the registers, the stack, and the stack pointer.
30
A=
B=
R0=
R1=
R2=
R7=
2. For Question 1, indicate the largest value (in decimal) that each register can contain.
PC =
A=
B=
R0=
R1=
R2=
R7=
3. For Question 1, indicate the largest value (in hex) that each register can contain.
PC =
A=
B=
R0=
R1=
R2=
R7=
4. Who generates each of the following files and what is the use of each.
.asm
.lst
.obj
.abs
.hex
31
5. Find the value of the CY flag after the execution of the following code.
(a)
MOV A,#85H
ADD A,#92H
(b)
MOV A,#15H
ADD A,#72H
(c)
MOV A,#0F5H
ADD A,#52H
(d)
MOV A,#0FF
INC A
8. Upon popping data from the stack, the SP register is ___________ (decremented,
incremented).
9. Can you change the value of the SP register? If yes, explain why you would want
to do that.
10. The stack uses the same area of RAM as bank ______.
32
Materials:
8051 assembler and simulator.
MTS-51 Trainer
Activity 1
Sequentially and repeatedly turn on/off the 8 LEDs from the leftmost LED to the rightmost LED.
The on time of each LED is 0.1 seconds.
Activity 2
Sequentially and repeatedly turn on/off the 8 LEDs from the leftmost LED to the rightmost LED.
When the rightmost LED is reached, the sequence is inverted. The on time of each LED is 0.1
seconds.
Activity 3
Sequentially turn on/off two LEDs from the two ends towards the middle. When the middle
reached, the sequence is inverted. The ON time of each LED is 1 second.
Activity 4
Turn on LEDs according to the following cases and repeat each case 8 times.
Case 1: Turn on LEDs from left to right.
Case 2: Turn on LEDs from right to left.
Case 3: Blink two sets (left and right sides) of LEDs alternately.
Case 4: Blink all of 8 LEDs.
33
Materials:
8051 assembler and simulator.
MTS-51 Trainer
Activity 1
(Two-Digit Up Counter)
Sequentially and repeatedly show the numbers 00 through 99 on DS3 and DS4. Each number
stays on 0.5 seconds.
Activity 2
Sequentially and repeatedly show the numbers 99 through 00 on DS3 and DS4. Each number
stays on 0.5 seconds.
Activity 3
Sequentially show the numbers from 00 to 99 and then from 99 to 00 on DS3 and DS4, and repeat
the sequence. Each number stays on 0.7 seconds.
Activity 4
Sequentially show the numbers from 00 to 99 on DS3 (ten digit) and DS4 (Units digit) using table
look up. Each number stays on 0.3 seconds.
34
Materials:
8051 assembler and simulator.
MTS-51 Trainer
Hardware Description:
The signal to the speaker driver input comes from P3.7 pin. When a HIGH is fed to it the speaker
turns ON. When a LOW is fed the speaker is turned OFF.
Activity 1
(Speaker control)
Generate a 1-KHz tone for the Speaker interface on the MTS-51 trainer.
Activity 2
Speaker sounds a 1 KHz tone for 0.5 seconds and then keeps silence 0.5 seconds.
35
Laboratory Exercise 9
OBJECTIVES:
This experiment demonstrates the interfacing and control of 8x8 dot matrix LED (D3). And
uses it to display static and dynamic alphabets and decimal number.
HARDWARE DESCRIPTION:
The D3 is a common cathode matrix LED. The row scan signal is emitted from P2 and the
column scan signal is emitted from P0. Both row and column scan signal are active-high signals,
that is, all LEDs are turned on when the row and column signals are all 1s. The 2803 Darlington
pairs are used to sink column currents.
MATERIALS:
8051 assembler and simulator.
MTS-51 Trainer
ACTIVITY 1
Sequentially turn on the column LEDs from column 1 to column 8 eight times, and then turn on
the row LEDs from row 1 to row 8 eight times.
ACTIVITY 2
ACTIVITY 3
ACTIVITY 4
Sequentially show 5x7-dot characters A through Z and numbers 0 through 9, and move it from the
left to right.
36
Laboratory Exercise 10
OBJECTIVES:
To learn Step Motor interfacing and to control the on-board 4-phase step motor M1 on
MTS-51 Trainer.
HARDWARE DESCRIPTION:
The motor coils A, B, A, B are energized by the signals on P2.3, P2.2, P2.1, P2.0,
respectively. Place switch SW2_8 in ON position. There are three switching schemes: 1phase-on, 2-phase-on and 1-2-phase-on switching.
MATERIALS:
8051 assembler and simulator.
MTS-51 Trainer
ACTIVITY 1
(Direction Control)
Drive the Step-motor to rotate in Clock-Wise (CW) direction using 2-phase-on switching.
ACTIVITY 2
(Revolution Control)
Drive the Step-motor to rotate one revolution CW and then rotate one revolution CCW,
continuously.
ACTIVITY 3
(Speed Control)
Drive the Step-motor to rotate one revolution CCW and then rotate two revolutions CW but with
double the CW revolution speed, continuously.
37
Laboratory Exercise 11
OBJECTIVES:
This experiment demonstrates the matrix keyboard control.
Using the matrix keyboard control to the 4-phase step motor M1 on MTS-51 Trainer.
Hardware Description:
The matrix keyboard KB1 and ecoder 74C922 builds the keyboard circuit. If a key is pressed ,
the corresponding binary value will present on the outputs DOD-DOA (P1.3 P1.0) of the
encoder, as well as Data Available (DA) signal on the DA output. The DA signal is inverted by
an inverter and then connected to P3.2 (INT0) pin.
MATERIALS:
8051 assembler and simulator.
MTS-51 Trainer
ACTIVITY 1
1. Show the key number on the 7-segment display DS4 when a key is pressed.
2. Place SW2-3 in ON position.
ACTIVITY 2
Using the following keys on matrix keyboard, control the state of LEDs:
a) Key 0 pressed, all the 8 LEDs light up simultaneously.
b) Key 1 pressed, all the 8 LEDs blink.
c) Key 2 pressed, two sets (left and right sides) of LEDs blink alternately.
ACTIVITY 3
ACTIVITY 4
The step motor rotates CW the same number of revolutions as the key pressed (0-9)
38
Laboratory Exercise 12
OBJECTIVES:
This experiment demonstrates the application of LCD module (LCM). LCMs are widely
used to display alphanumeric characters. The LCM on MTS-51 Trainer is a 20 characters x
2 lines back-light LCM.
Hardware Description:
SW2-5 should be placed in ON position. P0 lines are connected to the data bus DB0-DB7
of LCM. P1.5, P1.6, and P1.7 are connected to RS, R/W, and E pins, respectively.
MATERIALS:
8051 assembler and simulator.
MTS-51 Trainer
ACTIVITY 1
Show the character string Hello ! Welcome in the middle of the first line of LCM.
ACTIVITY 2
Show the character string Sir Syed University in the middle of the first line of LCM and blink it
every 0.5 second interval.
ACTIVITY 3
Show the character string Hello ! Welcome on the right side of the first line of LCM and slowly
move to the middle position, and blink it.
ACTIVITY 4
Show the key value on the LCM screen and blink the cursor.
ACTIVITY 5
Design a 4-digit counter which automatically increments its value every second, and shows the
result in the middle of the first line of LCM screen.
ACTIVITY 6
39
Laboratory Exercise 13
OBJECTIVES:
To learn on-chip Timer/ counter control and their operation in Modes 0 and 1.
Demonstrate the operation of basic pulse counter
Hardware Description:
Mode 0: 13-bit timer
Mode 1: 16-bit timer/ counter
SW2-4 should be placed in ON position.
MATERIALS:
8051 assembler and simulator.
MTS-51 Trainer
ACTIVITY 1
(Timer/counter Mode-0)
Program timer/counter 0 operating in mode 0 and blink LEDs (D5) alternately. The ON/OFF time
is 1 second.
ACTIVITY 2
(Timer/counter Mode-1)
Program timer/counter 0 operating in mode 1 and sequentially turn on/off LEDs from leftmost to
the rightmost. The ON/OFF time is 0.5 seconds each.
ACTIVITY 3
Count the number of pulses from the 555 oscillator output and show the result on 7-segment
displays.
40
Laboratory Exercise 14
OBJECTIVES:
This experiment demonstrates the control application of photo interrupter.
Hardware Description:
The MTS-51 has two photo-interrupts PH1 and PH2. When light is blocked, the
phototransistor is cut off and low presents on the inverter output terminal. When light is
not blocked the phototransistor conducts in saturation and a high presents on the inverter
output terminal
MATERIALS:
8051 assembler and simulator.
MTS-51 Trainer
ACTIVITY
Use PH2 output to control the direction of rotation of the step motor. When PH2 is not blocked by
an object (for example, a piece of paper), the step motor rotates CW. If PH2 is blocked by an
object, the step motor rotated CCW.
41
Laboratory Exercise 15
OBJECTIVES:
This experiment demonstrates the Serial Communication using on-chip serial port Mode 1.
This experiment demonstrates the Output port expansion using serial port Mode 0.
Hardware Description:
The serial port in mode 0 acts a shift register which sends 8 data bits through RXD and the
TXD on transmit. SIPO is followed.
If two MTS-51 trainers are used, the JP2s on MTS-trainers should be interconnected such
that TXD of one is connected to the RXD of other, with a common Ground for both.
MATERIALS:
8051 assembler and simulator.
MTS-51 Trainer
ACTIVITY 1
(UART in Mode-1)
When a key is pressed on one MTS-51 trainer, the key is displayed on the 7-segment of the other
MTS-51 trainer
ACTIVITY 2
Program for the following sequence:
1. Sequentially turn on/off LEDs from left to right, 4 times
2. Sequentially turn on/off LEDs from right to left, 4 times
3. Sequentially turn on/off LEDs from left to right, and then invert the sequence 2 times.
4. Blink two sets of LEDs (right and left sides) alternately, 4 times
5. Turn on/off two LEDs ends to the middle and then from middle to ends, 4 times
[Place SW2_2 in ON position to enable LED pack 04]
42