Working on a project to design a PWM generator that has full-scale accuracy of 0.1%. It is generated by reading a variable voltage from the power supply through a voltage divider and producing an equivalent PWM output. I am filtering the output to measure the average voltage. I'm noticing that my output does not swing within 0.1%. I wonder if there are ways to make the PWM more precise and be able to reach the specs of 0.1% of full-scale?
I am not giving out schematics because they are very basic. What I am asking for is suggestions. I level shift my output with a comparator, then I filter it out to get the DC voltage back. I have succeded in getting a 0.1% FS accuracy. However, this was really a trial and error method, measuring the difference between input and output and adjusting my code accordingly. I don't like this; I much prefer a more systematic method. Maybe I am asking to much, there will just be a difference between thoery and practice.