Microprocessor & Interfacing LAB 501) (Becp: Lab Ma Nual V Semester
Microprocessor & Interfacing LAB 501) (Becp: Lab Ma Nual V Semester
Interfacing LAB
(BECP 501)
LAB MA NUAL
V SEMESTER
3
To perform BCD To HEX Conversion and HEX to BCD
Conversion.
4
To Design Counter Using Timer
6
Interfacing with 8085/8086-8279, 8255.
8
Stepper motor Interfacing and Seven Segment Display
Interfacing using 8051.
EXPERIMENT-1(A)
ALGORITHM:
Flow Chart:
PROGRAM:
OBSERVATION:
Input: 80 (4150)
80 (4251)
Output: 00 (4152)
01 (4153)
RESULT:
ALGORITHM:
1) Start the program by loading HL register pair with address of memory location.
2) Move the data to a register (B register).
3) Get the second data and load into Accumulator.
4) Add the two register contents.
5) Check for carry.
6) Increment the value of carry.
7) Check whether repeated addition is over and store the value of product and
carry in memory location.
8) Terminate the program.
PROGRAM:
OBSERVATION:
Input: FF (4150)
FF (4151)
Output: 01 (4152)
FE (4153)
RESULT:
ALGORITHM:
PROGRAM:
Output: FE (4300)
RESULT:
Thus the program to find the largest number in an array of data was executed
EXPERIMENT-3(A)
ALGORITHM:
FLOW CHART
PROGRAM:
LXI H,4150
MOV A,M Initialize memory pointer
ADD A MSD X 2
MOV B,A Store MSD X 2
ADD A MSD X 4
ADD A MSD X 8
ADD B MSD X 10 INX H Point to LSD
ADD M Add to form HEX
INX H
MOV M,A Store the result HLT
OBSERVATION:
Output: 4152 : 1D H
RESULT:
Thus the program to convert BCD data to HEX data was executed.
EXPERIMENT-3(B)
AIM:-To convert given Hexa decimal number into its equivalent BCD number using 8085
instruction set
ALGORITHM:
PROGRAM:
Input: 4150 : FF
RESULT: Thus the program to convert HEX data to BCD data was executed.
EXPERIMENT-6(A)
APPARATUS REQUIRED:
The output will be initially low after mode set operation. After loading the counter, the
output will remain low while counting and on terminal count, the output will become high
until reloaded again.
Let us see the channel in mode0. Connect the CLK 0 to the debounce circuit and
execute the following program.
PROGRAM:
MVI A, 30H ;Channel 0 in mode 0.
OUT CEH
MVI A, 05H ;LSB of count.
OUT C8H
MVI A, 00H ;MSB of count.
OUT C8H
HLT
It is observed in CRO that the output of channel 0 is initially low. After giving ‘x’ clock
pulses, we may notice that the output goes high.
The following program initializes channel 0 of 8253 in Mode 1 and also initializes
triggering of gate. OUT 0 goes low as clock pulses and after triggering It goes back to
high level after five clock pulses. Execute the program and give clock pulses through the
debounce logic and verify using CRO.
PROGRAM:
MVI A, 32H ;Channel 0 in mode 1.
OUT CEH ;
MVI A, 05H ;LSB of count.
OUT C8H
MVI A, 00H ;MSB of count.
OUT C8H
OUT DOH ;Trigger Gate 0.
HLT
It is a simple divide by N counter. The output will be low for one period of the input
clock. The period from one output pulse to next equals the number of input count in the
count register. If the count register is reloaded between output pulses, the present period
will not be affected, but the subsequent period will reflect a new value.
It is similar to mode 2 except that the output will remain high until one half of the count
and goes low for the other half provided the count is an even number. If the count is odd
the output will be high for (count +1)/2 counts. This mode is used for generating baud rate
of 8251.
PROGRAM:
We utilize mode 3 to generate a square wave of frequency 150 kHz at Channel 0.Set the
jumper so that the clock of 8253 is given a square wave of Frequency 1.5 MHz. This
program divides the program clock by 10 and thus the Output at channel 0 is 150 KHz.
The output is high after the mode is set and also during counting. On Terminal count, the
output will go low for one clock period and becomes high again. This mode can be used
for interrupt generation.
Counter starts counting after rising edge of trigger input and the output goes low for one
clock period. When the terminal count is reached, the counter is retrigerrable. On terminal
count, the output will go low for one clock period and becomes high again. This mode can
be used for interrupt generation.
RESULT:
Thus the 8253 PIT was interfaced to 8085 and the operations for mode 0, Mode 1 and
mode 3 was verified.
EXPERIMENT-7(A)
AIM: Interfacing with 8085/8086-8279, 8251
APPARATUS REQUIRED:
PROGRAM:
4130 - FF
4131 –FF
4132 –FF
4133 –FF
4134 –FF
4135 –FF
4136 –FF
4137 –FF
4138 –98
4139 –68
413A -7C
413B -C8
413C -1C
413D -29
413E -FF
413F -FF
RESULT:
Thus 8279 controller was interfaced with 8085 and program for rolling display was
executed successfully.
EXPERIMENT-7(B)
AIM: Interfacing with 8085/8086-8279, 8251.
THEORY:
The 8251 is used as a peripheral device for serial communication and is programmed by
the CPU to operate using virtually any serial data transmission technique. The USART
accepts data characters from the CPU in parallel format and then converts them into a
continuous serial data stream for transmission. Simultaneously, it can receive serial data
streams and convert them into parallel data characters for the CPU. The CPU can read the
status of USART ant any time. These include data transmission errors and control signals.
Prior to starting data transmission or reception, the 8251 must be loaded with a set
of control words generated by the CPU. These control signals define the complete
functional definition of the 8251 and must immediately follow a RESET operation.
Control words should be written into the control register of 8251. These control words are
split into two formats:
This format defines the Baud rate, Character length, Parity and Stop bits required to work
with asynchronous data communication. By selecting the appropriate baud factor sync
mode, the 8251 can be operated in Synchronous mode.
S2 S1 EP PEN L2 L1 B2 B1
CHARACTR LENGTH
0 1 0 1
0 0 1 1
6 7
5 BITS BITS BITS 8 BITS
PARITY ENABLE
1= ENABLE 0 = DISABLE
S2 S1 EP PEN L2 L1 B2 B1
CHARACTER LENGTH
0 1 0 1
0 0 1 1
5 BITS 6 BITS 7 BITS 8 BITS
PARITY ENABLE
1= ENABLE 0 = DISABLE
This format defines a status word that is used to control the actual operation of 8251. All
control words written into 8251 after the mode instruction will load the command
instruction.
The command instructions can be written into 8251 at any time in the data block
during the operation of the 8251. to return to the mode instruction format, the master reset
bit in the command instruction word can be set to initiate an internal reset operation which
automatically places the 8251 back into the mode instruction format. Command
instructions must follow the mode instructions or sync characters.
Thus the control word 37 (HEX) enables the transmit enable and receive enable
bits, forces DTR output to zero, resets the error flags, and forces RTS output to zero.
TRANSMIT ENABLE
1=Enable 0 = Disable
RECEIVE ENABLE
1=Enable 0 = Disable
ERROR RESET
1=Reset Error Flags
PE,OE,FE
REQUEST TO SEND
HIGH will force RTS
Output to Zero
INTERNAL RESET
HIGH Returns 8251 to
Mode Instruction Format
PROGRAM:
MVI A,36H
OUT CEH
MVI A,0AH
OUT C8H
MVI A,00
OUT C8H
LXI H,4200
MVI A,4E
OUT C2
MVI A,37
OUT C2
MVI A,41
OUT C0
RST 1
ORG 4200
IN C0
STA 4500
RST 1
OBSERVATION:
Output: 4500 41
RESULT:
Thus the 8251 was initiated and the transmission and reception of character was
done successfully.
Experiment-8(A)
AIM : -Stepper motor Interfacing and Seven Segment Display Interfacing using 8051.
APPARATUS REQUIRED:
THEORY:
A seven segment display consists of seven LEDs arranged in the form of a squarish’8′
slightly inclined to the right and a single LED as the dot character. Different characters
can be displayed by selectively glowing the required LED segments. Seven segment
displays are of two types, common cathode and common anode. In common cathode
type , the cathode of all LEDs are tied together to a single terminal which is usually
labeled as ‘com‘ and the anode of all LEDs are left alone as individual pins labeled as a,
b, c, d, e, f, g & h (or dot) . In common anode type, the anode of all LEDs are tied
together as a single terminal and cathodes are left alone as individual pins. The pin out
scheme and picture of a typical 7 segment LED display is shown in the image below.
.
ALGORITHM:
1. Digit drive pattern of a seven segment LED display is simply the different logic
combinations of its terminals ‘a’ to ‘h‘ in order to display different digits and dcharacters.
2. The common digit drive patterns (0 to 9) of a seven segment display are shown in the table
below
3. The circuit diagram shown above is of an AT89S51 microcontroller based 0 to 9 counter
which has a 7 segment LED display interfaced to it in order to display the count.
4. This simple circuit illustrates two things. How to setup simple 0 to 9 up counter using
8051 and more importantly how to interface a seven segment LED display to 8051 in order
to display a particular result.
5. The common cathode seven segment display D1 is connected to the Port 1 of the
microcontroller (AT89S51) as shown in the circuit diagram. R3 to R10 are current limiting
resistors. S3 is the reset switch and R2,C3 forms a debouncing circuitry
PROGRAM:
Experiment-8(B)
AIM : -Stepper motor Interfacing and Seven Segment Display Interfacing using 8051.
APPARATUS REQUIRED:
8051 Trainer Kit
Stepper Motor Interface Board
Seven segment display
THEORY:
A motor in which the rotor is able to assume only discrete stationary angular position is
a stepper motor. The rotor motion occurs in a stepwise manner from one equilibrium
position to next.
The motor under our consideration uses 2 – phase scheme of operation. In this scheme,
any two adjacent stator windings are energized. The switching condition for the above
said scheme is shown in Table.
In order to vary the speed of the motor, the values stored in the registers R1, R2, R3 can be
changed appropriately.
ALGORITHM:
PROGRAM:
ORG 4100
START: MOV DPTR,#4500H
MOV R0,#04
AGAIN: MOVX A,@DPTR
PUSH DPH
PUSH PDL
MOV DPTR,#FFC0H
MOV R2, 04H
MOV R1,#FFH
DLY1: MOV R3, #FFH
DLY: DJNZ R3,DLY
DJNZ R1,DLY1
DJNZ R2,DLY1
MOVX @DPTR,A
POP DPL
POP DPH
INC DPTR
DJNZ R0,AGAIN
SJMP START
DATA:
RESULT:- Stepper motor Interfacing and Seven Segment Display Interfacing using 8051
is Studied.