So, as promised, the re-design of the charge controller. … now under the the influence of a few glasses of wine, so this should be interesting…
As I mentioned in my last post, it was clear that the old logic just wasn’t playing nice with this controller, and that using this controller to maintain the voltage to the nodes below 13.6V was unrealistic.
The absolute limits I have to work with are 16V and 11.8V.
The 11.8V comes from the combination of regulator voltage drop and ATX PSU power range limits: they don’t operate below about 10.8V, if you add 700mV, you get 11.5V … you want to allow yourself some head room. Plus, cycling the battery that deep does it no good.
As for the 16V limit… this is again a limitation of the LDOs, they don’t operate above 16V. In any case, at 16V, the poor LDOs are dropping over 3V, and if the node is running flat chat, that equates to 15W of power dissipation in the LDO. Again, we want some headroom here.
The Xantrex charger likes pumping ~15.4V in at flat chat, so let’s go 15.7V as our peak.
Those are our “extreme” ranges.
At the lower end, we can’t disconnect the nodes, but something should be visible from the system firmware on the cluster nodes themselves, and we can thus do some proactive load shedding, hibernating virtual instances and preparing nodes for a blackout.
Maybe I can add a small 10Mbps Ethernet module to an AVR that can wake the nodes using WOL packets or IPMI requests. Perhaps we shut down two nodes, since the Ceph cluster will need 2/3 up, and we need at least one compute node.
At the high end, the controller has the ability to disconnect the charger.
So that’s worked out. Now, we really don’t want the battery getting that critically low. Thus the time to bring the charger in will be some voltage above the 11.8V minimum. Maybe about 12V… perhaps a little higher.
We want it at a point that when there’s a high load, there’s time to react before we hit the critical limit.
The charger needs to choose a charging source, switch that on, then wait … after a period check the voltage and see if the situation has improved. If there’s no improvement, then we switch sources and wait a bit longer. Wash, rinse, repeat. When the battery ceases to increase in voltage, we need to see if it’s still in need of a charge, or whether we just call it a day and run off the battery for a bit.
If the battery is around 14.5~15.5V, then that’s probably good enough and we should stop. The charger might decide this for us, and so we should just watch for that: if the battery stops charging, and it is at this higher level, just switch to discharge mode and watch for the battery hitting the low threshold.
Thus we can define four thresholds, subject to experimental adjustment:
Symbol | Description | Threshold |
Critical high voltage | 15.7V | |
High voltage | 15.5V | |
Low voltage | 12.0V | |
Critical low voltage | 11.8V |
Now, our next problem is the waiting… how long do we wait for the battery to change state? If things are in the critical bands, then we probably want to monitor things very closely, outside of this, we can be more relaxed.
For now, I’ll define two time-out settings… which we’ll use depending on circumstances:
Symbol | Description | Period |
Low-frequency polling period | 15 sec | |
High-frequency polling period | 5 sec |
In order to track the state, I need to define some variables… we shall describe the charger’s state in terms of the following variables:
Symbol | Description | Initial value |
Last-known battery voltage, set at particular points. | 0V | |
The current battery voltage, as read by the ADC using an interrupt service routine. | 0V | |
Timer delay… a timer used to count down until the next event. | ||
Charging source, an enumeration:
|
0 |
The variable names in the actual code will be a little more verbose and I’ll probably use #defines for the enumeration.
Below is the part-state-machine part-flow-chart diagram that I came up with. It took a few iterations to try and describe this accurately, I was going to use a state machine syntax similar to what my workplace uses, but in the end, found the ye olde flow chart shows it best.
In this diagram, a filled in dot represents the entry point, a dot with an X represents an exit point, and a dot in a circle represents a point where the state machine re-enters the state and waits for the main loop to iterate once more.
You’ll note that for this controller, we only care about one voltage, the battery voltage. That said, the controller will still have temperature monitoring duties, so we still need some logic to switch the ADC channel, throw away dummy samples (as per the datasheet) and manage sample storage. The hardware design does not need to change.
We can use quiescent voltages to detect the presence of a charging source, but we do not need to, as we can just watch the battery voltage rise, or not, to decide whether we need to take further action.
Recent Comments