AVR Analog Comparator

I haven’t put much time into the light-based programmer I was working on. But I did get some advice from Devlin Thyne who pushed me in a different direction on it. He suggested I use Manchester Encoding which only needs one input. It’s a method of rolling the clock signal and data into one. But before I do that, I’m going to switch over to using the AVR Analog Comparator hardware. It’s an easy way to get a 1 or 0 out of an analog input. See my simple example after the break.

Continue reading

Parallel port trigger tells me when I’m transcoding

I decided to finish up my Cylon Eye (Larson Scanner) project by adding it as a status indicator for my computer. I record over the air programming and transcode it to DVD quality. Since things can be a bit slower when FFmpeg is running, I set it up for the Eye to scan to let me know it’s processing a video file in the background. All the details after the break but here’s the gist of the system:

  • Python script started by the FFmpeg transcoding script
  • It controls the Parallel port, driving pin 1 high to turn on the cylon eye
  • the ‘pidof’ command is called every minute for FFmpeg. When it is not found, the cylon eye is turned off and the script exits

Continue reading

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.

Developing a Larson Scanner

I’ve been hard at working coding my own Larson Scanner. This is the iconic sweeping light seen in the Cylons on Battlestar Gallactica or on the front of KITT, the car from Knight Rider.

As I discussed in my previous post, the thing that makes these look neat is the fading tail that chases the brightest light. Originally that was accomplished with capacitors which caused the light to fade as they discharged. I implemented the same concept, using a microcontroller and pulse-width modulation to manage the fading.

After the break I’ll go through the development process and share the code. I did this using an AVR microcontroller but you can use any chip you want. The gist of my process is this:

  1. Develop software (interrupt) based pulse-width modulation
  2. Write a function to monitor PWM values and automatically subtract from those over time to cause automatic fading.
  3. Use a buffer to track which LED is ‘active’ and do not fade that one. As soon as that buffer is shifted the old ‘active’ diode will start to fade.
Simple, right? Here’s a video overview to convince you:

And of course you’ll want to look at the most recent code.

Continue reading