SlideShare a Scribd company logo
UNIT-5
INTERFACING
MICROCONTROLLER
1
UNIT 5 Syllabus
• Programming 8051 Timers
• Serial Port Programming
• Interrupts Programming
• LCD & Keyboard Interfacing
• ADC, DAC & Sensor Interfacing
• External Memory Interface
• Stepper Motor & Waveform generation
2
8051
TIMERS
3
8051 Timer Modes
Timer 0
Mode 3
Mode 2
Mode 1
Mode 0
Mode 2
Mode 1
Mode 0
Timer 1
8051 TIMERS
4
TMOD Register
GATE:
When set, timer/counter x is enabled, if INTx pin is high and TRx
is set.
When cleared, timer/counter x is enabled, if TRx bit set.
C/T*:
When set(1), counter operation (input from Tx input pin).
When clear(0), timer operation (input from internal clock).
5
TMOD Register
The TMOD byte is not bit addressable.
6
00- MODE 0
01- MODE 1
10- MODE 2
11- MODE 3
TCON Register
7
TF 1-Timer 1 overflow flag
TF0-
TR1- Timer 1 Run control bit
TR0-
IE1- Interrupt 1
IE0-
IT1- Timer 1 interrupt
IT0-
8051 Timer/Counter
OSC ÷12
TLx
(8 Bit)
/ 0
C T 
/ 1
C T 
INT PIN
Gate
TR
T PIN
THx
(8 Bit)
TFx
(1 Bit)
INTERRUPT
8
OSC ÷12
TL0
/ 0
C T 
/ 1
C T 
0
INT PIN
Gate
0
TR
0
T PIN
TH0
INTERRUPT
TIMER 0
TF0
9
TL0
(5 Bit)
INTERRUPT
TIMER 0 – Mode 0
OSC ÷12
/ 0
C T 
/ 1
C T 
0
INT PIN
Gate
0
TR
0
T PIN
TH0
(8 Bit)
TF0
13 Bit Timer / Counter
Maximum Count = 1FFFh (0001111111111111)
10
TL0
(8 Bit)
INTERRUPT
TIMER 0 – Mode 1
OSC ÷12
/ 0
C T 
/ 1
C T 
0
INT PIN
Gate
0
TR
0
T PIN
TH0
(8 Bit)
TF0
16 Bit Timer / Counter
Maximum Count = FFFFh (1111111111111111)
11
TH0
(8 Bit)
Reload
TIMER 0 – Mode 2
8 Bit Timer / Counter with AUTORELOAD
TL0
(8 Bit)
OSC ÷12
/ 0
C T 
/ 1
C T 
0
INT PIN
Gate
0
TR
0
T PIN
TH0
(8 Bit)
TF0 INTERRUPT
Maximum Count = FFh (11111111)
12
TL0
(8 Bit)
INTERRUPT
TIMER 0 – Mode 3
OSC ÷12
/ 0
C T 
/ 1
C T 
0
INT PIN
Gate
0
TR
0
T PIN
TF0
Two - 8 Bit Timer / Counter
OSC ÷12
1
TR
TH0
(8 Bit)
INTERRUPT
TF1
13
OSC ÷12
TL1
/ 0
C T 
/ 1
C T 
Gate
TH1
INTERRUPT
TIMER 1
TF1
1
INT PIN
1
TR
1
T PIN
14
TL1
(5 Bit)
INTERRUPT
TIMER 1 – Mode 0
OSC ÷12
/ 0
C T 
/ 1
C T 
Gate
TH1
(8 Bit)
TF1
13 Bit Timer / Counter
Maximum Count = 1FFFh (0001111111111111)
1
INT PIN
1
TR
1
T PIN
15
TL1
(8 Bit)
INTERRUPT
TIMER 1 – Mode 1
OSC ÷12
/ 0
C T 
/ 1
C T 
Gate
TH1
(8 Bit)
TF1
16 Bit Timer / Counter
Maximum Count = FFFFh (1111111111111111)
1
INT PIN
1
TR
1
T PIN
16
TH1
(8 Bit)
Reload
TIMER 1 – Mode 2
8 Bit Timer / Counter with AUTORELOAD
TL1
(8 Bit)
OSC ÷12
/ 0
C T 
/ 1
C T 
Gate
TH1
(8 Bit)
TF1 INTERRUPT
Maximum Count = FFh (11111111)
1
INT PIN
1
TR
1
T PIN
17
Timer modes
TCON Register (1/2)
• Timer control register: TMOD
– Upper nibble for timer/counter, lower nibble for
interrupts
• TR (run control bit)
– TR0 for Timer/counter 0; TR1 for Timer/counter 1.
– TR is set by programmer to turn timer/counter on/off.
• TR=0: off (stop) TR=1: on (start)
TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0
Timer 1 Timer0 for Interrupt
(MSB) (LSB)
TCON Register (2/2)
• TF (timer flag, control flag)
– TF0 for timer/counter 0; TF1 for timer/counter 1.
– TF is like a carry. Originally, TF=0. When TH-TL roll
over to 0000 from FFFFH, the TF is set to 1.
• TF=0 : not reach
• TF=1: reach
• If we enable interrupt, TF=1 will trigger ISR.
TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0
Timer 1 Timer0 for Interrupt
(MSB) (LSB)
Equivalent Instructions for the Timer Control
Register
For timer 0
SETB TR0 = SETB TCON.4
CLR TR0 = CLR TCON.4
SETB TF0 = SETB TCON.5
CLR TF0 = CLR TCON.5
For timer 1
SETB TR1 = SETB TCON.6
CLR TR1 = CLR TCON.6
SETB TF1 = SETB TCON.7
CLR TF1 = CLR TCON.7
TF1 IT0
IE0
IT1
IE1
TR0
TF0
TR1
TCON: Timer/Counter Control Register
Programs in 8051 TIMERS
Timer Mode 1
• In following, we all use timer 0 as an example.
• 16-bit timer (TH0 and TL0)
• TH0-TL0 is incremented continuously when TR0 is set to 1. And
the 8051 stops to increment TH0-TL0 when TR0 is cleared.
• The timer works with the internal system clock. In other words,
the timer counts up each machine cycle.
• When the timer (TH0-TL0) reaches its maximum of FFFFH, it
rolls over to 0000, and TF0 is raised.
• Programmer should check TF0 and stop the timer 0.
Steps of Mode 1 (1/3)
1. Choose mode 1 timer 0
– MOV TMOD,#01H
2. Set the original value to TH0 and TL0.
– MOV TH0,#FFH
– MOV TL0,#FCH
3. You had better to clear the flag to monitor: TF0=0.
– CLR TF0
4. Start the timer.
– SETB TR0
Steps of Mode 1 (2/3)
5.The 8051 starts to count up by incrementing the
TH0-TL0.
– TH0-TL0=
FFFCH,FFFDH,FFFEH,FFFFH,0000H
FFFC FFFD FFFE FFFF 0000
TF = 0 TF = 0 TF = 0 TF = 0 TF = 1
TH0 TL0
Start timer
Stop timer
Monitor TF until TF=1
TR0=1 TR0=0
TF
Steps of Mode 1 (3/3)
6. When TH0-TL0 rolls over from FFFFH to 0000,
the 8051 set TF0=1.
TH0-TL0= FFFEH, FFFFH, 0000H (Now TF0=1)
7. Keep monitoring the timer flag (TF) to see if it is
raised.
AGAIN: JNB TF0, AGAIN
8. Clear TR0 to stop the process.
CLR TR0
9. Clear the TF flag for the next round.
CLR TF0
Mode 1 Programming
XTAL
oscillator ÷ 12
TR
TH TL TF
Timer
overflow
flag
C/T = 0
TF goes high when FFFF 0
Timer Delay Calculation for XTAL = 11.0592 MHz
(a) in hex
• (FFFF – YYXX + 1) × 1.085 s
• where YYXX are TH, TL initial values respectively.
• Notice that values YYXX are in hex.
(b) in decimal
• Convert YYXX values of the TH, TL register to
decimal to get a NNNNN decimal number
• then (65536 – NNNNN) × 1.085 s
Example 1 (1/3)
• square wave of 50% duty on P1.5
• Timer 0 is used
;each loop is a half clock
MOV TMOD,#01 ;Timer 0,mode 1(16-bit)
HERE: MOV TL0,#0F2H ;Timer value = FFF2H
MOV TH0,#0FFH
CPL P1.5
ACALL DELAY
SJMP HERE
50% 50%
whole clock
P1.5
Example 1 (2/3)
;generate delay using timer 0
DELAY:
SETB TR0 ;start the timer 0
AGAIN:JNB TF0,AGAIN
CLR TR0 ;stop timer 0
CLR TF0 ;clear timer 0 flag
RET
FFF2 FFF3 FFF4 FFFF 0000
TF0 = 0 TF0 = 0 TF0 = 0 TF0 = 0 TF0 = 1
Example 1 (3/3)
Solution:
In the above program notice the following steps.
1. TMOD = 0000 0001 is loaded.
2. FFF2H is loaded into TH0 – TL0.
3. P1.5 is toggled for the high and low portions of the pulse.
4. The DELAY subroutine using the timer is called.
5. In the DELAY subroutine, timer 0 is started by the “SETB TR0”
instruction.
6. Timer 0 counts up with the passing of each clock, which is provided by the
crystal oscillator.
As the timer counts up, it goes through the states of FFF3, FFF4, FFF5, FFF6,
FFF7, FFF8, FFF9, FFFA, FFFB, FFFC, FFFFD, FFFE, FFFFH. One more
clock rolls it to 0, raising the timer flag (TF0 = 1). At that point, the JNB
instruction falls through.
7. Timer 0 is stopped by the instruction “CLR TR0”. The DELAY subroutine
ends, and the process is repeated.
Notice that to repeat the process, we must reload the TL and TH
registers, and start the timer again (in the main program).
Example 2 (1/2)
• This program generates a square wave on pin P1.5 Using timer 1
• Find the frequency.(dont include the overhead of instruction delay)
• XTAL = 11.0592 MHz
MOV TMOD,#10H ;timer 1, mode 1
AGAIN:MOV TL1,#34H ;timer value=3476H
MOV TH1,#76H
SETB TR1 ;start
BACK: JNB TF1,BACK
CLR TR1 ;stop
CPL P1.5 ;next half clock
CLR TF1 ;clear timer flag 1
SJMP AGAIN ;reload timer1
Example 2 (2/2)
Solution:
FFFFH – 7634H + 1 = 89CCH = 35276 clock
count
Half period = 35276 × 1.085 s = 38.274 ms
Whole period = 2 × 38.274 ms = 76.548 ms
Frequency = 1/ 76.548 ms = 13.064 Hz.
Note
Mode 1 is not auto reload then the program must reload the
TH1, TL1 register every timer overflow if we want to have a
continuous wave.
Find Timer Values
• Assume that XTAL = 11.0592 MHz .
• And we know desired delay
• how to find the values for the TH,TL ?
1. Divide the delay by 1.085 s and get n.
2. Perform 65536 –n
3. Convert the result of Step 2 to hex (yyxx )
4. Set TH = yy and TL = xx.
Example 3 (1/2)
• Assuming XTAL = 11.0592 MHz,
• write a program to generate a square wave of 50 Hz
frequency on pin P2.3.
Solution:
1. The period of the square wave = 1 / 50 Hz = 20 ms.
2. The high or low portion of the square wave = 10 ms.
3. 10 ms / 1.085 s = 9216
4. 65536 – 9216 = 56320 in decimal = DC00H in hex.
5. TL1 = 00H and TH1 = DCH.
Example 3 (2/2)
MOV TMOD,#10H ;timer 1, mode 1
AGAIN: MOV TL1,#00 ;Timer value = DC00H
MOV TH1,#0DCH
SETB TR1 ;start
BACK: JNB TF1,BACK
CLR TR1 ;stop
CPL P2.3
CLR TF1 ;clear timer flag 1
SJMP AGAIN ;reload timer since
;mode 1 is not
;auto-reload
8051
Serial
Port
37
38
Basics of Serial Communication
• Serial data communication uses two methods
– Synchronous method transfers a block of data at a time
– Asynchronous method transfers a single byte at a time
• There are special IC’s made by many manufacturers
for serial communications.
– UART (universal asynchronous Receiver transmitter)
– USART (universal synchronous-asynchronous Receiver-
transmitter)
39
40
41
Asynchronous – Start & Stop Bit
• Asynchronous serial data communication is
widely used for character-oriented transmissions
• The start bit is always a 0 (low) and the stop
bit(s) is 1 (high)
42
Asynchronous – Start & Stop Bit
43
Data Transfer Rate
• The rate of data transfer in serial data
communication is stated in bps (bits per second).
• Another widely used terminology for bps is baud
rate.
– It is modem terminology and is defined as the
number of signal changes per second
44
8051 Serial Port
• Synchronous and Asynchronous
• SCON Register is used to Control
• Data Transfer through TXd & RXd pins
• Some time - Clock through TXd Pin
• Four Modes of Operation:
Mode 0 :Synchronous Serial Communication
Mode 1 :8-Bit UART with Timer Data Rate
Mode 2 :9-Bit UART with Set Data Rate
Mode 3 :9-Bit UART with Timer Data Rate
45
Registers related to Serial Communication
1. SBUF Register
2. SCON Register
3. PCON Register
46
SBUF Register
• SBUF is an 8-bit register used solely for serial communication.
• For a byte data to be transferred via the TxD line, it must be
placed in the SBUF register.
• SBUF holds the byte of data when it is received by 8051 RxD
line.
47
SBUF Register
• Sample Program:
48
SCON Register
SM0 SM1 SM2 REN TB8 RB8 TI RI
Enable Multiprocessor
Communication Mode
Set to Enable
Serial Data
reception
9th Data Bit
Transmitted
in Mode 2,3
9th Data Bit
Received in Mode 2,3
Set when Stop bit Txed
Set when a Cha-
ractor received
49
8051 Serial Port – Mode 0
The Serial Port in Mode-0 has the following
features:
1. Serial data enters and exits through RXD
2. TXD outputs the clock
3. 8 bits are transmitted / received
4. The baud rate is fixed at (1/12) of the oscillator frequency
50
8051 Serial Port – Mode 1
The Serial Port in Mode-1 has the following
features:
1. Serial data enters through RXD
2. Serial data exits through TXD
3. On receive, the stop bit goes into RB8 in SCON
4. 10 bits are transmitted / received
1. Start bit (0)
2. Data bits (8)
3. Stop Bit (1)
5. Baud rate is determined by the Timer 1 over flow rate.
51
8051 Serial Port – Mode 2
The Serial Port in Mode-2 has the following
features:
1. Serial data enters through RXD
2. Serial data exits through TXD
3. 9th data bit (TB8) can be assign value 0 or 1
4. On receive, the 9th data bit goes into RB8 in SCON
5. 11 bits are transmitted / received
1.Start bit (0)
2.Data bits (9)
3.Stop Bit (1)
6. Baud rate is programmable
52
8051 Serial Port – Mode 3
The Serial Port in Mode-3 has the following
features:
1. Serial data enters through RXD
2. Serial data exits through TXD
3. 9th data bit (TB8) can be assign value 0 or 1
4. On receive, the 9th data bit goes into RB8 in SCON
5. 11 bits are transmitted / received
1.Start bit (0)
2.Data bits (9)
3.Stop Bit (1)
6. Baud rate is determined by Timer 1 overflow rate.
53
Programs in 8051 serial port
TIMER 1 MODE 2 {AUTO RELOAD}
UNIT-5.ppt
UNIT-5.ppt
UNIT-5.ppt
MOV TMOD, #20H ; Timer 1, mode 2
MOV TH1,#-06 TH1 is loaded to set the baud rate.
MOV SCON, #50H
SETB TR1 ; Run Timer 1
L2 : MOV SBUF, # ’A’
Loop: JNB TI, Loop ; Monitor RI
MOV A, SBUF
CLR TI
SJMP L2
Write a program for the 8051 to transfer letter ‘A’
serially at 4800 baud rate, continuously.
MOV TMOD, #20H ; Timer 1, mode 2
MOV TH1,#-06 TH1 is loaded to set the baud rate.
MOV SCON, #50H
SETB TR1 ; Run Timer 1
Loop: JNB RI, Loop ; Monitor RI
MOV A, SBUF
CLR RI
SJMP Loop
Program the 8051 to receive bytes of data serially, and
put them in P1. Set the baud rate at 4800.
8051
Interrupts
60
INTERRUPTS
• An interrupt is an external or internal event
that interrupts the microcontroller to inform it
that a device needs its service
• A single microcontroller can serve several
devices by two ways:
1. Interrupt
2. Polling
61
Interrupt
–Upon receiving an interrupt signal, the
microcontroller interrupts whatever it is doing
and serves the device.
–The program which is associated with the
interrupt is called the interrupt service routine
(ISR) .
62
Steps in Executing an Interrupt
1. It finishes the instruction it is executing and saves the address of
the next instruction (PC) on the stack.
2. It also saves the current status of all the interrupts internally (i.e:
not on the stack).
3. It jumps to a fixed location in memory, called the interrupt vector
table, that holds the address of the ISR.
4. The microcontroller gets the address of the ISR from the
interrupt vector table and jumps to it.
5. It starts to execute the interrupt service subroutine until it
reaches the last instruction of the subroutine which is RETI
(return from interrupt).
6. Upon executing the RETI instruction, the microcontroller returns
to the place where it was interrupted.
63
Steps in executing an interrupt
• Finish current instruction and saves the PC on stack.
• Jumps to a fixed location in memory depend on type
of interrupt
• Starts to execute the interrupt service routine until
RETI (return from interrupt)
• Upon executing the RETI the microcontroller returns
to the place where it was interrupted. Get pop PC
from stack
Interrupt Sources
• Original 8051 has 6 sources of interrupts
– Reset (RST)
– Timer 0 overflow (TF0)
– Timer 1 overflow (TF1)
– External Interrupt 0 (INT0)
– External Interrupt 1 (INT1)
– Serial Port events (RI+TI)
{Reception/Transmission of Serial Character}
8051 Interrupt Vectors
66
8051 Interrupt related Registers
• The various registers associated with the use of
interrupts are:
– TCON - Edge and Type bits for External Interrupts 0/1
– SCON - RI and TI interrupt flags for RS232 {SERIAL
COMMUNICATION}
– IE - interrupt Enable
– IP - Interrupts priority
67
Enabling and Disabling an Interrupt
• The register called IE (interrupt enable) that is
responsible for enabling (unmasking) and
disabling (masking) the interrupts.
68
Interrupt Enable (IE) Register
• EA : Global enable/disable.
• --- : Reserved for additional interrupt hardware.
• ES : Enable Serial port interrupt.
• ET1 : Enable Timer 1 control bit.
• EX1 : Enable External 1 interrupt.
• ET0 : Enable Timer 0 control bit.
• EX0 : Enable External 0 interrupt.
MOV IE,#08h
or
SETB ET1
--
69
Interrupt Priority
70
Interrupt Priority (IP) Register
PS PT1 PX1 PT0 PX0
Reserved
Serial Port
Timer 1 Pin
INT 1 Pin Timer 0 Pin
INT 0 Pin
Priority bit=1 assigns high priority
Priority bit=0 assigns low priority
71
72
KEYBOARD
INTERFACING
73
KEYBOARD INTERFACING
• Keyboards are organized in a matrix of rows
and columns
The CPU accesses both rows and columns
through ports .
• ƒ
Therefore, with two 8-bit ports, an 8 x 8
matrix of keys can be connected to a
microprocessor
When a key is pressed, a row and a
column make a contact
74
• Otherwise, there is no connection
between rows and columns
• ‰
A 4x4 matrix connected to two ports
The rows are connected to an
output port and the columns are
connected to an input port
75
4x4 matrix
76
77
Connection with keyboard matrix
Final Circuit
Stepper Motor
Interfacing
80
Stepper Motor Interfacing
• Stepper motor is used in applications such as;
dot matrix printer, robotics etc
• It has a permanent magnet rotor called the shaft
which is surrounded by a stator. Commonly used
stepper motors have 4 stator windings
• Such motors are called as four-phase or unipolar
stepper motor.
81
82
83
Full step
84
Step angle:
• Step angle is defined as the minimum degree of
rotation with a single step.
• No of steps per revolution = 360° / step angle
• Steps per second = (rpm x steps per revolution) /
60
• Example: step angle = 2°
• No of steps per revolution = 180
85
A switch is connected to pin P2.7. Write an ALP to
monitor the status of the SW.
If SW = 0, motor moves clockwise and
If SW = 1, motor moves anticlockwise
SETB P2.7
MOV A, #66H
MOV P1,A
TURN: JNB P2.7, CW
RL A
ACALL DELAY
MOV P1,A
SJMP TURN
CW: RR A
ACALL DELAY
MOV P1,A
SJMP TURN 86
DELAY: MOV R1,#20
L2: MOV R2,#50
L1:DJNZ R2,L2
DJNZ R2,L1
RET
LCD Interfacing
{before discussed in Unit 3 LCD
interfacing using 8086}
87
88
Pin Connections of LCD:
89
90
A/D Interfacing
{before discussed in Unit 3 A/D
interfacing using 8086}
91
Interfacing ADC to 8051
ADC0804 is an 8 bit successive approximation analogue to digital
converter from National semiconductors. The features of ADC0804
are differential analogue voltage inputs, 0-5V input voltage range, no zero
adjustment, built in clock generator, reference voltage can be externally
adjusted to convert smaller analogue voltage span to 8 bit resolution etc.
92
ADC Interfacing:
93
D/A Interfacing
{before discussed in Unit 3 D/A
interfacing using 8086}
94
8051 Connection to DAC808
95
program to send data to the DAC to
generate a stair-step ramp
96
SENSOR
INTERFACING
take temperature sensor for example
97
98
99
Shunt voltage diod
potentiometer
EXTERNAL
MEMORY
INTERFACING
100
Access to External Memory
• Port 0 acts as a multiplexed address/data bus. Sending the
low byte of the program counter (PCL) as an address.
• Port 2 sends the program counter high byte (PCH) directly to
the external memory.
• The signal ALE operates as in the 8051 to allow an external
latch to store the PCL byte while the multiplexed bus is made
ready to receive the code byte from the external memory.
• Port 0 then switches function and becomes the data bus
receiving the byte from memory.
101
Presented by C.GOKUL,AP/EEE , Velalar College of Engg & Tech, Erode
102

