2. INTERFACE 4×4 MATRIX KEYPAD WITH AVR
ATmega 32 MICROCONTROLLER
Keyboard is used in our ATM Machine, Computer, Mobile Phone
etc.
what is the maximum keyboard size which can be interfaced with
8051 microcontroller
The answer is 16*16 as 8051 (AT89C51) has 32 I/O pins
3. Typically one port pin is required to read a digital input into the
controller.
When there are a lot of digital input that has to be read, it is not
feasible to allocate one pin for each of them.
This is when a matrix keypad arrangement is used to reduce the
pin count
Therefore, the number of pins that are required to interface a
given number of inputs decreases with increase in the order of
the matrix.
4. If The Matrix Is 2×2, You Will Need 2 Pins For
The Rows And 2 Pins For The Columns In
Such A Case There Is No Difference In The
Cost Of Reading That Many Inputs. But If You
Consider A 10×10 Matrix You Will Just Need
20 Pins (10 For The Rows And 10 For The
Columns) To Read 100 Digital Inputs.
5.
6. Initially all switches are assumed to be released. So there is no
connection between the rows and columns.
When any one of the switches are pressed, the corresponding rows
and columns are connected (short circuited).
This will drive that column pin (initially high) low. Using this logic,
the button press can be detected. The colors red and black is for
logic high and low respectively.
7. Step 1:
The first step involved in interfacing the matrix keypad is to write all
logic 0’s to the rows and all logic 1’s to the columns. In the image,
black line symbolizes logic 0 and red line symbolizes logic 1.
For now let us assume that, the circled key is pressed and see how
the key press can be detected by a software routine.
8. Step 2:
Now the software has to scan the pins connected to columns of the
keypad. If it detects a logic 0 in any one of the columns, then a key
press was made in that column. This is because the event of the
switch press shorts the C2 line with R2. Hence C2 is driven low.
9. Step 3:
Once the column corresponding to the key pressed is located, the
next thing that the software has to do is to start writing logic 1’s to
the rows sequentially (one after the other) and check if C2 become
high.
The logic is that if a button in that row was pressed, then the value
written to that row will be reflected in determined column (C2) as
they are short circuited.
10. Step 4:
The procedure is followed till C2 goes high with logic high is written
to a row. In this case, a logic high to the second row will be reflected
in the second column.
Note: color of the lines indicate the logic values they return
11. We already know the key press happened at column 2. Now we
have detected that the key is in row 2. So, the position of the key in
the matrix is (2,2)
12.
13. This section will show how to interface a DAC (digital-to-
analog converter) to the 8051
DAC INTERFACING
14. Digital-to-analog (DAC) converter :
The digital-to-analog converter (DAC) is a device widely used to
convert digital pulses to analog signals
MC1408 DAC (or DAC808) :
In the MC1408 (DAC0808), the digital inputs are converted to
current (Iout), and by connecting a resistor to the Iout pin, we convert
the result to voltage. The total current provided by the Iout pin is a
function of the binary numbers at the D0-D7 inputs of the DAC0808
and the reference current (Iref), and is as follows
15. where D0 is the LSB, D7 is the MSB for the inputs, and Iref is the input current that
must be applied to pin 14.
16.
17. GENERATING A SINE WAVE
To generate a sine wave, we first need a table whose values
represent the magnitude of the sine of angles between 0 and 360
degrees. The values for the sine function vary from -1.0 to +1.0 for
0 – to 360- ° angles. Therefore, to achieve the full-scale 10 V
output, we use the following equation.
18. Vout of DAC for various angles is calculated and shown:
21. A thermistor responds to temperature change by changing
resistance
Its response is not linear
The complexity associated with writing software for such nonlinear
devices has led many manufacturers to market the linear
temperature sensor
22. LM34 and LM35 Temperature Sensors
The sensors of the LM34/LM35 series are precision integrated-
circuit temperature sensors
The output voltage is linearly proportional to the Fahrenheit/Celsius
temperature
The LM34/LM35 requires no external calibration since it is
inherently calibrated
It outputs 10 mV for each degree of Fahrenheit/Celsius
temperature
23.
24. Signal Conditioning and Interfacing LM35
Signal conditioning is a widely used term in the world
of data acquisition
It is the conversion of the signals (voltage, current, charge,
capacitance, and resistance) produced by transducers to
voltage, which is sent to the input of an A-to-D converter
Signal conditioning can be a current-to-voltage conversion or a signal
amplification
The thermistor changes resistance with temperature