Hi - I believe it is primarily due to the peak detector. For other reasons, I have to use the AVR's A/D with its built-in 1.1 volt reference instead of the 3.3V rail, which would affect accuracy (a little anyway). I also use the A/D on the AVR to read a volume control pot and two different input power voltages, and I have noticed the input power voltage readings are pretty consistent (but not dead on) unit to unit, so I attribute the errors to the peak detector. I haven't looked at it in detail though. Next version will either have automated calibration or (preferably) a respin with a CPLD. And note the peak detect output for a 100hz, 1Khz, 10Khz sinewaves of equal amplitude is not the same. The attack/release of the detector affects everything. I do suggest prototyping this before committing to this design path... make several of the peak detect circuits and see if variability will require calibration for your needs. It just wasn't as simple as it first seemed for my requirements, alas. Good lucks! J David Duffy (AVD) wrote: > Thanks for the reply Jesse. I'm intrigued by the calibration requirement > though. Was the variation in the AVR or the analogue circuitry? Was it > due to the lack of resolution in the A2D? > David... > > Jesse Lackey wrote: >> Hi, I did this with an AVR a year and a half ago. There are some >> niggles. Depending on how accurate you'd like to be, how fast you can >> sample, and the voltage range of the incoming signal, how accurate you >> need to be for 100Hz vs. 1Khz vs. 10Khz frequencies, you may or may not >> need to: >> >> 1. amplify or cut incoming signal to scale to the A/D range >> 2. use a peak detector. I used the precision half-wave rectifier sample >> circuit from the National Semi LM3916 datasheet. >> 3. calibrate for unit-to-unit variation in peak detector output for a >> given input signal level >> 4. do some tweaking of averaging of samples to get a >> reasonably-responsive VU display >> >> The device this was for had small size and power consumption as critical >> parameters, and I decided to do it in firmware. The original plan was >> to sample the internal digital audio stream (it is a mic pre with A/D, a >> specialty portable pro audio thing) but the AVR couldn't do it for 96Khz >> or 192Khz audio sample rates, a mistake I made from not reading the AVR >> datasheet closely enough and no space/time for a CPLD or other external >> helper digital logic. So this was all something of a (successful) hack, >> unfortunately. >> >> I am able to get -30db (relative to about 2.5Vpp fullscale input) >> reliably. But each unit requires calibration, a hassle. >> -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist