geekhack

geekhack Projects => Making Stuff Together! => Topic started by: emenelopee on Wed, 21 March 2018, 20:18:49

Title: Per-key LED circuit, Teensy/QMK
Post by: emenelopee on Wed, 21 March 2018, 20:18:49
Apologies if this has been covered before, but my searches are not turning up anything. Also I'm bad at searches.

What's the current best method to work per-key LEDs into the Teensy/QMK environment? I went the easy route and hooked up all LEDs in parallel (each with a resistor) and mainlined straight into the 5V with a variable resistor controlling the light levels. I'm beginning to think I should have gone through a more robust method. What would that be? I've seen some examples using (I think) a transistor to control the current. Is this the preferred method? What does the circuit look like? If it's as simple as swapping out my variable resistor for a transistor, that would be easy to retrofit.

Or is it better to go through some sort of controller with separated zones? What does this circuit look like?

My intention is to make sure the Teensy/USB hub is not at risk of blowing through over-current (I have a sneaky suspicion I blew one out for this reason, though I can't be certain), and to maybe get more brightness out of the LEDs which I believe an oscillating current can do without taking the average draw over the USB capacity.

NB: full size keyboard with 100+ keys.
Title: Re: Per-key LED circuit, Teensy/QMK
Post by: a-c on Thu, 22 March 2018, 13:13:44
https://itp.nyu.edu/physcomp/labs/motors-and-transistors/using-a-transistor-to-control-high-current-loads-with-an-arduino/ (https://itp.nyu.edu/physcomp/labs/motors-and-transistors/using-a-transistor-to-control-high-current-loads-with-an-arduino/)

Google "arduino high current switch" for a lot of other examples.
Title: Re: Per-key LED circuit, Teensy/QMK
Post by: cest73 on Fri, 01 January 2021, 08:42:34
I'm totally aware this is somewhat a dead end, but any luck so far to the OP?

I look exactly for the same answer and figured as much as following thus far:

1. the keyboard power source limits our budget to pretty much 500mA and 5V at most - that's 2.5W max

2. We are best to keep things even below that level at ideally 200ma and 2.5...2.9V on average for the ~104 LEDs if we speak standard keyboards

3. All above considered, an BD 139/140 as a power stage should be by far enough for this affair (low forward voltage BJT) perhaps to be driven with an 3904/3906 signal transistor to off load the AVR pin (just about any high gain transistor capable to drive hundreds of miliamps) ideally in a Sziklay topology instead of more commonly used Dralington layout.

4. It would be far more cool to have the LEDs driven each on their own, but that definitively means multiplexing - question is - could we possibly reuse any of the sense/scan rows that already go across the PCB (i can't imagine to pull this off w/o an PCB)

5. We talk A90USB1286 here, right? (Teensy++ 2.0)
Title: Re: Per-key LED circuit, Teensy/QMK
Post by: King Icewind on Fri, 01 January 2021, 10:31:22
Most are using a mosfet connected to a PWM pin, power, and ground along with necessary resistors. LEDs are connected to power and the pwm pin is simply completing the circuit to ground at whatever rate it’s at. You can use a component like the DMN3018SSS-13 (https://www.digikey.com/en/products/detail/diodes-incorporated/DMN3018SSS-13/2952005).
Title: Re: Per-key LED circuit, Teensy/QMK
Post by: cest73 on Fri, 01 January 2021, 17:57:17
At USB power levels (500mA max and 5V at most) there is hardly any advantage for picking just about any MOSFET versus a modern low FVD bipolar transistor.

See, they are as sluggish as any BJT if the gate is driven anything below 7V.

Remember, we aren't driving those 100+ LEDs at their nominal power (~20-30mA each) - we try push some 1 - 2mA at 1.7 - 2.9V on average per LED.

If we had LED guaranteed to light up below 2V (like the original old green LEDs) we could stack two in series and share the current draw on them - 52x2mA - we'd have quite decent amount of (green) light at 105mA already (provided the resistors and switch are picked and driven right) .

If we speak of parallel configuration.

But I would like to see a per switch controlled LED and will consult the QMK documentation about any chance for that, as the TKC-1800 board clearly has this as an option (LED headers and holes).

Title: Re: Per-key LED circuit, Teensy/QMK
Post by: cest73 on Sat, 02 January 2021, 03:41:34
Most are using a mosfet connected to a PWM pin, power, and ground along with necessary resistors. LEDs are connected to power and the pwm pin is simply completing the circuit to ground at whatever rate it’s at. You can use a component like the DMN3018SSS-13 (https://www.digikey.com/en/products/detail/diodes-incorporated/DMN3018SSS-13/2952005).

That 3018 does indeed fit the current rating at given voltage level and driving the gate off an MCU pin, provided the PCB company can source that part it would be a good switch for our power.

It would be even more convenient if we could have it's footprint and model in KiCAD for the cool renders to include it  ;)
Title: Re: Per-key LED circuit, Teensy/QMK
Post by: hvontres on Sat, 02 January 2021, 05:27:34
I would go with a transistor on the 5V bus controlled with a PWM pin on the Controller. QMK already has functions for setting up different levels and has some simple effects as well. I think it can even support multiple zones as well.
Title: Re: Per-key LED circuit, Teensy/QMK
Post by: Findecanor on Sat, 02 January 2021, 06:49:28
But I would like to see a per switch controlled LED and will consult the QMK documentation about any chance for that, as the TKC-1800 board clearly has this as an option (LED headers and holes).
If you are designing a new PCB, you could check out the ISSI LED controller chip family. There is some support for several of them in QMK (drivers/issi).