Charger Program

The current and voltage measurements are averaged over a minute for the purpose of setting the set point and optional reporting for logging. There are actually two set points to prevent hunting. The algorithm provides maximum current for voltages below "high_volts" tapering linearly down to float current at "float_volts".
Above and below open and short voltages the current is cut off. There are also limits on the duty-cycle.
Each main loop the current measurement is compared to the upper and lower set points. If outside, the duty cycle is changed by 1. This promotes stability.
The charger operates as designed into a resistive test load, with a large capacitor, and also into our RV house battery, which has two large batteries in parallel. However, it has higher than expected currents into the Prius battery, but still works acceptability.

Program