Interrupt and scanning method of keypad operation, Computer Engineering

Assignment Help:

INTERRUPT METHOD - USING PORTB CHANGE INTERRUPT

By using 4 by 4 matrix keypad connected to PORTA and PORTB. The rows are connected to PORTA-Low (RA1-RA4) and the columns are connected to PORTB-High (RB4-RB7),

which is the PORTB-Change interrupt. The matrix keypad connection operation is explained in the following stages:

1 When the preceding key is released, Zero's will be the output to all rows at once and columns would be read and checked often until the column becomes high. If high, the program waits for a short period of time and then it returns next stage, i.e. waiting for a key to be pressed.
2 To ensure that a key is pressed, the columns are connected to the PORTB-Change interrupt. Hence, if a key pressed, this will cause an interrupt and microcontroller to execute the ISR. The main duty of the ISR is to ensure that the first key press was not erroneous as a result of noise as well as waiting for 20ms to prevent the key press from being interrupted as multiple key presses.
3 Detecting which row the key pressed belongs to, the microcontroller grounds one row at a time and then read the column each time. If all columns are detected HIGH, then the key press cannot belong to that row: hence it grounds the next row and continues until it finds the row the key press belongs.
4 To recognize the key press, the microcontroller rotates the column bits, i.e. a bit at a time, into the carrying flag and check to see if it is set LOW.

SCANNING METHOD

This is done by switching only one ROW at a time to be low. For example, If I set ROW1 low we can then read just the top row of buttons, button 1 will take COL1 low, button2 will take COL2 low, and the same for buttons '3' and 'F' in COL 3 and COL 4.

Hence, the other 12 lower buttons would not have any effect because their respective ROW lines are still high. So to read the other keys we need to take their respective ROW lines low, i.e. taking ROW2 low will allow us to read the second row of buttons (4, 5, 6, and E) again as the other three ROW lines are now high, the other 12 buttons have no effect.

We can then repeat this for the last two Row's using ROW3 and ROW4, so we read four buttons at a time, taking a total of four readings to read the entire keypad. This is a common technique for reading keyboards, and is known as 'Keyboard Scanning'.

However, one obvious problem that may occur is that "What will happens if more than one key is pressed at a time?", there are a number of ways to deal with this, although I might not include this stage in my code, but if time permit me I will try to do so. The methods are as follows:
1) To check for multiple key presses and ignore them,
2) To accept the first key, then find which is pressed. This way is simpler.
Various commercial products deal with this situation in similar ways, some reject multiple key presses, and some just accept the first one.

Firstly, check to see if any of the 12 keys are pressed (by making all the ROW lines low) and waiting until no keys are pressed; this will avoid problems with key presses repeating.

If no keys are pressed or detected, it jumps to the routine Keys which repeatedly scans the keyboard until a key is pressed, and the call for a delay.

Once a key has been pressed the result is returned in the variable e.g. 'key', and then logically AND with 0x0F to be entirely sure it's between 0 and 15. Then the next this value is passed to a look-up table or Key mapped matrix i.e. [COL] [ROW] which translates the key to its required value (in this case the ASCII value of the labels on the keys).

Finally, the ASCII value is stored back in the 'key' variable (just in case you might need it storing) and the routine returns with the ASCII value in the working (W) register.


Related Discussions:- Interrupt and scanning method of keypad operation

Explain register indirect addressing, Q. Explain Register Indirect Addressi...

Q. Explain Register Indirect Addressing? In this addressing technique the operand is data in memory pointed to by a register. Or we can say in other words that the operand fie

Electronic typewriter , Electronic typewriter : An electronic typewriter h...

Electronic typewriter : An electronic typewriter has a 'memory' or 'electronic brain' which enables it to recall the whole document at a time and type it automatically at the pres

Illustrate design of combinational circuits, The digital circuits that we u...

The digital circuits that we use now-a-days are constructed with NOR or NAND gates in place of AND-OR-NOT gates. NOR & NAND gates are known as Universal Gates as we can realize any

Hardware implementation for signed-magnitude data, Hardware Implementation ...

Hardware Implementation for signed-magnitude data When multiplication  is  implemented  in  digital  computer,  we  change  process lightly. Here, in place of providing registe

Determine the bios function with one illustration, Determine the BIOS funct...

Determine the BIOS function with one illustration BIOS stands for Basic Input Output System. It is a set of programs to provide most basic low-level services like services keyb

Aussie wine tours awt, Business Narrative Aussie Wine Tours (AWT) condu...

Business Narrative Aussie Wine Tours (AWT) conduct tours of the wineries of Victoria's Yarra Valley wine region. The tours take place on the last Sunday of each month. Currentl

Insert images in dreamweaver, Q. Insert images in Dreamweaver? You will...

Q. Insert images in Dreamweaver? You will learn two methods to insert images in Dreamweaver-using Dreamweaver's main menu and using Objects panel. 1. Click anywhere in the l

Explain procedure level of parallel processing, Procedure Level Here, p...

Procedure Level Here, parallelism is obtainable in the form of parallel executable procedures. In that case, design of algorithm plays a key role. E.g. every thread in Java is

Combinational logic circuits, A circuit can be designed to perform manydiff...

A circuit can be designed to perform manydifferent functions e.g.a circuit has 3 inputs A, B and C and 3 outputs:Output X is logic level 1 (or 'high') if one or moreinputs are at l

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd