SlideShare a Scribd company logo
Keypad
Interfacing
Done by
Akhash Kumar
Sriram Prasad MI
Kamlesh Kumar R
Keypad Interfacing
4×4 matrix keypads are
commonly used keypads in
embedded applications. Such
keypads are seen in telephones
and other commonly seen
applications.
Advantages of Matrix Keypad
The advantage of a matrix
keypad is that the use of it
will allow the programmer
to reduce the number of
pins to be used. In a 4×4
matrix keypad
● THE CPUI ACCESSES BOTH
ROWS AND COLUMNS
THROUGH PARTS
● WHEN A KEY IS PRESSED A
ROW AND COLUMN MAKE A
CONTACT. OTHERWISE THERE
IS NO CONTACT BETWEEN
THEM.
Matrix keypad
Debouncing
These are spurious spikes generated during keypress events. Normally
several spikes get generated during a key press because of the
mechanical contacts in the switch and it causes multiple spikes
Key-press Detection
FOR KEYPAD INTERFACING TWO PROCSSES SHOULD HAPPEN:
• KEY-PRESS DETECTON
• KEY-PRESS IDENTIFICATION
THERE ARE TWO WAYS BY WHICH THE PIC18 CAN PERFORM THE KEY
DETECTION.
• INTERRUPT METHOD
• SCANNING METHOD
INTERRUPT METHOD OF KEY PRESS
DETECTION
• Keypad connected to Port B
• Rows are connected to Port B high
• Columns are connected to Port B low.
Scanning
Introduction
● In this method, To detect a
key , the microcontroller
grounds all the rows by
providing zero
Attachments
[ App wireframe, Screenshots, ]
Step 1
Assume we pressed a button
Step 2
If it detects a logic 0 in
any one of the columns,
then a key press was
made in that column.
Step 3
The logic is that if a
button in that row
was pressed, then the
value written that row
will be reflected in the
corresponding column
(C2) as they are short
circuited.
Step 4
The procedure is followed
till C2 goes high when logic
high is written to a row. In
this case, a logic high to
the second row will be
reflected in the second
column.
CODE for
Interrupt
Method
D15H EQU D'100’; delay high byte of value
D15L EQU D'255’; low byte of value
COL EQU 0x08; holds the column found
DR15mH EQU 0x09; registers for 15 ma delay
DR15mL EQU 0x0A;
ORG 0x000000
Initialization
High priority Interrupt
ORG 0x000008
HI_ISR BTFSC INTCON,RBIP; Was it a PORTB change?
BRA RBIF_ISR; yes then go to ISR
RETFIE; else return
Main Function
ORG 0X00
CLRF TRISD; make PORTD output port
BCF INTCON2, RBPU; enable PORTB pull-up resistors.
MOVLW 0XF0; (Make PORTB high input ports
MOVWF TRISB; Take PORTB low output ports )
MOVWF PORTB; ground all rows
CPFSEQ PORTB; are all keys open
GOTO KEYOPEN; wait until keypad ready
KEYOPEN
0XFE =
1111 0000
MOVLW upper(KCODEO)
MOVWF TBLPTRU ; load upper byte of TBLPTR
MOVLW high(KCODEO)
MOVWF TBLPTRH ; load high byte of TBLPTR
BSF INTCON, RBIE; enable PORTB change interrupt
BSF INTCON, GIE; enable all interrupts globally
LOOP GOTO LOOP; wait for key press.
--key identification ISR
RBIF_ISR CALL DELAY; wait for debounce
MOVFF PORTB,COL ; get the column of key press
MOVLW 0XFE
MOVWF PORTB; ground row 0
CPFSEQ PORTB; Did PORTB change?
BRA ROW0; yes then row 0
MOVLW 0XFD;
MOVWF PORTB; ground row 1
CPFSEQ PORTA; Did PORTB change?
BRA ROW1; yes then row 1
0XFE =
1111 1110
0XFD =
1111 1101
MOVLW 0XFB;
MOVWF PORTB; ground row 2
CPFSEQ PORTB; Did PORTB change?
BRA ROW2; yes then row 2
MOVLW 0XF7;
MOVWF PORTB; ground row 3
CPFSEQ PORTB; Did PORTB change?
BRA ROW3; yes then row 3
GOTO BAD RBIF; no then key press too short
0XFB =
1111 1011
0XF7 =
1111 0111
ROW0 MOVLW Low (KCODEO); set TBLPTR start of row 0
BRA FIND; find the column
ROW1 MOVLW low (KCODE1); set TBLPTR= start of row I
BRA FIND; find the column
ROW2 MOVLW low (KCODE2); set TBLPTR = start of row 2
BRA FIND; find the column
ROW3 MOVLW low (KCODE3); set TBLPTR start of row 3
BRA FIND; find the column
BAD RBIF MOVLW 0x00; return null
GOTO WAIT; wait for key release
FIND MOVWF TBLPTRL; load low byte of TBLPTR
MOVLW 0XF0
XORWF COL ; invert high nibble
SWAPF COL, F; bring to low nibble
AGAIN RRCF COL; rotate to find column
BC MATCH ; column found, get the ASCII code
INCF TBLPTRL; else point to next col. address
BRA AGAIN; keep searching
0XF0 =
1111 0000
MATCH TBLRD*+; get ASCII code from table.
MOVFF TABLAT, PORTD; display pressed key on PORTD
WAIT MOVLM 0XF0;
MOVWF PORTB; reset PORTB
CPPSEQ PORTB; Did PORTB change?
BRA WAIT; yes then wait for key release.
BCF INTCON, RBIF; clear PORTB, change flag
RETFIE; return and wait for key press.
-------------delay
DELAY MOVLW D15mH; high byte of delay.
MOVWF DR15mH; store in register
D2: MOVLW D15mL; low byte of delay
MOVWF DR15mL; store in register
D1: DECF DR15mL, F; Stay until DR15ml becomes 0
BNZ D1
DECP DR15mH, F; loop until all DR15m= 0x0000
BNZ D2
RETURN
----key scan code look-up table
ORG 300H
KCODE0: DB '0','1', '2', '3'; ROW 0
KCODE1: DB '4','5', '6', '7'; ROW 1
KCODE2: DB '8','9', 'A', 'B'; ROW 2
KCODE3: DB 'C' ,'D', 'E', 'F'; ROW 3
Doubts
Thank You

