Reduce the solar threshold so that we're at the point where the SSR can
work properly. i.e. we're at first light.
The battery can discharge for an hour or two at this point, which will
give it a break from the charger just before sunrise. This may trigger
the other charge controller to charge the battery during the day.
Drop the battery voltage just a fraction so we are past the "knee" of
the discharge curve at 12.8V.
At night, we probably don't want to just hammer the batteries with 14.4V
all the time. If we switch to "solar mode", that'll give the batteries
a bit of a break from the charger.
Before when blinking LEDs I just XORed a bit-mask, that turns out to be
unwise as they blinked out of phase which was just annoying, but it is
still useful to have that "flashing" state to draw your attention to a
problem or to indicate a state.
- We use a single 8-bit register to hold things like the blink phase
(which is XORed each cycle), and whether we have checked the ADCs.
- Temperature LEDs blink when fan is in "kick-start" state.
- Battery voltage LED now has three states:
- On: battery is above minimum voltage (good)
- Off: battery is low
- Blinking: battery is critical (bad)
- In "solar" mode, mains charger LED will blink if we are in the
"waiting for low voltage timeout" sub-state.
- Re-introduce the "critically low" threshold which kick-starts the
charger immediately (like the "low" threshold does now).
- Add a charging time so we consider the charger to be "charging" for
`T_CHARGE_S` seconds, then check to see the battery has reached the
float voltage.
- Delay starting the charger until the battery has been low for
`T_LOW_S` seconds to prevent the charger flapping in and out.
- Re-work the state machines so charging and discharging uses the same
timer.
- Drop the minimum voltage down a touch so we're not flapping the mains
charger in unnecessarily.
- Halve the boost time so that the sun has a better chance of keeping
the battery up.
Raise battery minimum voltage threshold to account for inaccuracy in the
ADC readings (which can be as much as 500mV). Lower the solar threshold
so that it doesn't flap when clouds pass over.
- Thermal setpoint: the SOIC version of the microcontroller reads a
little higher than the DIP version, so make it a little more
forgiving.
- Delta voltage can be a more forgiving too.
By incrementing the battery voltage on compare, we ensure we are seeing
a steadily increasing voltage. If we're not seeing that, then we flag
the warning.
If the charge isn't rising, we should wait before acting on it in case
it is temporary in nature.
It was hoped that the charger delay should be enough, but it seems it
still can flap. We reset the warning if we see an improvement, or let
the timer expire if we don't.
If the charger is doing a bulk charge, it'll likely be dumping high
current into the battery, resulting in a high voltage appearing at the
terminals.
We don't want to disturb this… we want to wait until the charger thinks
it's done, which it signifies by turning off. We should see the voltage
drop back and continue falling. If we're above our "high" threshold at
this point, *then* we might consider leaving it off.
After some thought, the original code isn't going to do what is needed.
The following image is a re-design of the firmware having re-assessed
the requirements.
We should delay our shutdown in case the charger decides to ramp down
itself. Otherwise we can get the situation where a smart charger starts
high, tripping the high threshold immediately, leading to the controller
and charger oscillating between on and off.
This will get copied over to setpoints.h, where the developer can
customise them. If they do so, and I have to change things, the
Makefile will warn them of this.
It appears the minimum PWM is more strongly dependent on battery voltage
than I had planned, it needs to be just a little higher to ensure the
fan keeps turning at low RPM.
- Adjust the calculations so that we base our initial PWM at 0 then
clamp to minimum PWM
- Implement a fan kick-start mode
- Start with fan off so kick-start mode works