0
\$\begingroup\$

I'm currently using 74HC595 shift register to light leds. Recently I decided to start using RGB leds instead of simple 1-color leds. Which means that I now have to use 3 output pins for each individual led. So far so good.

The problem however, is that I cannot fully enjoy the power of the RGB leds. I would like to use the full color-depth by mixing the 3 color components (Red,Green,Blue) at different individual distinct brightnesses.

There is an Output-Enable pin on the 74HC595 which can be used to control the brightness, but as far as I know, its value applies to all output pins, and cannot be used to set the brightness of individual outputs.

Can it be done with the 74HC595 shift-register, or is there a more appropriate component ?

\$\endgroup\$
  • \$\begingroup\$ There is no obvious relation between shift registers and LEDs, either monochrome or RGB. \$\endgroup\$ – Eugene Sh. Jun 16 '15 at 20:38
  • \$\begingroup\$ @EugeneSh. I'm steering about 100 leds that are arranged in a matrix. They need to be addressed individually. So, using shift registers I can steer over hundred leds using just 4 data pins of an arduino. Something like this: learn.adafruit.com/adafruit-arduino-lesson-4-eight-leds/… \$\endgroup\$ – bvdb Jun 16 '15 at 20:43
  • \$\begingroup\$ Are you familiar with PWM control for LEDs? \$\endgroup\$ – Hadley Research Jun 16 '15 at 20:52
  • \$\begingroup\$ @HadleyResearch yes, the Output-Enable uses PWM. ; but still only to control the output-level of all pins together, not for individual ones, right ? \$\endgroup\$ – bvdb Jun 16 '15 at 20:58
  • \$\begingroup\$ @bvdb - instead of switching on and off the Output Enable, you can shift in waveforms that then get shifted out to the individual color channels. You are correct that Output Enable is global for the chip, however \$\endgroup\$ – Hadley Research Jun 16 '15 at 21:02
2
\$\begingroup\$

Although you could run a shift register fast enough to PWM some LEDs, there are dedicated RGBA LED drivers which will take a serial input and perform PWM. One arbitrary example is the TLC5971:

The TLC5971 is a 12-channel, constant-current sink Spectrum PWM: driver. Each output channel has individually 16-bit (65536 steps) adjustable currents with 65536 PWM grayscale (GS) steps. Also, each color group can be controlled by 7-bit (128 steps) for each color group 128 constant-current sink steps with the global brightness control (BC) function. GS control and BC are accessible via a two-wire signal interface.

\$\endgroup\$
1
\$\begingroup\$

A simple idea using you current hardware: You could rearange your Matrix so that the shift register controls the common pin of your LEDs. Then you can control the color pins using pwm. This would set one column to the same color though.

\$\endgroup\$
1
\$\begingroup\$

The simple answer is, no, you can't do it.

The longer answer is, yes, you can do it, but it will take more than you think and will probably be harder.

Let's take a group of 8 LEDs. You can drive one from each output of a 595, right? (As long as you don't try to drive them too hard).

Now you want to drive 3 inputs to each LED. This will take 3 595s - call them the red595, green595 and blue595. With this setup, you can only turn each LED on or off, so you get 7 different colors (8 if you count black as a color).

Now you want to turn each LED partially on or off, and each one independently. You can do this by providing each 595 with PWM data. So lets look at LED1, the red channel. Let's say you want to control its intensity in 8 steps. What you can do is update it in cycles of 8 updates. Let's say you want to set it to level 3 on a scale of 0 to 7. The binary equivalent of 3 (in octal representation) is 011. So you would send a cycle of red values that look like 1,1,1,0,0,0,0,0. The LED would be on for 3/8ths of a cycle, at full brightness when it is on.

Now, lets say you have 100 LEDs. It will take 13 595s to control them. The LEDs must have a PWM frequency better than about 30-50 Hz, or they will appear to flicker, and higher is better for colored LEDs. Let's say you run at 60 Hz. To update the entire string of LEDs will take 100 clock cycles. Since each PWM takes 8 cycles, the 595s must be fed at a clock rate of at least 100 x 8 x 60, or 48,000 Hz. For each data output, the computer must determine which pixel is being sent, what its value is, and what the PWM value should be. That's not hard at 48 kHz. For 3 colors, the effective clock rate must be 3 times 48 KHz, or 144 kHz. Still not too bad (probably). The physical clock rate can remain at 48 kHz, since you can use 3 lines for data, set them up, then send a single clock to all 3 x 13, or 39 595s.

But let's say that you want 256 intensity levels. Now the clock rate has to be 256 x 100 x 60, or 1.53 MHz, and that's starting to look rather iffy. Not only that, you can still use this physical clock rate for 3 colors, since you can use 3 data lines and clock the 595s from the same clock. But. For each physical clock you have to determine 3 separate color values, calculate 3 different PWM values, and output those 3 bits to data lines. And all in about 650 nsec.

You may find this something of a challenge.

\$\endgroup\$
  • \$\begingroup\$ YMMV, but 60Hz is definitely not enough - if you want to avoid flickering, >100Hz is recommended. This is not impossible, if one's using an MCU with a hardware SPI port. An average 32-bit MCU with SPI + DMA support, like a Cortex M3 or a PIC32, can solve such a problem very easily. 256 intensity levels are probably more than needed. \$\endgroup\$ – Laszlo Valko Jun 16 '15 at 23:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.