For boards with STM32G431, the ADC2 is used for fast current measurement,
synchronized with the half bridge switching PWM.
With this change, the ADC2 is triggered in the center of high-side
MOSFET ON signal using a second PWM output of TIM1.
The reason is that the voltage disconnect thresholds used in the load outputs
need to be multiplied with number of batteries aswell. As the DcBus class
should contain all voltage-relevant information, it is the right place for the
multiplier.
The binding .yaml was forgotten in previous charge pump commit. CONFIG_PWM was
moved from prj.conf to board_defconfig as not all boards need the PWM driver.
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 battery is only full if the topping voltage is still reached AND the
current is below cut-off threshold at the same time. This was not always
detected correctly with previous 2s target voltage monitoring interval.
In addition to that, a new timer was introduced to count seconds at target
voltage and improve full charge detection due to timeout.
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.
First step of unifying different ports connected to one bus. At a later
step, also the load and charger classes should inherit from PowerPort
class to make overall charge controller structure more clean.
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.
So far, only publishing messages are supported (no RX yet).
Logging is switched on again, but with minimal output only (suitable
for small F0 MCUs). CAN is activated by default for MPPT 2420 LC.
Indentations of class definitions and preprocessor statements were not
uniform throughout the code. This commit cleans up indentations as well
as the order of include statements.
Style conventions see: https://github.com/LibreSolar/coding-style