Searching \ for '[PIC]: A to D convertor use for switch decoding' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'A to D convertor use for switch decoding'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: A to D convertor use for switch decoding'
2003\02\26@005627 by Michael Reid

picon face
Does anyone have any experience in using an A to D input with a ladder
resistor array of 8 resistors and 8 switches to allow for the 8 switches to
be used without taking up more than 1 I/O into the processor?

If the resistors are all 1k in value then the input voltage will correspond
to whichever button is pressed?  Is this a practical route to explore?

We are designing a keypad for a control system and I/O's are at a premium.
We need a 1 or 2 color LED per switch so that will use a mess of I/O's.


Thanks in advance

Mike

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\26@014546 by Andre Abelian

picon face
Mike,

Let me save you some time use metal film resisters 1%

Andre Abelian




-----Original Message-----

Does anyone have any experience in using an A to D input with a ladder
resistor array of 8 resistors and 8 switches to allow for the 8 switches
to
be used without taking up more than 1 I/O into the processor?

If the resistors are all 1k in value then the input voltage will
correspond
to whichever button is pressed?  Is this a practical route to explore?

We are designing a keypad for a control system and I/O's are at a
premium.
We need a 1 or 2 color LED per switch so that will use a mess of I/O's.


Thanks in advance

Mike

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\26@023858 by Eric Bohlman

picon face
2/25/03 11:27:14 PM, Michael Reid <spam_OUTmikecreidTakeThisOuTspamMSN.COM> wrote:

>Does anyone have any experience in using an A to D input with a ladder
>resistor array of 8 resistors and 8 switches to allow for the 8 switches to
>be used without taking up more than 1 I/O into the processor?

There are a couple examples on Microchip's site; the one I remember offhand was in the "tips and
tricks" document for the 12F629/675.

>If the resistors are all 1k in value then the input voltage will correspond
>to whichever button is pressed?  Is this a practical route to explore?
>
>We are designing a keypad for a control system and I/O's are at a premium.
>We need a 1 or 2 color LED per switch so that will use a mess of I/O's.

Sounds reasonable, but read the application notes; you'll want to watch out for noise pickup and for
boundary ambiguity.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\26@075507 by Ray Gallant

flavicon
face
I've done this for card node I.D. no problem but my I had plenty of  1%
metal film resistors handy, so I used those in the a/d environment.
I also compared and verified the a/d result with a couple of hits.  As a
decoupling capacitor, I used a 0.01uF in order not to affect the response
time as much. {slewrate}

{Original Message removed}

2003\02\26@081941 by Olin Lathrop

face picon face
> Does anyone have any experience in using an A to D input with a ladder
> resistor array of 8 resistors and 8 switches to allow for the 8
> switches to be used without taking up more than 1 I/O into the
> processor?
>
> If the resistors are all 1k in value then the input voltage will
> correspond to whichever button is pressed?  Is this a practical route
> to explore?

I have never done this, but it sounds like it should work.  Note that the
switches are connected in a priority arrangement.  Multiple simultaneous
key presses will appear like a single key press of the highest priority
key.  If this isn't a problem, then you're probably fine.

You will also want to do some filtering and detection of settling of the
A/D value before assuming a key is pressed.  Since the ladder produces a
single voltage, it will slew thru legitimate states before settling on the
proper voltage for the key pressed.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\26@085024 by Alan B. Pearce

face picon face
>I have never done this, but it sounds like it should work.
>Note that the switches are connected in a priority arrangement.
>Multiple simultaneous key presses will appear like a single
>key press of the highest priority key.  If this isn't a
>problem, then you're probably fine.

Not necessarily. It is potentially (no pun intended) possible to detect any
and all switch states. However I looked at doing this some time back, and
came to the conclusion that you are probably limited to 3 or 4 switches max
on a single A/D input, as the resistor array is not being used in a true
R/2R arrangement, which would changeover switches to switch between ground
and a reference voltage, to get the maximum number of states out of the
available range. In my case I was looking to use it as a way of getting
address information into the PIC at start-up, so I needed to be able to
sense all switches.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\26@085852 by Olin Lathrop

face picon face
> Not necessarily. It is potentially (no pun intended) possible to detect
> any and all switch states.

Yes, if you use R/2R ladder.  However, that severly limits the number of
switches based on the accuracy of the resistors, as you pointed out.

I straight muli-tap divider allows for more switches with lower tolerance
parts, but does have the priority issue.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\26@091257 by Dennis J. Murray

flavicon
face
Olin - I'm not entirely sure I agree with multiple keypresses showing as the
highest priority keypress.  Maybe I missed the original post, but I didn't
read where he described the actual wiring.  IF he's using the resistor
ladder as nothing more than a multi-tap voltage divider and the switches do
nothing more than route a particular tap to the A/D input, then multiple
keypresses will short out part of the ladder, giving you an A/D input not
representative of either valid keypress.

Do you disagree?

Dennis

{Original Message removed}

2003\02\26@094619 by Ian McLean

flavicon
face
FOr an example, this is done for switch decoding on the Pocket Programmer (a
good PIC programmer).  The schematics are at http://www.bubblesoftonline.com, and
show a schematic for four button control.  It dooes indeed use a resistor
ladder to determine the voltage input to a single A/D port on the PIC.

Rgs
Ian.



{Original Message removed}

2003\02\26@094824 by Olin Lathrop

face picon face
> Olin - I'm not entirely sure I agree with multiple keypresses showing
> as the highest priority keypress.  Maybe I missed the original post,
> but I didn't read where he described the actual wiring.  IF he's using
> the resistor ladder as nothing more than a multi-tap voltage divider
> and the switches do nothing more than route a particular tap to the A/D
> input, then multiple keypresses will short out part of the ladder,
> giving you an A/D input not representative of either valid keypress.
>
> Do you disagree?

I was envisioning a different topology from the one you describe because
it is too sensitive to part tolerance.  The original poster was vague
about his topology, so I went with the most sensible approach:


 +V
  |
  R
  |
  *----------*-------  to PIC A/D pin
  |          |
  |          o /
  |           /
  R          o
  |          |
  |         GND
  |
  *-----------
  |          |
  |          o /
  |           /
  R          o
  |          |
  |         GND
  |
  *-----------
  |          |
  |          o /
  |           /
  R          o
  |          |
  |         GND
  |

 etc...

Note that the various Rs might not be the same value.  The top R should be
larger than the others, which could be the same for simplicity.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\26@095906 by Dennis J. Murray

flavicon
face
Understand.  Your approach makes much more sense and does give priority
encoding, which MAY be exactly what he needs!

{Original Message removed}

2003\02\26@101601 by Roman Black

flavicon
face
Dennis J. Murray wrote:
>
> Olin - I'm not entirely sure I agree with multiple keypresses showing as the
> highest priority keypress.  Maybe I missed the original post, but I didn't
> read where he described the actual wiring.  IF he's using the resistor
> ladder as nothing more than a multi-tap voltage divider and the switches do
> nothing more than route a particular tap to the A/D input, then multiple
> keypresses will short out part of the ladder, giving you an A/D input not
> representative of either valid keypress.
>
> Do you disagree?



I do, the switches go from each ladder rung to
ground. The uppermost switch pressed has priority.
It requires one R for each sw, the ADC tap is
taken after the top R, at the point where the top
sw connects. This system can use identical R values,
and still provide safe (ie large) boundaries with
an 8bit ADC.
-Roman

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\26@112538 by Michael Reid

picon face
I posted this question and the diagram below is what I envisioned.  If this
is used for a home automation system as envisioned, then most likely
lighting scenes will be programmed to each button. When pressed and held for
longer than 1/2 second, the scene ramps the light level up or down. If
multiple buttons are pressed at the same time, the system just ignores this
in software.

thanks everyone for your feedback. I'll look at the examples.

