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.
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
- 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
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
- 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
Previous load output expected the battery port as a parameter and checked if
discharging of the battery was allowed. New implementation has own load port
and needs to check if current output (i.e. positive direction) is allowed.
Overvoltage setting is now configured via power port sink_voltage_max.
Previous naming with chg/dis didn't make much sense e.g. for load output or solar panels. Voltage
targets are now named with source or sink. Current limits are defined based on their direction
(negative or positive). ASCII art graphic added for better explanation of passive sign convention.
Reason: Previous idea with storing the voltage only once and not in every port
doesn't work well for droop settings, e.g. the DC/DC output port doesn't know
the actual battery current, which should be used to calculate the droop caued
by wire resistance.
- Solar and battery ports now defined as references to actual hardware ports at very beginning of main.cpp, allowing to use the references also in data_objects.cpp
- Different charger types (PWM / MPPT) are configured more clearly by switching on/off features (DC/DC, PWM switch and load) in PCB configuration
The DC bus type caused issues because current limits could not be defined individually for each
connection to a junction, as described in issue #50.
With this commit, also some structs were converted to C++ classes to improve readibility of the
code and make sure that pointers (e.g. to PowerPort objects) are always assigned during
initialization.
- Discharging control separated from charger state machine
- Unit-tests for discharging control added
- DC bus chg/dis_enabled flags removed, control now only based on chge/dis_current_limit values
- _current_max values renamed to _limit to make more clear that values for discharging direction must be negative
- Load output struct now stores pointer to internal and external DC bus objects
- DcBus representing actual screw terminals renamed
- Internal DC bus at DC/DC low voltage side added for correct DC/DC control
- DC/DC struct now stores pointers to HV and LV bus objects. Redundant voltage and current measurement variables removed.
- Unit tests updated
DC/DC control needs further improvements to make use of the changes
* Minor fix in documentation
* Make CAN compile again
* Now able to disable uart_serial
* Boots and runs CAN
Requires matching thingset-cpp library
The placement of the ts_can.process_asap/process_1s is a little hack,
but I did want to add even more ifdefs in the main method.
Renaming the functions could do the trick.
BTW, serial and CAN thingset can be run at the same time, no problems.
* Some cleanups in the CAN interface
* log.h: fix signature of log_update_min_max_values
looks like it was changed in log.cpp, but not adjusted in log.h,
somewhen in the past
* adc_dma: only define variables if they are really required
* reduce scope of variables in interface_can.cpp
* `changed` was reassigned a value before the old one was used
* README: reformat flashing troubleshooting section
* README: punctuation fixes
* README: add troubleshooting tip for bad connection between nucleo and MPPT
- Using PlatformIO's embedded unit testing with native environment
- mbed-dependent .cpp files escaped with #ifndef UNIT_TEST
- First tests for charger module added under test/ directory
- Files for interfaces connected via UEXT are stored in separate uext/ directory
- UEXT init and process function names independent of connected module
- LED function names adjusted to start with leds_
- main.cpp structure simplified