Parts / Bill of Materials

This is what's needed for this project

Schematic

MSP430G2553 or similar, need 4K Flash

Application Notes

LED Driving

The LED matrix is of 8 x 8 elements. They are driven by 15 GPIO pins. They are multiplexed w/ 8 rows and 8 column scheme. Since there are only 15 pins after we use 1 pin for ADC input, the multiplexing has row 1 and column 0 sharing a single pin. This means that the particular LED on row 1 and column 0 cannot be lit. This is a compromise as there are just not enough GPIO pins to drive all LED elements.

Sound Capture

Sound is capture via the on board condenser microphone on the breadboard. As microphone signals are small, we need to amplify it to a level that the msp430 ADC10 can use w/ a reasonable resolution. I had used a two-stage op-amp amplifier for this purpose.


The op-amp amplifier is consist of two stages, each w/ a about 100x gain. I had adopt the TLC272 as it is also a very common part and it works w/ 3V. The gain bandwidth being about 1.7Mhz means that for our gain of 100x, we can only guarantee it would work nicely (i.e. maintain the gain we want) under 17Khz. (1.7Mhz / 100).


Originally I intend to make this spectrum analyzer measure up to 16-20Khz, but in the end I found about 8Khz is good enough to show music. This can be changed by replacing the LM358 w/ something of audio-rated and changing the sampling rate. Just look for the gain bandwidth of the op-amps you choose.

Sampling and FFT

The FFT function used is the "fix_fft.c" code that many projects had adopted, it has been floating around in the internet for some years. I had tried a 16 bit version and a 8 bit version. Eventually I settled for the 8 bit version as for my purpose, I did not see a major advance on the 16 bit version.


I do not have a good understanding of the FFT mechanism except that it's a time domain to frequency domain conversion. That means the rate (time) of the sound samples, after feeding to the FFT calculation function, will affect the frequency of the amplitude I am getting as a result. So by adjusting the rate to sample sound, I can determine the frequency band as the result.


TimerA 0 CCR0 is used to keep the sampling time. We first determine the counts we need to achieve the band frequency (corresponds to our DCO clock rate of 16Mhz). i.e. TA0CCR0 set to (8000/(BAND_FREQ_KHZ*2))-1; where BAND_FREQ_KHZ is 8 for me. It can be changed if you got a better op-amp and / or wants it be different.

Frequency Bands and Amplitude Scaling

The firmware process 16 bands at one sweep, and the capture timing produces 500Hz separation between these banks. The LED matrix is of 8 columns and will only display 8 bands / amplitudes. Instead of displaying one every two bands, a non-linear frequency band list is used to show the more dynamic frequency bands (in terms of music). The list is of 500Hz gaps at the low end, 1KHz gaps in the middle bands and 1.5Khz bands in the highs.


The amplitude of individual bands are scaled down to 8 levels, which are represented by the number of horizontal 'dots' on the LED matrix display.The amplitude levels are scaled down via a non-linear map that translates FFT results into one of the 8 dots. A sort-of logarithmic scaling is used as it best represent our perception of sound levels.


There is built-in AGC logic and the spectrum analyser will try to scale down the amplitude levels when there are multiple peak levels detected in the previous cycles. This is done with a sliding ruler comparing table.