I am designing a SMPS (see previous question if curious) and need to provide the mcu with an output feedback voltage to dial in the duty cycle for closed loop control.
Using an Arduino (Leonardo in this case), I am always frustrated with the fluctuation of 'counts' returned from AnalogRead(). I have tried slowing the polling (I only want 50-100ms response), running average software filters, and other software band-aids. The purpose of this question is whether it can be solved in hardware instead so I can tinker and learn a bit.
Version 1 of my circuit looked like this:
The purpose of Resistor R8 was to limit current for the D4 5.1V Zener in case the analog input saw more than 5V so as to not damage the mcu pin. But because it was in series with the analog input, it would create a voltage drop and therefore skew results. As the load resistance varied (potentiometer) so did the voltage across R8 and it was hard to calibrate the analog input in software.
I then began learning about using an op-amp as a buffer instead which has "infinite" input resistance, and therefore whatever series resistor value was chosen would be magnitudes smaller and have minimal effect on the outcome.
Version 2 of my circuit looks like this:
The output is much more stable, but my question is whether I am 'over-doing' it with this circuit?. How do you calculate an RC time constant when the op-amp has infinite resistance? As stated above, I want my response time to be 50-100ms with 20-50mV peak to peak range. I feel like this is certainly doable... Any suggestions or tips and tricks would be suggested.
I am guessing the simplest solution would be a low pass filter with R = 100K and C = 150nF but figured this was a good learning opportunity to explore op-amps too.
PS: the 74LVC2G66 device is what I am using to enable and disable 10K pullup and 10K pulldown resistors for other experiments. When both switches are off, they ~should not effect the series resistance of the analog input.