MSGEQ7-Based DIY Audio Spectrum Analyzer: Testing

Here's a step-by-step guide for testing a simple 14-band (2 x 7) audio spectrum analyzer using two MSGEQ7s and a chipKIT or Arduino microcontroller development platform.

In my previous column on this topic, we discussed the step-by-step construction of the first pass at a MSGEQ7-based DIY audio spectrum analyzer for use in my BADASS Display project. Of course, once you've built something, the first thing you have to do is test it to make sure it's functioning as expected (and to debug and fix it if it isn't).

Electrostatic discharge protection
This is something I should have mentioned in the construction article. Please, please, please don't neglect to use electrostatic discharge (ESD) protection. I cannot tell you how frustrating it is to blow an LED or disable one of the pins on your microcontroller because you forgot to take suitable precautions. Well, I could tell you, because I've certainly done it enough times, but I prefer not to talk about it.

You can pick up a cheap and cheerful ESD wrist strap from Best Buy. This will typically have a crocodile (alligator) clip on the end. I personally tend to clip this to a wire I plug into the ground rail of my breadboard. Given a choice, however, I'd really like to find something that would plug into the ground pin on a wall plug, so I could be 100% grounded before I touch anything. I'm open to suggestions on this point.

Checking the wiring
Before I power anything up on any project, the first thing I do is print a copy of the schematic. The one below shows components for the left audio channel, hence the "L" postscripts on the signal and component names. When I was performing my bringup, I also printed a copy of the schematic for the right audio channel.

Next, I go through the circuit component by component and wire by wire, comparing each element in the schematic to the corresponding element on the circuit board (or breadboard, in this case). I use a highlighter to mark things off in the schematic as I check them. Apart from anything else, if anything is not highlighted at the end, we know we've got a problem. As it turned out, I had made an error. If you don't recall this from my previous column, take a look at the breadboard below, and compare it to the schematic above.

If you look closely at the photograph, you will observe that the AUDIO_IN_L wire linking the TIP pin on the audio jack breakout board is directly connected to pin 5 of the left MSGEQ7 chip. Similarly, the AUIDIO_IN_R wire from the RNG pin on the breakout board is connected to pin 5 of the right MSGEQ7 chip. In reality, the TIP and RNG pins should be connected to the "input sides" of resistors R2L and R2R, respectively. The corrected version is shown below.

Applying power for the first time
The next thing I do is power everything up. This is where I keep a wary eye open and my nose aquiver for any components that start to leak acrid magic smoke. Also, I touch the tops of various components to check if they're unduly warm.

Next, I use my multimeter to check that I'm seeing power and ground values in the expected places, along with any other values I might reasonably expect to see, like Vdd/2 on the ground reference pins (pin 6) on the MSGEQ7s.

Rechecking the audio signal
As one final check before I plugged everything together, I decided to re-verify the audio signal. The image below shows my iPad-based Oscium iMSO-204 oscilloscope. The sine-wave signal on the bottom is coming from the Frequency Generator Kit I acquired a few weeks ago (on the bottom right of this picture). The audio signal on the top is coming from my iPod, which is also being used to drive an external amplifier and speaker system.

Quick and dirty test of the monitor and display
Before I actually plugged an audio source into the spectrum analyzer, I wanted to check that my display routine was giving me the sort of results I'd expect. As you may recall from the "Creating the first-pass software" section of my previous blog, we display the data we've read out of the MSGEQ7s on to our host computer's screen as numerical values.

Returning to the breadboard image above, do you remember the gray wires linking the DATA_OUT_L and DATA_OUT_R wires to the microcontroller's analog pins A0 and A1, respectively? Well, I unplugged the breadboard end of the wire connected to pin 3 of the left MSGEQ7 and connected it to the 3.3V power rail. Similarly, I unplugged the breadboard end of the wire connected to pin 3 of the right MSGEQ7 and connected it to the 0V ground rail. When I ran my program and looked at the display on the screen, it -- not surprisingly -- appeared as shown below.

I then swapped these wires so that the left input was connected to 0V and the right input was connected to 3.3V, and I observed this being reflected in the display. Finally, I returned these wires to their original positions on the breadboard. So far, so good.

@Garcia ref Dissipative anti-static mats... while I am not against them per se, I would not like one all over my workbench. If you happen to be testing a switched mode power supply module (and I occasionally do this with PSUs scrounged from old equipment) you want a good insulating bench area to put them on, as they don't always have a frame and the bottom of the PCB has some nice shocking voltages on it. I sometimes keep a piece of that plastic corrugated cardboard type stuff for the same reason. If I'm probing around on the mains side I'll usually get an isolation transformer out too - don't have a death wish yet :-)

