SPIN ZONE
ADVENTURES IN PROPELLER PROGRAMMING
■ BY JON WILLIAMS
BIG FUN WITH SMALL LEDs
There are times when my friends comment that I lead a "charmed" life, and
there are many days that I agree. This summer, for example, was a hoot. I had
the honor of being invited to participate in DEFCON 19 — a blast in itself —
but even better was getting to spend time with old friends (and uber-hackers), Ryan Clarke and Joe Grand. My job at DEFCON was to play "the
Spy" — the human element of a cryptography game set up by Ryan. When
not providing clues or misleading players, I spent time in the Hardware
Hacking village and taught three standing-room-only classes on Propeller
programming. Parallax very generously provided QuickStart boards for
participants, and as the boards have built-in LEDs, we used them in the training.
Of course, it happened. When I explained that we would learn how to control LEDs, a few participants
— not thinking I noticed — rolled their eyes. Let me tell
you, LEDs are cool; if you do things well, that is. In this
article, I'm going to show how to create a simple, multi-output LED modulator, and how I put it to use to make
cool displays. With the holidays upon us, this is a good
time to grab a Propeller and add cool lighting effects to
your own projects.
SIMPLE LED MODULATION
14 November 2011
Some time back, I explained a driver that used a
methodology called BAM (bit angle modulation) for
driving LEDs. I've used it. Note the past tense. For simple
LED modulation, I have trashed BAM. Why? Well, at the
mid-point of the duty cycle, that is, the transition from 127
to 128, and vice versa, there can be a dip or spike in
apparent brightness. While working on a display for a
gaming company, I just found I'd had enough of this
abhorrent behavior. If I noticed, the client would, and that
was not acceptable. The problem can be overcome when
using just one output and tricks in code, but I never do
that. I'm routinely doing four to eight — and sometimes
more — dimming channels in my projects.
So ... back to the beginning. Even the plain Jane
BASIC Stamp I has a PWM command that works well for
LED modulation and for charging RC circuits; in fact, that's
what this type of PWM is best at. Let me clarify.
Most of the time when we describe PWM, we think
of a duty cycle (ratio of "on" time to period) and
frequency (based on the period). The duty cycle changes
per the requirements of the output while the frequency
remains fixed. This PWM is really good for motor
control where we can set the frequency best suited to
the motor construction, and vary the duty cycle to change
speed (see my column in the May ‘ 11 issue for more on
this).