Audio Spectrum Analyzer with Freescale GT60 LCD

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Audio Spectrum Analyzer with Freescale GT60 LCD

1,189 Views
CamiloA_
Contributor III

Using a microcontroller FreescaleHCS08 family (8 bits) and ANSI C language, configure the internal ADC converter to take a sample every 25US (40KHz) and so apply a 64-point FFT in real time (thanks to the internal bus microcontroller running at 20MHz), resulting in 32 levels representing frequencies from 20Hz to 20kHz with a range of 312.5Hz each level. As we have a display of 16 x 2 characters, we made an average of the value of contiguous levels in order to obtain results in 16 levels and to represent them as bars

 

look at my blog (future updates)

http://candelectronica.blogspot.com/

Labels (1)
0 Kudos
4 Replies

421 Views
celsoken
Contributor V

From user's viewpoint it is real time. Nice job, Camilo!

0 Kudos

421 Views
JimDon
Senior Contributor III

Awesome!

Is thesource code available?

 

0 Kudos

421 Views
rocco
Senior Contributor II

As an audio guy, I am impressed.

 

If anybody had asked me if a S08 was fast enough to implement a spectrum analyzer, I would have said "no way". I would never have guessed you could execute a 64-point FFT in real-time. How often is the FFT computed? Is the FFT code available somewhere?

 

 

0 Kudos

421 Views
Encoder
Contributor I

Hi Rocco, hi guys.

The application of Camilo is tricky and his short video is really impressive but the answer to the Rocco's question is still "no". A HC9S08 cannot perform 40kHz sample 8bit FFT "real time" at any clock speed up to 40 or 50MHz (20/25MHz busclock).

Camilo instead shown it may perform a "live" Audio Analyzer with 20 kHz band and 64x8bit samples giving 16 or 32 frequency output lines up to 20kHz windowed or unwindowed.

To do that you do not either need a lot of resources: any small 9S08 MCU with at least 512B RAM and 8kB flash can do the job at 20MHz busclock or even at 10MHz, so much less powerful than a 9S08GT60 at full speed. I guess than a 1.12$ (Digikey/100pcs) 16 pin 9S08SH8CTG running at 20MHz or even a less powerful 0.88$ (Digikey/100pcs) 16 pin 9S08QB8CTG running at 10MHz could do the job, in the same electrical diagram of Camilo, with some pins left unused... I will explain how.

-------------------

Performing a basic 256x8bit FFT on a 20MHz BusClock 9S08 MCU requires at least:

  • 6.4ms sample time (256 samples, 40ks/s)
  • ~25ms FFT calculation elapsing time (full 8 bit signed precision, 37-40dB dynamic range on output)
  • 512B RAM (+256Bytes if the output array should not cover the input data which isn't usually required)
  • <1kB FLASH ROOM, including tables

To perform the same duty with 64 samples, some process and LCD display on 2x16ch display you'll need approx (same clock):

 

  • 1.6ms sample time (64 samples, 40ks/s)
  • ~5ms (25/(2*2*(8/7)*(7/6)) FFT calculation elapsing time for 32 sample output frequency lines 0-20kHz
  • ~1ms output processing and formatting
  • ~2.5ms LCD display
  • 256B RAM keeping separate 4x64B input, output and elaboration vectors
  • <1kB FLASH ROM, including tables for FFT and <2kB for the whole application

From this calculation you may easily see you need some 10ms for a full upgrade of the display. Being the display vs. sample time some 4:1 this is not "real time" (there is some 3/4 of the time in which the input is ignored) but a real "live" application which is not practically discernible from "real time" for our purpose. I do not take in count massive processing during the ADC sample time which cannot anyway make a real difference (less than 10%).

From my experience there is not a visible improvement on upgrading an alphanumeric display more than 10 times/s, i.e.. every 100ms. From this derives that even slowing the busclock to 10MHz or even 5MHz you may be able to display 20 or 10 screens/s with "a lot of time" to perform other tasks. Obviously the sample time would be only 1/35 or 1/70 of the "real time" but nevertheless for practicaly anybody you would not see any difference from 100%.

All assumptions are valid for good Assembly program. I do not know how C would perform, but I would not be surprised that it was (badly?) worse if not very well designed...

 

Salvatore

0 Kudos