I'm not an electrical engineer, so a simple task has me baffled for the last week or so.
I am working on project where I am required to feed a blackbox device with a stable adjustable voltage. The box will be sampling the voltage provided by analog read.
The readings I provide it will be around 1.8 & 3.1V (2 modes of operation) and will be shifting for values of 0.01V to limits of +-0.2 (so in mode1 I need readings of between 1.6 and 2.0 and in mode 2 I need readings between 2.9 and 3.3) This readings will be changing so Vout must reflect the changes in a timely manner.
I am using an Arduino to obtain the data, calculate it to voltage and push out a PWM.
I am using a pro mini, powered by 5V applied to its raw pin which puts the device into 3.3V mode. Thus my Aref and 100% PWM cycle both equal 3.3V
The frequency of PWM is at about 20kHz (I can slightly modify this if required).
I have slapped together another Arduino to act as my signal analyser (as I lack an oscilloscope), with which I am probing the Vout line (it implements an LCD and pushes analogRead data to screen, with some added qualifiers I can make it show me the extreme values of Vout).
So now that I can see what is being spit out I can start working on it. So I read a lot of filters literature, but half of it is not really making sense to me. What I gathered is that I need to implement a lowpass filter to smoothen Vout.
So I tried building a RC filter, selecting C and R values "by luck", trying different combinations and orders of RC filters I can manage to get the Vout swing (initially 3.3-0) down to 3.3-2.7 when targeting 3V. Although better, it is still nowhere near the accuracy I require. (the parts I have on hand just now are a bit limited, so there were a 0.1uC,1/8uC 1uC, a 100uC, a 1500uC, and resistors from 10K down to 0.25K in my tests) IIRC the combination I have set up currently is 100uC/1K 1st order (adding orders was giving me negligible improvements, so I might be misunderstanding that concept)
Further reading has hinted that I might need a bit more than just a filter to deal with this, so far internet's best suggestion seems to be a combination of LM317 as an adjustable regulator and a MOSFET to convert the PWM to a variable resistance.
Figure 37 in the LM317 tech sheet seems like the regulator part I could use for this, but I can't seem to figure out the variable resistance part of what I need.
So my question is twofold as I am assuming I might have gone a wrong direction with this:
Is this the best way to do this? I am trying to keep parts and cost numbers down, so I don't want to go down the whole MOSFET regulator road if it turns out I'm just using an incorrect filter.
How do I do solve this challenge?