The Godfather talking
This is god damn my place! Capisci?
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 20, 2024, 04:28:52 04:28


Login with username, password and session length


Pages: [1]
Print
Author Topic: PIC keyin: max 15 buttons using only 4 pins, debounced, full IT controlled  (Read 3782 times)
0 Members and 1 Guest are viewing this topic.
zuisti
Senior Member
****
Offline Offline

Posts: 409

Thank You
-Given: 242
-Receive: 780


« on: May 11, 2011, 02:39:21 14:39 »

This is a simple passive binary encoder (I'm using cheap Si diodes like 4148) plus a special
IT routine, which resolves the bouncing and double keystroke problems (I think so, try it ...)

Key pressing is sensed via PORTB pin change IT, and TIMER2 is used for a 20 msec debouncing.
Lookup table to define key return values (keys defined to zero value are ignored).

Sensing depressed key(s) is possible also at power on (see the demo program).

Only one key is sensed at a time, then the system is insensitive to the other button is
pressed, and a new key will be accepted only when all buttons are released.

Written a small program in Proton to demonstrate the concept:
Attached a ZIP with the basic source, the HEX file and the DSN.

The program is using the internal pullups:
.... Clear OPTION_REG.7 ' RBPU, portb pullups on
In a noisy environment I use external pull-up resistors directly on the encoder output lines,
and small RC filters to defend the PIC inputs. In this case the internal pullups are disabled.

I'm using also assembly snippets so for recompiling use the Proton 3408 (max. 3506), because
the 3511..3515 versions have some bugs (the version 3517 will be fixed these as I've read).
Note: my tests indicate that this is just for handling of some embedded assembly instructions
and only on 14-bit core devices (PIC16xxx). PIC18xxx is working as well.

The IT routine wich I'm using  is easy to write also in C language (it's well commented).

Greeting
zuisti


Logged
borberk
Senior Member
****
Offline Offline

Posts: 296

Thank You
-Given: 309
-Receive: 598


« Reply #1 on: May 11, 2011, 04:14:52 16:14 »

Similar solution is to use one A/D port and resistor chain connected to Vcc. Buttons are grounding resistor interconnections and voltage applied to A/D is changing.
Logged
max
Senior Member
****
Offline Offline

Posts: 315

Thank You
-Given: 1600
-Receive: 52


« Reply #2 on: May 11, 2011, 07:28:50 19:28 »

Hi,

See the following link

http://www.sonsivri.com/forum/index.php?topic=26492.msg89795#msg89795

Using just 4 diodes and 4 i/o pins you can sense 12 switches,
using 5 diodes and 5 i/o pins you can sense 20 switches.
I have tested the circuit physically and its working fine.

Regards
Logged

Fate arrived and made the conscious unconscious It silenced the activity of life.
zuisti
Senior Member
****
Offline Offline

Posts: 409

Thank You
-Given: 242
-Receive: 780


« Reply #3 on: May 11, 2011, 11:08:52 23:08 »

Similar solution is to use one A/D port and resistor chain connected to Vcc.
Hi 'borberk';
Thank you for your response.
Yes, I've already tried this solution too: only one input pin, but more CPU time is required.
The key-code assigning, the debouncing and the protecting against double keystrokes is also
more difficult as in my present 'clear digital' solution, wich is simple, extremely fast,
and works full in the background (it runs in IT time and only if a keystroke is occured).
However, for some non-time-critical applications I'm using also the A/D method.

http://www.sonsivri.com/forum/index.php?topic=26492.msg89795#msg89795
Using just 4 diodes and 4 i/o pins you can sense 12 switches...
Thanks 'max';
Your circuit is also interesting but it also requires a continous (periodic) polling
in a loop to sense a keystroke, then - after a debouncing time - again to determine it.
« Last Edit: May 11, 2011, 11:10:55 23:10 by zuisti » Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC