Go Down

Topic: Resistor based Keypad (Read 487 times) previous topic - next topic

elcouz

#15
Aug 02, 2020, 05:32 am Last Edit: Aug 02, 2020, 05:47 am by elcouz
You could have issues over time with this setup.
Cheap audio gear used this principle in the eighties, and this was quickly abandoned because (small tact) switches get bad (resistive) over time.
Better to use a port expander, with the switches in a matrix.
Leo..
Cars still use resistor ladders for many steering controls and radio input. It work well, it shouldn't drift if you use good tactile switch from reputable brands , use a precise ADC with a good clean vref and don't forget less than 1% tolerance on the resistors.

In fact, I'm trying to do the opposite right now.*

Anyway there still plenty of things that use that technique to interface many switches. If you don't cut corner on components you should get the same results in long terms as a direct connection to GPIO.

The only immediate drawback of resistor ladder switches is that you are limited to a single key press. Other than that it's very simple to implement you only need two wires and depending on the ADC precision can got up to ~10 switches on the same ADC.

Looking at your design, it think you are at the edge of precision for an Arduino 10-bit ADC. Any slight temperature drift from the resistors (are they 5%?) or voltage fluctuation of your adc vref is gonna create problems.



Don't give up! :)



* resistor ladder "emulation"


Paul__B

Cars still use resistor ladders for many steering controls and radio input. It work well, it shouldn't drift if you use good tactile switch from reputable brands , use a precise ADC with a good clean vref and don't forget less than 1% tolerance on the resistors.
And the "tact"-style pushbutton on my odometer/ trip meter has now totally failed.  It used to work when the car was hot but now not even then.

I don't think it is even part of a resistor ladder, it's is just a sole switch input to the ASIC.

OK, so the car is 16 years old.  Are you saying they didn't use a "good tactile switch from a reputable brand"?  I don't think it has anything to do with 1% tolerance (which is quite ridiculous in this application)!  :smiley-roll:

I am clearly with Wawa in #11.  :smiley-lol:  Good luck with your cruise control in 10 years!

LeChatQuiRit

Sorry for the delayed response, went out today for the first time since March.

Some questions about your design. What material are you using to make the contacts with the circuit board pads? Notice the board that works has bare copper. The one with problems has tin coating on the copper. Perhaps scrub the tin really well.

The size of the contacts seems to be extremely small based on the keypads I have seen in the past. Those had serpentine traces from both sides of the connection that provided a huge area for the contact.

The keys from years ago used carbon filled conductive foam. The foam would die from ozone and probably other stuff in the air.

Paul
Paul

The solder is "0.8mm Lead Free Solder Wire with Rosin Core Flux Sn99.3 Cu0.7 " (
https://www.amazon.co.uk/gp/product/B07XQ9XTV8-and the actual physical connector is a 2.54mm pitch pin. The other end of the pin is a female Dupont connector which is attached to a Cherry mx at the other end via 2 inch wires. I'm using Cherry MX because I had a handful of them floating about.


The coating (as JLCPCB state it) is

Quote
HASL - Hot Air Solder Leveling

HASL is a type of finish used on printed circuit boards (PCBs). For hot air solder leveling finish, the board will be dipped in a bath of molten solder and then passed through a conveyor of hot air knives that brush the excess solder off. Basically, the copper pads are pre-tinned with the thinnest layer of solder, and the tinning protects the bare copper underneath. which can provide the board with a good shelf-life, and the existing layer of solder makes the molten joints much easier to join. It is a commonly used and cheap finish for most DIY projects. However, it is not suitable for fine pitch components since HASL leaves uneven surfaces.
Although I opted for the lead free version which has some additional notes, but not a lot.

Quote
Lead-free HASL

Lead-free HASL is variant from HASL, which is lead-free and qualified for ROHS compliance products. Please note that higher soldering temperatures are required for lead-free solder.
 
All of the traces I used in Kicad are  0.25mm. (9.84mils). It's interesting that you mention pad sizes, would trace sizes also have an impact? I found an old keypad and the traces are about 3mm wide on that.

Do you think upping the trace width and creating a larger pad footprint would help?



elcouz

#18
Aug 02, 2020, 10:53 pm Last Edit: Aug 02, 2020, 10:57 pm by elcouz
OK, so the car is 16 years old.  Are you saying they didn't use a "good tactile switch from a reputable brand"?  I don't think it has anything to do with 1% tolerance (which is quite ridiculous in this application)!  :smiley-roll:


ANALOG sensing require some tight tolerance on circuit design, if you use subpart product it's gonna show.


Temperature drift of resistors is real, cheap resistor can have more than 1000 ppm of TCR let alone the 5% tolerance of ohms value which change per resistor basis. 5% of 10k is still +/- 250 ohms on each you add.

Let says 1000 ppm for a cheap resistor. 10k ohms will drift ... 1000/1000000 ppm = 0.001 * 10 000 ohms  = 10 ohms drift per Celcius. a 30C change would make it drift by 300 ohms. Enough to be pickup by ADC.

Also the pack of 1000 of tactile switch from Aliexpress special from unknown source without a proper datasheet on contact resistance or coating on the contacts.

This is why AEC-Q200 exist in the automotive industry. Before everybody do what they want using any component. Now electronic standards have stricten and reliability improved.


The more resistors (switches) you add in the ladder the more drift and instability occurs in the readings. You narrow your reading range for each key press they have the potential to overlap.

Paul_KD7HB

Sorry for the delayed response, went out today for the first time since March.



Paul

The solder is "0.8mm Lead Free Solder Wire with Rosin Core Flux Sn99.3 Cu0.7 " (
https://www.amazon.co.uk/gp/product/B07XQ9XTV8-and the actual physical connector is a 2.54mm pitch pin. The other end of the pin is a female Dupont connector which is attached to a Cherry mx at the other end via 2 inch wires. I'm using Cherry MX because I had a handful of them floating about.


The coating (as JLCPCB state it) is

Although I opted for the lead free version which has some additional notes, but not a lot.

All of the traces I used in Kicad are  0.25mm. (9.84mils). It's interesting that you mention pad sizes, would trace sizes also have an impact? I found an old keypad and the traces are about 3mm wide on that.

Do you think upping the trace width and creating a larger pad footprint would help?



The trace size will have no effect. The effect you need is to increase the contact probability for the switch pad. Think of two combs, the teeth of each are mated together, so they almost touch, but don't touch. The contact pad if in good condition will contact several of the teeth on each side of the comb and make a fairly good contact for the circuit.

Should have not shredded to picture the other day!

Paul

Paul__B

Suffice to say, the "tact" switch - used in digital mode - in my car odometer/ trip meter has failed.  I must say I am not keen to pull the dashboard apart to fix it.  It was not a cheap car.

I have had to replace the most used "tact" switch on our "Sangean" digital radio clock.  That is not a cheap brand.

If you can have such problems using the switches as digital inputs, I have to caution against getting too enthusiastic about the analog resistor ladder concept if you desire durability.  :smiley-roll-sweat:

TomGeorge

#21
Aug 03, 2020, 05:26 am Last Edit: Aug 03, 2020, 05:27 am by TomGeorge
Hi,
Can you try this in your code please?
Code: [Select]
reading = analogRead(keyp[i]);
 reading = analogRead(keyp[i]);

Use two analogReads, there is only one ADC, it is multiplexed to the analog input pins.
It takes time to read a pin and if different pins are read there can still be a charge from the last read on the ADC input capacitor.

By adding a second read, the first is not used and the second gives time for the ADC to respond, it is an old ADC trick.

Thanks.. Tom... :)
Everything runs on smoke, let the smoke out, it stops running....

LeChatQuiRit

#22
Aug 03, 2020, 10:26 am Last Edit: Aug 03, 2020, 10:33 am by LeChatQuiRit
Tom,

It didn't work with the two analog reads so I stuck another one with a 2ms delay before reading each one

Code: [Select]
   
        delay(2);
        reading = analogRead(keyp[i]);
        delay(2);
        reading = analogRead(keyp[i]);
        delay(2);
        reading = analogRead(keyp[i]);


This seems to have made a massive difference I'm not getting any other keypresses sent on any keypad other than the one I'm pressing. Also seems to have zero effect on key repeat time which is good too :D

I asl decided to stick it all in a for next loops and average the results, Not sure it's needed but it did allow me to see the values being read.

I'll do more testing but this might well have cured the issue.

Many thanks to you and everyone who offered assistance.

I'll do more testing and report back.



Go Up