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.

Larson Scanner project introduction

Okay, it’s time to make a realistic Larson Scanner. You may know it as a Cylon Eye from Battlestar Gallactica or the lights on the front of KITT, the car in Knight Rider. It’s a popular project because it looks cool, but I’ve seen (and built) a ton of lousy imitations. What makes the original so interesting is that the bright tracking light leaves a fading tale behind it. That’s a bit more work to implement, but I’m up for the challenge. Update: check out the complete project.

After the break I embedded a video of the Larson Scanner from Knight Rider. You can pause it to get an idea of what’s going on here. The brightest light is always on the leading edge, the rest fade with time.

So my implementation will happen in a couple of stages:

  • Write some code to drive a PWM signal on the pins of an AVR microcontroller
  • Write some code to automatically fade an LED once the focus has left it
  • Write some code to change where the focus is on a row of LEDs
This is just an introduction so check back soon! Continue reading

Light bulb microcontroller salvaged with HVSP

The ATtiny13 microcontroller from that LED light bulb is now waiting for new firmware. I used High Voltage Serial Programming to erase the chip, which clears the lock bits. I then reset the high fuse back to 0xFF. It was 0xFA before which disables the reset pin (and enables brownout detection) making In System Programming impossible.

I finished mapping out the PCB and it does use the example circuit from the buck converter's datasheet. Looks like it was outputting 12V and using a 7V zener diode to step down to the 5V source the tiny13 needed. I'm going to depopulate the PSU and patch in a 12V feed for further testing. I'm thinking my first project will be a red/green flasher for a Christmas porch light.

LED lightbulb schematic

I had a bit of time to test out the PCB from that LED light bulb. I've just been using continuity tester and ohm-meter for this. Here's the LED logic. High-side transistors but I haven't quite figured out how the resistors are wired. I've also established the A/C side of the switching regulator but I'm having trouble figuring out the output. Similar to the example in the datasheet but not quite the same.