More Related Content

PPTX
5th unit embedded system and iot design timer and controller
PPTX
5-Timer Mode 2 Programming-18-03-2024.pptx
PPTX
6-Interrupts Programming-27-03-2024.pptx
PPT
8051 ch9
PPT
4.Timer_1.ppt
PPT
8051 Timer
PPTX
8051 MICROCONTROLLER TIMER AND ITS APPLICATIONS
PPTX
Microcontrollers-MODULE4.pptx
5th unit embedded system and iot design timer and controller
5-Timer Mode 2 Programming-18-03-2024.pptx
6-Interrupts Programming-27-03-2024.pptx
8051 ch9
4.Timer_1.ppt
8051 Timer
8051 MICROCONTROLLER TIMER AND ITS APPLICATIONS
Microcontrollers-MODULE4.pptx

Similar to UNIT-5.ppt (20)

PPT
8051 ch9-950217
PPT
Programming 8051 Timers
PPTX
KTU_Microprocessor and Microcontrollers_Module2
PPT
lecture 12 counter_microcontroller2.ppt
PPTX
Timer programming for 8051 using embedded c
PPTX
Microprocessor Week 9: Timer and Counter
PDF
UNIT 1 8 BIT EMBEDDED PROCESSOR CS3691 6TH SEM CSE
PPT
12 mt06ped007
PPTX
Timer programming
PPT
MICROCONTROLLER TIMERS.ppt
PPT
Microcontroller 8051 timer and counter module
PPT
MICROCONTROLLER TIMERS.GHGHGHGHGHGHGHGHGppt
PDF
EC8691 - UNIT 5.pdf
PPTX
Module-03 Timers and serial port communication
PDF
9 timer programming
PPTX
MICROCONTROLLER_ VTU_8051 TIMERS AND SERIAL PORTSModule3.pptx
PPTX
UNIT 5 Interfacing and Mixed Signal Controller.pptx
PPTX
UNIT 5.pptx
8051 ch9-950217
Programming 8051 Timers
KTU_Microprocessor and Microcontrollers_Module2
lecture 12 counter_microcontroller2.ppt
Timer programming for 8051 using embedded c
Microprocessor Week 9: Timer and Counter
UNIT 1 8 BIT EMBEDDED PROCESSOR CS3691 6TH SEM CSE
12 mt06ped007
Timer programming
MICROCONTROLLER TIMERS.ppt
Microcontroller 8051 timer and counter module
MICROCONTROLLER TIMERS.GHGHGHGHGHGHGHGHGppt
EC8691 - UNIT 5.pdf
Module-03 Timers and serial port communication
9 timer programming
MICROCONTROLLER_ VTU_8051 TIMERS AND SERIAL PORTSModule3.pptx
UNIT 5 Interfacing and Mixed Signal Controller.pptx
UNIT 5.pptx
Ad

