I'm trying to do a audio spectrum analizer using a 16C73 and the only
problem I have is how to measure the amplitude of the incoming signal.
I have to measure the amplitude at 32Hz, 64Hz, 125Hz, 250Hz, 500Hz,
1000Hz, 2000Hz, 4000Hz, 8000Hz and 16000Hz.
I don't want to do a separate bandpass filter for each frequency, I just
want to dos this by software.
Does any one have any ideas?
> From: nogueira <.....nogueiraKILLspam@spam@MANDIC.COM.BR>
>
> I'm trying to do a audio spectrum analizer using a 16C73 and the only
> problem I have is how to measure the amplitude of the incoming signal.
> I have to measure the amplitude at 32Hz, 64Hz, 125Hz, 250Hz, 500Hz,
> 1000Hz, 2000Hz, 4000Hz, 8000Hz and 16000Hz.
> I don't want to do a separate bandpass filter for each frequency, I just
> want to dos this by software.
> Does any one have any ideas?
Ok, so you've given up on the complete FFT adventure (don't blame you).
If you are interested in specific frequencies like the above, you
can use the technique implemented in my DTMF decoder to measure the
amplitude of single, selected, tones. However, given the wide range
of frequencies involved, this may not prove feasible.
May I suggest a tunable filter front-end? I have experimented with
a device called the MF8 (National Semiconductor), which is a tunable
band pass filter, in an application similar to the one you are
describing.
The beauty of this device is that both the centre frequency and Q are
digitally controlled, plus you get an op-amp front end to add a little
gain if required. The Q is set to one of 32 values from 0.5 to over
100 (I think) based on 5 digital inputs. The centre frequency is
set by sending a clock rate of either 50 or 100 times the desired
centre frequency to a digital input.
Some problems with this approach:
. the MF8 requires +- >=5V supplies (or >=10) so level shifting will be
required for the ADC.
. Sampling will be slow at the low frequencies since you will need to
allow the output to settle for 4 or more cycles depending on the Q.
If you sample for N cycles, the total sample time will be
N/32 + N/64 + ... ~= N/16 seconds.
. The required max sample rate will be 8*16KHz for sufficient accuracy
(+-1.5dB). I think the PIC ADC can keep up with this, but you'd better
check. If not fast enough, add an analogue peak detector to the MF8
output, and sample this at the end of 10 cycles. An extra PIC pin will
need to be assigned to the duty of resetting the peak detector.
. The required clock rate at 16KHz will be 50*16KHz = 800KHz so you will
need to run the PIC at high speed and use the PWM module, controlling the
frequency with the period register, and maintaining as close as possible
to 50% duty cycle.
How often do you have to sample the bands? I think the PIC could easily handle
a software digital filter and look at one frequency band at a time. Since you
don't need a really sharp bandpass, you could probably use a FIR and minimize
instability problems arising from coefficient quantization in an IIR.
BTW - Does anyone know of good, inexpensive filter design software that handles
coefficient quantization to 8 and 16 bits?
nogueira wrote:
>
> I'm trying to do a audio spectrum analizer using a 16C73 and the only
> problem I have is how to measure the amplitude of the incoming signal.
> I have to measure the amplitude at 32Hz, 64Hz, 125Hz, 250Hz, 500Hz,
> 1000Hz, 2000Hz, 4000Hz, 8000Hz and 16000Hz.
> I don't want to do a separate bandpass filter for each frequency, I just
> want to dos this by software.
> Does any one have any ideas?
>
Sure...
When you say you don't want a "separate bandpass filter for each frequency"
I assume you mean a hardware bandpass filter. There are at least four ways
you could resolve the amplitudes of these frequencies using software bandpass
filters. First, let's assume your sample rate is way beyond the Nyquist rate,
Ts >> 2*16000 Hz.
1) FFT - forget it. It gives you too much information.
2) 10 DFT's tuned to your frequencies
3) 10 Bandpass IIR filters tuned to your frequencies
4) 10 Bandpass FIR filters tuned to your frequencies
Now, since you say this is an audio spectrum analyzer, this implies there
will be signals at frequencies other than the ones you're sampling. If you
wish to bin the frequencies together (e.g. like you would if you are driving
10 LED bar graph), then either the FIR or IIR filters would be the best choice.
If you truly wish to sample exactly at the frequencies you listed AND you
wish to reject everything else, then the DFT's would be the best choice.
(You actually could use the FIR or IIR approach for this case, but the order
of the filter becomes fairly large when you desire sharp cutoffs. But on the
other hand, the DFT can be viewed as very high order FIR filter.)
The implementaion of the DFT's can be done using the Goertzel algorithm that
has been alluded to in the DTMF thread. The design of IIR and FIR filters is way
beyond the scope of this e-mail. Furthermore, you would be hard pressed to
implement any of these approaches in "real time" with a PIC.
BTW, the TLA's :
DFT = Discrete Fourier Transform
IIR = Infinite Impluse Response
FIR = Finite Impulse Response
I'll mention one other approach that's sort of a variation of the FIR filter. It
actually falls under the category of Multirate Signal Processing. Conceptually,
what you want to do is to have several cascaded filters. For example, the first
filter set separates the high and the low frequencies. These are then followed
by other filter sets that further separate the signal into high and low
components.
After N stages, you have 2^N frequency bins. Now, it is not intuitively obvious
but you can SIGNIFICANTLY reduce the computation by decimating the lower
frequencies.
(The intuitive belief is that decimation introduces aliasing, and it will if the
filters are not designed correctly.) If you're interested in the theory, check
out:
Advanced Digital Signal Processing
Zelniker and Taylor
ISBN: 0-8247-9145-2
Don't let the word "Advanced" in the title scare you. If you know anything about
DSP, this book is very readable. If you don't know anything about DSP, then you
have a right to be scared.
> How often do you have to sample the bands? I think the PIC could easily
handle
> a software digital filter and look at one frequency band at a time. Since you
> don't need a really sharp bandpass, you could probably use a FIR and minimize
> instability problems arising from coefficient quantization in an IIR.
>
> BTW - Does anyone know of good, inexpensive filter design software that
handles
> coefficient quantization to 8 and 16 bits?
>
> - Mark Sullivan -
>
Get DSPlay. It's free and it generates FIR and IIR coefficients, along
with the C function to implement them.
> I'm trying to do a audio spectrum analizer using a 16C73 and the only
> problem I have is how to measure the amplitude of the incoming signal.
> I have to measure the amplitude at 32Hz, 64Hz, 125Hz, 250Hz, 500Hz,
> 1000Hz, 2000Hz, 4000Hz, 8000Hz and 16000Hz.
> I don't want to do a separate bandpass filter for each frequency, I just
> want to dos this by software.
> Does any one have any ideas?
Exar make a fange of chips with bandpass filters, peak detectors and
built in MUX and ADC with serial control, you might want to drop one
of those in and get it over with.
Cheers
--
Do any of my posts make it to the list ???
--
Kalle Pihlajasaari kalleKILLspamdata.co.za
Interface Products Box 15775, Doornfontein, 2028, South Africa
+27 (11) 402-7750 Fax: +27 (11) 402-7751
At 10:00 AM 7/17/96, Kalle Pihlajasaari wrote:
>Hi Octavio,
>
>> I'm trying to do a audio spectrum analizer using a 16C73 and the only
>> problem I have is how to measure the amplitude of the incoming signal.
>> I have to measure the amplitude at 32Hz, 64Hz, 125Hz, 250Hz, 500Hz,
>> 1000Hz, 2000Hz, 4000Hz, 8000Hz and 16000Hz.
>> I don't want to do a separate bandpass filter for each frequency, I just
>> want to dos this by software.
>> Does any one have any ideas?
>
>Exar make a fange of chips with bandpass filters, peak detectors and
>built in MUX and ADC with serial control, you might want to drop one
>of those in and get it over with.
>
>Cheers
>--
>Do any of my posts make it to the list ???
yes, but you don't see them.
Have you considered learning a little DSP with TI's $99.00 320 demo board?
I seen ads all over but haven't made that leap yet.
Dr. Craig Hollabaugh
Wireless Scientific, Inc.
1890 South 14th Street
Building 100, Suite 105
Amelia Island, FL 32034
904 261 6977
904 261 2129 fax .....wsciKILLspam.....net-magic.net