-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
219 lines (161 loc) · 9.32 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="assets/css/style.css">
<link rel="shortcut icon" href="https://github.com/gmostofabd/melab-store/blob/main/Images/melab-bd_logo.jpg?raw=true" type="image/x-icon">
<script src="https://github.com/gmostofabd/melab-store/blob/main/sharedfooter.js" type="text/javascript" defer></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(function(){
$('#sidebar1').load("assets/sidebar1.html");
});
</script>
<meta charset="utf-8">
<meta name="Keywords" content="Microcontroller,8051,Assembly,Programming,Code,Proteus">
<!--Facebook Open graph Mete Tags-->
<meta property="og:url" content="https://gmostofabd.github.io/8051-Keypad/" />
<meta property="og:type" content="article" />
<meta property="og:title" content="Exp. 07 : 8051 Keypad Matrix." />
<meta property="og:description" content="4x4 Keypad interfacing with 8051 Microcontroller" />
<meta property="og:image" content="assets/images/keypad_8051_ckt.png" />
<title>8051 Keypad</title>
</head>
<body bgcolor=white>
<div id="header_common"><img src="https://github.com/gmostofabd/melab-store/blob/main/Images/8051_Tutorial_Banner.png?raw=true" alt="common_banner"></div>
<div id="topic_container"><h2>Exp. 07: Keypad Interfacing with 8051</h2></div>
<table align = center width=1000 height=1000 bgcolor= white>
<tr>
<td width=800 align=center valign=top style="padding-left: 10px; padding-right: 10px;">
<h3>Introduction:</h3>
<blockquote>
<p>
When we want to interface one key to the microcontroller then it needs one GPIO pin.
But when we want to interface many keys like 9, 12 or 16 etc., then it may acquire
all GPIO pins of your microcontroller. To save some GPIO pins of microcontroller,
we can use MATRIX KEYPAD.
E.g. if we want to interface 16 keys to the microcontroller then we require 16
GPIO pins but if we use matrix 4x4 keypad then we require only 8 GPIO pins of
microcontroller.
<br><br>This article is about interfacing a 4x4 key pad to 8051 microcontroller.
A clear knowledge on interfacing key pads to 8051 is very essential while
designing embedded system projects which requires character or numeric input
or both. For example projects like digital code lock, numeric calculator etc.
</p>
</blockquote>
<h3>Hardware Discussion : Matrix Keypad</h3>
<div class="box_70"><img src="assets/images/hexkeypad_1.png"/></div>
<div class="capt_cont">Fig: 4x4 Keypad Matrix (Hex Keypad)</div>
<h3>Keypad Matrix Features :</h3>
<ul>
<li>Reduced I/O required.</li>
<li>Available in tactile switches and membranes.</li>
<li>Less debounce chances.</li>
<li>Long life</li>
<li>Robust application's</li>
<li>Supports wide environmental conditions.</li>
</ul>
<h3>Keypad Matrix Basics</h3>
<div class="box_80"><img src="assets/images/keyscanningsteps.png" alt="LCD mdules"></div>
<div class="capt_cont">Fig: Hex Keypad internal wiring and Effect of a Switch Press</div>
<blockquote>
<p>
Hex key pad is essentially a collection of 16 keys arranged in the form of a 4×4 matrix.
Hex key pad usually have keys representing numeric 0 to 9 and characters A to F.
The simplified diagram of a typical hex key pad is shown in above figure.
</p>
</blockquote>
<h3>How Works ?</h3>
<blockquote>
<p>
The hex keypad has 8 communication lines namely R1, R2, R3, R4, C1, C2, C3 and C4.
R1 to R4 represents the four rows and C1 to C4 represents the four columns. When a
particular key is pressed the corresponding row and column to which the terminals
of the key are connected gets shorted. For example if key 1 is pressed row R1 and
column C1 gets shorted and so on. The program identifies which key is pressed by
a method known as column scanning. In this method a particular row is kept low
(other rows are kept high) and the columns are checked for low. If a particular
column is found low then that means that the key connected between that column
and the corresponding row (the row that is kept low) is been pressed. For example
if row R1 is initially kept low and column C1 is found low during scanning,
that means key 1 is pressed.
</p>
</blockquote>
<h3>Key Scanning:</h3>
<blockquote>
<p>
To detect a pressed key, the microcontroller grounds all rows by providing 0
to the output latch, and then it reads the columns shown in above fig. <br>
If the data read from columns is = 1111, no key has been pressed shown in
above fig. and the process continues till key press is detected. <br>
Now, consider highlighted key in above fig. is pressed. After pressing key,
it makes contact of row with column shown below. <br>
If one of the column bits has a zero, this means that a key press has occurred. <br>
For example, if C1:C4 = 1011, this means that a key in the C2 column has been pressed. <br>
After detecting a key press, microcontroller will go through the process of identifying the key. <br>
</p>
</blockquote>
<h3>Process of Identifying the Key</h3>
<blockquote>
<p>
Starting from the top row, the microcontroller will ground it by providing a low to row R1 only.<br>
Now read the columns, if the data read is all 1s, no key in that row is pressed and the
process continues for the next row. <br>
So, now ground the next row, R2. Read the columns, check for any zero and this process continues
until the row is identified.<br>
E.g. In above case we will get row 2 in which column is not equal to 1111.
So, after identification of the row in which the key has been pressed we can easily find out
the key by row and column value. <br>
</p>
</blockquote>
<h3>Circuit Diagram :</h3>
<div class="box_90"><img src="assets/images/keypad_8051_ckt.png" alt="ckt_diagram" width="600" height="350"></div>
<div class="capt_cont">Fig: 4x4 Keypad Interfacing with 8051</div>
<h3>Circuit Discussion :</h3>
<blockquote>
<p>The circuit diagram for demonstrating interfacing hex keypad to 8051 is shown below.
Like previous 8051 projects, AT89S51 is the microcontroller used here. The circuit
will display the character/numeric pressed on a seven segment LED display.
The circuit is very simple and it uses only two ports of the microcontroller, one for
the hex keypad and the other for the seven segment LED display.
<br><br>The hex keypad is interfaced to port 1 and seven segment LED display is
interfaced to port 0 of the microcontroller. Resistors R1 to R8 limits the current
through the corresponding segments of the LED display. Capacitors C1, C2 and crystal
X1 completes the clock circuitry for the microcontroller. Capacitor C3, resistor R9
and push button switch S1 forms a debouncing reset mechanism.
</p>
</blockquote>
<h3>Assembly Program : <a href="https://github.com/gmostofabd/8051-7Segment/blob/main/codes/7seg_1d_8051.asm">4x4_keypad_8051.asm</a></h3>
<div class="prog_cont"><embed type="text/html" src="codes/KEYPAD_7SEG_8051_2.asm" width="500" height="500"></div>
<h3>Code Discussion:</h3>
<blockquote>
<p>
</p>
</blockquote>
</td>
<td valign=top>
<div class="vdo_lst_cont">
<h3>Lesson Video</h3>
<iframe width="186" height="130" src="https://www.youtube.com/embed/tgbNymZ7vqY"></iframe>
</div>
<div id="sidebar1"></div>
</td>
</tr>
</table>
<table width=1000 height=50 align= center border="1">
<tr>
<td>Prev topic: Push Button Interfacing with 8051</td>
<td>Next topic: LED Matrix interfacing with 8051</td>
</tr>
</table>
<div id="footer_common">
<div class="prj_footer_cell">
<strong>Top Tutorial sites </strong>
<ul class="ul_footer">
<li id="active"><a href="http://www.melab-bd.com/home.html"><strong>Circuit Today</strong></a></li>
<li><a href="http://www.melab-bd.com/about.html"><strong>Radio Electronics</strong></a></li>
<li><a href="http://www.melab-bd.com/product.html"><strong>MikroE</strong></a></li>
</ul>
</div>
</div>
</body>
</html>