Here's a step-by-step guide to constructing a simple 14-band (2 x 7) audio spectrum analyzer using two MSGEQ7s and a chipKIT or Arduino microcontroller development platform.
Creating the first-pass hardware
When I started this project, I knew I was going to construct my first incarnation on a breadboard. One thing I needed was a 3.5mm stereo jack socket. I performed a web search and found a printed circuit board (PCB) mountable socket, so I ordered it. I'd foolishly assumed that something that said "PCB mountable" would have a traditional 0.1" pin pitch, and that its leads would be long enough to be used with a solderless breadboard. I was wrong on both counts. Eventually, I purchased a different 3.5mm PCB audio jack and an associated breakout board from SparkFun.
You'll also need some 0.1" pitch standard male header pins, which -- as far as I recall -- don't come with the breakout board. Happily, I have loads of these lying around. Solder the jack on to the top of the breakout board, and solder a strip of five header pins on to the bottom of board (with the long ends pointing away from the board, so they can plug into the breadboard).
Let's move on to the breadboard itself. I'm using a full-sized solderless breadboard, similar to this Adafruit board. I say "similar" because there are myriad tiny differences between such boards from different suppliers, but most of these are superficial.
Just in case you are new to all this, one important thing to note is that all the holes in the horizontal row under the red "+" line at the top of the board are connected together. Similarly, all the holes in the horizontal row above the blue "-" line at the top of the board are connected together. The same applies for the corresponding rows at the bottom of the board. In the fullness of time, we will connect our power supply to the "+" rows and our ground (GND) to the '-' rows.
The really clever part is that the pins in each vertical column are connected together. If you look at the larger version of the above image, the A, B, C, D, and E pins in column 0 are connected together. Similarly, the F, G, H, I, and J pins in column 0 are connected together, and so forth for all the other columns.
As we previously noted, most of the differences between the boards from different manufactures are superficial -- the way they number the pins, for example. However, there can be the occasional gotcha. If you look at the large version of the first breadboard image above, you will see small gaps in the middle of the horizontal red (power) and blue (ground) lines. On some boards, this may indicate that the left and right sides are separate.
This is exactly the way my board looks. I should have used my multimeter to check whether the two sides were separate. However, I was happily cruising along on autopilot, so I simply assumed that the two halves of the board were separated, and I proceeded to connect them together without thinking.
This leads us to the question of color coding one's wires. Given a choice, I usually use red and black wires to indicate power and ground connections, respectively. I subsequently use different colored wires to indicate various functions and types of signals. Thus, you might wonder about my using blue and green wires above. The answer is very pragmatic. When I started building this project, I quickly realized that I had only dribs and drabs left in my various pre-formed jumper wire kits, so I ended up using whatever was to hand at the time.
The next step is to add the audio jack/breakout board combo to the breadboard, and then add the two MSGEQ7s, as shown below.
Now we add the capacitors and resistors, as illustrated below. These component names match the schematic we showed earlier; the only difference is that we now have two channels, so each component name includes an 'L' or 'R' postfix indicating "Left" or "Right," respectively.
Now it's time to add the wires. Observe the two red wires associated with the TIP and RNG ("Ring") pins on the audio-jack breakout board. These correspond to the left and right audio channels coming from the iPad. Don't worry about the TSH and RSH pins on the breakout board; we won't be using them.
Also observe the red wire on the left side of the board linking the two power rails and the black wire on the right side of the board linking the two ground rails. As you'll see in the photograph below, I started off by mounting these side by side, but I later moved the ground wire as shown in the graphic above purely for aesthetic reasons. Now, let's pause for a moment to take a sanity check and look at the real board.
Did you spot the errors in the above photograph? (For the sake of charity, let's pretend these errors were "intentional" to make an educational point.) The thing is that, if you look closely at this photograph (and also at the next photograph shown below), you will observe that the wire from the TIP pin on the audio jack breakout board is directly connected to pin 5 of the left-hand MSGEQ7 chip. Similarly, the wire from the RNG pin on the breakout board is connected to pin 5 of the right-hand MSGEQ7 chip. In reality, the TIP and RNG pins should be connected to the "input sides" of resistors R2L and R2R, respectively (this is shown correctly in the graphical versions of these images). I discovered these mistakes as part of my test procedures (see also my step-by-step test guide).
The next step is to hook the breadboard up to the microcontroller board -- the chipKIT MAX32, in this example. For this, we use flexible flying leads. We start by connecting one of the '+' power rails on the breadboard to the +3.3V power supply header pin on the chipKIT (or the +5V supply on an Arduino). We also connect one of the '-' ground rails on the breadboard to one of the two GND header pins on the chipKIT or Arduino. Personally, I don't think you can have a good enough ground connection, so I connected both GND header pins on the chipKIT, as shown below. I know there are additional power and ground connections on both chipKIT MAX32s and Arduino Megas. For the purposes of this guide, I'm just focusing on the ones on the main power header.
The DATA_OUT from pin 3 on the left (and left channel) MSGEQ7 is connected to analog input A0 on the chipKIT. Similarly, the DATA_OUT from pin 3 on the right MSGEQ7 is connected to analog input A0 on the chipKIT.
Digital output pin 23 from the chipKIT is connected to the RESET input (pin 7) on the right MSGEQ7. A second flying lead is used to connect pin 7 on the right MSGEQ7 to pin 7 on the left MSGEQ7. Similarly, digital output pin 22 from the chipKIT is connected to the STROBE input (pin 4) on the right MSGEQ7. A second flying lead is used to connect pin 4 on the right MSGEQ7 to pin 4 on the left MSGEQ7. Once again, let's take a quick sanity check and look at a photograph of the current setup.
Page 1: Introducing the MSGEQ7
Page 2: Creating the first-pass hardware
Page 3: Creating the first-pass software
Page 4: Modifying the hardware to add the LEDs
Page 5: Modifying the software to drive the LEDs
To Page 3 >