published on

Let's build a cube!

Backstory

I’ve decided to try to build a 5x5x5 RGB LED Cube. This would be my first full-color cube, and it’s one size bigger than the last one.

Last time, I connected the entire cube structure directly to an ATMega328P. I, erm… way exceeded its absolute maximum ratings; but, The Little Microcontroller That Could is a champ and is still working.

I think I know a little bit more about what I’m doing this time. :)

The Plan

The plan this time is to build the cube structure separate from the driver board, so that I don’t have to desolder the cube every time I need to fix the driver board. Also, down the road if I want to try a completely different method of controlling the cube, I can just plug it in.

I’m also planning on basing the driver board around the Arduino, rather than trying to build in a MCU, USB -> UART, etc. into every revision. This should be cheaper, easier, and add more appeal to anyone with an Arduino should they decide to follow along.

I would like the cube to be controllable over the Arduino’s serial connection. Essentially, I want to be able to plug this thing into a computer and upload animations into SRAM. This way the cube can be controlled from code running on a computer, rather than static animations that are hard-coded into the MCU’s flash storage.

The Parts

LEDs

I just bought 200 diffused common-anode RGB LEDs off of eBay for $9.12, with free shipping from China. It’ll be awhile. They didn’t include a proper datasheet, but the specification included in the eBay listing is as follows:

Parameter Value
Diameter approx 5mm
Color Red, Green, Blue
Pin sequence Red, Anode, Green, Blue
Forward voltage R: 1.8-2.2, G: 3.0-3.4, B: 3.0-3.4
Current 20mA
Power 600mW
Viewing angle approx 25°

Driver IC

I went with common-anode LEDs, because the driver ICs that I’ve been looking at are all designed to sink current rather than source it. Specifically, I’m looking at the TLC5941.

The TLC5941 is designed in such a way that multiple can be daisy-chained together. Each one has 16 channels, and each LED requires 3 channels (one for each color). Since I’m multiplexing, only one layer of the cube is actually on at any given time. That means I need 5 * 5 * 3 => 75 channels, or 5 daisy-chained TLC5941 drivers.

It seems that there are a few gotchas to be aware of with the TLC5941 chip, so I’ll have to make sure to address these.

Layer MOSFETs

In order to switch each layer on and off, I’m going to need 5 logic-level p-channel MOSFETs acting as high-side switches. Each color in an LED needs 20mA, so the MOSFETs will need to be able to source 20mA * 75 channels => 1.5A. This also means that the driver will need it’s own power supply, since the Arduino’s 5V rail can only source 500mA when powered over USB.

I haven’t decided on a MOSFET yet, but recently I’d considered the NDP6020P for another project. It might be perfect for this.

SRAM

The Arduino has 2KB of SRAM available, but it isn’t enough to store more than a few frames of a full-color animation. Each LED has three colors and, with the TLC5941, each color could glow at one of 4096 different levels of intensity. If we wanted to allow all 4096 possible intensity levels, we’d need 12 bits per color. That’s 36 bits per LED, or 563 bytes per frame. Add an extra byte or two to store the frame’s duration.

One thing we could do to reduce the amount of memory is to only use 1 byte per color, rather than 12 bits. That would give 256 different levels of intensity, and reduce the bytes-per-frame count to 375. But even then, only 5 frames could fit in SRAM at a time.

If, however, we add additional SRAM to the circuit using something like the 23LC1024, which provides 1Mibit of SRAM, we should be able to store 349 (lower brightness ‘resolution’) frames. The nice thing about this particular IC is that it uses the SPI bus, so it doesn’t require a ton of Arduino IO pins, and each additional IC requires only one additional Arduino IO pin to pull the IC’s CS (Chip Select) pin low.

Power

In previous projects, I’d used the LM7805 linear voltage regulator. It has a maximum output of 1.5A, which is exactly what we need; however, I’m worried that it might get too hot. I’m not sure what the best way to power this thing is yet, but I’d like the whole circuit to run off of 5V if possible so that there isn’t a ton of power dissipated in the LEDs and TLC5941. This power supply from Adafruit might be a good option, and since it’s a switching-mode power supply I shouldn’t need a voltage regulator.

Stay Tuned

I’m going to try to document everything as I go along. It’ll be awhile until the LEDs arrive in the mail, but be sure to check back soon, and subscribe to the RSS feed for updates!

comments powered by Disqus