More Related Content

What's hot

Lect19 Engin112
Lect19 Engin112Lect19 Engin112
Lect19 Engin112
John Williams
 
Sequential logic circuits flip-flop pt 3
Sequential logic circuits   flip-flop pt 3Sequential logic circuits   flip-flop pt 3
Sequential logic circuits flip-flop pt 3
Sarah Sue Calbio
 
Edge Trigged Flip Flops
Edge Trigged Flip FlopsEdge Trigged Flip Flops
Edge Trigged Flip Flops
Faizan Janjua
 
flip flops
flip flops flip flops
flip flops
Unsa Shakir
 
Flip flops
Flip flopsFlip flops
Flip flops
jyoti_lakhani
 
Bolascriollas
BolascriollasBolascriollas
Bolascriollas
Luis Zurita
 
8.flip flops and registers
8.flip flops and registers8.flip flops and registers
8.flip flops and registers
Deepak Sharma
 
Clock triggering, Flip Flop(RS and JK)
Clock triggering, Flip Flop(RS and JK)Clock triggering, Flip Flop(RS and JK)
Clock triggering, Flip Flop(RS and JK)
AmshalEjaz1
 
flip flop Presentation
flip flop  Presentationflip flop  Presentation
flip flop Presentation
maalik123
 
Presentation on Flip Flop
Presentation  on Flip FlopPresentation  on Flip Flop
Presentation on Flip Flop
Nahian Ahmed
 
