top of page

Audio Spectrum Analyzer

I spent the better part of 2020 building VU meters, and using them as the subject that drives me to learn PCB design.  This project represents my "graduation" from the subject, with a more complex design and more serious programming/timing involved.

specturm_analyzer_render.png
Layout

The board is laid out as follows:

Bottom left - Electret biasing and amplification (problematic - read section)

Bottom middle - TM1640 LED Driver and Atmega328PB MCU

Bottom right - ICSP and Serial breakout (J2 and J3), decoupling capacitors, and Micro USB connector for power

Top - LED bar graph modules

Design

Starting with the microphone:  Electret microphones have a FET built in, so biasing them (with the correct polarity!) with a simple resistor to Vcc creates a common drain amplifier as shown:

Electret_condenser_microphone_schematic.

The bulk of the amplifier was inspired by a very cute circuit from The Art Of Electronics, the main difference being that they used a JFET as the "front end" and I used a BJT:

spectrum_analyzer_audio_amp.png

This is a nice low-distortion closed-loop amplifier, with very easy gain-setting via R26.  Here is how it works:

The Voltage divider R18/R21 Sets the base of Q6 at about 5V * (68/124) = 2.74V

Since we have pretty low current in Q6, we should only have ~0.6V Vbe drop, so ~2.15V at Ve6.

Now here is where it gets tricky - That 2.15V across the emitter resistor R23 is not what sets the quiescent current through Q6 - Ic6 is actually determined by the collector resistor R17! Vbe4 is applied directly across R17, thus forcing Ic6 = Vbe4/R17 ~= 0.7V/10k ~= 70uA. 

Ic4 is determined by the same trick, with the base-emitter voltage of Q5 applied across it's 1k collector resistor.  You can see the open-loop gain growing at this point, with 2 common-emitter amplifiers chained together.  The feedback loop is closed after Q5, which acts as a follower to buffer the output from the collector of Q4.

The other neat part of this circuit is the closing of the feedback loop.  Ve6 is fixed at ~2.15V with a low impedance, so the output voltage (Ve5) is set by the current divider created by R24 and R22 along with the .7mA from Ie5.  In this case, the Ve5 rests around ~ 2.26V.  It is then fed the RC network at right to remove the DC component.  AC gain is very easily set by changing R26, with Av ~ R22/R26.  

Problems

Let's just say this project has been a painful lesson in the importance of decoupling.

The TM1640 LED driver is great - drives up to 8x16 LEDs with just an I2C (ish) protocol.  But, it creates a boatload of switching noise and I didn't plan around it enough.  The datasheet specifies one 10nF and one 100uF capacitor to be placed as close as possible to the chip, and I forgot the big one.  It was a catastrophic mistake that created major noise on the 5V line that amp uses.  If you look at the DC biasing with R18 and R21, you will see that it's just a resistive divider.  Yes, that does indeed mean that the switching noise is present at the amplifier input, and as it is not a differential amplifier the noise is just amplified as if it were signal. 

The result?  It's unusable.  I had to build an op-amp amplifier on perf board and hook it up to some test points that I thankfully added to the board, and then it worked fine.  The moral of the story?  Decoupling good, CMRR good, ignoring switching noise bad.  V2 will just need a few fixes to hopefully operate like a champ.  

Full Schematic 
specturm_analyzer_schematic_full.png
bottom of page