FIGURE 1. Low band filter.
hardware in the μC. The following
operations are required:
1) Sample value replaced by its
2) Sample is compared to a min
threshold and, if smaller, is replaced
by a value that causes the channel to
remain off during its display period.
3) Sample value is clipped to a
maximum value, if required.
4) Sample value converted into a range
necessary for the PWM hardware.
5) Processed sample is stored in memory for the display process thread.
The Display Thread
the manipulation of the Gain variable
used to control the AGC Gain
element. The value of the Gain
variable can change by at most, one;
each execution of the SM which
allows the gain to change up to 16
times a second as different program
material is applied to the color organ.
• Digital Filters — The four channels of
the color organ represent four bands
of frequency selectivity implemented
using third order lattice wave digital
filters. Each acquired sample is
processed by all four filters. Table 1
gives the specifics.
• PWM Processing — The final step in
the real-time processing of samples is
the conversion of the filter outputs
into a form that can drive the PWM
The display processor is executed
every 256 microseconds by the
watchdog interrupt. One channel
of color organ output is done each
interrupt. The display processor
(see wdt_isr in the listing) performs
the following operations:
1) Disables Timer A’s PWM output line.
2) Determines which channel of output to display from the value of Slot.
3) Sets the output port bits to select
the appropriate output channel from
4) Fetches the processed PWM value
for the selected channel and loads it
into Timer A’s compare register.
5) Resets Timer A’s counter and starts
the PWM output.
6) Increments Slot and returns from
Four new values of processed
PWM data are stored in memory
every 62. 5 microseconds but the
display processor only picks up one of
these values every 256 microseconds
FIGURE 2. Low mid band filter.