Mbed Audio Spectrum Analyzer Using the MSGEQ7
Introduction to the MSGEQ7
The goal of this project is to interface the MSGEQ7 7-Band Graphic Equalizer chip made by Mixed Signal Integration to the Mbed to create a 7-band Audio Spectrum Analyzer.
The method in which this chip operates is that inside there are 7 band-pass filters, tuned to pass 7 frequencies: 63, 160, 400, 1000, 2500, 6250, and 16000 Hz. The output of each filter is connected to a peak detector, and then a multiplexer controlled by reset and strobe lines.
At each falling edge of the strobe line, the outputs of the filter peak detectors are sequentially placed on the analog output line of the chip. At start up the chip needs to be reset, accomplished by bringing the reset line high and cycling the strobe line. After the reset line is brought low, the strobe line can then be clocked to retrieve the 7 frequencies sequentially. After all 7 frequencies have been output, the chip starts back over at the first frequency.
Note that the analog output of the chip requires 36uS settling time after switching and before reading in order to get valid data.
Interfacing with the MSGEQ7
In order to use the MSGEQ7, several external components are required. The following is the minimum BOM:
- 2 - 100 nF Capacitors
- 1 - 10 nF Capacitor
- 1 - 33 pF Capacitor
- 1 - 200 kΩ Resistor
In my example circuit, I did not have a 200 kΩ resistor, so I instead used 2 100 kΩ resistors in series. The signal input in my circuit is from a 3.5mm jack, with the signal line connected to the 'ring' of the jack and the grounds connected together. Note that this is a mono design, but could be converted to a stereo design by interfacing another MSGEQ7 and connecting it to the 'tip' connection on the jack.
The following is the circuit schematic to interface the MSGEQ7 to the Mbed:
Breadboard version of schematic:
We will wire the circuit up to the Mbed with the following connections:
This chip is fairly straightforward to interface with in terms of which pins to toggle and how the data is read off of the chip, but there are a areas in which it might be easy to make a mistake.
If you are having trouble getting correct data off of your chip, double check your power supply values. According to the MSGEQ7 datasheet, the chip can run off of input voltages between 2.7 to 5.5, but they recommend 5V.
Also, it is possible that your power supply is noisy, therefore make sure to include the 100nF decoupling capacitor for the VDD chip input.
The values of most of the passives do not need to be exactly the same value as specified in the schematic, but make sure to have as close to exact values for the clock oscillator resistor and capacitor, as these will effect the performance of the chip greatly.
The MSGEQ7 Mbed Library
Library used to interface to the 7-band Graphic Equalizer Chip MSGEQ7, made by company Mixed Signal Integration
The MSGEQ7 Library API
The MSGEQ7 library is very simple to use. In the class called 'MSGEQ7' there are 3 public functions and 2 arrays.
Descriptions of functions: MSGEQ7(PinName reset, PinName strobe, PinName analog) - Creates a MSGEQ7, taking 3 pin arguments specifying which Mbed pins are connected to the chip's reset, strobe, and analog out lines.
void readByte() - Interfaces with the MSGEQ7 chip and reads out all 7 frequency data values and stores the values in the byte array (in the form of an array of unsigned chars) called freqDataByte, of length 7. Each value stored ranges from 0 to 255, with 255 representing the maximum sound magnitude the MSGEQ7 chip can detect at that frequency.
void readInt(int max) - Interfaces with the MSGEQ7 chip and reads out all 7 frequency data values and stores the values in the integer array called freqDataInt, of length 7. Each reading will be scaled so that the stored data ranges from 0 to value 'max' specified by the user. This 'max' variable allows the user to scale the output of the chip to a useful range.
The user chooses between readByte() and readInt(int max) based on what form they want the data returned to them in. The user needs only to call one of those functions, not both.
Once the function readByte() or readInt(int max) has been executed, the frequency data from the MSGEQ7 chip is stored in a certain array, depending on which function was called.
readByte() stores data in freqDataByte, and readInt(int max) stores data in freqDataInt. Both arrays are available as public data arrays in the MSGEQ7 class. For both arrays, the data at index = 0 is the value at frequency = 63Hz, and the data at the last position, index = 6 is the value at frequency = 16kHz.
See example program MSGEQ7_Hello_World for an example of basic API usage.
Demonstration of MSGEQ7 library interfacing with MSGEQ7 7-band Graphic Equalizer Chip made by Mixed Signal Integration.
2 comments on Mbed Audio Spectrum Analyzer Using the MSGEQ7:
Please log in to post comments.