@Crusty... "Why is it that switch mode supplys seem to generate these tingles?"

I've seen, on many schematics of these beasts, a small (1-10 nF) X2 Cap between the common of the mains side and the common of the low voltage side. I'm not sure why this is needed, but if the common of your mains side happens to be on the live leg, you'd get enough through a few nF to give you a tingle. If it's for a Laptop or a bedside clock, fine, but if it's for something I'll be touching I much prefer an old-fashioned hunk of iron.

@Crusty - in addition to giving you tingles, the wall brick will have no or fixed (high) current limiting. Just in case you make a wrong connection which will cause you to lose the magic smoke in your new board, use your lab power supply and set the current limit to one which will only just supply the board under normal conditions, or even a bit less. Much safer way to go. Once you know it's all working, change to the wall wart if you are brave... :-)

@all, This topic brings me onto! which power supply should I decide to use before I liven up my board?

Do I use the big dual linear power supply, very stable and takes up a lot of my small bench, or do I use the little wall socket, switch mode brick.

After getting one hell of a tingle from the Wall brick via the low volatage side last night I am just begining to think that whilst the wall bricks are usefull I would rather not get that tingle.

Why is it that switch mode supplys seem to generate these tingles, I had a co worker who was leathal to work with, as she always disconnected the ground pin from her scope supply and it always seemed to be me that caught a tingle, so much so, that I ended up wearing insulated gloves when I worked in her lab.

@elizabethsimon: "the surface of the anti-static mat and the wrist strap are NOT shorted to ground but have some resistance that is sufficient to dissipate the static charge without shocking you."

As far as I remember, my ankle anti-static band is labeled as 1 Mega Ohm between the strap in contact with the skin and the part that touches the floor -- of course, this is useless unless you are on a special dissipative floor such as the one in SMD facilities.

I've got a couple of large anti-static mats on my workbench as well as a couple smaller ones that were designed to be used as keyboard mats. The grounding points on these mats have a socket for the ground strap and a wire with a ring terminal. The ring terminal is supposed to attach to the grounded screw between the outlets on a standard duplex wall outlet.

This works well if you have a permanent workbench but it's not practical if you happen to be using a dining table or some such that has to be cleared off when you're done. On the other hand, using the mat to protect the surface of said table is a good idea. What I'd suggest doing in that case is to ground the mat to the power strip that you will be using to power your equipment.

By the way, the surface of the anti-static mat and the wrist strap are NOT shorted to ground but have some resistance that is sufficient to dissipate the static charge without shocking you.

The going rate @1 for most of these is US $11 per square foot for ready-made ones including the grounding point and grounding wire. Typically they have 2 grounding points to allow daisy-chaining of adjacent benches, or attachment of a wrist strap. I've bought several of these for my lab benches at work. My only beef with them is the grounding conductor attachment sticks up from the surface over 1/2 inch so you can't put any equipment in that area.

It turns out that the standard banana plug is a pretty good fit in the standard US U-ground outlet. Most ground straps I see (and the grounding leads of the anti-static mats mentioned above by Garcia-Lasheras) come with a nice black banana plug AND an alligator clip that the banana plug can be plugged into. The better ones have stacking banana plugs so you can plug both the anti-static mat and the wrist strap into a solid ground. The alligator clip method is perfect for working on PCs with a metal chassis but not very good for a breadboard!

Added comment: that standard banana plug is a BIT loose, but it's easy to expand the diameter: a 4-way split (common) one will accept taking a small flat-blade screwdriver (the kind every engineer has several "giveaway" ones) under each leaf to expand the effective diameter. Even the old/cheap plin solid pin versions can be modified with a similar surgery.