Electronics > Microcontrollers

Reading Keypad MPLab Assembly

(1/2) > >>

jpanhalt:
In a previous post I showed a nice box (https://www.eevblog.com/forum/mechanical-engineering/mitutoyo-982-537-1-dro-display-with-series-572-linear-scales/msg5287843/#msg5287843  ).  I'd like to use that keypad now.  My device of choice is an enhanced, mid-range PIC16F1xxx using MPLab Assembly 8.92.

Attached are two images of how the pads are arranged according to the 9-conductor FFC numbered L to R, 1..9.  There seem to be 2 sets: SetA = conductors 1..5 and SetB = 6..9, i.e., 20 combinations for 20 keys.

In previous projects reading smaller keysets, I just converted the key/port pin to a number and used a jump table.  I could easily do the same with four jump tables or a table of tables as described years ago by Peter Anderson at Johns Hopkins.

My question: Is there a simpler, perhaps more obvious way?  I am not adverse to adding a new chip that would convert the 9-inputs to a 5-bit number.  If so, please recommend a multiplexer chip that can do that.

EDIT: Added a single table that may be clearer.



jwet:
It depends how code starved you are.  I did a lot of assembly with <2k or ROM. 

Here is something to try perhaps, if not smaller, might be easier to understand than just a bunch of RETLW   code statements.

You can observe that all the numbers are either an 8 or a 9.  You could branch somewhere and decode the things.  Its likely that all numbers get handled the same way so after decoding them, you'll fall through to some common code (append digit).

The cursor keys are almost all 7's, you could do similar two stage decode.

You'll probably find that you end up with the same size.

Look up tables are pretty efficient, especially if you run them through a c compiler- good C compilers use tricks like folding, etc and can improve your logic.  You can do all the same in assy.

Have fun.

jpanhalt:
I love coding in Assembly.  It's fun and relaxing.  While modern PIC's have much more room, I enjoy the challenge of keeping the code tight.  The instruction set for enhanced 16F  PIC's was improved a little. 

I just worked out a bit of code to do what I want.  Basically I need to convert a set PORT pin to a bit position, not binary value, to keep the table small.  That doesn't take a lot of code for bits 0..3 (i.e., Set B in the revised single table).  From there, it's a typical jump  table.

When I get something working, I will post it here.  Right now, it's about time to receive Sunday calls from my children and start dinner.

John

Benta:
Dunno why you have a problem with this.
It's obviously a 4 x 5 matrix. Super easy to decode (hardware-wise).

Whether you then use the result in a table or bitwise is up to you.

jpanhalt:
So far as I know, the PIC 16F1xxx chips do not have hardware decoding.  Can you give a simple example?  It's obvious how to do it with 2 ports and some firmware, and that is what my rough code does.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod