Which kind of diodes I should use in buttons/keys matrix input? (Making gaming keyboard)
When making matrix input of NxM columns/rows with push buttons, there should be a diode next to each button to prevent "ghosting" and able read many keys pressed together correctly. There is a lot of pictures everywhere.
My problem is, which diodes to use (and why).
Solution: 1N4148 diode
generally if you want connect diode to Arduino pin, use this one as it would be OK under nearly any normal use
75 V reverse voltage
1 V forward voltage at 10 mA
10 mA recommended current (destroys at 1 A 1 sec pulse) (and you do not want more then 10 mA anyway)
usable to some hundreds kHz (so using digitalRead/digitalWrite and some logic you are probably a way slower anyway)
super extra common for long time (even 10 years ago was considered "classical") and still actual (so when you get old, it would still be here)
dirty cheap (buy few hundreds just now and you do not need care anymore)
(OLD) More details:
I would use 5 V Arduino (ATmega32U4), datasheet states for input low voltage max 0.3Vcc, which is 1.5 V and minimal high input voltage 0.7Vcc = 3.5 V and pullups at least 1.5 kΩ (Vcc-0.4 V / 3 mA)
I would like to use 74HC138 3-to-8 decoder for addressing, which makes one of 8 outputs Low (max 0.1 V), while other 7 High (min 4.5 V) and drive the Arduino inputs Low, if button is pressed.
To be on safe side, I would like also add resistors on each pin to make sure, that bad programming (make some input pin OUTPUT and HIGH and pressing key connect it to LOW output on other side) could not damage the circuits, so it looks like 5 V/20 mA = 250 Ω (and I will hope it would not hit more pins, so I would not consider total port/chip limitations).
In typical case it would be 5 V - 1.5 kΩ pullup - input - 250 Ω - wires and button - diode - 250 Ω - 0.1 V for selected line.
If the diode would be theoretical and ideal, then there is (in the worse case) promised to be max 1.2 V on Input, which is slightly less then "maximal low" voltage (1.5 V) and like 5V/2 kΩ = 2.5 mA current.
But the diode is not ideal and have some forward voltage, which make the case even worse.
So I probably cannot use simply INPUT_PULLUP
but I need to use INPUT
and set some higher pullup there to "burn" more volts on it to compensate for the diode.
The Input Current for each pin is 10 μA (in or out) and I heard some recommendation, that on resistor divider should be the total current 10x more, then the input current, so it would mean 100 μA = 0.1 mA
The pullup then could go as high as ((5 V - 0.1 V - Vf)/0.1 mA ) - 500 Ω If the forward voltage would be 1 V (wild guess) it would go to something like 38.5 kΩ pullup and 1.15 V on input. The maximal Vf forward voltage would be like 1.35 V (at 0.1 mA), pullup 35 kΩ and 1.5 V on input.
- It is the right path, how to compute it or did I some mistake?
- I want use scanning frequency at least 800 Hz (8 lines and results 100x per second) or more (like 10 kHz to be done fast and to have more time to spend with other tasks, like sending USB packets, computing macros, managing light effects etc)
- which common and cheap SMD diodes I should buy?
- reverse voltage over 5 V, current over 100 mA, switch frequency over 10 kHz, forward voltage under 1.3 V at 0.1 mA (rather much less to have safe gap from limits)
- really common cheap model, so everybody would know it and so I could use it everywhere in similar settings without thinking ( or even computing like in previous section)
- preferably what you (and everyone else and his dog too) use for such cases
- I would like to order from AliExpress, so rather higher margin for guaranteed values
- preferably to fit on 0.1 inch spaced universal PCB (0805 SMD LEDs are really easy to solder there (so rather not smaller than that), but it may be twice the size too or something like that)
- I would buy like some hundreds of such diodes to have them ready on hands and I will probably make more similar projects over time for me and my friends
Thanks for all comments and suggestions
- 1.5k
- 2
- 11
- 20