S14: Spectrum Analyzer for Audio Frequency Signals

From Embedded Systems Learning Academy
Revision as of 18:16, 22 May 2014 by Proj user13 (talk | contribs) (Software Design)

Jump to: navigation, search

Grading Criteria

  • How well is Software & Hardware Design described?
  • How well can this report be used to reproduce this project?
  • Code Quality
  • Overall Report Quality:
    • Software Block Diagrams
    • Hardware Block Diagrams
      Schematic Quality
    • Quality of technical challenges and solutions adopted.

Spectrum Analyzer for Audio Frequency Signals

Abstract

We plan to build a Spectrum Analyzer for Audio Frequency signals. Our device is able to display frequencies in audio of up to 4 kHz, which covers the most of the of the frequency range of typical music. The main inspiration for our project was applications of music visualizers which are seen in much software like Windows Media Player. Our spectrum analyzer will try to mimic such visualizers using an audio amplifier and a LED display. The display will light up a range of LEDs from low to high according to audio frequency using FFT as the algorithm for analyzing audio input. This gives a fully dynamic LED display for audio frequency.

Introduction

A Spectrum analyzer is used in measuring the magnitude of an input signal versus a frequency for a certain frequency range of an instrument. The primary use of a Spectrum analyzer is to measure power of spectrum of unknown or known signals. An input signal that a spectrum analyzer measure is electrical, however, signals like acoustic pressure or optical waves can also be measured by use of an appropriate transducer.

By analyzing the spectra of electrical signals, dominant frequency, power, distortion, harmonics, bandwidth, and other spectral components of a signal can be observed that are not easily detectable in time domain waveforms. These parameters are useful in the characterization of electronic devices, such as wireless transmitters.

The display of a Spectrum analyzer has frequency on the horizontal axis and the amplitude displayed on the vertical axis. In general observation, a Spectrum analyzer looks like an oscilloscope and, in fact, some lab instruments can function either as an oscilloscope or a spectrum analyzer.

Objectives

The main objective of our project was to display the audio input given to the mic through an LED display. The range of frequency was kept to 4K Hz as it covers most of the frequency range for a typical musical instrument. The LED matrix will be able to display change in the audio signal correspondingly.

The scope of the project was divided into 3 main parts :

  • ADC interfacing with the audio input through mic
  • Performing FFT calculations on the LPC1758 board and communication of the same to LED matrix.
  • Interfacing of the 16 X 32 LED matrix with LPC1758 board


Team Members & Responsibilities

  • Anand Dumbre
    • ADC interfacing + LED Interfacing
  • Chinmay Vaidya
    • Fast Fourier Transforms + Hardware.
  • Kevin Beadle
    • LED interfacing

Schedule

Show a simple table or figures that show your scheduled as planned before you started working on the project. Then in another table column, write down the actual schedule so that readers can see the planned vs. actual goals. The point of the schedule is for readers to assess how to pace themselves if they are doing a similar project.

Week# Date Planned Task Actual Task
1 03/13/14 Order & receive parts. Ordered the parts.late by 1 week as parts were not available
2 03/20/14 Interface microphone/LED strip to SJ One board. Obtained the parts. Started work on Microphone and LED.
3 03/27/14 Design band pass filter to reduce noise. Done
4 04/03/14 Analyze audio signals with Matlab using FFT. The waveforms were not coming out properly. FFT code was working alright
5 04/10/14 Write code to process audio signal on SJ One board. FFT code working fine.
6 04/17/14 Write algorithm to output audio signal to LED strip. ADC and FFT output coming out properly
7 04/24/14 Test algorithm using different audio sources. Tested using various Youtube audio. Still working on porting of LED strip.
8 05/01/14 Finalize project firmware.
9 05/08/14 Finalize project demonstration.
10 05/13/14 Finalize project report.

Parts List & Cost

Give a simple list of the cost of your project broken down by components. Do not write long stories here.

Component Name Quantity Cost per Item Total Cost
Audio Amplifier Board 1 25$ 25$
LPC1758 Board 2 70$ 140$
LED Matrix (16 X 32) 1 35$ 35$
Wires 50 0.5$ 25$

Design & Implementation

Hardware Design

The flow of our Hardware datapath is very linear. The audio board with Mic was interfaced with the LPC1758 board by connecting the audio, envelope, gate,Vcc and Ground ports to the board. The input from mic is fed to the ADC on the board. The ADC is internally connected to the processor. The FFT calculations are done on the board and the output of the FFT is given to other LPC1758 board by UART communication. The LPC1758 board is interfaced with the LED matrix. The block diagram of our Spectrum analyzer hardware is shown below.

Spring14 Spectrum Analyzer.jpg


Each block diagram hardware design will be explained as follows:

  • Audio Input : The audio input can be provided by playing a song or even just by talking into the mic
  • Audio Amp & Filter design: The audio amp board had an in-built mic which provided the input. Filter design was implemented and the filter was direct connected to the audio board. The filter design was implemented as shown in the image.


  • LPC1758 Board (ADC + FFT): The LPC1758 board has an in-built ADC. The output from audio board is connected to ADC of the board. The audio, envelope, gate, Vcc and ground ports from audio board will be connected to ADC ports. All the FFT calculations are software based and computed directly on the processor.
  • LPC1758 Board (for LED matrix interfacing) : The communication between the two LPC1758 boards is done by UART. The UART communication uses Tx and Rx ports of both the boards.
  • 16 x 32 LED Matrix : The LED matrix is connected to LPC1758 board by connecting the A,B,C,R1,B1,R2,B2,G1,G2,Clk,OE and Latency of the Matrix to the port pins of LPC1758 board. The connections is as shown in the image below.

