simulate this circuit – Schematic created using CircuitLab
I am using the PIC16F1786 in a current transducer to measure 0-1 Amp DC. I use an A/D converter to measure voltage from a Hall Effect and along with some software calculations use the Programmable Switch Mode Controller to produce a 12-bit PWM. Using that PWM to produce a final output of 0-5VDC.
I use software to calibrate two end points at 0 Amp DC input and 1 Amp DC input to create a y = mx + b equation to map my A/D readings from the Hall Effect to my PWM output.
Near my end points of calibration my final output is exactly where I expect it to be, however in between seems to exhibit some nonlinearities. I have double checked my mapping from A/D to PWM and it seems correct.
What I am seeing is, if using my two calibrated end points and I find the exact mid-point I would expect to see exactly (or pretty darn close) to half my Final Output. However, I am seeing between 20-25mV higher than I am expecting. Unfortunately this needs to be a high precision product and this is too large of an error.
Is there any known issues with PWMs being slightly non-linear? Everything from my oscilloscope readings tells me that it is a perfectly square waveform. Or perhaps my Final Output stage may be slightly off? All of my components are 1%, would it be worth trying to use 0.1% resistors?