Ds flip flop
Ds flip flopDs flip flop
Ds flip flop
Khairul Azhar
 
7.1 flip flops
7.1 flip flops7.1 flip flops
7.1 flip flops
Santiago Reinoso
 
D Flip Flop
D Flip Flop D Flip Flop
D Flip Flop
Pradhan Rishi Sharma
 
Flip Flops DLD
Flip Flops DLDFlip Flops DLD
Flip Flops DLD
Assad Shehbaz
 
Latches and flip flops
Latches and flip flopsLatches and flip flops
Latches and flip flops
mubashir farooq
 
Ports 0f 8051
Ports 0f 8051Ports 0f 8051
Ports 0f 8051
Virender Rihani
 
Microcontroladores: El microcontrolador 8051 con LCD 16x2
Microcontroladores: El microcontrolador 8051 con LCD 16x2Microcontroladores: El microcontrolador 8051 con LCD 16x2
Microcontroladores: El microcontrolador 8051 con LCD 16x2
SANTIAGO PABLO ALBERTO
 
Introduction to Sequential circuits and flip flops
Introduction to Sequential circuits and flip flops Introduction to Sequential circuits and flip flops
Introduction to Sequential circuits and flip flops
Nt Arvind
 
Flip flop
Flip flop Flip flop
Flip flop
AttaRahmanQureshi
 
2.3 sequantial logic circuit
2.3 sequantial logic circuit2.3 sequantial logic circuit
2.3 sequantial logic circuit
Wan Afirah
 

What's hot (20)

Lect19 Engin112
Lect19 Engin112Lect19 Engin112
Lect19 Engin112
 
Sequential logic circuits flip-flop pt 3
Sequential logic circuits   flip-flop pt 3Sequential logic circuits   flip-flop pt 3
Sequential logic circuits flip-flop pt 3
 
Edge Trigged Flip Flops
Edge Trigged Flip FlopsEdge Trigged Flip Flops
Edge Trigged Flip Flops
 
flip flops
flip flops flip flops
flip flops
 
Flip flops
Flip flopsFlip flops
Flip flops
 
Bolascriollas
BolascriollasBolascriollas
Bolascriollas
 
8.flip flops and registers
8.flip flops and registers8.flip flops and registers
8.flip flops and registers
 
Clock triggering, Flip Flop(RS and JK)
Clock triggering, Flip Flop(RS and JK)Clock triggering, Flip Flop(RS and JK)
Clock triggering, Flip Flop(RS and JK)
 
flip flop Presentation
flip flop  Presentationflip flop  Presentation
flip flop Presentation
 
Presentation on Flip Flop
Presentation  on Flip FlopPresentation  on Flip Flop
Presentation on Flip Flop
 
Ds flip flop
Ds flip flopDs flip flop
Ds flip flop
 
7.1 flip flops
7.1 flip flops7.1 flip flops
7.1 flip flops
 
D Flip Flop
D Flip Flop D Flip Flop
D Flip Flop
 
Flip Flops DLD
Flip Flops DLDFlip Flops DLD
Flip Flops DLD
 
Latches and flip flops
Latches and flip flopsLatches and flip flops
Latches and flip flops
 
Ports 0f 8051
Ports 0f 8051Ports 0f 8051
Ports 0f 8051
 
Microcontroladores: El microcontrolador 8051 con LCD 16x2
Microcontroladores: El microcontrolador 8051 con LCD 16x2Microcontroladores: El microcontrolador 8051 con LCD 16x2
Microcontroladores: El microcontrolador 8051 con LCD 16x2
 
Introduction to Sequential circuits and flip flops
Introduction to Sequential circuits and flip flops Introduction to Sequential circuits and flip flops
Introduction to Sequential circuits and flip flops
 
Flip flop
Flip flop Flip flop
Flip flop
 
2.3 sequantial logic circuit
2.3 sequantial logic circuit2.3 sequantial logic circuit
2.3 sequantial logic circuit
 