----
{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\26@122019 by Dave Tweed

face
flavicon
face
Olin Lathrop <.....olin_piclistKILLspamspam@spam@EMBEDINC.COM> wrote:
> > Olin - I'm not entirely sure I agree with multiple keypresses showing
> > as the highest priority keypress.  Maybe I missed the original post,
> > but I didn't read where he described the actual wiring.  IF he's using
> > the resistor ladder as nothing more than a multi-tap voltage divider
> > and the switches do nothing more than route a particular tap to the A/D
> > input, then multiple keypresses will short out part of the ladder,
> > giving you an A/D input not representative of either valid keypress.
>
> I was envisioning a different topology from the one you describe because
> it is too sensitive to part tolerance.  The original poster was vague
> about his topology, so I went with the most sensible approach:

When you said priority encoder, I thought maybe you meant SPDT switches,
like this, which gives 0V for no switch pressed, and 1-5 V in equal steps
for a switch press.

     o +5V
     |
     |       o----- to A/D
     |    NO  \NC
     +-----o   o
     |         |
    10K      o-+
     |    NO  \NC
     +-----o   o
     |         |
    10K      o-+
     |    NO  \NC
     +-----o   o
     |         |
    10K      o-+
     |    NO  \NC
     +-----o   o
     |         |
    10K      o-+
     |    NO  \NC
     +-----o   o
     |         |
    10K        V
     |
     V

However, your approach gives several advantages, in terms of using SPST
switches with one side grounded. It isn't hard to work out resistor values
that also give equal-size steps; for example, using 5% resistors:

             o +5V
             |
            10K
0.00V   ---   |
    +--o o---+---- to A/D
    |        |
    |       2400
0.97V|  ---   |
    +--o o---+
    |        |
    |       4300
2.01V|  ---   |
    +--o o---+
    |        |
    |       8200
2.99V|  ---   |
    +--o o---+
    |        |
    |       24K
3.98V|  ---   |
    +--o o---+
    |
    V

This gives 5V for no switch pressed, and 0-4V in approximately equal steps
for a switch press.

-- Dave Tweed

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\26@123359 by Andre Abelian

picon face
You are grounding each pin adc input will get the same voltage
On every switches In your schematic you are changing the current not the
voltage.
To change the voltage use some thing like this
Use 1% metal film resisters R1 thru Rx can be any value
In your case you can use 8x1k resisters.


+VDD 5v
  |
  R1
  |            /
  *----------o/  o----------|
  |                         |
  |                         |
  |                         |
  R2                        |
  |                         |
  |                         |
  |            /            |
  *----------o/  o----------*----------o to pic ADC input
  |                         |
  |                         |
  |                         |
  R3                        |
  |                         |
  |                         |
  |            /            |
  *----------o/  o----------|
  |
  |
  |
  R4
  |
  |
  |
 GND



Andre Abelian




{Original Message removed}

2003\02\26@125650 by Olin Lathrop

face picon face
> If multiple buttons are pressed at the same time, the system
> just ignores this in software.

No, it will ignore it in hardware.  That's what I've been trying to say
about the way this scheme automatically prioritizes the switches.  Note in
the diagram below that if the top switch is closed, the PIC input will be
low regardless of what the other switches are doing.  Any switch closed
masks all others further down the chain.

{Quote hidden}

*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\26@125657 by Olin Lathrop

face picon face
{Quote hidden}

That would work except that the PIC pin needs to float to a well defined
"no button pressed" level when no button is pressed.  This will draw a
significant current in the divider chain, because the pullup or pulldown
can't be more than 10Kohms, and the divider would have to be significantly
less to overcome it and still produce reasonable size step changes.  You
also have to think carefully about what happens when more than one button
is pressed at a time.  You could work out a scheme where every combination
produces a different voltage, but then we'd be back to high parts
tolerance senstivity for more than a few buttons.

By the way, you could lose either R1 or R4 in the diagram above, but not
both.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\26@134652 by Andre Abelian

picon face
You are right but If you look at it in detail then you also need ceramic
Cap for filtration I just gave him general idea.

Andre Abelian


{Original Message removed}

2003\02\26@145710 by Robert Ussery

flavicon
face
From: "Michael Reid" <mikecreidspamKILLspamMSN.COM>
| We are designing a keypad for a control system and I/O's are at a premium.
| We need a 1 or 2 color LED per switch so that will use a mess of I/O's.
<snip>

Addressing a different aspect of your problem, had you considered an LED
driver or a serial latch array for driving the LEDs, to save you some pins?
These are particularly useful when you need lots of current to drive the
LED's, as when you're overdriving them for sufficient luminosity. I'm don't
know what the current rating on the pic pins is, but I think driving a whole
array of LEDs with the PIC might take too much current.
Anyway, I've found these drivers very useful in gaining extra pins...

- Robert

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

More... (looser matching)
- Last day of these posts
- In 2003 , 2004 only
- Today
- New search...