Recently uploaded (20)

PDF
Digital Logic Computer Design lecture notes
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
Welding lecture in detail for understanding
PPT
Project quality management in manufacturing
DOCX
573137875-Attendance-Management-System-original
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
Geodesy 1.pptx...............................................
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Digital Logic Computer Design lecture notes
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
CYBER-CRIMES AND SECURITY A guide to understanding
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Internet of Things (IOT) - A guide to understanding
Welding lecture in detail for understanding
Project quality management in manufacturing
573137875-Attendance-Management-System-original
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
bas. eng. economics group 4 presentation 1.pptx
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Geodesy 1.pptx...............................................
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Ad

UNIT-5.ppt

  • 2. UNIT 5 Syllabus • Programming 8051 Timers • Serial Port Programming • Interrupts Programming • LCD & Keyboard Interfacing • ADC, DAC & Sensor Interfacing • External Memory Interface • Stepper Motor & Waveform generation 2
  • 4. 8051 Timer Modes Timer 0 Mode 3 Mode 2 Mode 1 Mode 0 Mode 2 Mode 1 Mode 0 Timer 1 8051 TIMERS 4
  • 5. TMOD Register GATE: When set, timer/counter x is enabled, if INTx pin is high and TRx is set. When cleared, timer/counter x is enabled, if TRx bit set. C/T*: When set(1), counter operation (input from Tx input pin). When clear(0), timer operation (input from internal clock). 5
  • 6. TMOD Register The TMOD byte is not bit addressable. 6 00- MODE 0 01- MODE 1 10- MODE 2 11- MODE 3
  • 7. TCON Register 7 TF 1-Timer 1 overflow flag TF0- TR1- Timer 1 Run control bit TR0- IE1- Interrupt 1 IE0- IT1- Timer 1 interrupt IT0-
  • 8. 8051 Timer/Counter OSC ÷12 TLx (8 Bit) / 0 C T  / 1 C T  INT PIN Gate TR T PIN THx (8 Bit) TFx (1 Bit) INTERRUPT 8
  • 9. OSC ÷12 TL0 / 0 C T  / 1 C T  0 INT PIN Gate 0 TR 0 T PIN TH0 INTERRUPT TIMER 0 TF0 9
  • 10. TL0 (5 Bit) INTERRUPT TIMER 0 – Mode 0 OSC ÷12 / 0 C T  / 1 C T  0 INT PIN Gate 0 TR 0 T PIN TH0 (8 Bit) TF0 13 Bit Timer / Counter Maximum Count = 1FFFh (0001111111111111) 10
  • 11. TL0 (8 Bit) INTERRUPT TIMER 0 – Mode 1 OSC ÷12 / 0 C T  / 1 C T  0 INT PIN Gate 0 TR 0 T PIN TH0 (8 Bit) TF0 16 Bit Timer / Counter Maximum Count = FFFFh (1111111111111111) 11
  • 12. TH0 (8 Bit) Reload TIMER 0 – Mode 2 8 Bit Timer / Counter with AUTORELOAD TL0 (8 Bit) OSC ÷12 / 0 C T  / 1 C T  0 INT PIN Gate 0 TR 0 T PIN TH0 (8 Bit) TF0 INTERRUPT Maximum Count = FFh (11111111) 12
  • 13. TL0 (8 Bit) INTERRUPT TIMER 0 – Mode 3 OSC ÷12 / 0 C T  / 1 C T  0 INT PIN Gate 0 TR 0 T PIN TF0 Two - 8 Bit Timer / Counter OSC ÷12 1 TR TH0 (8 Bit) INTERRUPT TF1 13
  • 14. OSC ÷12 TL1 / 0 C T  / 1 C T  Gate TH1 INTERRUPT TIMER 1 TF1 1 INT PIN 1 TR 1 T PIN 14
  • 15. TL1 (5 Bit) INTERRUPT TIMER 1 – Mode 0 OSC ÷12 / 0 C T  / 1 C T  Gate TH1 (8 Bit) TF1 13 Bit Timer / Counter Maximum Count = 1FFFh (0001111111111111) 1 INT PIN 1 TR 1 T PIN 15
  • 16. TL1 (8 Bit) INTERRUPT TIMER 1 – Mode 1 OSC ÷12 / 0 C T  / 1 C T  Gate TH1 (8 Bit) TF1 16 Bit Timer / Counter Maximum Count = FFFFh (1111111111111111) 1 INT PIN 1 TR 1 T PIN 16
  • 17. TH1 (8 Bit) Reload TIMER 1 – Mode 2 8 Bit Timer / Counter with AUTORELOAD TL1 (8 Bit) OSC ÷12 / 0 C T  / 1 C T  Gate TH1 (8 Bit) TF1 INTERRUPT Maximum Count = FFh (11111111) 1 INT PIN 1 TR 1 T PIN 17
  • 19. TCON Register (1/2) • Timer control register: TMOD – Upper nibble for timer/counter, lower nibble for interrupts • TR (run control bit) – TR0 for Timer/counter 0; TR1 for Timer/counter 1. – TR is set by programmer to turn timer/counter on/off. • TR=0: off (stop) TR=1: on (start) TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0 Timer 1 Timer0 for Interrupt (MSB) (LSB)
  • 20. TCON Register (2/2) • TF (timer flag, control flag) – TF0 for timer/counter 0; TF1 for timer/counter 1. – TF is like a carry. Originally, TF=0. When TH-TL roll over to 0000 from FFFFH, the TF is set to 1. • TF=0 : not reach • TF=1: reach • If we enable interrupt, TF=1 will trigger ISR. TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0 Timer 1 Timer0 for Interrupt (MSB) (LSB)
  • 21. Equivalent Instructions for the Timer Control Register For timer 0 SETB TR0 = SETB TCON.4 CLR TR0 = CLR TCON.4 SETB TF0 = SETB TCON.5 CLR TF0 = CLR TCON.5 For timer 1 SETB TR1 = SETB TCON.6 CLR TR1 = CLR TCON.6 SETB TF1 = SETB TCON.7 CLR TF1 = CLR TCON.7 TF1 IT0 IE0 IT1 IE1 TR0 TF0 TR1 TCON: Timer/Counter Control Register
  • 23. Timer Mode 1 • In following, we all use timer 0 as an example. • 16-bit timer (TH0 and TL0) • TH0-TL0 is incremented continuously when TR0 is set to 1. And the 8051 stops to increment TH0-TL0 when TR0 is cleared. • The timer works with the internal system clock. In other words, the timer counts up each machine cycle. • When the timer (TH0-TL0) reaches its maximum of FFFFH, it rolls over to 0000, and TF0 is raised. • Programmer should check TF0 and stop the timer 0.
  • 24. Steps of Mode 1 (1/3) 1. Choose mode 1 timer 0 – MOV TMOD,#01H 2. Set the original value to TH0 and TL0. – MOV TH0,#FFH – MOV TL0,#FCH 3. You had better to clear the flag to monitor: TF0=0. – CLR TF0 4. Start the timer. – SETB TR0
  • 25. Steps of Mode 1 (2/3) 5.The 8051 starts to count up by incrementing the TH0-TL0. – TH0-TL0= FFFCH,FFFDH,FFFEH,FFFFH,0000H FFFC FFFD FFFE FFFF 0000 TF = 0 TF = 0 TF = 0 TF = 0 TF = 1 TH0 TL0 Start timer Stop timer Monitor TF until TF=1 TR0=1 TR0=0 TF
  • 26. Steps of Mode 1 (3/3) 6. When TH0-TL0 rolls over from FFFFH to 0000, the 8051 set TF0=1. TH0-TL0= FFFEH, FFFFH, 0000H (Now TF0=1) 7. Keep monitoring the timer flag (TF) to see if it is raised. AGAIN: JNB TF0, AGAIN 8. Clear TR0 to stop the process. CLR TR0 9. Clear the TF flag for the next round. CLR TF0
  • 27. Mode 1 Programming XTAL oscillator ÷ 12 TR TH TL TF Timer overflow flag C/T = 0 TF goes high when FFFF 0
  • 28. Timer Delay Calculation for XTAL = 11.0592 MHz (a) in hex • (FFFF – YYXX + 1) × 1.085 s • where YYXX are TH, TL initial values respectively. • Notice that values YYXX are in hex. (b) in decimal • Convert YYXX values of the TH, TL register to decimal to get a NNNNN decimal number • then (65536 – NNNNN) × 1.085 s
  • 29. Example 1 (1/3) • square wave of 50% duty on P1.5 • Timer 0 is used ;each loop is a half clock MOV TMOD,#01 ;Timer 0,mode 1(16-bit) HERE: MOV TL0,#0F2H ;Timer value = FFF2H MOV TH0,#0FFH CPL P1.5 ACALL DELAY SJMP HERE 50% 50% whole clock P1.5
  • 30. Example 1 (2/3) ;generate delay using timer 0 DELAY: SETB TR0 ;start the timer 0 AGAIN:JNB TF0,AGAIN CLR TR0 ;stop timer 0 CLR TF0 ;clear timer 0 flag RET FFF2 FFF3 FFF4 FFFF 0000 TF0 = 0 TF0 = 0 TF0 = 0 TF0 = 0 TF0 = 1
  • 31. Example 1 (3/3) Solution: In the above program notice the following steps. 1. TMOD = 0000 0001 is loaded. 2. FFF2H is loaded into TH0 – TL0. 3. P1.5 is toggled for the high and low portions of the pulse. 4. The DELAY subroutine using the timer is called. 5. In the DELAY subroutine, timer 0 is started by the “SETB TR0” instruction. 6. Timer 0 counts up with the passing of each clock, which is provided by the crystal oscillator. As the timer counts up, it goes through the states of FFF3, FFF4, FFF5, FFF6, FFF7, FFF8, FFF9, FFFA, FFFB, FFFC, FFFFD, FFFE, FFFFH. One more clock rolls it to 0, raising the timer flag (TF0 = 1). At that point, the JNB instruction falls through. 7. Timer 0 is stopped by the instruction “CLR TR0”. The DELAY subroutine ends, and the process is repeated. Notice that to repeat the process, we must reload the TL and TH registers, and start the timer again (in the main program).
  • 32. Example 2 (1/2) • This program generates a square wave on pin P1.5 Using timer 1 • Find the frequency.(dont include the overhead of instruction delay) • XTAL = 11.0592 MHz MOV TMOD,#10H ;timer 1, mode 1 AGAIN:MOV TL1,#34H ;timer value=3476H MOV TH1,#76H SETB TR1 ;start BACK: JNB TF1,BACK CLR TR1 ;stop CPL P1.5 ;next half clock CLR TF1 ;clear timer flag 1 SJMP AGAIN ;reload timer1
  • 33. Example 2 (2/2) Solution: FFFFH – 7634H + 1 = 89CCH = 35276 clock count Half period = 35276 × 1.085 s = 38.274 ms Whole period = 2 × 38.274 ms = 76.548 ms Frequency = 1/ 76.548 ms = 13.064 Hz. Note Mode 1 is not auto reload then the program must reload the TH1, TL1 register every timer overflow if we want to have a continuous wave.
  • 34. Find Timer Values • Assume that XTAL = 11.0592 MHz . • And we know desired delay • how to find the values for the TH,TL ? 1. Divide the delay by 1.085 s and get n. 2. Perform 65536 –n 3. Convert the result of Step 2 to hex (yyxx ) 4. Set TH = yy and TL = xx.
  • 35. Example 3 (1/2) • Assuming XTAL = 11.0592 MHz, • write a program to generate a square wave of 50 Hz frequency on pin P2.3. Solution: 1. The period of the square wave = 1 / 50 Hz = 20 ms. 2. The high or low portion of the square wave = 10 ms. 3. 10 ms / 1.085 s = 9216 4. 65536 – 9216 = 56320 in decimal = DC00H in hex. 5. TL1 = 00H and TH1 = DCH.
  • 36. Example 3 (2/2) MOV TMOD,#10H ;timer 1, mode 1 AGAIN: MOV TL1,#00 ;Timer value = DC00H MOV TH1,#0DCH SETB TR1 ;start BACK: JNB TF1,BACK CLR TR1 ;stop CPL P2.3 CLR TF1 ;clear timer flag 1 SJMP AGAIN ;reload timer since ;mode 1 is not ;auto-reload
  • 38. 38
  • 39. Basics of Serial Communication • Serial data communication uses two methods – Synchronous method transfers a block of data at a time – Asynchronous method transfers a single byte at a time • There are special IC’s made by many manufacturers for serial communications. – UART (universal asynchronous Receiver transmitter) – USART (universal synchronous-asynchronous Receiver- transmitter) 39
  • 40. 40
  • 41. 41
  • 42. Asynchronous – Start & Stop Bit • Asynchronous serial data communication is widely used for character-oriented transmissions • The start bit is always a 0 (low) and the stop bit(s) is 1 (high) 42
  • 43. Asynchronous – Start & Stop Bit 43
  • 44. Data Transfer Rate • The rate of data transfer in serial data communication is stated in bps (bits per second). • Another widely used terminology for bps is baud rate. – It is modem terminology and is defined as the number of signal changes per second 44
  • 45. 8051 Serial Port • Synchronous and Asynchronous • SCON Register is used to Control • Data Transfer through TXd & RXd pins • Some time - Clock through TXd Pin • Four Modes of Operation: Mode 0 :Synchronous Serial Communication Mode 1 :8-Bit UART with Timer Data Rate Mode 2 :9-Bit UART with Set Data Rate Mode 3 :9-Bit UART with Timer Data Rate 45
  • 46. Registers related to Serial Communication 1. SBUF Register 2. SCON Register 3. PCON Register 46
  • 47. SBUF Register • SBUF is an 8-bit register used solely for serial communication. • For a byte data to be transferred via the TxD line, it must be placed in the SBUF register. • SBUF holds the byte of data when it is received by 8051 RxD line. 47
  • 49. SCON Register SM0 SM1 SM2 REN TB8 RB8 TI RI Enable Multiprocessor Communication Mode Set to Enable Serial Data reception 9th Data Bit Transmitted in Mode 2,3 9th Data Bit Received in Mode 2,3 Set when Stop bit Txed Set when a Cha- ractor received 49
  • 50. 8051 Serial Port – Mode 0 The Serial Port in Mode-0 has the following features: 1. Serial data enters and exits through RXD 2. TXD outputs the clock 3. 8 bits are transmitted / received 4. The baud rate is fixed at (1/12) of the oscillator frequency 50
  • 51. 8051 Serial Port – Mode 1 The Serial Port in Mode-1 has the following features: 1. Serial data enters through RXD 2. Serial data exits through TXD 3. On receive, the stop bit goes into RB8 in SCON 4. 10 bits are transmitted / received 1. Start bit (0) 2. Data bits (8) 3. Stop Bit (1) 5. Baud rate is determined by the Timer 1 over flow rate. 51
  • 52. 8051 Serial Port – Mode 2 The Serial Port in Mode-2 has the following features: 1. Serial data enters through RXD 2. Serial data exits through TXD 3. 9th data bit (TB8) can be assign value 0 or 1 4. On receive, the 9th data bit goes into RB8 in SCON 5. 11 bits are transmitted / received 1.Start bit (0) 2.Data bits (9) 3.Stop Bit (1) 6. Baud rate is programmable 52
  • 53. 8051 Serial Port – Mode 3 The Serial Port in Mode-3 has the following features: 1. Serial data enters through RXD 2. Serial data exits through TXD 3. 9th data bit (TB8) can be assign value 0 or 1 4. On receive, the 9th data bit goes into RB8 in SCON 5. 11 bits are transmitted / received 1.Start bit (0) 2.Data bits (9) 3.Stop Bit (1) 6. Baud rate is determined by Timer 1 overflow rate. 53
  • 54. Programs in 8051 serial port TIMER 1 MODE 2 {AUTO RELOAD}
  • 58. MOV TMOD, #20H ; Timer 1, mode 2 MOV TH1,#-06 TH1 is loaded to set the baud rate. MOV SCON, #50H SETB TR1 ; Run Timer 1 L2 : MOV SBUF, # ’A’ Loop: JNB TI, Loop ; Monitor RI MOV A, SBUF CLR TI SJMP L2 Write a program for the 8051 to transfer letter ‘A’ serially at 4800 baud rate, continuously.
  • 59. MOV TMOD, #20H ; Timer 1, mode 2 MOV TH1,#-06 TH1 is loaded to set the baud rate. MOV SCON, #50H SETB TR1 ; Run Timer 1 Loop: JNB RI, Loop ; Monitor RI MOV A, SBUF CLR RI SJMP Loop Program the 8051 to receive bytes of data serially, and put them in P1. Set the baud rate at 4800.
  • 61. INTERRUPTS • An interrupt is an external or internal event that interrupts the microcontroller to inform it that a device needs its service • A single microcontroller can serve several devices by two ways: 1. Interrupt 2. Polling 61
  • 62. Interrupt –Upon receiving an interrupt signal, the microcontroller interrupts whatever it is doing and serves the device. –The program which is associated with the interrupt is called the interrupt service routine (ISR) . 62
  • 63. Steps in Executing an Interrupt 1. It finishes the instruction it is executing and saves the address of the next instruction (PC) on the stack. 2. It also saves the current status of all the interrupts internally (i.e: not on the stack). 3. It jumps to a fixed location in memory, called the interrupt vector table, that holds the address of the ISR. 4. The microcontroller gets the address of the ISR from the interrupt vector table and jumps to it. 5. It starts to execute the interrupt service subroutine until it reaches the last instruction of the subroutine which is RETI (return from interrupt). 6. Upon executing the RETI instruction, the microcontroller returns to the place where it was interrupted. 63
  • 64. Steps in executing an interrupt • Finish current instruction and saves the PC on stack. • Jumps to a fixed location in memory depend on type of interrupt • Starts to execute the interrupt service routine until RETI (return from interrupt) • Upon executing the RETI the microcontroller returns to the place where it was interrupted. Get pop PC from stack
  • 65. Interrupt Sources • Original 8051 has 6 sources of interrupts – Reset (RST) – Timer 0 overflow (TF0) – Timer 1 overflow (TF1) – External Interrupt 0 (INT0) – External Interrupt 1 (INT1) – Serial Port events (RI+TI) {Reception/Transmission of Serial Character}
  • 67. 8051 Interrupt related Registers • The various registers associated with the use of interrupts are: – TCON - Edge and Type bits for External Interrupts 0/1 – SCON - RI and TI interrupt flags for RS232 {SERIAL COMMUNICATION} – IE - interrupt Enable – IP - Interrupts priority 67
  • 68. Enabling and Disabling an Interrupt • The register called IE (interrupt enable) that is responsible for enabling (unmasking) and disabling (masking) the interrupts. 68
  • 69. Interrupt Enable (IE) Register • EA : Global enable/disable. • --- : Reserved for additional interrupt hardware. • ES : Enable Serial port interrupt. • ET1 : Enable Timer 1 control bit. • EX1 : Enable External 1 interrupt. • ET0 : Enable Timer 0 control bit. • EX0 : Enable External 0 interrupt. MOV IE,#08h or SETB ET1 -- 69
  • 71. Interrupt Priority (IP) Register PS PT1 PX1 PT0 PX0 Reserved Serial Port Timer 1 Pin INT 1 Pin Timer 0 Pin INT 0 Pin Priority bit=1 assigns high priority Priority bit=0 assigns low priority 71
  • 72. 72
  • 74. KEYBOARD INTERFACING • Keyboards are organized in a matrix of rows and columns The CPU accesses both rows and columns through ports . • ƒ Therefore, with two 8-bit ports, an 8 x 8 matrix of keys can be connected to a microprocessor When a key is pressed, a row and a column make a contact 74
  • 75. • Otherwise, there is no connection between rows and columns • ‰ A 4x4 matrix connected to two ports The rows are connected to an output port and the columns are connected to an input port 75
  • 77. 77
  • 81. Stepper Motor Interfacing • Stepper motor is used in applications such as; dot matrix printer, robotics etc • It has a permanent magnet rotor called the shaft which is surrounded by a stator. Commonly used stepper motors have 4 stator windings • Such motors are called as four-phase or unipolar stepper motor. 81
  • 82. 82
  • 83. 83
  • 85. Step angle: • Step angle is defined as the minimum degree of rotation with a single step. • No of steps per revolution = 360° / step angle • Steps per second = (rpm x steps per revolution) / 60 • Example: step angle = 2° • No of steps per revolution = 180 85
  • 86. A switch is connected to pin P2.7. Write an ALP to monitor the status of the SW. If SW = 0, motor moves clockwise and If SW = 1, motor moves anticlockwise SETB P2.7 MOV A, #66H MOV P1,A TURN: JNB P2.7, CW RL A ACALL DELAY MOV P1,A SJMP TURN CW: RR A ACALL DELAY MOV P1,A SJMP TURN 86 DELAY: MOV R1,#20 L2: MOV R2,#50 L1:DJNZ R2,L2 DJNZ R2,L1 RET
  • 87. LCD Interfacing {before discussed in Unit 3 LCD interfacing using 8086} 87
  • 88. 88
  • 90. 90
  • 91. A/D Interfacing {before discussed in Unit 3 A/D interfacing using 8086} 91
  • 92. Interfacing ADC to 8051 ADC0804 is an 8 bit successive approximation analogue to digital converter from National semiconductors. The features of ADC0804 are differential analogue voltage inputs, 0-5V input voltage range, no zero adjustment, built in clock generator, reference voltage can be externally adjusted to convert smaller analogue voltage span to 8 bit resolution etc. 92
  • 94. D/A Interfacing {before discussed in Unit 3 D/A interfacing using 8086} 94
  • 95. 8051 Connection to DAC808 95
  • 96. program to send data to the DAC to generate a stair-step ramp 96
  • 98. 98
  • 101. Access to External Memory • Port 0 acts as a multiplexed address/data bus. Sending the low byte of the program counter (PCL) as an address. • Port 2 sends the program counter high byte (PCH) directly to the external memory. • The signal ALE operates as in the 8051 to allow an external latch to store the PCL byte while the multiplexed bus is made ready to receive the code byte from the external memory. • Port 0 then switches function and becomes the data bus receiving the byte from memory. 101
  • 102. Presented by C.GOKUL,AP/EEE , Velalar College of Engg & Tech, Erode 102