Similar to Keypad interfacing

Keypad and dc motor
Keypad and dc motor Keypad and dc motor
Keypad and dc motor
vijaydeepakg
 
Microcontroller- An overview
Microcontroller- An overviewMicrocontroller- An overview
Microcontroller- An overview
PANIMALAR ENGINEERING COLLEGE
 
Keypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDACKeypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDAC
nanocdac
 
timers.pdf
timers.pdftimers.pdf
timers.pdf
ssusere1f79a
 
Instruction types
Instruction typesInstruction types
Instruction types
JyotiprakashMishra18
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051
logesh waran
 
Instruction 8.pptx
Instruction 8.pptxInstruction 8.pptx
Instruction 8.pptx
HebaEng
 
Keypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 MicrocontrollerKeypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 Microcontroller
Sudhanshu Janwadkar
 
Chp6 assembly language programming for pic copy
Chp6 assembly language programming for pic   copyChp6 assembly language programming for pic   copy
Chp6 assembly language programming for pic copy
mkazree
 
PIC Presentation_final updated.pptx
PIC Presentation_final updated.pptxPIC Presentation_final updated.pptx
PIC Presentation_final updated.pptx
ShabanamTamboli1
 
[ASM]Lab7
[ASM]Lab7[ASM]Lab7
[ASM]Lab7
Nora Youssef
 
Basic of Firmware & Embedded Software Programming in C
Basic of Firmware & Embedded Software Programming in CBasic of Firmware & Embedded Software Programming in C
Basic of Firmware & Embedded Software Programming in C
Kapil Thakar
 
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
ShashiKiran664181
 
lec15_x86procedure_4up.pdf
lec15_x86procedure_4up.pdflec15_x86procedure_4up.pdf
lec15_x86procedure_4up.pdf
hasan58964
 
Arm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.pptArm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.ppt
Manju Badiger
 
Switch Control and Time Delay - Keypad
Switch Control and Time Delay - KeypadSwitch Control and Time Delay - Keypad
Switch Control and Time Delay - Keypad
Ariel Tonatiuh Espindola
 
An Example MIPS
An Example  MIPSAn Example  MIPS
An Example MIPS
Sandra Long
 
Arithmetic instructions
Arithmetic instructionsArithmetic instructions
Arithmetic instructions
Robert Almazan
 
Https _doc-0o-c4-apps-viewer.googleusercontent
Https  _doc-0o-c4-apps-viewer.googleusercontent Https  _doc-0o-c4-apps-viewer.googleusercontent
Https _doc-0o-c4-apps-viewer.googleusercontent
vijaydeepakg
 
Lab manual mp
Lab manual mpLab manual mp
Lab manual mp
HarshitParkar6677
 

Similar to Keypad interfacing (20)

Keypad and dc motor
Keypad and dc motor Keypad and dc motor
Keypad and dc motor
 
Microcontroller- An overview
Microcontroller- An overviewMicrocontroller- An overview
Microcontroller- An overview
 
Keypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDACKeypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDAC
 
timers.pdf
timers.pdftimers.pdf
timers.pdf
 
Instruction types
Instruction typesInstruction types
Instruction types
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051
 
Instruction 8.pptx
Instruction 8.pptxInstruction 8.pptx
Instruction 8.pptx
 
Keypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 MicrocontrollerKeypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 Microcontroller
 
Chp6 assembly language programming for pic copy
Chp6 assembly language programming for pic   copyChp6 assembly language programming for pic   copy
Chp6 assembly language programming for pic copy
 
PIC Presentation_final updated.pptx
PIC Presentation_final updated.pptxPIC Presentation_final updated.pptx
PIC Presentation_final updated.pptx
 
[ASM]Lab7
[ASM]Lab7[ASM]Lab7
[ASM]Lab7
 
Basic of Firmware & Embedded Software Programming in C
Basic of Firmware & Embedded Software Programming in CBasic of Firmware & Embedded Software Programming in C
Basic of Firmware & Embedded Software Programming in C
 
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
 
