10-Band Graphic Equalizer
10-Band Graphic Equalizer
10-Band Graphic Equalizer
Senior Project
2011
i
TABLE OF CONTENTS
Section Page
Acknowledgements ..................................................................................................iv
I. Introduction........................................................................................................1
II. Background.......................................................................................................3
Microcontroller ............................................................................................... 10
Display ............................................................................................................13
Power Supply...................................................................................................15
V. Construction....................................................................................................21
Simulation........................................................................................................21
Assembly..........................................................................................................23
VI. Testing...........................................................................................................24
Appendices
A. Schematics......................................................................................................31
B. Simulations .....................................................................................................37
E. Component Locations...................................................................................... 44
Figures
Figure 1: Equalizer Circuit....................................................................................... 31
Acknowledgements
I would like to thank my senior project advisor, Dr. Tina Smilkstein, for guiding me
through the project and listening to my ideas. I would also like to thank my faculty
I. Introduction
This project consists of a 10-band, two channel graphic equalizer with a light
emitting diode (LED) display. Left and right channels are operated on separately by
ten sliders for each side. Moving the sliders up or down strengthens or weakens the
inverting band-pass filter that adds gain or attenuation over a certain range of
frequencies, but has no effect outside the band. Each block of the equalizer circuitry
acts on one of the ten frequency bands; an inverting summer with unity gain
recombines the individual signals. The output of the inverting summer serves as both
the speaker and display circuitry input so that the LED display will reflect any signal
alterations. A repeated combination of a band-pass filter and peak detector for each
frequency band comprises the display circuitry. The band-pass filter used here has a
higher quality factor than those used in the equalizer, and removes any content
outside the desired frequency band. Once it passes through the filter, the signal
continues to the peak detector, where a capacitor follows the signal voltage until a
maximum occurs. The capacitor holds the maximum until either a new maximum
Atmega328P microcontroller samples the peak detector values of all ten bands and
translates the recorded value to a number of LEDs to turn on. The microcontroller
runs a real-time operating system (RTOS), using a separate task to sample each
frequency band and write related data. After determining which LEDs to light up, the
These drivers handle all display details, including pulse-width modulation (PWM). A
550 watt ATX computer power supply provides all power to the system.
Moving the equalizer sliders modifies whatever audio signal enters the circuit.
With the ranges and frequency bands available, the system can negate audio
and room acoustics. The system can also alter the signal to make it sound as if it were
old-time radio.
Several design issues degraded the quality of the physical product. Poor trace
routing during PCB layout resulted in constant interference or noise in the output
signal. The display experienced an intermittent glitch that toggled it on and off, due to
a poor quality push button. Misleading designations led to the purchase of logarithmic
taper rotary potentiometers of limited use. Despite these problems, the final product
II. Background
Graphic equalizers (EQs) have been used since the 1920’s to adjust audio
recording sound levels. The term “graphic equalizer” comes from the graph of signal
gain versus frequency. An equalized signal has a flat line with no gain. In the context
of audio, “equalizer” does not actually mean flattening the signal as in other
that result in a non-equalized signal. This type of signal modification may have
practical or aesthetic purposes [1]. Each slider on an equalizer board either boosts
recording process and the acoustics of the room. Large banks of equalizers restore the
balance of the frequencies of the sound-reproduction to that of the original source [2].
equalizers can also dramatically change how someone hears audio or music.
Depending on the EQ settings, audio can distort to different acoustic settings. For
example, boosting the midranges and cutting the low frequencies can alter music to
sound like old-time radio. Typically, audio receivers in home sound systems have
dials to adjust bass and treble (low and high frequencies) to a user’s preference [1].
Typically, EQs control frequencies over a range of 20Hz to 20kHz, which is the range
III. Requirements
The project consists of a two channel (stereo) 10-band graphic equalizer with
output display and bass and treble control. An audio signal from a computer or other
multimedia device serves as the system input. Resistor potentiometer sliders either
boost or cut the intensity in each corresponding band. Resistor potentiometer knobs
do the same for signal bass (low frequencies) and treble (high frequencies). The
equalizer circuitry sends the modified audio waveform to a set of speakers. An LED
frequency band examined. Using the equalizer circuit output as the display input
ensures the display reflects any boost or cut alterations to the original signal. A
from the peak detectors and translates the value to the correct display output. A push
button allows a user to toggle the LED display on or off and a second button resets
the microcontroller. Designing and manufacturing a printed circuit board utilizing the
circuit design as a template presents a cleaner and more professional looking product.
5
IV. Design
Equalizer Circuitry
input to the equalizer. A series of 20 adjustable band-pass filters (ten per channel) and
bass and treble filters (one each for both channels) perform all audio modifications
separate from one another. Each frequency band filter (Figure 1) produces a modified,
inverted version of the input signal. The filter outputs are recombined using an
inverting summer with unity gain (Figure 2), which results in a non-inverted output
waveform that sounds different from the original. As shown in Figure 7, these narrow
band-pass filters boost or cut the amplitude in a specific frequency band while leaving
all other content untouched. The capacitor placed across the terminals of the slide
potentiometer acts as an open circuit, while the capacitor between the potentiometer
wiper and the op-amp negative input acts as a short circuit [4]. This configurations
allows a user to either boost audio content by moving a slider up (wiper moves to the
left in Figure 1) or cut content by moving the slider down (wiper moves to the right in
Figure 1). At frequencies lower than the center frequency, the capacitor between the
slide potentiometer wiper and the op-amp inverting input acts like an open circuit. At
frequencies higher than the center frequency, the capacitor between the potentiometer
terminals acts as a short. As seen in Figure 8, the result is a bump or dip in the
frequency versus gain graph, centered over a specified frequency band [4]. Each
frequency band can attain a maximum gain of about ±12.5dB. Both the maximum op-
6
amp supply voltages and the resistance of the slide potentiometers limit the maximum
attainable gain.
Bass and treble control (Figure 3) behaves much like the equalizer circuitry.
The two capacitors behave as open circuits at low frequencies and shorts at high
frequencies [4]. Any audio higher than the bass cutoff frequency and lower than the
treble cutoff frequency has a gain of 0dB and remains unaltered. The op-amp behaves
as an inverting amplifier, which makes it easy to integrate with the equalizer circuitry.
Simply add the signal together with the equalizer band-pass outputs via the inverting
summer circuit. For low frequency content, the virtual open circuits result in purely
resistive amplifier feedback [4]. Moving the wiper of the bass resistor potentiometer
to the left in Figure 3 decreases the resistance and results in gain. Moving the bass
wiper to the right in Figure 3 increases amplifier resistance and attenuates the signal.
At higher frequencies, the virtual short circuits provided by the capacitors results in
shorting the bass potentiometer and connecting the treble potentiometer to the op-amp
inverting input [4]. Moving the treble potentiometer wiper to the left in Figure 3
reduces the amplifier resistance and boosts the signal, while moving it to the right
increases resistance and cuts the signal. In this design, the bass and treble cutoff
frequencies are roughly 14Hz and 23kHz, respectively. Imperfect filter response
causes the circuit to actually modify frequencies outside this range, but to a
TL074 J-FET op-amps were selected for this project as they have high slew
rate (rate of change), low noise and distortion, quad package availability and
7
relatively low cost. The high slew rate (13V/µs) means the chips operate at high
speeds and keep up with any audio signal passed through them. Low noise and
distortion (15nV/√Hz) means the chips will not introduce an appreciable amount of
unwanted change into the audio signal. A quad package works well because each
frequency band utilizes a total of four op-amps: one for the equalizer circuitry, one
for the display band-pass filter and two for the peak detector.
Display Circuitry
Once the audio input signal passes through the equalizer circuitry, it continues
to both the speakers and the equalizer display circuitry. This ensures the display
reflects any alterations made by moving the slide potentiometers from their
midpoints. In the display circuitry, a set of ten band-pass filters (Figure 4) split the
signal into their respective frequency bands, invert it and add a gain of 20dB. The
design of these filters comes from Texas Instruments Application Report SLOA093
[10]. Inverting the audio signal does not present a problem as this signal will not
transmit to a speaker. Additionally, the audio signal positive and negative peaks are
roughly equal in magnitude. Following the magnitude of the negative peaks produces
peak detector voltage levels that are nearly identical to those if the positive peaks
were followed. The filters in this section differ from those in the equalizer in that they
allow the desired frequency to pass while removing all other spectral content.
Comparing the graphs in Figure 7 and Figure 9 shows the differences between the
equalizer and display filters. Each frequency band overlaps a small amount (about
8
3dB) with the adjacent bands. This seems undesirable at first glance, but actually
provides better display results. Without overlap, only a very narrow frequency range
will pass through to the peak detector and light up the LED display. Not all music
will contain the specific required frequency for a long enough period to produce a
visually interesting output at a certain band. Allowing the bands to overlap adds more
content to the display and adds a feeling of transition between the bands.
A simple peak detector (Figure 5) follows the band-pass filter voltage output
to the highest value and holds it until either the microcontroller samples it and toggles
the reset pin, or a larger value occurs. A 1µF capacitor acts as the voltage storage
element, holding the maximum voltage level seen between resets. Several capacitor
sizes were tested during the prototyping phase, including 10µF, 1µF and 100nF.
Circuit performance appeared unaffected by the capacitance used. Both voltage level
and charge hold time were comparable between capacitor sizes. Ultimately, 1µF
capacitors were chosen because the 10µF capacitors were more expensive and the
Under normal operation, the microcontroller grounds the transistor gate, which breaks
the capacitor discharge path. When the microcontroller sends a reset signal, the
transistor turns on and provides a path for the capacitor to discharge. MOSFETs with
low gate charge and low on-resistance were chosen to keep up with the relatively
likely not affect circuit performance terribly much. The same holds true for the diode
chosen; the 1N914 simply appeared in the original peak detector schematic.
Each peak detector contains a buffer stage that both isolates the 1µF charge
capacitor and adds a gain of 2.64. A gain of 2.64 rests slightly higher than the
midpoint of the ADC window used. It also produced the most visually appealing
output when a .WAV file functioned as a voltage source in simulation. The peak
detector used in this project tends to attenuate higher frequency content by a small
amount. To combat this, each frequency band includes a different value resistor
connected from the detector output to the buffer op-amp’s inverting input.
Prototyping the peak detector on a breadboard and passing through the circuit a sine
wave with amplitude of one and a frequency equal to the frequency band (i.e. 32Hz,
64Hz, etc) determined the proper resistor values. Increasing the resistor magnitude
until the output equaled 2.64 times the input provided resistor sizes.
Inserting a 5V Zener diode between the peak detector output and ground
protects the microcontroller and the on-chip ADC. A 51Ω, ½ watt resistor between
the buffer op-amp output and the peak detector output provides enough current to turn
on the Zener diode when applying a minimum of 5V across the diode. The 51Ω
resistor remains the only ½ watt resistor in the project; at a maximum peak detector
output of 12V, seven of them dissipate across the resistor to lock the Zener diode at
5V. Using Ohm’s Law, the maximum power through the 51Ω resistor equates to 0.96
watts. This discrepancy in power ratings was a design oversight. However, no resistor
sustains current for more than a few dozen milliseconds before the peak detector
10
resets, so the components are unlikely to exceed maximum ratings. When the peak
detector output falls below 5V, the Zener diode turns off and acts like an open circuit.
The output can range anywhere from zero to five volts. Once the output reaches at
least 5V, the Zener diode turns on and locks the output to five volts. This feature
prevents any voltage higher than the ADC window from traveling to the
microcontroller.
simulated using LT Spice. Most either failed to hold maximum signal voltages on the
charge capacitor or attenuated the high frequency signal content. The circuit chosen
harbors neither of these drawbacks; it leaks current at a small pace and therefore
holds a charge for a long time and attenuates the high signal frequency content by
already included in the TL074 package, form the circuit. The advantages of this
simple circuit make it more desirable than a complex one with several dozen
Microcontroller
possesses a fairly large amount of Flash memory (32 Kbytes) and SRAM (2 Kbytes),
comes in a convenient 28-pin dual-inline package and can easily use FreeRTOS. Of
the 28 pins available, all but AREF and PC5 connect to devices, making the 328P a
more efficient choice than the comparable 40-pin Atmega32. The internal RC
11
16MHz external oscillator would generate a faster and more accurate clock source.
However, the pins required to connect the extra circuitry control some of the peak
detector reset pins. Since the project does not require precise timing and the pins are
unavailable, the internal oscillator was deemed sufficient for this project.
A simple push button connected to pin PC6 resets the microcontroller when
pressed. Under normal operation, PC6 connects to VCC through a 10kΩ pull-up
resistor. When pressed, the reset button shorts the pin directly to ground. This resets
the microcontroller and forces it to reload the program stored in Flash memory. As an
added bonus, pressing the reset button gives the appearance of holding the current
peak detector voltage levels. The ADC uses its 5V supply as the reference voltage,
and does not apply extra gain to the sampled waveform. Using an ADC reference
voltage of five volts provides better resolution than one volt when following a band-
pass filter with a gain of 20dB. Since the microcontroller only has five ADC channels
and there are ten frequency bands, an analog multiplexor switches between the inputs
to sample all bands. The multiplexor chosen for this project is an Analog Devices
ADG406BNZ bi-directional 16:1 multiplexor that uses four select lines and one
enable line. This particular chip provides enough input lines for all ten frequency
bands and can operate at a wide range of single and dual supply voltages.
Additionally, part samples were provided free of charge by Analog Devices. A low
12
pass filter (comprised of a 10µH inductor and a 100nF capacitor) quiets any noise or
transients from the ADC supply voltage. This provides a steady input and reference
voltage for the ADC to use, which in turn results in more accurate voltage
conversions.
Once the ADC translates the sampled voltage into a digital representation, the
information to the display drivers. The range follows a linear distribution over the
five volt reference level. There are nine possible display states, so the voltage
between each state is approximately 0.56 volts. The digital representation of this
voltage is a hex number between 0x000 and 0x3FF, where 0x000 corresponds to 0V
and 0x3FF corresponds to 5V. The ranges used in the microcontroller code are
predetermined hex numbers and not the voltages themselves. This method of
calculating the number of LEDs to light up on the display saves time and power
because the microcontroller does not need to convert the sampled value to a voltage
first.
All large DIP packages sit in IC frames, which allows for easy removal should
they cease to function or be needed elsewhere. The flexibility afforded by the frames
justifies the extra few cents. Small DIP packages such as the TL074 are soldered
and reset microcontroller pins, as well as VCC and ground. When an external device
13
wishes to program the microcontroller, it pulls the reset pin low to disable the
microcontroller and ready it for modification. The programmer can then transfer new
program data over the serial communication port. The external device releases the
rest pin when finished, allowing the microcontroller to resume operation. Atmel
design document AVR042 [7] shows the correct pin connections for an ISP header.
Display
An 8x10 (eight rows, ten columns) common cathode LED matrix serves as the
equalizer display. Two Maxim MAX7221CNG+ LED display drivers control which
LEDs turn on based on the data received from the microcontroller. Each chip can
drive a maximum of eight LED columns; the equalizer has ten. Cascading two drivers
solves this issue; one chip controls the left half of the display while the other chip
drives the right half. The drivers utilize pulse width modulation (PWM) to strobe the
LED matrix columns at a pace faster than the eye can see. PWM limits the current
drawn from the power supply and allows for easy adjustment of brightness levels.
Assigning exactly half of the columns to each driver ensures that they strobe the
columns at the same rate, which keeps the LEDs at the same brightness level. Should
one driver control more columns than the other, the LEDs attached to it will appear
dimmer because it must sweep more area in the same amount of time. For this
project, the display drivers light up the LEDs at maximum intensity by setting the
inter-digit blanking time to 31/32 of a cycle. The MAX7221 chips fully support SPI
The water clear LEDs were chosen over diffuse cover LEDs for several
reasons. With a luminous intensity of 380mcd, the water clear package emits
significantly brighter color than the 2mcd diffuse cover LEDs. Additionally, the water
clear LEDs require a smaller voltage drop and less current to operate, which means
they use less power. Also, they look more professional than similar packages with
tinted coverings. Both types of LEDs have the same viewing angle. While they cost
significantly more (6.5 cents versus 11 cents per LED), the benefits of water clear
To set the current through each LED column, VCC connects to the ISET pin
of the display driver through a single resistor. A combination of the LED forward
voltage drop and required operating current determines the necessary size of this
resistor. Plotting the common values provided in the MAX7221 datasheet allows for
extrapolation of the resistance value. The LEDs used in this project require a forward
capacitor decouple the positive voltage rail and ground. These decoupling capacitors
sit directly next to the driver chips and reduce the effects of power supply ripple due
To further reduce these effects, separate 5V rails power the MAX7221 chips and the
microcontroller.
A push button, connected to PD2 (external interrupt zero), disables the LED
display. Pressing the button a second time re-enables the display. Much like the reset
15
button, the pin normally connects to VCC through a 10kΩ pull-up resistor. When
pressed, the display on/off button shorts the microcontroller pin to ground. This
generates an interrupt in the program code that sends a display on or off command to
the display drivers. The MAX7221 chips still receive data while the LEDs are off, so
the display will resume with current sound levels when re-enabled.
Power Supply
A 550 watt computer power supply (PSU) provides 5V, 12V and -12V rails at
a current rating far above project requirements. An early project draft included a
custom power supply, but this was ultimately too expensive to implement. A simply
ATX computer supply costs only $22 and guarantees clean, constant voltage rails. In
order to turn the supply on, the green wire (pin 16) must shorted to ground. Some
PSUs require a 10Ω, 10 watt resister between the green wire and ground to supply
any current, but the PSU used in this project does not. A 24-pin female Molex
connector connects the PSU wires to the custom PCB. This allows for quick and
Unfortunately, the PSU includes a 60mm fan with distracting built in LEDs. Analog
circuitry (±12V lines) has a dedicated ground wire, as does the microcontroller and
display drivers (5V lines). Separating ground connections of analog and digital
circuitry prevents high frequency noise from contaminating the output audio
waveform.
16
Based on LT Spice simulations, the maximum current drawn by the ±12 volt
rails equals about 800mA each. The power supply used in the project was chosen
specifically because it can supply 1A at -12V. All other supplies examined were rated
for 0.8A at -12V, which leaves little room for error. Should the system attempt to
draw more than the maximum allowed current, system glitches may appear. The extra
current rating leaves room to avoid any issues. Current ratings for 12V and 5V lines
Microcontroller Code
The microcontroller runs a real-time operating system (RTOS), which allows for
reusable, modular code and easy task and interrupt handling. This project uses a
version of FreeRTOS that has been ported from the Atmega323 version to work on
the Atmega328P. To achieve this, only a few lines of code need to change; these
alterations were found on the AVR Freaks forum [5] and are listed below:
File: port.c
portCLEAR_COUNTER_ON_MATCH changed from "0x08" to "(1<<WGM12)"
portPRESCALE_64 changed from "0x03" to "((1<<CS11)|(1<<CS10))"
portCOMPARE_MATCH_A_INTERRUPT_ENABLE changed from "0x10" to "(1<<OCIE1A)"
references to "TIMSK" changed to "TIMSK1"
references to "SIG_OUTPUT_COMPARE1A" changed to "TIMER1_COMPA_vect"
transmission. Cooperative mode also ensures that each task runs to completion before
reentering the blocked state. When compiled, the application and FreeRTOS footprint
size fills up 8042 bytes. This constitutes 24.5 percent of available Flash memory.
Additionally, the estimated SRAM data contains 1843 bytes, which constitutes 90.0
17
percent of available space. Typically, 80 percent pushes the maximum allowed data
size, as this estimate does not include any variables declared locally. However, each
task uses only a single-byte variable, so the application for this project should not
tasks, each with their own task definition. The code written for this project uses ten
tasks—one for each frequency band—but only a single task definition. When created,
each task receives a set of parameters that determines how it functions and what
frequency band it belongs to. These parameters are passed to the task using a
structure that contains the band number, the port letter and pin number that controls
the peak detector reset, and the pin configuration to select an analog multiplexor
channel. When the task runs, it disables interrupts using the taskENTER_CRITICAL
API to avoid an external interrupt during SPI data transmission. Interrupts are re-
enabled at the end of the task with the taskEXIT_CRITICAL API call. Once
interrupts are disabled, pins C1, C2, C3 and C4 are configured to select the
milliseconds allows the multiplexor output to settle. The ADC then takes a sample of
the channel by setting the ADSC bit of the ADC control register, delaying by the
maximum conversion time of 260µs (as stated in the Atmega329P datasheet), then
transfers the result to the corresponding slot in the voltage value array. Hardware
clears the ADSC bit once the conversion completes, so there is no need to clear it
according to the sampled voltage level. A variable called write_level contains the hex
code that determines which LEDs in a column turn on. This minimizes code
redundancy by having only one SPI write function call instead of one in every IF
statement. Once the microcontroller determines the number of LEDs in the column, it
writes the correct data to the corresponding MAX7221 chip. Next, the
microcontroller resets the band’s peak detector by toggling a specific pin, which a
SWITCH/CASE statement determines. Finally, a delay API places the task back in
the blocked state for 2ms. This allows other tasks to run before the current task
returns to the ready state. Increasing or decreasing the task block time changes how
responsive the display appears. A smaller delay time may toggle the LEDs too
quickly to see while a larger delay may cause the display to look slow and sluggish.
A second task and task definition exists for toggling the display on or off with
a button press. This task only runs once the external interrupt vector INT0_vect gives
the binary semaphore. Once the task takes the semaphore and runs once, it releases it
and cannot run again until the interrupt gives the semaphore once more. As the
display toggle button is non-ideal, pressing it oscillates the voltage applied to the
microcontroller pin between VCC to ground before settling. To combat this, the task
immediately enters the blocked state for 50ms as a button de-bounce. This prevents
the task from running and resetting rapidly when pressing the button. Once the task
variable ext_int_data to determine if the current display state. Once the task
19
determines the display status, it transmits the data required to toggle it to the opposite
state. The task_EXITCRITICAL API re-enables interrupts at the end of the task.
All tasks definitions written for this project are reentrant. The requirements for
reentrancy are:
can interrupt the task and it therefore uses the static voltage array atomically. This
also satisfies the hardware condition as the multiplexor and peak detector transistor
switch are both controlled within the atomic block. Additionally, all other variables
used either pass in from the parameter structure or exist locally. Therefore, the tasks
only use data in an automatic way. Lastly, the code does not call any non-reentrant
functions. The initialization functions are called before interrupts are enabled and can
therefore be considered reentrant. Since all conditions are satisfied, the tasks are
reentrant.
Writing data to the MAX7221 LED display drivers requires the use of the
chip no-operation (no-op) codes. As the output of one chip connect to the input of the
other, the no-op command serves to push data through one chip and into the next.
Writing to the first diver in the chain requires sending two no-op codes (0x00)
followed by the digit (column) number and segment code (number of LEDs). Writing
to the second display chip follows a similar convention, except the column and
segment data precedes the two no-op commands. Once the four commands have
20
V. Construction
Simulation
All circuit design and simulation work was completed using LT Spice IV.
Components placed in the circuits used real world models of the devices actually used
in the project. This gives a clearer picture of what to expect from circuit output when
physically constructed. Both frequency and time domain circuit responses were
examined. For the frequency domain, a signal with the parameter “.AC 1” as the input
allows the program to generate a graph of frequency versus gain. This graph can help
analyze filter design and demonstrate circuit response. For the time domain analysis,
a .WAV file functions as the voltage input to the circuit. As audio signals are rarely
pure waveforms, a realistic input to the system generates simulation results that are
more useful when designing audio systems. See Figure 10 for an example simulation
plot.
Printed circuit board design and layout was completed using CadSoft EAGLE.
As the Spice design incorporated single op-amps and not the quad package TL074s,
the circuit import function was not used. Instead, a schematic for a single band was
generated and copied several times, with the appropriate values changed for each
iteration. This new schematic was then used to create a printed circuit board layout,
which appears in Figures 11 through 14. Again, the circuitry for a single band was
laid out and copied for the remaining bands. The rest of the components were placed
22
according to nearest logical neighbor available space. The power connector and
3.5mm jacks needed to stay near the edge of the board, preferably on the left. The
display drivers were placed above the microcontroller and analog multiplexor so they
rest closer to the display connector pins. Since the peak detectors all feed into the
All power rails were routed by hand. This was done to avoid daisy-chaining
the power and ground connections between components, which can cause line noise
and interference. Each part connects to a power or ground rail that runs across the
board. All other traces were routed with a second program called FreeRouting. This
application works by importing a board layout from Eagle and simply routing all un-
routed traces. After finding a possible way to route all traces, the program attempts to
optimize the layout through an iterative process. This process will run until there are
no remaining changes that reduce total trace distance. However, the amount of time to
reach this point boarders on absurdly long. After a few hours, any optimizations made
will result in such minor improvements that stopping the application constitutes a
more efficient use of time. Once the process has halted, the layout can export back
Purchasing two boards with different patterns always costs more money than
two boards with a single pattern. Therefore, two identical printed circuit boards, one
microcontroller with less memory can sample peak detector values on each board.
Some alterations were required to use a single board layout with one power and audio
23
input. Two three-pin connectors jump either the left or right audio signal to the
equalizer input or output. The unconnected pins connect to the input and output of the
second board. This way, each board can operate on the left or right audio signal.
Power forwards to the second board through simple jumper wires. The push buttons
also connect between boards; the microcontroller pins jump together so that button
Assembly
component to the custom boards by hand. Since this method of assembly was decided
before PCB design, mostly through-hole components comprise the system. This
allows for simpler construction with less chance of error. After each component was
soldered to the board, the connections were checked with a multimeter continuity test.
Touching one multimeter lead to the component leg and one to an electrically
connected hole produces a beep noise if the connection is good. Otherwise, the
multimeter will not beep. This ensures that every solder joint has a good connection,
and eliminates tedious checking should something fail to work after all components
are soldered.
24
VI. Testing
Each phase of the project underwent extensive testing before continuing to the
next. Many hours of LT Spice simulations ensured the circuit would operate as
intended. Using .WAV files as circuit voltage input allowed for simulation with a real
audio waveform. The .WAV output feature provided tactile results, as it recorded the
Eagle design rules and error checking features verified the printed circuit
board design. An additional visual examination verified that each trace connected the
proper component pins or leads. Consulting all part datasheets during the visual
inspection ensured the connections matched the schematic. Every part soldered
during project assembly was continuity tested using a multimeter. For this type of
test, the multimeter beeps to signal an electrical connection exists. This verification
After hardware construction, an audio signal was applied to the input while
the sliders were left in the middle position. This tests that the audio makes it through
the circuit. Next, the sliders were moved one by one to verify their functionality.
Display and microcontroller code were first implemented and tested using an STK500
development board. This removes extra variables from the equation and allows for
testing of code functionality only. Once the code worked on an external board, the
During the microcontroller code testing phase, a glitch occurred that toggled
attempt to solve this issue, but it was ultimately determined that the button itself was
generating the error. This was verified by disabling external interrupts in the code, but
leaving the display toggle function intact. The display continued uninterrupted for
the speakers. The constant, high switching rate of the digital circuitry causes this
interference. The quick switching between high and low states generates both ripple
in the ground levels and electromagnetic interference. The PCB design separates the
minimize this type of interference. However, all ground wires connect to the same
place in the power supply (hence the term common ground), so audible high
frequency digital interference still exists in the output waveform. The LED display
driver connections pass near the positive and negative 12 volt rails, as well other
analog device traces. The PWM of the drivers means the display connections are
always switching high to low and vice versa, which causes inductance in nearby lines.
of space between analog and digital traces reduces switching-induced noise. Adding
ground lines that parallel any digital traces could also reduce noise. Decoupling
capacitors between positive and negative rails also reduces noise by smoothing
supply ripple caused by digital circuitry. Two 10µF decoupling capacitors were
placed near the MAX7221 display drivers in an attempt to minimize supply ripple,
but the other glaring design issues make them a moot point. Further aggravating the
noise problem, the analog multiplexor was powered from the 12V and analog ground
rails. As these analog connections pass near several digital lines, the constant select
interference problem, the transistors in the peak detector constantly switch on and off
and connect to the same analog ground as the input and output signals. Separating
ground lines and more intelligent trace routing and component placement will
The six pin ISP header was added to the design after most of the PCB layout
was completed. As a result, the only edge space available for it was on the opposite
side of the board from the microcontroller. As nothing connects to the ISP head most
of the time, this would not normally constitute an issue. However, when a
programmer pushes data to the microcontroller, a high pitch static noise appears at the
audio output. While not a huge problem, this source of potential interference is worth
mentioning.
Incorrect assumptions lead to the use of resistors with ½ watt power ratings
when one watt ratings were required. As the maximum voltage output of the peak
detector roughly equals the 12V supply, the maximum voltage dissipated across the
resistor in series with the Zener diode should be 7V, not 5V as originally thought.
However, should this particular resistor exceed the ½ watt power rating, it will not
Due to an incorrect datasheet listing, the audio input pins were connected
backwards. The intended left channel board operated on the right channel while the
right hand board operated on the left channel signal. This mix up rendered useless the
two pins designated for jumping input and output signals to and from the right side
board. Jumping the right side pins together on the three-pin channel connector of the
28
left board fixed the left channel input and output. Jumping the left side pins from the
same header directly to the input pin of the header on the ride hand board fixed the
right channel.
interrupt that disables the display. Waiting a sufficient amount of time or pressing the
button re-enables the display. Testing the buttons with a multimeter shows that they
appear to work as intended. However, disabling external interrupts (but not interrupts
or the task code) eliminates the glitch. Therefore, the button itself must cause the
issue. This may stem from poor quality manufacturing since the push-buttons were
the cheapest available. Incorporating a higher quality button should fix the problem.
ordered have an audio taper which means they conform to a logarithmic function.
Rotating them does not increase or decrease resistance linearly. Therefore, the middle
of the potentiometer turn radius does not correspond to the “zero” position. Only a
small fraction of the possible rotation produces a noticeable audio change. A similar
issue was encountered with the slide potentiometers; the first sliders ordered had an
audio taper as well. Once the error was recognized, the sliders were replaced with the
correct linear taper components. The rotary potentiometers for bass and treble were
not returned because they were ordered from a different supplier and shipping
handling costs would have far exceeded the price of the parts themselves. Using a
dual-gang linear rotary potentiometer would enhance the project by tying the bass and
29
treble controls of the channels together. Any changes made are applied to both
admirably well. An audio signal enters the circuit and exits modified according to
each slide potentiometer position. Moving the sliders up or down alters the intensity
in the corresponding frequency bands, which changes how the music sounds. The
LED display shows a visually interesting and accurate representation of the content in
each band, and reflects changes made with the sliders. A user can modify both left
The decision to use analog filters and discrete components was made with
little thought to project cost or complexity. Tables I and II demonstrate the fiscal
monstrosity this project formulates. Digital signal processing (DSP) would have
proven a simpler and cheaper approach. A single, large microcontroller would operate
could still provide tactile user input, but the controller would somehow sample the
position and apply settings to the output waveform accordingly. As an added bonus,
digital signal processing would allow for sharper filters with higher quality factors.
Sharper filters blend with adjacent frequency bands less and therefore may produce
better sounding audio. DSP could combine the entire audio recording suite into one
package.
30
VIII. Bibliography
[1] "Equalization." Wikipedia, the Free Encyclopedia, 4 May 2011. Web. 05 June 2011.
<http://en.wikipedia.org/wiki/Equalization>.
[3] "Equalization (audio)." Wikipedia, the Free Encyclopedia, 4 June 2011. Web. 05 June
2011. <http://en.wikipedia.org/wiki/Equalization_(audio)>.
[4] Franco, Sergio. "Graphic Equalizers." Design with Operational Amplifiers and Analog
Integrated Circuits. New York: McGraw-Hill, 2002. 125-26. Print.
[5] "FreeRTOS ATMega328-P Port." AVR Freaks Forum. Web. 26 May 2011.
<http://www.avrfreaks.net/index.php?name=PNphpBB2>.
[6] "Atmega 16 and Maxim Max7219." AVR Freaks Forum. Web. 26 May 2011.
<http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=717744>.
[8] "ATX (ATX12V) 24 Pin Power Supply Connector Pinout and Wiring." Handbook of
Hardware Pinouts, Cables Schemes and Connectors Layouts @ Pinouts.ru. Ed. Dave
Johnson, Ken Mazie, and Nick Dedman. 23 Mar. 2011. Web. 13 Apr. 2011.
<http://pinouts.ru/Power/atx_v2_pinout.shtml>.
[9] Barry, Richard. FreeRTOS Reference Manual: API Functions and Configuration Options.
[S.l.]: Real Time Engineers, 2009. Print.
[10] Carter, Bruce. "Filter Design in Thirty Seconds." Application Report SLOA093. Texas
Instruments, Dec. 2001. PDF. <http://focus.ti.com/lit/an/sloa093/sloa093.pdf>.
[11] "Know Code Size and Data Size." AVR Freaks Forum. Web. 4 June 2011.
<http://www.avrfreaks.net/index.php?name=PNphpBB2>.
[13] "MAX7221 LED DRIVER TUTORIAL." UMASS AMHERST M5. The College of
Engineering at UMass Amherst, 25 Jan. 2011. Web. 26 May 2011.
<http://www.ecs.umass.edu/ece/m5/tutorials/7221_led_driver_tutorial.html>.
[14] "Peak Detector Circuit." Electronics and Communications Engineering. 07 Jan. 2011.
Web. 10 Feb. 2011. <http://ecelab.com/circuit-peak-detector.htm>.
31
A. Schematics
Figure 1: Equalizer Circuit. A block of the equalizer circuit operates on a single frequency band.
Capacitors C1 and C2 determine which frequency band, and C1 will always be ten times greater
than C2. Adjusting the resistor potentiometer changes the intensity in corresponding band. The
design for this circuit comes from the textbook by Franco [4].
32
Figure 2: Inverting Summer. This block of circuitry adds the inverted and modified signals from
all ten bands and bass/treble circuits together. The resulting waveform reflects any changes
made to the input by the sliders and dials.
33
Figure 3: Bass and Treble Circuit. This block of circuitry modifies the low and high frequencies
outside the 10 bands operated on by the sliders. The design for this circuit comes from the
textbook by Franco [4].
34
Figure 4: Display Band-pass Filter. This filter allows a specific frequency to pass, while removing
any other content from the input. The combination of capacitors and resistors determine which
frequency passes. The design for this circuit comes from Texas Instruments [10].
35
Figure 5: Peak Detector Circuit. The capacitor follows the input waveform to the maximum value
and holds it until either a higher maximum occurs or the transistor switches on. The diode prevents
any loss on the capacitor when the input signal falls below the capacitor voltage level. The resistors
allow current to flow and/or provide output gain. The Zener diode prevents the output voltage
from exceeding 5V, which could result in incorrect measurements or damage the microcontroller
ADC. The basic design for this circuit comes from ECE Lab [14].
36
Figure 6: Full EQ Circuit. All circuit blocks combine to create a ten band graphic equalizer and display. The Quad J-FET op-amps, display
drivers, analog multiplexor and microcontroller are not shown.
37
B. Simulations
Figure 7: Equalizer Filter Response. Each frequency band can attain a maximum of about
12.5dB. The filters overlap and modify parts of adjacent bands, so the graph line of the output
will look "bumpy". The EQ also alters signal phase but the delay equals nearly 1/30th of a
second, a change small enough to go unnoticed by human ears.
Figure 8: EQ Filter Response at Single Frequency. As the slider moves up and down, the
intensity in the corresponding frequency band increases or decreases. The different lines
represent a slider at varying track positions.
38
Figure 9: Display Filter Response. Each display block has a band-pass filter that only allows the
specified frequency content to pass. Here, the bottom of the graph stops at 0dB, but each line
continues below. Therefore, the filters remove any content outside the desired frequency band.
Some overlap (~3dB) occurs between bands, but this can actually benefit the EQ. Additionally,
each filter alters the signal phase, inverting the waveform.
Figure 10: LT Spice Simulation. The top waveform comes from an imported .WAV file, and
follows an actual audio signal. The middle waveform results from the .WAV signal passing
through the 32Hz display band-pass filter. Only content in the 32Hz band continues to the peak
detector. The bottom waveform corresponds to the peak detector output. The capacitor charges
to the maximum value seen in the 32Hz band, and the buffering op-amp increases it by a factor
of 2.64. The maximum value of the bottom trace is 1.2V, while the maximum value of the middle
trace is 0.48V.
39
Price/
Device Value Manufacturer Part Number QTY
ea
Headers - 40-pin Tyco
9-146274-0 4 $2.15
Vertical breakaway Electronics
Headers - Right 40-pin Tyco
9-103323-0 7 $1.48
Angle breakaway Electronics
LED Display
MAX7221 Maxim MAX7221CNG+ 4 Samp
Driver
Power
MOLEX_24 Molex 39-28-8240 1 $3.66
Connector
Resistor 10k KOA Speer CMF1/41002FLFTR 128 $0.07
Resistor 1M KOA Speer MF1/4DCT52A1004F 40 $0.06
Resistor 33k KOA Speer MF1/4DCT52R3302F 4 $0.05
Resistor 23.7k KOA Speer MF1/4DCT52R2372F 6 $0.05
Resistor 1k KOA Speer MF1/4DCT52R1001F 2 $0.05
Resistor 15k KOA Speer MF1/4DCT52R1502F 2 $0.05
Resistor 102k KOA Speer MF1/4DCT52R1023F 2 $0.05
Resistor 2.61k KOA Speer MF1/4DCT52R2611F 2 $0.05
Resistor 13.7k KOA Speer MF1/4DCT52R1372F 2 $0.05
Resistor 93.1k KOA Speer MF1/4DCT52R9312F 2 $0.05
Resistor 2.4k KOA Speer MF1/4DCT52R2401F 2 $0.05
Resistor 15.8k KOA Speer MF1/4DCT52R1582F 2 $0.05
Resistor 105k KOA Speer MF1/4DCT52R1053F 2 $0.05
Resistor 2.7k KOA Speer MF1/4DCT52R2701F 2 $0.05
Resistor 28.7k KOA Speer MF1/4DC2872F 2 $0.06
Resistor 196k KOA Speer MF1/4DCT52R1963F 2 $0.05
Resistor 5.1k KOA Speer MF1/4DCT52R5101F 4 $0.05
Resistor 26.7k KOA Speer MF1/4DCT52R2672F 4 $0.05
Resistor 180k KOA Speer MF1/4DCT52R1803F 4 $0.05
Resistor 4.64k KOA Speer MF1/4DCT52R4641F2 4 $0.05
Resistor 158k KOA Speer MF1/4DCT52R1583F 2 $0.05
Resistor 4.02k KOA Speer MF1/4DCT52R4021F2 2 $0.05
Resistor 29.4k KOA Speer MF1/4DCT52R2942F 4 $0.05
Resistor 200k KOA Speer MFS1/4DCT52R2003F 4 $0.05
Resistor 5.11k KOA Speer MF1/4DCT52R5111F2 2 $0.05
Resistor 25.5k KOA Speer MF1/4DCT52R2552F 2 $0.05
Resistor 174k KOA Speer MF1/4DCT52R1743F 2 $0.05
Resistor 4.42k KOA Speer MF1/4DCT52R4421F 2 $0.05
Resistor 16.5k KOA Speer MF1/4DCT52R1652F 6 $0.05
Resistor 16.9k KOA Speer MF1/4DCT52R1692F 4 $0.05
Resistor 17.4k KOA Speer MF1/4DCT52R1742F 4 $0.05
Resistor 18k KOA Speer MF1/4DCT52R1802F 2 $0.05
Resistor 18.7k KOA Speer MF1/4DCT52R1872F 2 $0.05
Resistor 20.5k KOA Speer MF1/4DCT52R2052F 2 $0.05
Resistor 51 Xicon 293-51-RC 20 $0.09
Resistor 165 KOA Speer MF1/4DCT52R1650F 2 $0.05
Resistor 37.4k KOA Speer MF1/4DCT52R3742F 4 $0.05
41
Price/
Device Value Manufacturer Part Number QTY
ea
312-619AF-
100k Slide Pot Alpha (Taiwan) RA6043F-20-10EB1-B15 20 $1.63
100K
100k Rotary Pot 100k Pot TT Electronics P260T-D1BS3CA100K 2 $3.92
Tactile Switch SW_TAC Omron B3F-1002 2 $0.24
IC Frame IC_FRAME 3M 4828-3004-CP 2 $0.31
IC Frame IC_FRAME 3M 4824-3004-CP 4 $0.23
IC Frame IC_FRAME 3M 4828-6004-CP 2 $0.31
Green LED LED_5MM VCC VAOL-5GDE4 101 $0.11
Yellow LED LED_5MM VCC VAOL-5GCE4 40 $0.13
Red Led LED_5MM VCC VAOL-5GAE4 20 $0.12
12" F/F Wires - Sparkfun PRT-09389 1 $4.50
12" 6-pin Wires - Sparkfun PRT-10376 4 $1.95
12" 5-pin Wires - Sparkfun PRT-10375 4 $1.95
Broadway Com
ATX PSU 550W OKIA-BLACK-550 1 $21.99
Corp
Advanced
EQ PCB - GE v2.0.5 w/I 2 $33.00
Circuits
Advanced
Display PCB - LED v1.2 2 $33.00
Circuits
Washers Nylon Miner’s NYW4 24 $0.15
Stand-offs Nylon Miner’s SP-041 24 $0.20
Screws Aluminum Miner’s AWS-2K 24 $0.35
Table 1: Bill of Materials
Tax $16.92
Figure 11: Display PCB Layout. Left is the top copper layer, right is the bottom copper layer.
Two layers make the “criss-cross” style of the traces easy to realize.
43
Figure 2: Equalizer PCB Layout. Left is top copper layer, right is bottom copper layer. Power
traces are larger than others to allow for higher current magnitudes. All non-critical traces
routed with FreeRouting (http://www.freerouting.net/).
44
E. Component Locations
Figure 13: Display PCB Component Locations. Each LED has a ring with a "clipped" edge that
represents the cathode. Color identifiers are covered by the component itself.
45
Figure 14: Equalizer PCB Component Locations. Circuit inputs are located on the left and
power flows left to right. This corresponds to the way English text is read in books, so feels more
natural.
46
F. Program Listing
// Sean W. Michel
// EE Senior Project
// Graphic Equalizer v2.0.5
// Cal Poly, SLO
// Spring 2011
// Header includes
#include <stdint.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
// Function Prototypes
void vInitialize_IO(void);
void vInitialize_ADC0(void);
void vInitialize_SPI(void);
void vTransmitSPI(volatile int data);
void vTransmitLED_Right(int digAddress, int displayValue);
void vTransmitLED_Left(int digAddress, int displayValue);
void vClear_Disp(void);
void vInititialize_Disp(void);
// Semaphore definitions
xSemaphoreHandle xBinarySemaphore;
uint8_t mux_select;
} param_type;
/*-----------------------------------------------------------*/
int main(void)
{
// Create and take binary semaphores to avoid errors
vSemaphoreCreateBinary(xBinarySemaphore);
xSemaphoreTake( xBinarySemaphore, portMAX_DELAY );
// Create a task for each frequency band. If the MCU runs out of memory,
// just use a FOR loop to reduce the number of running tasks.
// Each task has the same priority since they all do the same thing.
// They take in a structure of information that contains four pieces
// of data specific to the band the task belongs to. The first item is
// the band number, used to determine which band is being operated on
// and which column to write data to. The second piece of data is the
// pin number that will reset the peak detector. The third item is an
// identifier for which port the reset pin belongs to. 0 corresponds
// to PORTB and 1 corresponds to PORTD. The last item is the mux select
// lines for the specific band. They all have the same priority because
// they all need to run, but none is more important than any other.
xTaskCreate( (pdTASK_CODE) vTaskGetLevels, (signed char *) "32Hz Band",
configMINIMAL_STACK_SIZE, &val[0], 0, NULL );
return 0;
}
/*-----------------------------------------------------------*/
for (;;)
{
// Disable interrupts to avoid button press accidents
taskENTER_CRITICAL();
// Set the correct pins to get right level from analog mux
PORTC = (xReceivedStructure->mux_select);
_delay_us(260);
// Write to the right side of the display if the band bumber is 6-10
else
{
vTransmitLED_Right((xReceivedStructure->band_number)-5,
write_level);
}
// Reset the peak detector by sending the transistor base high then
// toggle low. The switch/case statement chooses the correct port
// to write to. In this code, only port B and D are used for this
// purpose.
switch ( xReceivedStructure->port_letter )
{
case 0:
PORTB |= (_BV(xReceivedStructure->pin_number));
_delay_ms(10);
PORTB &= ~(_BV(xReceivedStructure->pin_number));
break;
case 1:
PORTD |= (_BV(xReceivedStructure->pin_number));
_delay_ms(10);
PORTD &= ~(_BV(xReceivedStructure->pin_number));
break;
default:
break;
}
// This task shutdowns the LED display once the external interrupt
// is triggered.
void vTaskDisplayShutdown(void)
{
// Binary count to establish if the display is already on
uint8_t ext_int_data = 0;
for (;;)
{
// This task unblocks once it the binary semaphore has been
// given. It won't run unless it gets it from the external
// interrupt vector.
xSemaphoreTake( xBinarySemaphore, portMAX_DELAY );
switch (ext_int_data)
{
case 0:
// Enter shutdown, disable display
vTransmitLED_Right(0x0C, 0x00);
vTransmitLED_Left(0x0C, 0x00);
ext_int_data = 1;
break;
case 1:
// Leave shutdown, enable display
vTransmitLED_Right(0x0C, 0x01);
vTransmitLED_Left(0x0C, 0x01);
ext_int_data = 0;
break;
default:
break;
}
/*-----------------------------------------------------------*/
(_BV(A1)) |
(_BV(A2)) |
(_BV(A3));
void vInitialize_SPI(void)
{
// Make sure SPI is not in low power mode
PRR &= ~(_BV(PRSPI));
vTransmitLED_Left(0x01, 0x00);
vTransmitLED_Left(0x02, 0x00);
vTransmitLED_Left(0x03, 0x00);
vTransmitLED_Left(0x04, 0x00);
vTransmitLED_Left(0x05, 0x00);
}