I'm trying to create a macro pad using cherry mx rgb keyswitches in a 5x5 matrix, but have hit a snag in the design process. nothing i have found online explains how to individually control the color of 25 rgb led's.
i cannot use those leds that have the driver built in, but instead have to use these instead, because they have to fit inside the keyswitches.
i plan on using an atmega 2560 directly attached to the pcb. on the schematic, please ignore the RGB led symbols, and instead focus on the circuit already outlined (the sympols are for common cathode). the leds are of the type common anode.
There are other such driver chips but the PCA9865 is the simplest to use in software. However, you can multiplex one of them in software, the TLC 5940. I used three to control up to 65 RGB LEDs in this project I designed some time ago http://www.thebox.myzen.co.uk/Hardware/Hexome.html
If you need just on / off control of each LED so you only have the primary / secondary colours the circuits are even simpler. Just use a simple 5 by 5 matrix circuit.
i have taken your advice about using one of the TLC series chips. however, i decided to use the TLC59581 chip instead.
Grumpy_Mike:
There are other such driver chips but the PCA9865 is the simplest to use in software. However, you can multiplex one of them in software, the TLC 5940. I used three to control up to 65 RGB LEDs in this project I designed some time ago
i am admittedly new to controlling rgb leds (i have never done it before), and i am wondering about what your using the TCP6108 for in your design.
i took a look at your supplied link and modified my schematic accordingly. i knew that it was possible to do this with regular led's, but for some reason it never clicked that it would also work with RGB leds.
what advantages does this method provide, other than saving on chips? where there any advantages to doing it the way i had done it previously, or would doing it that way simply add unneeded complications?
i decided not to multiplex the inputs, allowing me to press multiple keys at the same time.(or am i wrong ?)
also if anyone sees a problem with the way i have the leds connected or the chips configured, please let me know.
super7800:
what advantages does this method provide, other than saving on chips?
You certainly save on chips, but also substantially simplify the wiring.
super7800:
were there any advantages to doing it the way I had done it previously, or would doing it that way simply add unneeded complications?
Well, given more chips and more wiring, there are complications of not multiplexing and essentially all large displays or arrays are multiplexed - television is essentially a multiplex process, and computer memory is multiplexed (serialised).
Advantages of not multiplexing are powering each element continuously which may be more efficient in terms of power losses, and - not needing to perform the multiplexing in software (as in this case) or hardware - which is what the MAX7219 does.
super7800:
I decided not to multiplex the inputs, allowing me to press multiple keys at the same time.(or am I wrong ?)
Umm, yes, you are wrong! All that is required to multiplex the keys is to have a diode in series with each key to avoid ghosting.
i have still decided to continue to use non multiplexed inputs, as i have already managed to fit the chips onto the PCB layout, but doing it this way is definitely something to implement into future projects.
Paul__B:
Umm, yes, you are wrong! All that is required to multiplex the keys is to have a diode in series with each key to avoid ghosting.
i designed my PCB for this project and created an updated schematic (pics below), and will order them unless anyone sees a problem with the design. once again thanks to everyone who helped me on this so far.
Your project is headed for failure. Expensive failure. Stop now and correct the design. This is the best and least expensive time to make changes to the design.
You need to prototype this circuit before you have expensive PCB boards made. The probability is that there will be errors in your design which need correcting. Build a prototype on breadboard first.
The TLC59581 is not a suitable choice now because you are using only one third of its outputs.
You are multiplexing the LEDs but not the buttons. There is little point not multiplexing them together. You already have the complexity of multiplexing, so multiplexing the buttons is logical, further reduces the components required and does not make the code significantly more complex.
Your design uses two busses: SPI and I2C. Choose one bus and stick to it. This makes the design simpler and more consistent. For example you could use one tlc5940 to provide pwm outputs and one mcp23s17 to provide the digital inputs and outputs to control the scanning of the matrix and reading the buttons. Both chips use SPI bus.
Alternatively, if you have 5 more Arduino pins available, you would not need the mpc23s17, the Arduino could read the buttons directly.
PaulRB:
Alternatively, if you have 5 more Arduino pins available, you would not need the mpc23s17, the Arduino could read the buttons directly.
thanks for the advice. i implemented this and wow does it make things simpler. there i went making everything too complex again lol. i guess the simple solutions work the best.
PaulRB:
The TLC59581 is not a suitable choice now because you are using only one third of its outputs.
i still would like to use this IC, as it appears to be more accurate, and there are some other projects that i have in mind that could really take advantage of these outputs, so familiarizing myself with this chip now might be to my advantage. (it also has better analog dimming than the tlc5940, on top of other features). are there any libraries that can be modified to work with this chip? i found a library for the 5940 here. how difficult would it be to make this work with the TLC59581, or due to the existance of the afformentioned library should i just stick to using the 5940?
also if anyone sees a problem with the circuit design please let me know.
PaulRB:
So two problems with the TLC59581: no existing Arduino library and not breadboard compatible for prototyping. I would pay safe and go with the 5940.
yeah your right, using an existing Arduino library would make this project much easier. here is my updated schematic:
I just noticed C4, C6, C9,10,11. They don't look right. What are they for?
Also I'm not sure R34 to R38 should be there. The tlc chips have constant current circuits, so no series resistors are needed for the LEDs (and even if they were, 15 would be needed, not 5). Maybe you meant to put those resistors on the gates of the p-channel fets?
PaulRB:
I just noticed C4, C6, C9,10,11. They don't look right. What are they for?
if your refering to the 5 caps on the far left(C13-C17), they are decoupling caps that i added to prevent any unstable oscillation, but due to the short runs probably wont be needed. someone else had this problem and this was their solution.
the led's im using are common anode, but it should still fix any errors that might occur (or should i put them on the end of each cathode? perhaps they will end up not even being needed).
PaulRB:
Also I'm not sure R34 to R38 should be there. The tlc chips have constant current circuits
i was unsure about this, because some diagrams i found included resistors and others did not.
someone else had this problem and this was their solution.
That was me, the clip was from my Hexome project.
As to the dot correction register I have never got it to do anything.
Yes never put the current limiting resistance in the common line of an common anode or cathode LED. If you do then the brightness will depend on what the other LEDs in the package are on. Also if the red LED is on then it will prevent the other two colours coming on because there will not be enough voltage to turn them on.