lec15_x86procedure_4up.pdf
lec15_x86procedure_4up.pdflec15_x86procedure_4up.pdf
lec15_x86procedure_4up.pdf
 
Arm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.pptArm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.ppt
 
Switch Control and Time Delay - Keypad
Switch Control and Time Delay - KeypadSwitch Control and Time Delay - Keypad
Switch Control and Time Delay - Keypad
 
An Example MIPS
An Example  MIPSAn Example  MIPS
An Example MIPS
 
Arithmetic instructions
Arithmetic instructionsArithmetic instructions
Arithmetic instructions
 
Https _doc-0o-c4-apps-viewer.googleusercontent
Https  _doc-0o-c4-apps-viewer.googleusercontent Https  _doc-0o-c4-apps-viewer.googleusercontent
Https _doc-0o-c4-apps-viewer.googleusercontent
 
Lab manual mp
Lab manual mpLab manual mp
Lab manual mp
 

More from Akhash Kumar

Neural network
Neural networkNeural network
Neural network
Akhash Kumar
 
Fake news
Fake newsFake news
Fake news
Akhash Kumar
 
Internet of things
Internet of thingsInternet of things
Internet of things
Akhash Kumar
 
Logistic regression
Logistic regressionLogistic regression
Logistic regression
Akhash Kumar
 
Brahma 2019 school finals
Brahma 2019 school finalsBrahma 2019 school finals
Brahma 2019 school finals
Akhash Kumar
 
Brahma school 2021 final cut
Brahma school 2021 final cut Brahma school 2021 final cut
Brahma school 2021 final cut
Akhash Kumar
 
Brahma school 2021 prelims cut
Brahma school 2021 prelims cut Brahma school 2021 prelims cut
Brahma school 2021 prelims cut
Akhash Kumar
 
Brahma 2019 school prelim
Brahma 2019 school prelimBrahma 2019 school prelim
Brahma 2019 school prelim
Akhash Kumar
 
Shakespeare quiz - finals
Shakespeare quiz - finalsShakespeare quiz - finals
Shakespeare quiz - finals
Akhash Kumar
 
Shakesphere quiz prelims
Shakesphere quiz   prelimsShakesphere quiz   prelims
Shakesphere quiz prelims
Akhash Kumar
 

More from Akhash Kumar (10)

Neural network
Neural networkNeural network
Neural network
 
Fake news
Fake newsFake news
Fake news
 
Internet of things
Internet of thingsInternet of things
Internet of things
 
Logistic regression
Logistic regressionLogistic regression
Logistic regression
 
Brahma 2019 school finals
Brahma 2019 school finalsBrahma 2019 school finals
Brahma 2019 school finals
 
Brahma school 2021 final cut
Brahma school 2021 final cut Brahma school 2021 final cut
Brahma school 2021 final cut
 
Brahma school 2021 prelims cut
Brahma school 2021 prelims cut Brahma school 2021 prelims cut
Brahma school 2021 prelims cut
 
Brahma 2019 school prelim
Brahma 2019 school prelimBrahma 2019 school prelim
Brahma 2019 school prelim
 
Shakespeare quiz - finals
Shakespeare quiz - finalsShakespeare quiz - finals
Shakespeare quiz - finals
 
Shakesphere quiz prelims
Shakesphere quiz   prelimsShakesphere quiz   prelims
Shakesphere quiz prelims
 

Recently uploaded

AI for Legal Research with applications, tools
AI for Legal Research with applications, toolsAI for Legal Research with applications, tools
AI for Legal Research with applications, tools
mahaffeycheryld
 
Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...
bijceesjournal
 
TIME TABLE MANAGEMENT SYSTEM testing.pptx
TIME TABLE MANAGEMENT SYSTEM testing.pptxTIME TABLE MANAGEMENT SYSTEM testing.pptx
TIME TABLE MANAGEMENT SYSTEM testing.pptx
CVCSOfficial
 
