I'm very tight on board space, so I'm looking at how I can win back some board real estate..
My circuit needs to detect the signal level of an incoming audio stream - at the moment, I use the well trodden path....full wave rectifiying then smooting into a PIC ADC.
But since I have a lot of unused pins on my PIC...and it's not being pushed hard, then why not use some of its latent power to detect signal level? If nothing else, this will help me educate myself about sampling.
The maximuum audio frequency is about 1.5khz...the lowest is about 50Hz, the signal is quite sinusoidal, so to my questions.....
1. To try and catch peak (or close to it), what would be a good sampling frequency? (if it helps, I'm using a PIC16f1828 ...max internal oscillator of 40Mhz) - I'm thinking 10khz?
2. Is this methodology correct....
setup a time to interrupt at a rate of 10khz
in the interrupt routine take an ADC sample into a variable, compare it to the last if it's bigger keep it, if it's smaller ignore it.
run a bit of maths to convert peak voltage to RMS (ie multipy by .0707 using some FP workaround)
Have another timer setup to reset the ADC sample variable every 20ms (ie 50hz the lowest frequency)
Anything I'm missing - or any comments?
Bookmarks