I hope this is the right forum, I'm having a bit of a problem.
I'm powering a funduino pro mini using a 3S LiPo battery. I'm using the same battery to power a low resistance load and I need to measure the resistance of the load.
To provide the power to the load I'm using PWM (pin 9) to switch a mosfet via a gate driver. This works well and I can vary the power the load receives.
In order to measure the resistance I'm using a hall effect current sensor (ACS713) with the output of the sensor going straight to an ADC pin. I'm also measuring the voltage across the load using a differential amplifier, the output from this also goes to an ADC pin. As I know V and I it's easy to get R.
Now this works really well so long as the PWM duty cycle is 255. The resistance measured is consistent to within about .005 ohms which is excellent and agrees with my multimeter (same ballpark, my multimeter isn't that good :)).
However as the duty cycle of the PWM drops the voltage measured by the differential amplifier varies more and more wildly.
I'm measuring the battery voltage too using a basic divider.
I take 32 measurements of each, battery V, differential amplifier output and current sensor in turn in a loop then average them and subtract any offset before using them in my calculations. I have set the PWM frequency to ~32KHz. I don't have a scope :(.
Any ideas? I hope my explanation is clear enough.