-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
282 lines (210 loc) · 11.9 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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
<!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-Push-Button/" />
<meta property="og:type" content="article" />
<meta property="og:title" content="Exp-02 : 8051 Digital Input Read" />
<meta property="og:description" content="Push Button Interfacing with 8051 Microcontrollers" />
<meta property="og:image" content="assets/images/PUSHBUTTON_8051_Pull_Ckt.png" />
<title>8051 Digital Input</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. 02 : Push Button Interfacing</h2></div>
<table align = center width=960 bgcolor= white>
<tr>
<td width=760 align=center valign=top>
<h3>Introduction:</h3>
<blockquote>
<p>
A very simple and easy way to provide for human interaction with the microcontroller
is to insert a button into the circuit. We communicate with computers using two main
input devices: the mouse and the keyboard. A keyboard is nothing more than a bunch of
buttons. Adding a button or switch to the circuit enables the microcontroller to
receive human input.<br><br>
In the first experiment, we’ve focused on output only. Now we’re going to go to the
other end of spectrum and play around with inputs. Push button switches are widely
used in embedded system seen in very simple to highly complex systems. So, knowledge
about interfacing them to any microcontroller is very essential in designing such
systems. This lesson deals with the technicalities of push button interfacing with
8051 microcontroller and includes a simple example of microcontrollers digital Read
function and then so as to ON and OFF an LED.
</p>
</blockquote>
<h3>Hardware Discussion: Push Buttons</h3>
<blockquote>
<p>
A <strong>push-button</strong> (also spelled pushbutton) or simply button or tactile
switch is a component that connects two points in a circuit when you press it. Buttons
are typically made out of hard materials and its surface is usually flat or shaped to
accommodate the human finger or hand, so as to be easily depressed or pushed.
</p>
</blockquote>
<div class="box_70"><img src="assets/images/common_pb.png"/></div>
<div class="capt_cont">Fig: Some of available Push Buttons</div>
<h3>Push Button Features :</h3>
<ul>
<li>Two state mechanism. Initially, it remains in off state or normally</li>
<li><strong>open</strong> state but when it is pressed, we can say it <strong>close</strong> state.</li>
<li>Available Momentary and Latching types</li>
<li>Available size, color, shape etc.</li>
<li>Available in Vertical and Horizontal pin outs.</li>
<li>High Durability</li>
<li>Click response high.</li>
</ul>
<blockquote>
<p>
A typical push button switch has two active terminals that may be normally open
or closed and changes its state when pressed or depressed. Sometimes we get 4 pins
with push buttons having a paired (internally connected) terminals of each pin which
is illustrated in the following figure. There are also some push buttons are normally
closed but open when is pressed. Those are used for some special purposes.
</p>
</blockquote>
<div class="box_80"><img src="assets/images/pb_actions.png" alt="LCD mdules"></div>
<div class="capt_cont">Fig: 4 Pin Push Button Connections and Actions</div>
<h3>How it works?</h3>
<blockquote>
<p>
If we connect the push button switch directly to a Microcontroller to get digital input,
It means switch one pin is connected to Ground or 5v Vcc and another pin connected to 2
Microcontroller digital pin. In this case, the Microcontroller is read unstable input
from the push button.
<br><br>So, we need to connect a “pull-up” or “pull-down” resistors circuit to stabilizes
the input, when using the switch.
</p>
</blockquote>
<div class="box_80"><img src="assets/images/pb_method1.png" alt="LCD mdules"></div>
<div class="capt_cont">Fig: 4 Pin Push Button Connections and Actions</div>
<blockquote>
<p>
<strong>Pull-up Resistors :</strong>
If the push button one pin is connected to the Vcc through a resistor
and the other pin is connected to the ground, this circuit known as the pull-up resistor
circuit. In this case, the push button output is High(1) when the button is open, and the
output of the push button is Low(0) when the button is pressed.
<br><br><strong>Pull-down Resistors :</strong>
If the push button one pin is connected to the ground through a resistor and the other
pin is connected to the Vcc, this circuit known as the pull-down resistor circuit. In this
case, the push button output is Low(0) when the button is open, and the output of the push
button is High(1) when the button is pressed.
</p>
</blockquote>
<h3>Circuit Diagram : Push Button Interfacing to 8051.</h3>
<div class="box_90"><img src="assets/images/PUSHBUTTON_8051_Pull_Ckt.png"/></div>
<div class="capt_cont">Fig: Push Button interfacing with AT89S51</div>
<h3>Circuit Discussion :</h3>
<blockquote>
<p>
A push button switch is connected to PORT-0 PIN-0. The SW is connected externally
with a pull-up resistor since there is no internal pull-up resistor for port 0.
The other end of the push button is connected to ground.
<br><br>The voltages at the pins will be VCC (Approx) when the button is not pushed.
The input pin will get grounded on pressing the button. The LED connected to the
PORT-2 PIN-0 with a series resistor to limit the current. Our target is to ON the
LED as long as the Button (ON) is pressed and hold and vice versa.
</p>
</blockquote>
<h3>Assembly Program : <a href="https://github.com/gmostofabd/8051-7Segment/blob/main/codes/Push_Button_Pull_8051.asm">Push_Button_Pull_8051.asm</a></h3>
<div class="prog_cont">
<embed type="text/html" src="codes/Push_Button_Pull_8051.asm" width="500" height="500">
</div>
<h3>Code Discussion:</h3>
<h3>Post Run Discussion : Button Read Using Interrupt</h3>
<blockquote>
<p>
Let's start with a simple example - using an Interrupt to monitor a button press.
To start, we'll take a sketch you've likely seen before - the "Button" example
sketch included above in this article. This time, to read the button using an
external interrupt source we will connect the switch to the INT0 pin at P3.2
<br><br>An <strong>ISR</strong> is just like any other subroutine we write inside a
program, except for the difference that an ISR must always end with a
<strong>RETI</strong> instruction and not with a <strong>RET</strong> instruction
(as in the case of subroutines). An ISR when evoked, executes a certain lines
of code that does some kind of operations. It can be anything as defined by
the programmer. The only condition is that the first line of ISR must begin
from the corresponding vector address. Vector address of INT0 is 0003H and that
of INT1 is 0013H for the 8051 Microcontrollers.
</p>
</blockquote>
<h3>Circuit Diagram : Push Button Reading via External Interrupt.</h3>
<div class="box_90"><img src="assets/images/PUSHBUTTON_8051_INT_Ckt.png"/></div>
<div class="capt_cont">Fig: Push Button Reading via External Interrupt</div>
<h3>Assembly Program : <a href="http://">Push_Button_Intr_8051.asm</a> </h3>
<div class="prog_cont"><embed type="text/html" src="codes/Push_Button_Intr_8051.asm" width="500" height="500"></div>
</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>
<div class="exercise_section">
<h3>Exercises</h3>
<div class="row">
<div class="col">
<div class="exercise_section_text">
<ul><h4>Lab Task :</h4>
<li>Two switches are connected to MCU P3.1 and 3.2. And a LED is connected to P3.3.
Write a assembly program to check the status of the switches and perfom the followings:
<ul>
<li>- If switch1 is pressed, Turn ON the LED.</li>
<li>- If switch2 is pressed, Turn OFF the LED.</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="col">
<img src="assets/images/lab_task_ckt.png" alt="ckt_diagram">
</div>
</div>
<div class="row">
<div class="col">
<div class="exercise_section_text">
<ul><h4>Home Task :</h4>
<li>Design a circuit and write a program to perform as a 8 bit binary counter
using 8 LEDS or 8 logic state terminal on any port. Additionally there should be three push buttons;
for up count, downcount and reset operations.
</li>
</ul>
</div>
</div>
<div class="col">
<img src="assets/images/home_task_ckt.png" alt="ckt_diagram">
</div>
</div>
</div>
<div class="nav_topic">
<div class="prev_topic"><h4>Prev topic: LED Interfacing with 8051</h4></div>
<div class="next_topic"><h4>Next topic: Seven Segment Display interfacing with 8051</h4></div>
</div>
<div id="footer_common">
<div class="prj_footer_cell">
<font face="Verdana, Arial, Helvetica, sans-serif" color="#452063" size="4" ><strong>Top Tutorial sites </strong></font>
<ul>
<li><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/project.html"><strong>8051 Projects</strong></a></li>
<li><a href="http://www.melab-bd.com/trainings.html"><strong>101 Components</strong></a></li>
</ul>
</div>
</div>
<footer-component></footer-component>
</body>
</html>