Building a AVR Spectrum Analyzer #1: Preparing

Over the next few weeks I’ll be discussing the development and implementation of an AVR Spectrum Analyzer using an Atmega32 AVR by Atmel.
These are relatively light-weight 8bit microcontrollers that are great for learning the basics without getting to heavy and rich in features. Ideally, I will assume that you will have knowledge with regard to setting up and flashing the microcontroller with AVR Studio or AVRDude, this project is written in C (apart from the FFT routine which we don’t concern ourselves with anyway), therefore a basic understanding of C is required to complete this project.

In order to build your own SA, you’ll require the following hardware tools:

1. Atmega32 & Dev.Board with SPI/JTAG Interface
2. SPI or JTAG Interfacer (to communicate your microcontroller to your PC)
3. HITACHI HD44780 LCD Display
4. (Optional) External high-fidelity ADC – or just use the internal 12bit ADC of Atmega32.

And for the software development side of things, we’ll need the following:

1. Atmel AVR Studio 5.
2. AVR Dude (if using SPI)
3. Microcontroller simulation software – such as Proteus.
4. A Decent LCD Library for displaying content on the LCD
5. A Decent 8bit FFT Library/Routine for computing the spectrum

The simulation software isnt necessary, I’ve listed it here because its quite good for speedy debugging in that you dont have to build and reflash the microcontroller every time you make a change. Using software like, or similar to this, you can simply update the .hex file and restart the simulation.
Now your going to need some decent libraries, one for the LCD and one for the FFT. After alot of searching and experimenting with various libraries I found the following to be the “best” for my needs.
You don’t have to use the libraries if you find other alternatives in which work in a comparable manner – although the final implementation of code will need to change and the routines themselves may cause differences in the output of the LCD.

The FFT Routine can be downloaded from Chans website:
The LCD Library can be downloaded here from Peter Fleury’s website: and is categorized under the appropriate heading.

Okay, so we have all that we require to develop our SA, except for some design-architecture, how will our SA work?
The final implementation of the SA can be visualized here:

The ADC Samples a signal at 40kHz – the Nyquist minimum sampling rate for audio signals, this value is then inserted into a sampling buffer routine in which temporary holds the signals samples. The FFT Routine is run at intervals in which the is determined by the sampling buffer length.
During this period the LCD is continually updating.

The order of development will go as follows:

1. LCD Development – Understanding the Matrix and the way our LCD Works
2. Generating a Sinewave – Generating a sinewave for our FFT
3. Computing the FFT – Creating the spectrum of our sinewave
4. Sampling an input.

As this is a work in progress, please wait for the next installment of building an AVR Spectrum Analyzer.
In the next installment we will be looking at the HITACHI 44780 LCD in detail and getting some stuff displayed on the screen, such as text and we will be
looking at creating our graphics to display the “bars” for the LCD.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s