Secondary Menu

MSP430 Breadboard Audio Spectrum Analyser

This project is microphone based and require minimal external components. 2 x LR44 coin cells are used so that I can have the whole structure working in the confines of a 170 tie-point mini breadboard. ADC10, TimerA interrupt LPM wake-up, TimerA PWM like output, button use, integer arithmetic are used and demonstrated.

Features

8 bit integer FFT 16 samples at 500Hz separation

shows 8 amplitudes of 1K, 1.5K, 2K, 3K, 4K, 5K, 6K, 7.5K non-linear

partial logarithm map to show amplitudes, limited as resolution has been reduced for 8 bit FFT

Step 2: Plan Components Layout

The project is to be built on a 170 tie-point mini breadboard. The layout of components are as shown below. Of special note is that the 8x8 LED matrix is to be placed on top of the MSP430 MCU. Apart from components, there are also connecting jumper wires depicted by "+------+" characters.

Step 3: Assembly

You can start placing components based on the breadboard layout. As it's ASCII art so may not be very clear. You can pair w/ the photos in this step to identify all connections.

Care must be taken to position the IC chips. There is usually a dot on one of the corners to indicate pin 1 of a device.

I had used CAT5 ethernet cable wires and they are very easy to work on breadboard projects. If you have old CAT5 cables, you can cut it open and you will find there are 6 twisted wires inside. They are perfect for breadboards.

Step 4: Compile and Load Firmware

I am using mps430-gcc to compile the firmware but it should go well with TI CCS. You can avoid all the trouble of installing IDEs or compilers by going to TI CCS cloud, which is a web based IDE. It will even download the firmware to your target device.

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 Educational BoosterPack. 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.

Step 6: Operating the Device

Short key press in display mode cycles through no dot, one dot, 2 dots, and 3 dots display.