Lorick wrote: > I need to (hopefully) use the 16F876 to sample a sine wave that rides > on a 1.75v reference line, swinging from 0v to 3.5v but before I even > attempt this, I'm thinking it won't work because if an average value > of the sine wave is what's taken over time, then wouldn't I always get > a reading somewhere near that 1.75v reference line? Yes. The *average* value of any pure AC signal is zero, as it spends equal areas under the signal curve in either direction. So if you feed your signal into a low-pass filter, you will get the same voltage with and without signal. Although you say the reference line is 1.75V, it would probably be as well to implement an averaging algorithm to determine exactly what this is as read by the ADC. You probably want the standard FIR (Finite Impulse Response) filter function of adding the current sample to a 16- bit value and subtracting the "current average" which is 1/256 of the current tally. Of course, 1/256 of the current tally is merely the high byte of the tally plus the high bit of the low byte added (or in this case, both are being subtracted from the tally itself) for rounding correction. Now that you know what the "zero level" is, you would prefer to sum the squares of the instantaneous deviation from this level to measure your signal level as a MS (Mean Squares - it's a waste of time to take the square root again as the MS value is a perfectly good indicator). This however is messy as it involves multiplications and at least 24- bit accumulation, presuming you again use a FIR filter to smooth it. Instead, just sum the modulo of the deviation from the average (do the subtract, test the result and negate if presently negative) using the same averaging procedure. For a 1 kHz frequency, sample at approximately 16 k samples per second to get 16 points per cycle and all the mathematics should be easy on a 4 MHz crystal PIC. This method still measures signal plus noise. If you want to filter out the signal at a (one only) precise frequency of 1 kHz, then you need a different technique. -- Cheers, Paul B.