> I tried a simple passive RC filter on the A/D input in simulation - this > changes the square wave to a triangular wave (as I remember it should > from analog electronics). Each piece is actually an exponential. The waveform approaches a triangle wave when the RC time constant is large compared to the signal period. > I guess this would in itself improve the > averages because of the rising and falling slopes of the triangular > wave being hit more times than the low (or high) state. I only need to > sample the current about once a second. > > What is your idea for using 2 resistors and two caps ? Two RC filters in series. Filtering 5KHz PWM down to .5Hz average is easy. With a 10,000:1 frequency ratio a single R-C will do very nicely. However, the capacitor would need to be around 30uF with a single 10Kohm resistor. You could use R-C-R-C where R is 4.7Kohm and C is 100nF, then sample every millisecond and low pass filter the rest of the way in software. This has the advantage of a "live" value always available in software without the need to kick off an A/D reading when you need it. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics