Microprocessor Ece Lab Manual
Microprocessor Ece Lab Manual
Vi INSTITUTE OF TECHNOLOGY
SIRUNKUNDRAM-603108
Department of Electronics and Communication Engineering
EXPERIMENTS IN SYLLABUS
8086 PROGRAMING
1.
2.
3.
4.
INTERFACING EXPERIMENTS
1. Interfacing ADC and DAC
2. Interfacing with 8279,8259,8253.
3. Interfacing with stepper Motor and DC motor
COMMUNICATION BETWEEN TWO MP KIT
1. Serial Communication Between Two MP kit using 8251.
2. Parallel Communication Between Two Mp kit using Mode 1 and mode 2 of 8255.
8051 PROGRAMMING
1. Programming using Arithmetic,Logical,bit Manipulation
2. Programing in Timer,Interrupt,UART
3. Communication b/w 8051 and PC.
CONTENTS
Sl.No
Date
Experiment
Page
No
Signature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
EX NO :
DATE
AIM
To study about the 8086 microprocessor kit.
HARDWARE SPECIFICATIONS
1. CPU PROCESSOR AND CLOCK FREQUENCY
Intel 8086/8088 CPU at 5/4.77 MHz clock rate [Optionally 8 MHz]
2. MEMORY
MONITOR EPROM: F000:0000 - 3FFF for 16 K
EPROM EXPANSION: F000:0000 - 1FFF for 64 K
SYSTEM RAM: 0000:1000 - 3FFF for 16 K
SYSTEM RAM EXPANSION: 0000:1000 - FFFF for 64 K
INTERRUPT VECTORS: 0000:0000 - 03FF
3. PERIPHERALS
PARALLEL I/O: 48 I/O lines using two numbers of 8255.
SERIAL: One number of RS232C - Serial Interface using8251A USART.
TIMER: 3 Channel 16-bit Programmable Timer 8253. Channel0 used as baud rate generator
for the Serial Port.
4. DISPLAY
162 LCD DISPLAY [with Back light provision]
5. KEYBOARD
IBM PC-AT KEYBOARD
6. ON-BOARD BATTERY BACKUP: (Optional)
Onboard battery backup facility is optionally provided for RAM (U2 & U4).
7. POWER CONSUMPTION
+ 5 V: 1.5 Amps
SOFWARE SPECIFICATIONS
1. ASSEMBLER COMMAND
FUNCTION
This command is used to enter the mnemonics of 8086 and it gives the opcode for the
Mnemonics.
SYNTAX
#A <CR>
A - Line Assembler Command.
PROCEDURE
1. After entering the 'A' command, the kit is displayed as follows
Now, you entered the user RAM address and programs, for every mnemonics for 8086
entered,
it gives the opcode.
2. DIS-ASSEMBLER COMMAND
FUNCTION
This command gives the mnemonics and corresponding opcode in the given address.
SYNTAX
#U <CR>
U - Dis Assembler Command.
PROCEDURE
1. After entering the 'U' command, the kit is displayed as follows.
2) Use enter to examine the next location or to increment the memory location and the '--'
key to view previous locations. ie. to decrement the memory location.
3) To modify the contents, enter the new data and press enter key.
4) To terminate this command press a dot (.)
4. REGISTER COMMAND
FUNCTION
To examine and modify the register contents of the CPU.
SYNTAX
#R <R>
R - Register view / modify command word.
PROCEDURE
i) Enter register command when prompted for entry.
ii) Initially "AX" register is displayed
iii) Press enter or "-" key to view the subsequent or the previous register in the order as given
in the table below.
iv) Change data to any register if desired and press carriage return
v) The sequence is circular and there fore apressing enter key after the last register order,
Will again display the first one.
vi) To terminater this command press dot (.)
5. GO & EXEC COMMAND
FUNCTION
The GO command us used to Run a program. This command transfers control of the 8086A
CPU from the monitor program to user programs.
SYNTAX
# GO <ADDR> <CR>
GO - GO Command.
<ADDR> - 16 bit address. either segment : offset or offset only)
<CR> - Carriage return.
PROCEDURE
i) Type GO command with address from where execution should start.
ii) Now, the control is transferred to the address entered by you and the display will be as
shown below.
iii) To exit from the execution and to return control to the monitor, press reset key or
Interrupt key in the kit.
iv) By using INT-2 instruction with opcodes CD01, you can transfer control to monitor
without saving any registers. CD, 02 should be placed at the end of the program
6. TRACE COMMAND
FUNCTION
This command helps the user to execute programs in steps i.e instruction. This command will
be very helpful while debugging programs.
DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)
SYNTAX
#TR <Addr> <CR>
TR - Trace command word.
<Addr> - Program starting Address. (segment : offset of offset only)
<CR> - Carriage Return.
PROCEDURE
i) Enter the Trace command with the above syntax.
ii) Now the first instruction is executed an the registers are updated.
iii) The next instruction to be executed and the memory location are displayed.
iv) Since, registers are updated after each individual instruction, you can view the register
contents after any execution of individual instruction.
v) Press dot (.) to return to monitor and view registers or memory locations are desired.
vi) Continue single stepping after viewing register contents by again executing trace
command
8.INPUT COMMAND
FUNCTION
This command inputs data from the desired port.
SYNTAX
i) #IB <Port Address> <CR>
IB - Input Byte command word.
<Port Addr> - Valid Input Address. (i.e 0000 to FFFFH).
<CR> - Carriage return.
ii) #ISW <Port Addr> <CR>
IW - Input word command
PROCEDURE
i) Enter IB command in the above stated syntax.
ii) Now, the data would be read and displayed as shown below.
RESULT
Required Components
specification
Qty
1.
MICROPROCESSOR
2.
POWER CHORD
+5V SUPLLY
3.
KEY BOARD
THEORY
The "add" instruction requires either the addend or the augend to be in a register,
unless the source operand is immediate since the addressing modes permitted for the source
and destination are register-register, memory-register, register -memory, register-immediate,
and finally memoryimmediate. Our objective is to obtain the sum of two numbers in
memory.Hence one of the operands is initially moved to AX. Then using the add instruction,
16 bitaddition is performed.
The next arithmetic primitive is SUB. As discussed in ADD it permits the same modes of
addressing. Hence moving the minuend to a register pair is necessary. Then the result is
movedto a location in memory.
Unlike most of the 8 bit processors which do not have an arithmetic multiply
instruction, 16 bit processors from 8086 upward provide both signed and unsigned multiply
in their instruction sets to overcome the loss of efficiency in performing repeated addition.
The MUL instruction can have both 16 and 8 bit operands and the multiplicand is AX or AL,
accordingly the result for a byte multiply is a 16 bit number in AX while that for a word
multiply is a 32 bit number, the lower word of which is in AX and the higher word in DX.
Using the DIV instruction of 8086, both division of a double word by a word and a
word by a
byte can be performed. For the first case, the lower order word of the dividend is in AX and
the higher order word is in DX. The quotient is in AX and remainder in DX. For the second
case, the dividend is in AL, the quotient is in AL and the remainder in AH.
FLOW CHART
ALGORITHM
(i) 16-bit addition
Get the first number.
Add the second number to the first number.
Store LSBs of sum.
Store MSBs of sum
PROGRAM FOR ADDITION
Memory address
Opcodes
Mnemonics
MOV AX, [1100]
Comments
Load the data into 16 bit
register AX from the memory
1100
ADD AX,[1102]
MOV [1200], AX
HLT
EXAMPLE
OBSERVATION
ALGORITHM
(ii) 16-bit subtraction
Get the first number
Subtract the second number from the first number.
Store LSBs of difference
Store MSBs of difference.
Opcodes
Mnemonics
MOV AX, [1100]
Comments
Load the data into 16 bit
register AX from the memory
1100
SUB AX,[1102]
MOV [1200], AX
HLT
EXAMPLE
OBSERVATION
[1200] = 63FD
Opcodes
Mnemonics
MOV AX, [1100]
MOV BX,[1102]
MUL BX.
MOV [1200],DX
MOV [1202], AX
HLT
Comments
Load the data into 16 bit
register AX from the memory
1100.
Load the data in to BX register
from the memory 1102.
Multiply the Accumulator
content
with
the
BX
register.The higher order byte
will be stored in DX register
and the Lower order byte will
be stored in the AX register.
Move the DX content to 1200
Move the AX content to 1202.
Terminate the progream
EXAMPLE
OBSERVATION
Opcodes
Mnemonics
MOV DX, [1100]
MOV AX, [1102]
MOV CX,[1104]
DIV CX
Comments
Load the data into 16 bit
register DX from the memory
1100.
Load the data in to AX register
from the memory 1102.
Load the data in to CX register
from the memory 1104.
Divide the DX and
AX content by CX and the
result will be stored in DX and
AX
Move the AX content to 1200
MOV [1200], AX
MOV [1202], DX
.
Terminate the progream
HLT
EXAMPLE
Data: Dividend : [1100] = 0000
[1102] = FFFF
Divisor : [1104] = FFFF
Result:Quotient: [1200] = 0001
OBSERVATION
PROCEDURE
Enter the Mnemonics starting from the RAM address1000 by using (A command).
Enter the two input data in the location 1100 and 1102 using (SB command)
Execute the program with the command (GO starting address).
Check the corresponding result in the location 1200 and 1201
Change the data in the location 1100and 1102 and verify the result
RESULT
EX NO :
DATE :
STRING MANIPULATION
AIM:
i.
To move a byte string of length FF from a source to a destination using MOVSB
instruction
ii.
To fill the locations 1100 to 11FF in memory with the byte 34 using STOSB
APPARATUS REQUIRED
S.no
Required Components
specification
Qty
1.
MICROPROCESSOR
2.
POWER CHORD
+5V SUPLLY
3.
KEY BOARD
THEORY
Since the 8086 includes the string primitives, which require initialisation of the index
registers,the SI and DI registers are initialised to start of the source and start of the
destination array respectively. The direction flag is cleared to facilitate auto incrementing of
the index registers. The CX register is used to perform the operation repeatedly. The string
START
primitive used in MOVS. In the case of MOVE operation,
the status of the direction flag is
however immaterial. The function STOS will store the byte in AL or the word in AX
depending upon the operand size, from the location pointed to by the destination index DI. So
if we want to fill a block with a particular data then we should set destination index to the
beginning of the block and then use the STOSW instruction or theSTOSB instruction and use
DS,ES,SI,DI
CX to get the required length. S_ARRAY isInitialize
the location
1100 in this program.
ALGORITHM
a.
b.
c.
d.
e.
f.
Decrement CX
FLOWCHART
Check
for ZF=1
`
NO
OPCODES
MNEMONICS
COMMENTS
MOV SI,2000
MOV DI,2100
MOV CX, FF
PROCEDURE
i.
ii.
iii.
OPCODES
MNEMONICS
COMMENTS
MOV CX,,FFH
MOV DI,2100
MOV AX, 34H
EXAMPLE
Input: [AX] = 0034
Result: [1100] to [11FF] = 34
OBSERVATION
PROCEDURE
i.
ii.
RESULT
EX NO :
DATE :
AIM
Write an Assembly Language Program to arrange a given series of hexadecimal bytes in
ascending order
Write an ALP to find out the number of even and odd numbers from a given series of 16 bit
hexadecimal number.
THEORY
The simplest logic to decide wheather a binary number is even or odd is to check the least significant bit
of a number.if it is 0 ,the number is even else it is odd.Check LSB by rotaying the number through carry
flag and Increment even and odd number.
APPARATUS REQUIRED
S.no
Required Components
specification
Qty
1.
MICROPROCESSOR
2.
POWER CHORD
+5V SUPLLY
3.
KEY BOARD
ALGORITHM:
(i) Searching Even and odd numbers in an array
a.
b.
c.
d.
PROCEDURE
1.
2.
3.
4.
Memory
address
opcode
label
AGAIN:
ODD:
NEXT:
mnemonics
comments
MOV CL,COUNT
MOV SI,1200H
MOV AX,[SI]
ROR AX,01
JC ODD
INC BX
JMP NEXT
INC DX
ADD SI,02
DEC CL
JNZ AGAIN
Initialize count
Move the content
from the memory
location 1200 to SI
Move the content of
SI to AX
Rotate right without
carry
Carry occur means
go to ODD
MOV [1300],BX
MOV [1400],DX
HLT
LOOK UP TABLE
Increment BX(even)
Increment DX(odd)
Increment SI
Decrement count
Store Odd and even
value.
OBSERVATION
NO OF EVEN:
NO OF ODD :
FLOWCHART
ASCENDING ORDER
DESCENDING ORDER
START
START
INITIALIZE POINTER
INITIALIZE POINTER
COUNT = COUNT 1
COUNT = COUNT 1
FLAG = 0
FLAG = 0
YES
IS
POINTER
POINTER
NO
+1
YES
TEMP = POINTER
POINTER = POINTER + 1
POINTER + 1 = TEMP
POINTER = POINTER +1
COUNT = COUNT + 1
NO
IS
POINTER
POINTER NO
+1
TEMP = POINTER
POINTER = POINTER + 1
POINTER + 1 = TEMP
POINTER = POINTER +1
COUNT = COUNT + 1
NO
IS
IS
COUNT
COUNT
=0
YES
NO
=0
IS
IS
FLAG
FLAG
= 0
YES
STOP
YES
YES
= 0
STOP
ALGORITHM:
(ii) Sorting in ascending order:
e. Load the array count
f. Compare the numbers and exchange if necessary so that the two numbers are in
ascending order.
g. Decrement count.
h. Get the third number from the array and repeat the process until count is 0.
PROGRAM
Memory
address
opcode
label
mnemonics
comments
AGAIN0
MOV CX,COUNT
Initialize count
MOV SI,1200H
AGAIN1: MOV AX,[SI]
CMP AX,[SI+2]
JL PR1
XCHG [SI+2],AX
XCHG [SI],AX
PR1:
ADDSI,02
LOOP AGAIN1
DEC DX
JNZ AGAIN0
HLT
EXAMPLE
1200-11 1201-22 1202-44 1203-08
OUTPUT
1200-08 1201-11 1202-22 1203-44
OBSERVATION
INPUT
MEMORY ADDRESS VALUE
OUTPUT
MEMORY ADDRESS VALUE
PROCEDURE
1.Enter the mnemonics in the kit .
2.Enter the input value in the location 1200.
3.Execute the Program
4.check the values are arranged in ascending order in the location 1200.
RESULT
EX NO :
DATE :
AIM
DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)
To write a program to implement Real time Clock in 8086 kit using Timer.
APPARATUS REQUIRED
S.no
Required Components
specification
Qty
1.
MICROPROCESSOR
2.
POWER CHORD
+5V SUPLLY
3.
KEY BOARD
4.
9-9 CABLE
PC
1
RS232
1
1
SOFTWARE SPECIFICATION
MASM SOFTWARE
PROGRAM
code segment
assume cs:code
org
1000h
convert
call
display
mov
al,0b0h
out
16h,al
mov
cl,07h
mov
al,88h
out
14h,al
mov
al,80h
delay:
s2:
out
14h,al
s1:
nop
nop
nop
nop
in
al,14h
mov
dl,al
in
al,14h
or
al,dl
jnz
s1
dec
cl
jnz
s2
mov
si,1500h
mov
al,[si]
inc
al
mov
[si],al
cmp
al,3ch
jnz
start
mov
al,00h
mov
[si],al
inc
si
mov
al,[si]
inc
al
mov
[si],al
cmp
al,3ch
jnz
start
mov
al,0
mov
[si],al
inc
si
mov
al,[si]
inc
al
mov
[si],al
cmp
al,18h
jnz
start
mov
al,0
mov
[si],al
jmp
start
display:
mov
ah,06h
mov
dx,1600h
mov
ch,01h
mov
cl,0h
int
ret
convert:
mov
si,1500h
mov
bx,1608h
mov
al,24h
mov
[bx],al
mov
al,[si] ;seconds
mov
ah,0
mov
dh,0ah
div
dh
add
ah,30h
dec
bx
mov
[bx],ah
dec
bx
add
al,30h
mov
[bx],al
dec
bx
mov
al,3ah
mov
[bx],al
dec
bx
inc
si
mov
al,[si]
mov
ah,0
mov
dh,0ah
;minutes
div
dh
add
ah,30h
mov
[bx],ah
dec
bx
add
al,30h
mov
[bx],al
dec
bx
mov
al,3ah
mov
[bx],al
dec
bx
inc
si
mov
al,[si]
mov
ah,0
mov
dh,0ah
div
dh
add
ah,30h
mov
[bx],ah
dec
bx
add
al,30h
mov
[bx],al
;hours
ret
getc:
in
al,02h
and
al,0FFH
cmp
al,0f0h
jne
getc
code ends
end
PROCEDURE
1.Open command window (click:
start->run->type cmd )
3.In that window change the directry [Where you paste the masm
4.In the command window type the directory name after that change the directory to
8086(masm) after that type edit
5.After changing directory type edit then you get one window in that window you can write a
program
6.After writing a program click: file->save->exit [again we enter the commond window]
7.Type : masm filename,,;
Type: link filename,,;
masm(8086)software]
8.Type :
debug filename.exe
9.Type :
n filename.bin
10.Type :
wcs:1000
11.Type :
DC (data com will open then set the com port ,Baud rate ,parity)
inside the
12.connect the RS232 cable between PC and the Kit.In the kit type SI 1000
13.Type filename.bin [Only if the file specified is found in the default drive and directory
setting, will the option for displaying the count be displayed. Else the user response whether
to try again]
14. The real time clock will be displayed in the microprocessor kit.
RESULT
EX NO :
DATE :
AIM:
To write a program to roll your name in the 7 segment display
DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)
APPARATUS REQUIRED
S.no
Required Components
specification
Qty
1.
MICROPROCESSOR
2.
POWER CHORD
+5V SUPLLY
3.
KEY BOARD
8279 INTERFACING
1
VBMB 001
THEORY
The Intel 8279 is responsible for debouncing of the keys, coding of the keypad matrix and
refreshing of the display elements in a Microprocessor based development system. Its main
features are:
1) Simultaneous Keyboard and Display operation.
2 )3 Input modes such as Scanned Keyboard Mode, Scanned Sensor Mode and Strobed Input
Entry Mode.
3) 2 Output modes such as 8 or 16 character multiplexed displays, right entry or left entry
display formats.
4) Clock Prescaler.
5) Programmable Scan Timing.
6) 2 Key lockout or N-key Roll-over with contact debounce.7) Auto Increment facility for
easy programming.
1. Display Mode Setup: Control word-10 H
0
0
0
0
0
0
1
D
0
D
0
K
0
K
0
K
1
CD
1
CD
0
CF
0
CA
DD
00- 8Bit character display left entry
01- 16Bit character display left entry
10- 8Bit character display right entry
11- 16Bit character display right entry
KKK- Key Board Mode
000-2Key lockout.
2.Clear Display: Control word-DC H
1
1
1
1
0
0
1
CD
11
0
1
0
0
1
0
AI
HARDWARE ADDRESS
Command =c2H
Data= c0H
ALGORITHM :
FLOWCHART:
START
SET UP
POINTER
INITIALIZE THE COUNTER
DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)
PROGRAM
MEMORY
ADDRESS
OPCODES
MNEMONICS
COMMENTS
START:MOV
SI,1200
MOV CX,count
MOV AL,10
OUTC2,AL
MOV AL,CC
OUT C2,AL
MOV AL,90
OUT C2,AL
NEXT:MOV AL.[SI]
OUT C0,AL
CALL DELAY
INC SI
LOOP NEXT
JMP START
Initialize SI to 1200.
Initialize count.
Right entry.
Clear display.
RAM write display.
Delay routine.
DELAY:MOV
DX,A0FF
LOP:DEC DX
JNZ LOP
RET
LOOK UP TABLE
ADDRESS
DATA
SEGMENT DEFINITION
DATA BUS
D7
SEGMENTS d
D6
D5
D4
D3
D2
D1
D0
dp
PROCEDURE:
i.
ii.
iii.
iv.
RESULT
EX NO :
DATE :
AIM
To write a program to convert the anolog into digital voltage
PROBLEM STATEMENT
The program is executed for various values of analog voltage which are set with the
help of a potentiometer. The LED display is verified with the digital value that is stored in a
memory location.
APPARATUS REQUIRED
S.no
Required Components
specification
Qty
1.
MICROPROCESSOR
2.
POWER CHORD
+5V SUPLLY
3.
KEY BOARD
ANOLOG
CONVERTER
1
TO
THEORY
Microprocessors are Digital logic devices that can process only digital signals that are in
binary form logic levels (either 0 or 1 or 0 volts or 5 volts), But most industrial applications
involve physical variables such as temperature, pressure etc, which are continuously (varying
voltage) when converted to analog signal by transducers & signal condition, unlike digital
signals having either a low or high state. In most cases we want to control these signals
electronically. This automatic control can be achieved using a microprocessor. But
microprocessor can understand only digital language. Then how can it control these
parameters? So there should be some translater who can translate these analog signals to a
digital form which the Microprocessor considers formal. This is the place where an Analog to
Digital Converter (ADC) comes into the picture. Thus an Analog to Digital Converter is an
electronic circuit that converts the analog or continuous signal to digital or discrete.
HARDWARE ADDRESS
ALGORITHM:
(i)
Select the channel and latch the address.
(ii)
Send the start conversion pulse.
(iii)
Read EOC signal.
(iv)
If EOC = 1 continue else go to step (iii)
(v)
Read the digital output.
(vi)
Store it in a memory location
FLOW CHART FOR ADC
START
YES
STOP
PROGRAM
MEMORY
ADDRESS
OPCODES
MNEMONICS
COMMENTS
MOV AL,10
OUT C8,AL
MOV AL,18
OUT C8,AL
HLT
PROCEDURE:
i.
ii.
iii.
iv.
OBSERVATION:
ANALOG
VOLTAGE
DISPLAY
LOCATION
RESULT
EX NO :
DATE :
AIM:
To write a program to
i.
ii.
APPARATUS REQUIRED
S.no
Required Components
specification
Qty
1.
MICROPROCESSOR
2.
POWER CHORD
+5V SUPLLY
3.
KEY BOARD
DIGITAL
TO
CONVERTER
1
ANALOG VBMB 003
PROBLEM STATEMENT
The program is executed for various digital values and equivalent analog voltages are
measured and also the waveforms are measured at the output ports using CRO.
ALGORITHM
Square Waveform:
(i) Send low value (00) to the DAC.
(ii) Introduce suitable delay.
(iii) Send high value to DAC.
(iv) Introduce delay.
(v) Repeat the above procedure.
HARDWARE ADDRESS
FLOWCHART:
MEASUREMENT OF ANALOG VOLTAGE
START
SEND THE
DIGITALVALUE TO
ACCUMULATOR
DELAY
TRANSFER THE
ACCUMULATOR CONTENTS
TO DAC
STOP
OPCODES
MNEMONICS
COMMENTS
MOV AL,7FH
OUT C0,AL
HLT
7F(hex)=0v
Out the data in DAC1
Terminate the Program
PROCEDURE
i.
Enter the program from location 1000.
ii.
Connect the DAC interface kit to 8086 Processor
iii.
View the 0v output in the CRO
OBSERVATION
DIGITAL DATA
ANALOG VOLTAGE
OPCODES
MNEMONICS
COMMENTS
START:MOV AL,00
OUT C8,AL
CALL DELAY
MOV AL,FF
OUT C8,AL
CALL DELAY
JMP START
DELAY:MOV
DX,A0FF
LOP:DEC DX
JNZ LOP
RET
Delay routine
OBSERVATION
PROCEDURE:
i.
ii.
iii.
RESULT
EX NO :
DATE :
AIM:
To write a program to run the stepper motor at different speed.
APPARATUS REQUIRED
S.no
Required Components
specification
Qty
1.
MICROPROCESSOR
2.
POWER CHORD
+5V SUPLLY
3.
KEY BOARD
STEPPER MOTOR
1
1 Kg
PROBLEM STATEMENT
Write a code for achieving a specific angle of rotation in a given time and particular
number of rotations in a specific time.
THEORY
Stepper motor control is a very popular application of microprocessor in control area. They
are widely used in (simple position control systems in the open and closed loop mode) a
variety ofapplications such as computer peripherals (printers, disk driver etc.) and in the areas
of processcontrol machine tools, medicine, numerically controlled machines and Robotics.
ALGORITHM:
For running stepper motor clockwise and anticlockwise directions
(i)
Get the first data from the lookup table.
(ii)
Initialize the counter and move data into accumulator.
(iii)
Drive the stepper motor circuitry and introduce delay
(iv)
Decrement the counter is not zero repeat from step(iii)
(v)
Repeat the above procedure both for backward and forward directions
HARDWARE ADDRESS
FLOWCHART:
START
INTIALIZE COUNTER FOR LOOK UP TABLE
PROGRAM
MEMORY
ADDRESS
OPCODES
MNEMONICS
COMMENTS
START:MOV AL,09
OUT C0,AL
CALL DELAY
MOV AL,05
OUT C0,AL
CALL DELAY
MOV AL,06
OUT C0,AL
CALL DELAY
MOV AL,0A
OUT C0,AL
CALL DELAY
JMP START
DELAY:MOV
DX,A0FF
LOP:DEC DX
JNZ LOP
RET
PROCEDURE:
i.
ii.
iii.
RESULT
EX NO :
DATE :
DC MOTOR CONTROL
AIM
Required Components
specification
Qty
1.
MICROPROCESSOR
2.
POWER CHORD
+5V SUPLLY
3.
KEY BOARD
4.
DC MOTOR
1
VBMB 17
SOFWARE SPECIFICATION
MASM SOFTWARE
HARDWARE ADDRESS
PROGRAM
To control the speed of DC motor
Memory
address
opcode
mnemonics
comments
MOV AL,FF
OUT C0,AL
HLT
PROCEDURE
1.Enter the mnemonics in the kit .
2.Load maximum value FF to Accumulator
3.Execute the Program
4.varry the input value and check the speed.
OBSERVATION
MOV AL,00H
OUT 0D0H,AL
CALL DELAY
MOV AL,00H
OUT 0D8H,AL
IN AL,0C8H
MOV SI,1500h
MOV [SI],AL
MOV AL,00H
INC SI
MOV [SI],AL
HLT
PROCEDURE
1.Enter the mnemonics in the kit by down loading using MASM tool.
2.Load maximum value FF to Accumulator
3.Execute the Program
4.The count value will be stored in the location 1500.
OBSERVATION
RESULT
EX NO :
DATE :
8259 INTERFACING
OBJECTIVE
DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)
Required Components
specification
Qty
1.
MICROPROCESSOR
2.
POWER CHORD
+5V SUPLLY
3.
KEY BOARD
4.
8259 INTERFACING
1
VBMB 07
THEORY
The program initializesthe 8259 to type 8. So the interrupt vector for interrupt IRO is
0000: 0020 So at 0000:0020, enter the address0000: 1200H If the ISR is at 0:1200
In the ISR, non specific EOI command is given. In fully nested mode, the interrupt requests
are ordered in priority from 0 through 7 (0 highest). But in some applications there are a
number of interrupting devices of equal priority. In this mode, a device after being serviced
receives the lowest priority, This is known as Rotating priority
PROGRAM
Memory
address
opcode
mnemonics
MOV AL,17
OUT C0,AL
MOV AL,08
OUT C2,AL
MOV AL,01
OUT C2,AL
MOV AL,FE
OUT C2,AL
STI
HERE:SJMP HERE
INTEREPT SERVICE
MOV AL,20
OUT C0,AL
INT 2
INTERRUPT VECTOR:
0000: 0020 00
0000: 0021 12
0000: 0022 00
0000: 0023 00
OBSERVATION
RESULT
EX NO :
DATE :
8253 INTERFACING
OBJECTIVE
Required Components
specification
Qty
1.
MICROPROCESSOR
2.
POWER CHORD
+5V SUPLLY
3.
KEY BOARD
4.
8253 INTERFACING
1
VBMB 04
THEORY
MODE 0 - INTERRUPT ON TERMINAL COUNT:
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,
MODE 1 - PROGRAMMABLE ONE-SHOT:
After loading the counter, the output will remain low following the rising edge of the gate
input. The output will go high on the terminal count. It is re-triggerable, hence the output will
remain low for the full count after any rising edge of the gate input.
MODE 2 - RATE GENERATOR:
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 the next equals the number of input counts 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 the new value.
MODE 3 - SQUARE WAVE GENERATOR:
It is similar to Mode 2 except that the output will remain high until one half of count and go
low for the other half for even number count. If the count is odd, the output will be high for
(count+1)/2 counts and low for (count-1)/2 counts. This mode is used for generating baud
rate for 8251
MODE 4 - SOFTWARE TRIGGERED STROBE:
The output is high after 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.
MODE 5 - HARDWARE TRIGGERED STROBE:
Counter starts counting after rising edge of trigger input and output goes low for one clock
period when terminal count is reached. The counter is re-triggerable.
PROGRAM
MODE 0 - INTERRUPT ON TERMINAL COUNT
Memory
address
opcode
mnemonics
ORG 1000H
MOV AL,30
OUT CE,AL
MOV AL,05
OUT C8,AL
MOV AL,00
OUT C8,AL
HLT
NOTE: Please make sure that CLK 0 is connected to the debounce circuit.
PROCEDURE
1. Enter the program
2. Observe, using an CRO that the output of Channel 0 is initially low. After giving
six clock pulses, you may notice that the output goes high
MODE 1 - PROGRAMMABLE ONE-SHOT
Memory
opcode
mnemonics
address
ORG 1000H
MOV AL,32
OUT CE,AL
MOV AL,05
OUT C8,AL
MOV AL,00
OUT C8,AL
OUT D0,AL
HLT
1. The following program, initializes Channel 0 of 8253 in mode 1 and also initiates
triggeringof GATE 0. OUT 0 goes low, an clock pulse after triggering the gate and
goes back to highlevel after five clock pulses.
2. Execute the program, give clock pulses through the debounce logic and verify using
a CRO.
MODE 2 - RATE GENERATOR:
Memory
address
opcode
mnemonics
ORG 1000H
MOV AL,74
OUT CE,AL
MOV AL,0A
OUT CA,AL
MOV AL,00
OUT CA,AL
HLT
NOTE: Please make sure that CLK 1 is connected to PCLK. In a CRO observe the
input clock to channel 1 and the output OUT 1.
MODE 3 - SQUARE WAVE GENERATOR:
Memory
address
opcode
mnemonics
ORG 1000H
MOV AL,36
OUT CE,AL
MOV AL,10
OUT C8,AL
MOV AL,00
OUT C8,AL
HLT
NOTE: Set the jumper such that CLK 0 of 8253 is connected to PCLK. The above
program divides the PCLK by 10 and thus the channel 0 output is 150 KHz.
MODE 4 - SOFTWARE TRIGGERED STROBE
Memory
address
opcode
mnemonics
ORG 1000H
MOV AL,36
OUT CE,AL
MOV AL,0A
OUT C8,AL
MOV AL,00
OUT C8,AL
MOV AL,B8
OUT CE,AL
MOV AL,98
OUT CC,AL
MOV AL,3A
OUT CC,AL
HLT
opcode
mnemonics
ORG 1000H
MOV AL,1A
OUT CE,AL
MOV AL,05
OUT C8,AL
OUT D0,AL
HLT
HLT
PROCEDURE
1. Execute the program.
2. After giving six clock pulses, you can see using CRO, the initially high
output goes low. The output (OUT 0 pin) goes high on the next clock pulse.
OBSERVATION
RESULT
EX NO :
DATE :
SERIAL COMMUNICATION
OBJECTIVE
To implement serial communication between two kit
APPARATUS REQUIRED
S.no Required Components
specification
Qty
1.
MICROPROCESSOR
2.
POWER CHORD
+5V SUPLLY
3.
KEY BOARD
4.
9-9 cable
1
RS232
SOFWARE SPECIFICATION
MASM SOFTWARE
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 the USART at any time. These include data transmission errors and control
signals. The control signals define the complete functional definition of the 8251. Control
words should be written into the control register of 8251.These control words are split into
two formats: 1) Mode instruction word & 2) Command instruction word. Status word format
is used to examine the error during functional operation.
1...transmit enable
1...data terminal ready
1... receive enable
1... send break character
1.... reset error flags (pe,oe,fe)
1..... request to send (rts)
1...... internal reset
1....... enter hunt mode (enable search for sync characters)
1 ransmitter ready
1. receiver ready
1.. transmitter empty
1... parity error (pe)
1.... overrun error (oe)
1..... framing error (fe), async only
1...... sync detect, sync only
1....... data set ready (dsr)
ALGORITHM:
1. Initialize 8253 and 8251 to check the transmission and reception of a character
2. Initialize8253 to give an output of 150Khz at channel 0 which will give a 9600 baud rate
of 8251.
3. The command word and mode word is written to the 8251 to set up for subsequent
operations
4. The status word is read from the 8251 on completion of a serial I/O operation, or when
the host CPU is checking the status of the device before starting the next I/O operation
FLOW CHART:
START
Is it High
Yes
STOP
PROGRAM FOR TRANSMITTER
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV SI,1500H
MOV AL,36H
OUT 16H,AL
MOV AL,40H
OUT 10H,AL
MOV AL,01H
OUT 10H,AL
RELOAD: MOV CL,05H
CHECK: IN AL,0AH
AND AL,04H
JZ CHECK
MOV AL,[SI]
OUT 08H,AL
INC SI
CMP AL,3FH
JNZ RELOAD
DEC CL
JNZ CHECK
INT 02
CODE ENDS
END
MOV AL,36H
OUT 16H,AL
MOV AL,40H
OUT 10H,AL
MOV AL,01H
OUT 10H,AL
RELOAD: MOV CL,05H
CHECK: IN AL,0AH
AND AL,02H
JZ CHECK
IN AL,08H
MOV [SI],AL
INC SI
CMP AL,3FH
JNZ RELOAD
DEC CL
JNZ CHECK
INT 02
INT 02
CODE ENDS
END
PROCEDURE
1. Enter the transmitter program in one kit and receiver program in another kit
2. Connect RS232 cable b/w two kit
3. Now the data will be received serially to the receiver kit in the location 1500.
RESULT
EX NO :
DATE :
PARALLEL COMMUNICATION
OBJECTIVE
To implement parallel communication between two kit
APPARATUS REQUIRED
S.no Required Components
specification
Qty
1.
MICROPROCESSOR
2.
POWER CHORD
+5V SUPLLY
3.
KEY BOARD
4.
26 core cable
SOFWARE SPECIFICATION
MASM SOFTWARE
PROGRAM FOR TRANSMITER SIDE
code segment
assume cs:code,ds: code
org 1000h
mov al,82h
OUT 26h,al
mov al,3fh
OUT 20h,aL
loop: in al,22h
sub al,3fh
jnz loop
mov al,24h
out 20h,al
call delay
int 02
delay: mov bl,05h
lion: mov dl,0ffh
l2: dec dl
jnz l2
dec bl
jnz lion
ret
code ends
end
RECEIVER SIDE
code segment
assume cs:code,ds:code
org 1000h
mov al,90h
out 26h,al
check: in al,20h
sub al,3fh
jnz check
mov al,3fh
out 22h,al
mov cl,08h
call delay
mov si,1200h
l1: in al,20h
mov [si],al
call delay
inc si
dec cl
jnz l1
int 02
delay: mov bl,05h
lion: mov dl,0ffh
l2: dec dl
jnz l2
dec bl
jnz lion
ret
ret
code ends
end
PROCEDURE
1. Enter the transmitter program in one kit and receiver program in another kit
2. Connect 26 core cable b/w two kit
3. Now the data will be received parallel on the receiver kit in the location 1200.
RESULT
EX NO:
DATE :
OBJECTIVE
To perform Arithmetic operation,logical operation and bit manipulation using 8051 controller
APPARATUS REQUIRED
S.no
Required Components
specification
Qty
1.
MICROCONTROLLER
2.
POWER CHORD
+5V SUPLLY
3.
KEY BOARD
THEORY
As there is only one 16-bit Register in 89C51, 16-bit addition is performed by using ADDC
instruction twice, i.e. adding LSD first and MSD next. The one's complement of a number is
obtained by inverting all the bits in that number , that isreplacing all 1's by 0's and all 0's by
1's. The two's complement is the negative of that number.Setting bits can be done by ORing
that particular bit by 1.
EXAMPLE
The program is to add the 16-bit data 1234 with the data 5678 and store the result at the
locations
4150 and 4151 using immediate addressing.
RESULT: [4150] = AC (LSB);
[4151] = 68 (MSB).
DATAL1 - 34; DATAL2 = 78.
DATAM1 - 12; DATAM2 = 56.
DATAM1 - MSD OF DATA1,
DATAM2 - MSD OF DATA2,
DATAL1 - LSD OF DATA1,
DATAL2 - LSD OF DATA2
ALGORITHM:
1. Clear Program Status Word
2. Load accumulator A with any desired 8-bit data.
3. Load the register R 0 with the second 8- bit data.
4. Add these two 8-bit numbers.
5. Store the result.
FLOW CHART
Memory
address
opcode
mnemonics
CLR C
MOV A,#DATAL1
ADDC A,#DATAL2
MOV DPTR,#4150
MOVX @DPTR,A
INC DPTR
MOV A,#DATAM1
ADDC A,#DATAM2
MOVX @DPTR,A
HLT: SJMP HLT
RESULT:
OUTPUT
MEMORY LOCATION
DATA
4500
PROCEDURE
i) Enter the above opcodes from 4100 in the trainer.
ii) Execute the program.
iii) Check for the result at 4150 AND 4151
iv) Change data and see if the result at 4150 changes accordingly.
PROGRAM FOR ONES COMPLEMENT
Memory
address
opcode
mnemonics
MOV A,#DATA
CPL A
MOV DPTR,#4200
MOVX @DPTR,A
INC A
INC DPTR
MOVX @DPTR,A
HERE: SJMP HERE
PROCEDURE
i. Enter the opcodes and the data in the trainer.
ii. Execute the program and check for results.
iii Change data and check for the corresponding results.
PROGRAM FOR SETTING BIT
Memory
opcode
address
mnemonics
MOV A,#DATA1
ORL A,#DATA2
MOV DPTR,#4500
MOVX @DPTR,A
HERE: SJMP HERE
PROCEDURE:
i. Enter the opcodes and execute the program.
ii. Check whether the corresponding bits are set accordingly.
OBSERVATION
RESULT
EX NO:
DATE :
OBJECTIVE
To implement communication b/w 8051 with PC.
APPARATUS REQUIRED
S.no
Required Components
specification
Qty
1.
MICROCONTROLLER
2.
POWER CHORD
+5V SUPLLY
3.
KEY BOARD
4.
9 TO 9 CABLE
1
1
RS232
PROCEDURE
1. Type sm in the controller kit.
2. Now open the communication port.
3. Then it is ready to communicate with kit to PC
4. For Example if you type H in the communication window the help command will be
displayed in the PC
RESULT
EX NO :
DATE :
TIMER IN 8051
OBJECTIVE
Write a program to generate square wave using timer in P1.0
APPARATUS REQUIRED
S.no
Required Components
specification
1.
MICROCONTROLLER
2.
POWER CHORD
+5V SUPLLY
4. CRO
4.
KEY BOARD
Qty
1
1
1
THEORY
TMOD REGISTER
CALCULATION.
FFFF-7634=89CB+1=89CC=35276
35276X1.085s=38.274ms and frequency=26.127hz
OBSERVATION
PROGRAM
Memory
address
opcode
mnemonics
comments
MOV TMOD,#10
AA:MOV TL1,#34
MOV TH1,#76
SETB TR1
BACK:JNB TF1,BACK
CLR TR1
CPL P1.0
CLR TF1
SJMP AA
PROCEDURE:
i. Enter the opcodes and execute the program.
ii. square wave will be generated in the P1.0 pin
RESULT
EX NO :
DATE :
OBJECTIVE
Assume that the INT1 pin is connected to a switch that is normally high.whenever it goes low,it should
turn on a led.
APPARATUS REQUIRED
S.no Required Components
specification
Qty
1.
MICROCONTROLLER
2.
POWER CHORD
+5V SUPLLY
3.
KEY BOARD
1
1
THEORY
PROGRAM
Memory
address
opcode
mnemonics
comments
ORG 0013
SETB P1.3
MOV R3,#255
BACK:DJNZ R3,BACK
CLR P1.3
RETI
MAIN PROGRAM
ORG 30H
MAIN:MOV
IE,#10000100
HH:SJMP HH
PROCEDURE
i. Enter the opcodes and execute the program.
ii. when interrupt occurs P1.3 will goes to high.
OBSERVATION
RESULT
EX NO :
DATE :
UART IN 8051
OBJECTIVE
Write a program to transfer A in the communication port.
APPARATUS REQUIRED
S.no
Required Components
specification
Qty
1.
MICROCONTROLLER
2.
POWER CHORD
+5V SUPLLY
3.
KEY BOARD
9-9 CABLE
1
RS232 CABLE
THEORY
PROGRAM
Memory
address
opcode
mnemonics
comments
MOV TMOD,#20
MOV TH1,#-6
MOV SCON,#50
SETB TR1
GG:MOV SBUF,#A
HH:JNB TI,HH
CLR TI
SJMMP GG
RESULT