If you search for VU meter you will find examples of what you are working on.
With out a PIC the two attached pictures show an analog way of getting average and peak readings.
The rectifier is:
if MSB is 1 then shift left to remove that bit.
if MSB is 0 then compliment number +1 then shift left.
The peak detector (analog version):
The meter moves up at a rate set by R18 & C5. (fast)
The meter moves down at a rate set by R17+R18 & C5. (slow)
In software:
If the output of the rectifier > than the meter reading then (meter-rectifier)/x add to meter.
If rectifier is < meter then meter=meter-y.
Where y is a small number that will move the meter from full scale to 0 in about 600mS.
Where x sets the response time. (moving up)
There are several companies (THAT CORP and National see LM3915/16.) that have applications notes on the response of of VU meters. A typical test is to inject a 5khz tone for 10mS then stop. The meter should reach near full scale in 1.7mS and decay in 660mS.
My first try at a VU meter is attached. R2,3 set the input at 1/2 supply.
C1 blocks DC. 1/(2*2.14*50k*C1)=20hz set lowest frequency of intrest.
R1 & C2 makes a low pass filter to block information above 20khz.
R1 is to limit the current going into the PIC if the signal gets above 5 volts or below 0 volts. Could be 1k.
There is several better ways of setting the DC input of the ADC to 2.5 volts. More later.
Bookmarks