Driving Keypads with Microcontroller

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Driving Keypads with Microcontroller

1,881 Views
Thunder
Contributor III

Hi, I'm using an HCS08LG32 part.  Starting from an older design, I'm looking at upgrading the design and perhaps removing some redundant or un-needed parts.  Currently, the uP is driving a buffer chip (74LS244) thru some series resistors to the keypad connector.  I am basically driving 4 inputs and, depending which key is pressed, an input is shorted to an output.  This in turn goes thru more series resistors to a CMOS NOR logic gate for eventual analysis to determine which key was pressed.  Please see the attached circuit.

 

My question is what are the implications of removing the buffer chip and/or all the series resistors ?  Since the NOR gate is CMOS, I will keep the pull-downs for the inputs (since they'll be floating most of the time when no key is pressed).  I'm pretty sure that the uP can drive the NOR chip OK, but am not sure of what transients/problems might develop when keys are pressed/released.  Could these damage the uP ?  Could I get away with just some series resistors ?

 

Thanks.

Labels (1)
0 Kudos
Reply
6 Replies

631 Views
bigmac
Specialist III

Hello,

 

The proximity of the keypad to the MCU will mainly determine the likelihood of induced transients, and the need for additional buffering.  If the keypad is in the same enclosure as the MCU, I doubt that much would be gained by the buffering.

 

The series resistors were originally needed for current limiting should two or more keys associated with different columns be simultaneously pressed, where a conflict would occur between the active column and the inactive column(s).  If the MCU column outputs can be arranged so that only one column is actively driven at a time, and the other columns are high-Z (inputs), the series resistors can be eliminated.  You may find it more convenient to change the active logic state to low, so that the internal pullups can be used when a column is inactive, rather than external pulldown resistors.

 

I notice that the NOR-gate package (confusingly shown as a NAND gates in the schematic) is used as an encoder, to concentrate the six keypad rows into three inputs to the MCU.  If three additional GPIO pins happened to be available, the gate package could also be eliminated, and the internal pullups utilized, giving further simplification.

 

However, if you wish to retain the encoder, and use an active low column state, a NAND-gate (or AND-gate) package would now be needed, along with pullup resistors, rather than pulldown resistors.  A resistor value of 1k seems excessively low for the typical "standard" keypad.

 

Regards,

Mac

 

0 Kudos
Reply

631 Views
Thunder
Contributor III
0 Kudos
Reply

631 Views
Thunder
Contributor III

Thanks for your quick input.  The keypad scan algorithm I'm using is to write a logic 0 to the registers in each of the 4 driving uP pins.  Each uP "driver" is set up as an input with its pull-up resistor enabled.  Therefore, before the key scan, each uP pin driver is at a logic high (via the pullup).  The algorithm then sets each driver low one at a time  (by changing the data direction of the pin from an input to an output) while checking if a key was pressed.  I believe that this is something along the lines of what you're suggesting, i.e. preventing a conflict in the event that 2 keys are pressed simultaneously.

 

They keypad is actually embedded into a metal plate, behind which the pcb is contected via 4 standoffs.  A 4-inch flat ribbon cable connects the pcb to the keypad.  I'll do some bench testing first by shorting all the series resistors and bypassing the buffer.  I would tend to agree that the liklihood of a fatal transient migrating to the uP would be minimal.  They keypad itself is covered by a non-conductive piece of flexible plastic, so I think we should be safe from static electricity from the user.

BR

0 Kudos
Reply

631 Views
bigmac
Specialist III

Hello,

 

Your description is basically what I was suggesting. 

 

With the present circuit arrangement, the 75HC27 device is actually a triple 3-input NOR gate package, and would require an active high state to work as an encoder. 

 

For an active low state, to cater for the new configuration, the encoder device would need to be replaced by either a 74HC10 triple 3-input NAND gate, or a 74HC11 triple 3-input AND gate.  Using the latter AND device would mean that the 3-bit binary code for each keypress would remain the same as for the previous positive logic configuration.  Using the NAND gate would provide inverted logic to the MCU.

 

I am not sure whether this was clear from my previous post.

 

Regards,

Mac

 

0 Kudos
Reply

631 Views
Thunder
Contributor III

Hi, I have found 3 extra IO pins on the uP which will be used in monitoring key presses.  Together with the other 3 pins to determine keypress output, I can eliminate the logic gate altogether.  Now I have just the 4 "driving" pins to the keypad and the 6 GPIO which monitor output, removing also the buffer and series resistors.  Thanks again for your assistance.

0 Kudos
Reply

631 Views
PeterHouse
Contributor I

Static electricity is NOT blocked by a layer of non conductive plastic.  Your aliminum panel should be designed to SHUNT the static charge to ground.  You want to make sure the geometry of your housing and keypad conductors ALWAYS shunt the charge to the aluminum panel and NEVER to your keypad circuits.  You also want to make sure your PCB is star grounded to the chassis in such a way it is NOT in the static discharge curent path.

 

If you are always continously scanning your keypad you will be radiating a LOT of noise into your environment and will most probably fail any type of FCC testing if you need to go there.  In my experience, I have learned to design the keypad matrix so the uC only reads the inputs until a button press is detected and then performs single scans at 50ms or 100ms intervals until no buttons are pressed and the uC can go into the continous read state.  The eliminates the noise to scan time only with a very low duty factor and nearly eliminates any FCC issues.

 

Good Luck,

 

Peter House

0 Kudos
Reply