Open vanceb opened 2 weeks ago
The purpose of the battery monitor in the code is to ensure that the motor driver delivers the requested voltage. For that, it needs to know the current motor driver supply voltage. thus it is correct to measure the voltage after the diode.
However, I can see how a better estimate of the actual battery voltage might be useful in terms of preventing over-discharge. For that purpose it might be worth adding in a diode drop when reporting to the user.
Given all that, I am going to reject the pull request but I would consider one relating to the reporting interface. For a typical rectifier diode at resting currents I would expect the forward drop to be nearer 0.7Volts.
Diode D1 in the standard UKMARS Mazebot protects the system from reverse battery connection. This diode has a forward voltage drop of around 0.9V. This fix includes this voltage drop in the battery voltage calculation to more accurately reflect the actual battery voltage.