Matrix keypad component

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

hello community,

   

I downloaded the adjustable matrix keyboard developed by Bob Marlowe, thanks to that.

   

heres the link:http://www.cypress.com/forum/psoc-community-components/component-creation-part-1

   

There i used the "PortComponent2:

   

After updating all components, the errors showed by creator were gone. But now comes the problem:

   

I adjusted the keybaord to a 4x4 matrix and attached a LCD  and a to my PSoC 5lp 059,

   

If I press key 1 on my keypad, nothing happens, the other ones are doing fine, except that the last row is showing the same keys as the third row.
My keypad looks like:

   

123A
456B
789C
*0#D

I ajdusted the translation table in main.c to a 4x4 matrix. Now like described: key 1 nothing happens and for example key 0, i get an 8 like the row above.

   

Do I have to change something else in the code?

   

Thanks in advance,
Alexander 

0 Likes
1 Solution
Anonymous
Not applicable
        YES! So finally the problem is solved. So the part with key 1 had to be fixed like is posted it above. And i found out that psoc somehow had problems to set the Pins high. I added a 5 ms delay in line 157 directly after the writing of the zeros to the rows and the ones to the columns. And now it works!!! So obviously my psoc need some time to set the Pins high. Now the keypad is working fine. So i think it depends on the device if a delay is needed or not. So Bob thank you for your project, very nice work! 🙂   

View solution in original post

0 Likes
13 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

As usual: Can you please post your complete project, so that we all can have a look at all of your settings? To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

PLEASE HELP ME SOLVE THIS ERROR IN THE ATTACHED FILE AND REBUILD.

0 Likes

It is not quite polite to hijack the thread of someone else. StudentA askes some questions and I will try to help him in this thread. If you have any issues, please open a new topic in the right forum and give us some information, no need to shout.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

ok, so here it is, hope you can fix my mistakes 🙂

0 Likes
Anonymous
Not applicable

problem update:

   

I changed the ports of the keyboard, because port 0 on my psoc had some trouble with my lcd some weeks ago.

   

Result, the last row is now working fine. 0 and D are displayed and * and # do what they are meant to do.
So the only problem left is why the first key, in my case the 1, is not displayed.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Except placing code into generated files (which gets overwritten at next build) I cannot see any misplaced lines.

   

Set a breakpoint into line 201 of MyKeypad.c and press any key.

   

Check cable connections.

   

 

   

Bob

0 Likes

Dear Bob,

I have the same problem:  the first key in the Translation_Table not recognised at a 4x4 MAtrix Keypad.

(all other keys works perfectly !)

I have a different pin layout:

CYCODE char8 Translation_Table[MAXKEYVALUE ] = {
'D', 'C', 'B', 'A',
'#', '9', '6', '3',
'0', '8', '5', '2',
'*', '7', '4', '1'
};

 

In my case the first and the only problematic key is a 'D' in my case (D is does not matter specifically,  the first one status is the important).

 

I debuged your code and found the followings:

background -I checked all other keys -the result under CY_ISR(MyKeyPad_1_Debounce):

'Key' NewKey value (in decimal)
'1' 15
'4' 14
'7' 13
'*' 12

'2' 11
'5' 10
'8' 9
'0' 8

'3' 7
'6' 6
'9' 5
'#' 4

'A' 3
'B '2
'C' 1
'D' 0

So, I suspect that since the only button with NewKey value 'full'  zero (0b0000 0000) is the 'D' - all the others has some non-zero  value (contains at least one 1 in binary  )- this could be the problem -see later.

As a result your if condition when you check 'Nothing has happened' allways return at 'D' keys (NewKey and  Debounced_Keys are 0) as well unfortunately, see:

if ((uint8)((~NewKey) & (~Debounced_Keys))== 0xffu) // Nothing has happened
{
Debounced_Keys = NewKey;
return;
}

 

As it allways return (falsely), never will hit any other checks (Any key released, Key pressed seen first time,  etc)

 

You would be kind to comment my findings.

 

Any quick workaround for this problem (the +1 and -1 'solution' recommended by Anonymus seems like to be not serious) ?

 

Thanks in advance,

Best Regards,

 

Péter

 

 

 

 

 

 

 

 

 

0 Likes
Anonymous
Not applicable

seems that my joy about solving the first problem was too early. I checked the internal connections of my keypad and the connection to the PSoC several times. the problem with '1' is still present. If I now press for example 'A' i get 3A, like the buttons are somehow linked.
what do you exactly mean by breakpoint, how is the code for that.

   

Thanks in advance.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Please use Google to get explained what a 'Breakpoint' is. Read in Creator help about debugging.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hi,

   

i found and used the breakpoint at the recommended site but not further findings.
I really dont want to offend you since you are the author of this programm 🙂 but did you try the file I uploaded by yourself? Maybe I did something wrong and somehow changed the code?
I am really appreciating any help since I have no idea what could be wrong.

   

Alex

0 Likes
Anonymous
Not applicable
        Update: So the problem with 1 is fixed, i had to add +1 to the return value in line 156 of mykeypad.c. Thought that a 0 value there must be a problem. To compensate that i added -1 to the key value in line 96. After that key 1 was working.   
0 Likes
Anonymous
Not applicable
        The problem is maybe in the reading of the Pins of the last row. I used a putty to show some values and every time a key of the last row is dialled, the program gets the Information that First the key in the row above and immediately After that the key in the last row was pressed   
0 Likes
Anonymous
Not applicable
        YES! So finally the problem is solved. So the part with key 1 had to be fixed like is posted it above. And i found out that psoc somehow had problems to set the Pins high. I added a 5 ms delay in line 157 directly after the writing of the zeros to the rows and the ones to the columns. And now it works!!! So obviously my psoc need some time to set the Pins high. Now the keypad is working fine. So i think it depends on the device if a delay is needed or not. So Bob thank you for your project, very nice work! 🙂   
0 Likes