Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

8051 Microcontroller - 8 * 4 - Key Pad Matrix Interface

Status
Not open for further replies.

jitenmuni

Newbie level 3
Newbie level 3
Joined
Aug 22, 2010
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,313
Hello,

I am interfacing a 8 * 4 Matrix Keypad on 80C51 Controller.
I am using Port-1 - 4 Pins and Port 0 Full 8 Pins.

Can anyone please give me the Assembly language Code for the same.
I need to detect "Key Pressed" and "Key Released" Both.

Key Pressed has one function and Key Release has other funtions to be performed.

Hence I need the following from the Code:-
1) Which Key is Pressed out of 32 Keys
2) Key Pressed
3) Key Released.


Also let me know if any pull up etc is required for Port 0 / Port 1

Regards,
Jiten
 

Friend you should not be looking for the entire ready-made codes, instead you yourself can try to make the code yourself.
You can get all the help you need.
 

Hi Pillai,

I am stuck because of this Keypad Matrix, I need to do something immediately, Rest all is ready.
Can you help me by providing an algorithm or Flowchart.
 

Hi Jiten,
The algorithm you need to follow is this:
1)Dedicate 10ms with timer0 to 'move' an exclusive 0 through the rows(output)
2)Detect by interrupt that your 0 collided with colums(input)
3)Read from the port the resulting code = rows+colums
4)Search the matching of this code with previous codes of the 32 keys using a lookup table
5)Execute the action you have planned for each key

Can you follow simulation in Proteus?
Best regards,
Ray
 

1) Make rows =0, and cols=1
2) you need to detect when any of the cols become 0.
3) when any of the cols become zero, call a function which will detect the key pressed.

Steps to detect which key is pressed:
Col Detection:
-> whichever col pin is low is the column in which the key is pressed

Row Detection:

-> first make row0 =1 and all other rows=1, check the cols. If all cols=1, then the pressed key is not in that row.
-> Repeat this for all rows, and wherever all cols !=1 the pressed key is in that row.



Now use this row and col to get the value of the key from any look-up table...

Simple...
Try and ask again if any problem.. :)
 

Dear Pillai,

Thanks for the response.

I also want to detect when the key has been released.
Key Pressed has - Function 1 to be executed.
Key Released has - Function 2 to be executed.

Kindly elaborate on Key Release detection.

Regards,
Jiten


1) Make rows =0, and cols=1
2) you need to detect when any of the cols become 0.
3) when any of the cols become zero, call a function which will detect the key pressed.

Steps to detect which key is pressed:
Col Detection:
-> whichever col pin is low is the column in which the key is pressed

Row Detection:

-> first make row0 =1 and all other rows=1, check the cols. If all cols=1, then the pressed key is not in that row.
-> Repeat this for all rows, and wherever all cols !=1 the pressed key is in that row.



Now use this row and col to get the value of the key from any look-up table...

Simple...
Try and ask again if any problem.. :)
 

Does that mean that you have 64 tasks assigned to the 32 switches you are using..?
Do elaborate on your complete project requirement.
 

Does that mean that you have 64 tasks assigned to the 32 switches you are using..?
Do elaborate on your complete project requirement.


Hi,

My project in a nut shell is as follows:-

1) I have 2 Actuators, each actuator has a forward and reverse movement.
2) Light Switch and Output
3) Configurable Timer for Tumbler and Spitton output through switches
4) and so on..

So when I press switch for one actuator it should either go Forward or Reverse, hence the forward switch when pressed would move the actuator forward and when switch is released it will stop the Actuator.

Thus I have to detect Switch Pressed and Switch Released.

The Keypad matrix scanning alogrithm only gives me 2 details

1) Which key
2) Key Pressed

"Key Released" is also important for me.
 

Then I think you will need to implement multi-tasking in your program.
Because, you can jump to one task to be performed when the switch is pressed. But then you also have to timely scan whether that key has been released or not.

For multi tasking you can use any timer interrupt to continuously shift from the task1 and the checking of whether the key is released or not.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top