These variables define the voltage at zero current, which is the y axis
intercept of the droop curve (voltage vs. current).
As they do not always specifiy minimum or maximum boundary depending on
the sign of the droop resistance, intercept is a more suitable name.
Replaces previous "switch" and "pwm-out" bindings and allows to reference
either gpio or pwm handle and specify maximum current.
Also replacing CONFIG_HAS_LOAD and CONFIG_HAS_USB_PWR with DT_ variants.
Identified issues:
- The load output and USB charging port shared the same state machine,
which did not allow to set different switch-off thresholds.
- Load error codes were global, so it was not possible to have multiple
load instances.
This commit introduces load-specific error_flags, makes the LoadOutput
class inherit from PowerPort (to improve code readability), separates
the load driver better from higher level implementation and adds a
second LoadOutput object for the USB charging port.
The sink and source voltage boundaries for droop control and battery
charge voltage management are now part of the DcBus class.
Also added source and sink current margins, which will be used by the
DC/DC for control targets instead of port current limits, which were
difficult to synchronize before.
Preparation to separate current and voltage measurements and control
parameters into DcBus and PowerPort classes. This will help to
manage current from different sources (grid, solar) going towards
one bus and control the battery voltage. It will also help to align
multiple charge controllers in parallel, communicating via CAN bus.
- Alerts now set to +-20% of actual measured voltage
- Hysteresis for load overvoltage reconnect setpoint made configurable
- Added check for PWM switch MOSFET driver undervoltage
- State machine and control merged to one function
- Load states marked as deprecated, global error flags used instead
- Reduced duplicated code and made load control function easier to read
In addition to the normal error flags we now have
ERR_ANY_ERROR which may be used to clear all errors
at once or to use in has_error to see if there is any error flag set.
Rationale: Logging is used for historic data, but error flags are instantaneous data. Device status
is more generic and now contains also the internal temperature measurement.
- MCU temperature was renamed to internal_temperature
- NTC at board edge senses temperatures far above battery / ambient temperature at high loads and is now ignored
- Battery temperature always assumed 25ÂC unless external sensor is detected
- Switched back to older mbed version, as update broke comparator function
- Added voltage dip detection to disconnect load if charge controller is connected to small
battery or with bad wires and short circuit detection doesn't trigger
- Added more error flags to diagnose reasons for load disconnect
- Charge/discharge control in charger class sets global error flags
- Load state machine analyzes error flags to distinguish reasons for switching load off
- Temperature errors now identified correctly (issue #59)
- Delay before load re-connect after low voltage or overcurrent event now configurable
- Unit tests added