## Real-time Spectrum Analyzer on a PIC18F4550

We usually see spectrum analyzers as decorations to audio equipment – bouncing sets of bars that go up and down depending on what frequency the played tone is. I remembered building a similar project a few years back – its called a Led VU-Meter, though its nothing compared to the complexity of the math behind this project. This real time spectrum analyzer takes in audio signals, amplifies and level shifts it to fit the 0-5V range of the PIC18F4550’s 10 bit analog to digital converter – this is all done through an LM386 operational amplifier. Now the tricky part in this project is called coherency – this is the scheme where it should follow fs/fi = m/n, fs is the sampling frequency of the PIC18F4550’s ADC, Fi is the frequency of the sound being sampled and n is the number of samples. This is a requirement for FFT (which is entirely implemented in C!) or fast fourier transform. Each of the bars/columns of the 128×64 dot-matrix LCD on the spectrum analyzer would be a frequency bin in FFT. Continue reading