An Introduction to the Compiler Designss
An Introduction to the Compiler DesignssAn Introduction to the Compiler Designss
An Introduction to the Compiler Designss
ElakkiaU
 
Digital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptxDigital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptx
aryanpankaj78
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
Divyanshu
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
UReason
 
Engineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdfEngineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdf
edwin408357
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
Gas agency management system project report.pdf
Gas agency management system project report.pdfGas agency management system project report.pdf
Gas agency management system project report.pdf
Kamal Acharya
 
SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
harshapolam10
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
PIMR BHOPAL
 
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
Paris Salesforce Developer Group
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
ecqow
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 
Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...
Prakhyath Rai
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
Nada Hikmah
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 

Recently uploaded (20)

AI for Legal Research with applications, tools
AI for Legal Research with applications, toolsAI for Legal Research with applications, tools
AI for Legal Research with applications, tools
 
Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...
 
TIME TABLE MANAGEMENT SYSTEM testing.pptx
TIME TABLE MANAGEMENT SYSTEM testing.pptxTIME TABLE MANAGEMENT SYSTEM testing.pptx
TIME TABLE MANAGEMENT SYSTEM testing.pptx
 
An Introduction to the Compiler Designss
An Introduction to the Compiler DesignssAn Introduction to the Compiler Designss
An Introduction to the Compiler Designss
 
Digital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptxDigital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptx
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
 
Engineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdfEngineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdf
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
Gas agency management system project report.pdf
Gas agency management system project report.pdfGas agency management system project report.pdf
Gas agency management system project report.pdf
 
SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
 
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 
Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 

