Audio spectrum analyzer on PIC32 using pic microcontoller

Summary of Audio spectrum analyzer on PIC32 using pic microcontoller


This project implements a simple audio spectrum analyzer using a PIC32MX360F512L proto board and a 320×240 color LCD (LVC75Z779 Eval Board). It samples audio at ~48 kHz into a 2048-point buffer, performs a fixed-point 2048-point FFT in C, scales results to volts or decibels, and displays the spectrum; ADC Vref is set to 1 V and the input is DC-shifted by 0.5 V with coupling capacitor to accommodate the ADC input range.

Parts used in the Audio spectrum analyzer:

  • PIC32 proto board with PIC32MX360F512L
  • 320×240 color LCD (LVC75Z779 Eval Board)
  • SSD1928 module (display driver)
  • Potentiometer for ADC Vref (set to 1V)
  • Potentiometer to add 0.5V DC bias to audio signal
  • Coupling capacitor to isolate DC bias from audio source
  • Audio source (PC sound card, MP3 player, etc.)

This simple audio spectrum analyzer is based on PIC32 proto board on PIC32MX360F512L with 320×240px colour LCD (LVC75Z779 Eval Board).  The analyzer can be connected to unamplified audio source like PC’s sound card, MP3 player and so on.

Audio spectrum analyzer on PIC32SSD1928 Module Schematic diagram

The reference voltage of ADC is set to 1V with potentiometer connected to Vref+ pin of PIC32. Voltage of the audio signal could be negative but PIC’s ADC accepts only positive voltages. That’s why another pot is used to add 0.5V DC to audio signal. Finally coupling capacitor is used to isolate DC bias from audio source.

Software

PIC’s ADC is configured to take samples at ~48kHz frequency. When each sample is converted interrupt is generated and sampled value is placed to the buffer. Sampling is completed when 2048 point buffer is full. It takes about 42ms at 48kHz sampling frequency.

Since sampling is done automatically in background we have enough time to do all calculations to previous samples while sampling new ones. First fast Fourier transform is calculated, then the results of FFT are scaled to volts or decibels and finally spectrum is drawn on LCD. At 80MHz it takes about 35ms to do all calculations and draw image on the screen.

Audio spectrum analyzer on PIC32I found FFT algorithm for this project from here. It uses fixed point arithmetic and is written in pure C without any optimisations for PIC32. I have expanded it to be able to calculate 2048 point FFT. It takes about 9ms to calculate 2048 points but I think the performance could be improved by optimizing the code for MIPS architecture.

 

For more detail: Audio spectrum analyzer on PIC32

Quick Solutions to Questions related to Audio spectrum analyzer:

  • What microcontroller is used in the audio spectrum analyzer?
    The project uses a PIC32MX360F512L on a PIC32 proto board.
  • What display is used to show the spectrum?
    A 320×240 color LCD (LVC75Z779 Eval Board) driven by an SSD1928 module is used.
  • How is the ADC reference voltage set?
    The ADC reference voltage is set to 1V using a potentiometer connected to Vref+.
  • How is the audio input adjusted for the ADC's positive-only input?
    A potentiometer adds a 0.5V DC bias to the audio signal and a coupling capacitor isolates the DC bias from the audio source.
  • What is the sampling rate and buffer size for the analyzer?
    Sampling is done at about 48 kHz into a 2048-point buffer.
  • How long does sampling take for the full buffer?
    Filling the 2048-point buffer takes about 42 ms at 48 kHz.
  • What FFT algorithm implementation is used?
    A fixed-point FFT algorithm in pure C (expanded to 2048 points) from an external source is used.
  • How long does the FFT and display update take?
    At 80 MHz it takes about 35 ms to perform calculations and draw the spectrum; the 2048-point FFT itself takes about 9 ms.
  • Can the analyzer be connected directly to consumer audio sources?
    Yes, it can be connected to unamplified audio sources such as a PC sound card or MP3 player using the DC bias and coupling capacitor arrangement.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter