Dimming a 74HC595 with the Output Enable pin?
eagletalontim
Posts: 1,399
As the title states, I would like to dim the LED display with the output enable (OE) pin on the 74HC595. I have plenty of free cogs and was hoping to have a cog toggle the OE pin to dim the display based on a 0 to 100 variable.
Comments
Of course, the output enable controls all the outputs.
You could also use a cog to shift data very rapidly and get dimming that way.
Duane J
That's easily done with a fixed frequency pwm cog written in Spin. You can in fact control up to two fixed frequency PWM outputs (using both counters), so long as they can run them at the same frequency (I do this for motor control).
I knocked up this bit of code an tested it on a QuickStart. It works.
Keep in mind that the 74HC595 uses an active-low OE pin, so you'll need to invert you level, that is, for 25% brightness you'll set the PWM level to 75%.
A guy who used to work for Disneyland told me that he would often do a pseudo-log curve with this formula:
level * level / range
VERY common. Find a resistor value that is so restrictive on the LED that its right on the edge of max brightness.
Also using pulses that don't maintain 40% the entire time, find a good swap.
For instance, pulse one for 25% and then do the next pulse 75% and yet the next 25% etc... Don't use linear values in your pwm output. (all one % for the given brightness) alternate between % every other beat or so.
I'll need to try the Disneyland fade next time.
-Phil