Can you add some numbers what you have? (How much voltage changes under what exact load, what exect batteries do you use, what wires for power lines, etc).
It is not a high value. At 30A it is approximately a 120mV difference, like I said, it changes proportionally with the load and I code it out with the following:
voltageFull = ((Fvoltage * (ValueR1F + ValueR2F)) / ValueR2F) + (Icurrent / ulF);
The part you are interested is the last part: (Icurrent / ulF). ulF = 250 in my code.
Just to clarify, the pwm frequency is 490Hz, not changed from the default on the mcu. The sample rate in which I read all the calculations is 10Hz, 10x a second. The average that is taken is 100x on each input.
So the calculations function averages the sensors 100 times and spits that out 10 times a second. I tried higher averaging without a sample rate, I just let the code loop as fast as it could, but this is a tft touchscreen and I needed to make the touch more responsive.
The wires that carry the load from the battery to the discharger are 10awg wires, the voltage sensing is done on much smaller wires. Maybe 24awg.
Scope output is a DC line. The noise in the reading is the same noise I get with nothing attached. I will admit I have a few things running and it picks up noise just being where it is.
I have changed power sources from switched 14V and 12V to a 8.4V battery. No change in the output.
I am adding a schematic, a 3d view of the schematic, a pic of the actual wiring, output from my scope after the voltage divider and filter, and output at the battery.
This was a 10A load, the duty cycle is low at this load.