BCM and Exponential Duty Cycle improve LED intensity levels

BCM and Exponential Duty Cycle

PWM and Linear Duty Cycle

Having seen great success with my Larson Scanner I wanted to look around and see if there was room for improvement. I want to make it expandable and I knew I needed to work on the timing to get enough clock cycles out of the interrupts to make using shift registers feasible. Joby Taffey left a comment about his project which uses Binary Coded Modulation instead of PWM as a way to dim the LEDs. This turns out to be a fantastic method as it provides superb fading, just like PWM, but it takes far fewer clock cycles to achieve.

Previously I had read this fantastic tutorial on BCM but never tried it myself. It only took me about 60 minutes to whip up my own version (I had a nasty bug that took me 45 minutes to hunt down) since the hardware was already set up for me.

I’m going to be writing more about the change over to Binary Coded Modulation soon, and about using it with shift registers. But I wanted to check in about one big improvement: getting away from linear duty-cycle. You can see in the image on the right, the PWM levels on my original project are not very evenly distributed. The four or six LEDs on the right appear to be at the same brightness level.

Now look at the image on the left. Yes, it’s using BCM instead of PWM, but that’s not the reason for the improvement in the consistency of the intensity levels. It seems our eyes are not great at distinguishing between small intensity changes of a bright light source. By using a more exponential duty-cycle range (smaller steps when the LED is dim, larger steps when it is bright) we can make the intensity appear more uniformed over the 8 levels shown. Really all I did was start at 0x01 and double the value for each LED until I got to 0x80 for the brightest one in this picture. This is a good lesson to learn and I’ll be using the concept often in the future.

For those interested, here’s my code for the BCM example above. But like I said, I’m working on expanding the Larson Scanner using the concept so look for that post in the near future.

essential