Keypad interfacing

  • 2. Keypad Interfacing 4×4 matrix keypads are commonly used keypads in embedded applications. Such keypads are seen in telephones and other commonly seen applications.
  • 3. Advantages of Matrix Keypad The advantage of a matrix keypad is that the use of it will allow the programmer to reduce the number of pins to be used. In a 4×4 matrix keypad
  • 4. ● THE CPUI ACCESSES BOTH ROWS AND COLUMNS THROUGH PARTS ● WHEN A KEY IS PRESSED A ROW AND COLUMN MAKE A CONTACT. OTHERWISE THERE IS NO CONTACT BETWEEN THEM.
  • 6.
  • 7. Debouncing These are spurious spikes generated during keypress events. Normally several spikes get generated during a key press because of the mechanical contacts in the switch and it causes multiple spikes
  • 8. Key-press Detection FOR KEYPAD INTERFACING TWO PROCSSES SHOULD HAPPEN: • KEY-PRESS DETECTON • KEY-PRESS IDENTIFICATION THERE ARE TWO WAYS BY WHICH THE PIC18 CAN PERFORM THE KEY DETECTION. • INTERRUPT METHOD • SCANNING METHOD
  • 9. INTERRUPT METHOD OF KEY PRESS DETECTION • Keypad connected to Port B • Rows are connected to Port B high • Columns are connected to Port B low.
  • 10.
  • 12. Introduction ● In this method, To detect a key , the microcontroller grounds all the rows by providing zero
  • 14. Step 1 Assume we pressed a button
  • 15.
  • 16. Step 2 If it detects a logic 0 in any one of the columns, then a key press was made in that column.
  • 17. Step 3 The logic is that if a button in that row was pressed, then the value written that row will be reflected in the corresponding column (C2) as they are short circuited.
  • 18. Step 4 The procedure is followed till C2 goes high when logic high is written to a row. In this case, a logic high to the second row will be reflected in the second column.
  • 20. D15H EQU D'100’; delay high byte of value D15L EQU D'255’; low byte of value COL EQU 0x08; holds the column found DR15mH EQU 0x09; registers for 15 ma delay DR15mL EQU 0x0A; ORG 0x000000 Initialization
  • 21. High priority Interrupt ORG 0x000008 HI_ISR BTFSC INTCON,RBIP; Was it a PORTB change? BRA RBIF_ISR; yes then go to ISR RETFIE; else return
  • 22. Main Function ORG 0X00 CLRF TRISD; make PORTD output port BCF INTCON2, RBPU; enable PORTB pull-up resistors. MOVLW 0XF0; (Make PORTB high input ports MOVWF TRISB; Take PORTB low output ports ) MOVWF PORTB; ground all rows CPFSEQ PORTB; are all keys open GOTO KEYOPEN; wait until keypad ready KEYOPEN 0XFE = 1111 0000
  • 23. MOVLW upper(KCODEO) MOVWF TBLPTRU ; load upper byte of TBLPTR MOVLW high(KCODEO) MOVWF TBLPTRH ; load high byte of TBLPTR BSF INTCON, RBIE; enable PORTB change interrupt BSF INTCON, GIE; enable all interrupts globally LOOP GOTO LOOP; wait for key press.
  • 24. --key identification ISR RBIF_ISR CALL DELAY; wait for debounce MOVFF PORTB,COL ; get the column of key press MOVLW 0XFE MOVWF PORTB; ground row 0 CPFSEQ PORTB; Did PORTB change? BRA ROW0; yes then row 0 MOVLW 0XFD; MOVWF PORTB; ground row 1 CPFSEQ PORTA; Did PORTB change? BRA ROW1; yes then row 1 0XFE = 1111 1110 0XFD = 1111 1101
  • 25. MOVLW 0XFB; MOVWF PORTB; ground row 2 CPFSEQ PORTB; Did PORTB change? BRA ROW2; yes then row 2 MOVLW 0XF7; MOVWF PORTB; ground row 3 CPFSEQ PORTB; Did PORTB change? BRA ROW3; yes then row 3 GOTO BAD RBIF; no then key press too short 0XFB = 1111 1011 0XF7 = 1111 0111
  • 26. ROW0 MOVLW Low (KCODEO); set TBLPTR start of row 0 BRA FIND; find the column ROW1 MOVLW low (KCODE1); set TBLPTR= start of row I BRA FIND; find the column ROW2 MOVLW low (KCODE2); set TBLPTR = start of row 2 BRA FIND; find the column ROW3 MOVLW low (KCODE3); set TBLPTR start of row 3 BRA FIND; find the column BAD RBIF MOVLW 0x00; return null GOTO WAIT; wait for key release
  • 27. FIND MOVWF TBLPTRL; load low byte of TBLPTR MOVLW 0XF0 XORWF COL ; invert high nibble SWAPF COL, F; bring to low nibble AGAIN RRCF COL; rotate to find column BC MATCH ; column found, get the ASCII code INCF TBLPTRL; else point to next col. address BRA AGAIN; keep searching 0XF0 = 1111 0000
  • 28. MATCH TBLRD*+; get ASCII code from table. MOVFF TABLAT, PORTD; display pressed key on PORTD WAIT MOVLM 0XF0; MOVWF PORTB; reset PORTB CPPSEQ PORTB; Did PORTB change? BRA WAIT; yes then wait for key release. BCF INTCON, RBIF; clear PORTB, change flag RETFIE; return and wait for key press.
  • 29. -------------delay DELAY MOVLW D15mH; high byte of delay. MOVWF DR15mH; store in register D2: MOVLW D15mL; low byte of delay MOVWF DR15mL; store in register D1: DECF DR15mL, F; Stay until DR15ml becomes 0 BNZ D1 DECP DR15mH, F; loop until all DR15m= 0x0000 BNZ D2 RETURN
  • 30. ----key scan code look-up table ORG 300H KCODE0: DB '0','1', '2', '3'; ROW 0 KCODE1: DB '4','5', '6', '7'; ROW 1 KCODE2: DB '8','9', 'A', 'B'; ROW 2 KCODE3: DB 'C' ,'D', 'E', 'F'; ROW 3
  • 32.