View previous topic :: View next topic |
Author |
Message |
Sid2286
Joined: 12 Aug 2010 Posts: 119
|
Operating 4 Keys from Single Port |
Posted: Fri Dec 10, 2010 5:10 am |
|
|
Hi,
This is interesting, I was going through of one the circuits which has a 8051 on the circuit board.
I saw that there are four keys provided to the circuit however it is connected to only single pin of silicon.
I was wondering how that could have been implemented??
Regards,
Sid |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Fri Dec 10, 2010 5:29 am |
|
|
Simplest, the buttons form a DAC!...
(emphasis on the 'digital' here!).
Basically, you have the buttons each connected to a binary resistor (so - say, 500R, 1KR, 2KR, 4KR). Then have a single resistor matching the smallest, from the pin to 5V. No buttons pushed = 5v in. First button changes this by 2.5v, second by 1.25v, third by 0.625v, and last by 0.3125v. Read the voltage with an ADC, and you know what pattern is being pushed.
Obviously, you would really need to 'poll' this with a timer interrupt, to see when changes happen, and perhaps debounce a little.
Limitations are the resistances of the switches, accuracy of the resistors etc., but four switches is pretty easy/reliable.
Best Wishes |
|
|
Sid2286
Joined: 12 Aug 2010 Posts: 119
|
|
Posted: Fri Dec 10, 2010 6:44 am |
|
|
Ok!
Thats a valid reasoning! however there is more to it.....
I was little curious and was debugging the circuit using multimeter. My findings are as follows:-
1. There is only one key input to 8051.
2. The keypad connector has 4 buttons and obviously 4 buttons.
3. However, the keypad connector has an input from ULN2003 (4 inputs).
5. Input to ULN are different ranging resistor but those resistors are not coming from any ADC but they are simply grounded.
Its quite tricky :(
do suggest anything if any1 has a suggestions
regards,
sid |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Fri Dec 10, 2010 7:07 am |
|
|
Post the circuit or a link to it.
Always easier to figure stuff out when I can see it!
And I need a brain teaser with snow on the way. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Fri Dec 10, 2010 7:56 am |
|
|
The values would never come _from_ an ADC. What I was suggesting was that the switches themselves _formed_ a DAC, giving an analog voltage.
There are a lot of other ways to do this. However what you describe in hardware, does not appear to _quite_ make sense. It is however getting close to possible...
I'd suggest if there is a ULN, that the enable pin, is being operated by another logic line. The outputs of this are being used as 'open collector' drives, to discharge the pin, in a time depending on the resistors, and what switches are pressed. When switched 'off' the 8051 input is probably being pulled high by a resistor, and there is probably a small amount of capacitance is on the same line, which then charges up. So you just switch on the ULN, and the time taken tell the 8051 input is seen to switch 'low', tells you what switches are made.
Best Wishes |
|
|
Sid2286
Joined: 12 Aug 2010 Posts: 119
|
Connection details |
Posted: Fri Dec 10, 2010 9:04 am |
|
|
Thanks for your reply:)
Going into more detail, I did find Hct574 which might be used to drive an ULN. It was nice to study the circuit. Because it just made realize a better way!
Thank you for your time and effort!
Regards,
sid |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Fri Dec 10, 2010 9:21 am |
|
|
Here is a good article about TWELVE keys to one PicAxe pin and coded in
PicAxe basic. It would be easy to translate to CCS. All the parts values
and the circuit are included.
http://lancer3.com/1wkpad.htm _________________ Google and Forum Search are some of your best tools!!!! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Fri Dec 10, 2010 9:59 am |
|
|
Sid..
could you post the circuit or link?
The 8051 never had an ADC internally so I'd like to see how it was done.
Using an ADC for 'one pin' is child's play... |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Fri Dec 10, 2010 10:55 am |
|
|
Since this is a CCS compiler board the assumption is that he will be
converting the application to the CCS compiler on a PIC. If not, although
interesting, the entire topic belongs somewhere else...or at the least flagged as OT. _________________ Google and Forum Search are some of your best tools!!!! |
|
|
Sid2286
Joined: 12 Aug 2010 Posts: 119
|
|
Posted: Fri Dec 10, 2010 11:14 pm |
|
|
@dyeatman:- I'm working on PIC and the 8051 circuit came to me as a surprise..
I am working on a design wherein I would be having a display, 4 buttons, Rs-485 out and repeater output. as well as an analog input.
I did google about the same, but was not much successful in getting any clue.
I anyways was planning to use buttons so thought of getting ideas from CCS forum about the circuit. Honestly no offence meant
@ temtronic:- I will just post the circuit in a moment.
Regards,
Sid |
|
|
Sid2286
Joined: 12 Aug 2010 Posts: 119
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Sat Dec 11, 2010 3:39 am |
|
|
It is worth perhaps distinguishing two situations:
The 'binary tree' resistor pattern, read using either an internal ADC (on the PIC), or a ADC done by timing capacitor discharge, can handle multiple keys pressed at once. With care, and reasonable switches, this can probably handle up to about 6 keys.
The 'distinct value' resistor pattern (as shown in the example posted by dyeatman), can handle many more keys (it could be stretched further than the example given), but can't handle multiple keys pressed at once. For example, if you press the key with 200R, and the one with 680R, and the one with 390R, at once, the equivalent resistance being seen, is 110R6, which will (of course) be seen as the key with the 110R resistor....
Decoding multiple 'single keys', is much easier, that handling lots of keys pressed at the same time. Comes down to deciding what you 'need'.
Best Wishes |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Sat Dec 11, 2010 6:57 am |
|
|
Hay Sid thanks for the schematic.Now I understand what and how it works. Unfortunately it's not just a '4 pushbuttons and one i/o pin' circuit.
It actually needs 4 more I/O pins from the PIC(or other micro) to drive the pushbuttons.Very similar to any generic matrix keyboard decoder.
I was hoping to see some mysterious,clever circuit using only 1 I/O pin 'cause like others, I always seem to run out of them when new features are added!
As others have said, if you have an ADC port available it's easy to add up to a 4*4 matrix of switches,more if you use a very stable Vref.
Thanks for sharing though. |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Sat Dec 11, 2010 7:57 am |
|
|
@SID2286
You indicate you will be using a PIC and the CCS compiler (as I had
assumed) so you are on target posting here. That was the point I was
making, using the PIC ADC you can interface 12 (or even more) buttons
using one input as shown in the project where I gave you the link. Good
luck on your project! _________________ Google and Forum Search are some of your best tools!!!! |
|
|
|