Spring14 Spectrum Analyzer LEDMatrix.jpg

Hardware Interface

In this section, you can describe how your hardware communicates, such as which BUSes used. You can discuss your driver implementation here, such that the Software Design section is isolated to talk about high level workings rather than inner working of your project.

The Hardware Interface mostly consisted of pin connections to LPC1758 board from Audio Amp board, LPC1758 to LPC1758 UART connections and LPC1758 to LED Matrix. The schematic of the connections is given below.

Software Design

Show your software design. For example, if you are designing an MP3 Player, show the tasks that you are using, and what they are doing at a high level. Do not show the details of the code. For example, do not show exact code, but you may show psuedocode and fragments of code. Keep in mind that you are showing DESIGN of your software, not the inner workings of it.


The Software design implementation was done in 4 parts.

  • ADC configuration:
  • FFT calculations:

The main method of the FFT program was to wait for the ADC buffer to get full. According to the FFT algorithm, we considered a real and imaginary numbers as the input to the FFT matrix. A function for FFT was created which calculates the FFT matrix depending upon the inputs provided. In the main program, depending upon the size of array we use, it prints out the real and imaginary values of the Fast Fourier Transform. These values are to be sent to other board via Tx pin of UART. The steps in calculating FFT were as follows

  • Create a structure which includes the real and imaginary parts. It also includes declaration of matrix parameters
    As the matrix is 3 dimensional, consider i,j,k parameters and calculate the FFT for every i,j and k value using nested 'for' loops.
    Output the real and imaginary values of the FFT calculations. However as we need only the real values for spectrum analyzer,
   we can neglect the imaginary value while UART communication.
  • UART communication :

The UART communication between the two boards is solely for the purpose of providing the FFT values to LED matrix. There is only one way communications in this arrangement. The FFT values are sent through Tx pin and received by the other baord at Rx pin. We decided to use the UART as it is easy to implement in our case as we just had to send an 8 bit data over the bus.The UART was set to transmit with 8-bit character sizes, which takes a byte and transmit 8 bits serially. USART offers different frame formats including different character sizes, parity bits, and multiple stop bits, but we opted to use a 10-bit frame for simplicity and speed of transmission with 1 start bit, 8 character bits, and 1 stop bit.

  • Interfacing the LED Matrix:

The main problem in configuration of the LED Matrix was that its library was in Arduino. Also, the data sheet for the matrix was not available. Hence, we had to port it to the LPC1758. The pseudo code which we implemented in C is given as follows

  • The various ports for A,B,C,OE,Clk,R1,R2,G1,G2,B1 and B2 were set depending upon the port on which they were connected to LPC board.
   We used #define to make each pin correspond to the required port.
  • Initially we have to clear the display, then set the pins for A,B and C depending upon the row or column we need to select.
   For that, the bit masking for Apin, Bpin and Cpin was used. We used a 'for' loop to access all 32 columns of the LED matrix.
   Also, we need to  clear the interrupt flag after every operation of the display.
  • Then we set the required pins to output. After that, the timer frequency was allocated, the reset mode was configured.
   Along with that, the enabling of timer interrupt to occur according to our requirements.

The snippet of the code(especially the initial configurations) is given below.

Implementation

This section includes implementation, but again, not the details, just the high level. For example, you can list the steps it takes to communicate over a sensor, or the steps needed to write a page of memory onto SPI Flash. You can include sub-sections for each of your component implementation.

Testing & Technical Challenges

Describe the challenges of your project. What advise would you give yourself or someone else if your project can be started from scratch again? Make a smooth transition to testing section and described what it took to test your project.

Include sub-sections that list out a problem and solution, such as:

My Issue #1

The main issue was obtaining correct parts for the audio amplifier board and LED strip. The gain of amplifier needed to correct for required frequency. Also, the parts were not available on Websites. Resolution: checked the forums on the websites to obtain more information about the boards. Placed an order for deliver when available on the Adafruit and Sparkfun.

My Issue #2

We required the timer1 for ADC. However, the timer1 was configured for the I2C bus. Hence, we changed the I2C bus ports to timer2 and used the timer1 for ADC

My Issue #3

Adafruit Led strip had a library for Arduino. We need to port it to LPC in order to get our LED strip working.However, there are timing issues as the clock frequencies are not same for both. Issue is not resolved yet.

Conclusion

Conclude your project here. You can recap your testing and problems. You should address the "so what" part here to indicate what you ultimately learnt from this project. How has this project increased your knowledge?

Project Video

Upload a video of your project and post the link here.

Project Source Code

Send me your zipped source code and I will upload this to SourceForge and link it for you.

References

Acknowledgement

Any acknowledgement that you may wish to provide can be included here.

References Used

List any references used in project.

Appendix

You can list the references you used.