geekhack

geekhack Projects => Making Stuff Together! => Topic started by: SnowPatch on Tue, 17 February 2015, 05:42:43

Title: Combine keyboard- and RGB-controller
Post by: SnowPatch on Tue, 17 February 2015, 05:42:43
Hey yall. I am planning to build a 3x4 keypad with RGB lighting. I would like to ask if it would be possible to run the keyboard controller (arduino pro micro) and the RGB controller (BlinkStick Pro V1.0) on the same USB port? Thanks :)

PS: If you know a cheaper alternative to BlinkStick, that you can also make your own program to control, then please let me know :)
Title: Re: Combine keyboard- and RGB-controller
Post by: vvp on Tue, 17 February 2015, 11:04:52
Looks like you can go without a led driver for such a small keyboard:
4 + 3 = 7 pins for switch matrix scanning
4 + 3*3 = 13 pins for RGB LED matrix
So you need only 20 pins. ATmega32u4 will do.
That is at most about 40 mA ((500-100)/9 ≅ 40) per one led per one color. Big enough. You would need 3 FETs for max current amplification (because 9*40mA > 40mA (maximum current limit per port of ATmega32u4)).
That is if you are OK with at most ⅓ duty cycle (should be big enough at 40 mA per channel).
Title: Re: Combine keyboard- and RGB-controller
Post by: SnowPatch on Tue, 17 February 2015, 15:49:15
Hey vvp. That sounds interesting :) Would I still be able to make a program in Microsoft Visual Studio, that controls the RGB diodes, like I can on the BlinkStick? :)
Title: Re: Combine keyboard- and RGB-controller
Post by: neverused on Tue, 17 February 2015, 15:52:16
I should think so as it would all be PWM
Title: Re: Combine keyboard- and RGB-controller
Post by: SnowPatch on Tue, 17 February 2015, 16:00:28
Sounds great :) Right now I am actually in the process of designing the pcb, but I am not familiar with making matrixes. Any idea how the keyboard and rgb matrix should be set up? (btw, the RGB ligts are 4-pin diodes in case you missed that) :)
Title: Re: Combine keyboard- and RGB-controller
Post by: vvp on Tue, 17 February 2015, 18:03:43
Yes, all the LEDs will have PWM with at most 1/3, oops, wrong, 1/4 maximum duty cycle. It still should be good enough.

4+3 matrix scanning is the same as for all keyboards

4+3*3 LED matrix has:
Or if you wan to achieve 1/3 duty cycle then flip the LED matrix and use 3 + 3*4 = 15 pins for it. Then the final pin count is 15+7 = 22 (still well doable with ATmega32u4).
Title: Re: Combine keyboard- and RGB-controller
Post by: SnowPatch on Wed, 18 February 2015, 00:40:42
Hey vvp. Could I get you to make a little schematic or something of the 3+4*4 matrix? I am not intirely sure how it should be set up :)
Title: Re: Combine keyboard- and RGB-controller
Post by: vvp on Wed, 18 February 2015, 02:55:53
You probably meant 3 + 3*4. Here is an example:
[attach=1]
Title: Re: Combine keyboard- and RGB-controller
Post by: SnowPatch on Wed, 18 February 2015, 03:02:17
Would that make me able do individually light them? And does that works with my 4-pin RGB diodes?
Title: Re: Combine keyboard- and RGB-controller
Post by: vvp on Wed, 18 February 2015, 11:58:57
Would that make me able do individually light them?
Yes, it allows to control each color of each led separately.

And does that works with my 4-pin RGB diodes?
Who knows? You did not post a link to the specification of your LEDs.
It works with 4 pin RGB leds which have a common cathode and can handle at least 5V reverse voltage.

There are also 4 pin RGB leds with a common anode. Those need to flip GND with Vcc and N-channel FET with P-channel FET and logic in the firmware.

Anyway, the fact that you need to ask these questions (despite having looked at the scheme first) means that you need somebody who will do a complete design for you. Either find a person who will do it for you, or build something else already designed and published, or start to study how to design simple circuits.
Title: Re: Combine keyboard- and RGB-controller
Post by: thehijjt on Wed, 18 February 2015, 13:18:05
I have been thinking about doing something like this with an Adafruit Dotstar. They have an integrated driver, take spi communication, and don't have tight timing requirements. I think it would be possible to use a atmega 32u4 to do both the keyboard, and the rgb control.
Title: Re: Combine keyboard- and RGB-controller
Post by: SnowPatch on Wed, 18 February 2015, 13:57:41
Hey vvp. You are completely right that I dont have alot on knowledge on this area. Would you be interested in helping me designing the pcb in Eagle Board? I've already designed the CherryMX spots and the spot for the Pro Micro.

The LED's im going to use is: http://goo.gl/C4RuC0 (bought as common anode).
The specs of the my specific Pro Micro can be found here: http://goo.gl/ZaQV7L

:)
Title: Re: Combine keyboard- and RGB-controller
Post by: vvp on Wed, 18 February 2015, 14:45:33
Well Leonardo Pro Micro has a great price but it does not have enough ports pulled out. From 26 useful IO pins of ATmega32u4 only 18 pins pulled out to the PCB edges. But almost for sure you could hack it to get the additional 2 or 4 pins out too. For comparison, Arduino Micro has 24 pins easily available, and Teensy 2.0 has 25 easily available pins.

The other option is to make the matrices like this: 4+3 (keyboard) + 4+3*3 (led matrix) = 20 pins, but you can share the 4 keyboard scanning pins with the 4 pins of led matrix, so the needed number of pins is only 20-4 = 16 (which your Leonardo Pro Micro can easily provide).

The RGB LEDs you have look OK. Since they are common anode you would need to use FET-P instead of FET-N, flip polarity and flip logic in firmware. It does not really matter if your leds are common catode or anode ... you just flip all logic and that is it.

I cannot design and build this with you since I'm used to KICAD (and lazy to learn Eagle), and (much more important) I already have a project on my shoulders: katy keyboard (https://geekhack.org/index.php?topic=61323.0). Maybe you can find somebody else.