Commit Graph
80 Commits
Author SHA1 Message Date
Martin Jäger 15ee7d8553 Add VS Code settings and a small intellisense hack 2021-12-12 13:51:49 +01:00
Martin Jäger 46807deb98 Fix duplicate data object IDs (pub section) 2021-11-29 16:20:07 +01:00
Martin Jäger c54d8ebe05 Port unit tests to Zephyr build system 2021-10-05 14:59:39 +02:00
Martin Jäger 9d7bc0e771 Change signedness of some integers to fix warnings 2021-10-05 14:59:39 +02:00
Martin Jäger d107e9d7ab Rename some charger variables
- Float charging is the more correct and more commonly used term compared
  to trickle charging
- Putting voltage at the end of some variable names for more consistency
2021-08-29 16:57:43 +02:00
Martin Jäger a584bf8a7f Restructure data objects, BREAKING backwards compatibility!
This was necessary as some IDs were used that are reserved in spec v0.4.

The also includes some additions to the Python parser script.
2021-08-29 16:53:05 +02:00
Martin Jäger cc1d4267fa Update to ThingSet library v0.4
This includes mostly renaming of functions and data structure.

See thingset.io for details of protocol changes.
2021-08-29 09:54:59 +02:00
Martin Jäger 51e0a3ae82 Rename data_nodes to data_objects and update references
As part of the v0.4 ThingSet spec, data nodes are named objects.
2021-08-04 14:19:57 +02:00
Martin Jäger efc0bc8fdc Update to ThingSet library v0.3 2020-05-06 12:53:26 +02:00
Martin Jäger 6f490df537 Small fix of data object units 2020-05-06 12:53:26 +02:00
Martin Jäger 8380b928df Fix Solar_V data object for PWM CCs 2020-05-06 12:53:26 +02:00
Martin Jäger 8dd576e40e Configure PWM switch driver via DTS
Driver now moved to separate .c file to allow ISR handling in Zephyr.
2020-05-06 12:53:26 +02:00
Martin Jäger ce7f63b888 Introduce generic "outputs" DTS binding
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.
2020-05-06 12:53:26 +02:00
Martin Jäger affaa9d8e8 Move PCB type and version to DTS 2020-05-06 12:53:26 +02:00
Martin Jäger ab504e3dfa DC/DC and PWM switch configuration via DTS
As these settings are clearly hardware-specific, configuration was
moved from Kconfig (hidden symbols) to DTS. New bindings added.
2020-05-06 12:53:26 +02:00
Martin Jäger 2a71d02aeb Move PCB and user config to board Kconfig
Files in src/pcbs/xyz.h are moved to boards/xyz/board.h. User settings from
src/config.h are also configured via Kconfig, so the file is removed.
2020-04-30 10:53:58 +02:00
Martin Jäger daf43fb967 USB charging output control via LoadOutput class
- Introduce new CONFIG_HAS_USB_PWR_OUTPUT
- Improve charger.discharge_control function
- Add battery empty flag
2020-03-02 11:55:38 +01:00
Martin Jäger 1a9c290485 Charger.num_batteries moved to DcBus.series_multiplier
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.
2020-03-01 09:48:35 +01:00
Martin Jäger 651f66616b Add load info variable (combines state and error_flags) 2020-02-29 13:39:34 +01:00
Martin Jäger fa9d15e796 Separate load and USB out, improve state handling
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.
2020-02-21 18:27:36 +01:00
Martin Jaeger 6af8e6d93d Improve load voltage limits setup and update 2020-02-19 14:34:40 +01:00
Martin Jaeger 5f1d76ef74 Dedicated setup.cpp to clean up main.cpp
Also includes update of timestamp calculation in Zephyr.
2020-02-08 11:08:58 +01:00
Martin Jaeger 5dda805dab Zephyr: ThingSet reset function added 2020-02-07 17:24:07 +01:00
Martin Jaeger 43f90eea7c Move voltage control parameters to DcBus class
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.
2020-02-07 12:03:25 +01:00
Martin Jaeger a7d6dbc3b5 Let PWM switch class inherit from PowerPort
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.
2020-02-07 12:00:59 +01:00
Martin Jaeger f0e99cd80f Voltage replaced by DcBus ptr in PowerPort class
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.
2020-02-07 11:55:51 +01:00
Martin Jaeger 3a8103457f Add type-checking to data objects map 2020-01-31 14:50:32 +01:00
Martin Jaeger eed8c9114c Coding style updated/fixed
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
2020-01-28 13:20:01 +01:00
Martin Jaeger 16ca793bb3 Port configuration based on Kconfig implemented 2020-01-06 19:16:44 +01:00
Martin Jaeger 93418fc8c8 Fixed basic nanogrid port implementation
Instead of SOLAR_TERMINAL, GRID_TERMINAL has to be defined in config.h
(see also template).
2019-12-20 14:52:57 +01:00
Martin Jaeger 53ae6d4608 File headers shortened using SPDX-License-Identifier 2019-12-20 11:40:10 +01:00
Martin Jaeger 88148e70cb Initial compiling Zephyr integration 2019-12-20 10:37:50 +01:00
Martin Jaeger f254c77ab6 Refactoring of load control and state machine
- 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
2019-11-11 09:35:26 +01:00
Martin Jaeger 2992cebb81 Fixed internal temperature data output 2019-11-06 10:17:49 +01:00
Martin Jaeger b09f4ca809 More error flags added and defined as output data object 2019-11-01 12:58:31 +01:00
Martin Jaeger 22f9138a15 LogData renamed to DeviceStatus / dev_stat
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.
2019-11-01 09:54:01 +01:00
Martin Jaeger b0e265f3e9 NTC on PCB not used as battery temperature anymore
- 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
2019-10-31 11:22:03 +01:00
Martin Jaeger 975c03affd Load OC/UV recovery settings fixed 2019-10-30 15:13:58 +01:00
Martin Jaeger 68ae3227cc Discharge and load output control improvements
- 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
2019-10-24 16:04:32 +02:00
Martin Jaeger ba10a2882c Fixing load output and improved overvoltage config
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.
2019-10-23 13:16:04 +02:00
Martin Jaeger 42751c83c2 PowerPort member variables renamed
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.
2019-10-23 10:32:48 +02:00
Martin Jaeger f879dc9c5d DC bus integrated into PowerPort class
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.
2019-10-22 18:23:19 +02:00
Martin Jaeger a89ac7ff4b Fixing not working references to bat/solar ports in data_objects 2019-10-21 18:00:27 +02:00
Martin Jaeger b5c7f396e1 PowerPort configuration for different charger types improved
- 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
2019-10-20 17:44:32 +02:00
Martin Jaeger 0399c4e877 PowerPort added to store current independent from DC bus type
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.
2019-10-20 14:52:35 +02:00
Martin Jaeger d7ed3cdd13 STM32 bootloader activation from SW via BOOT0 pin 2019-10-18 17:01:33 +02:00
Martin Jaeger f33146e9de Battery discharging control restructured
- 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
2019-10-16 16:04:21 +02:00
Martin Jaeger cce6e2a9b3 Added main.h for common includes and extern variables 2019-10-16 12:03:49 +02:00
Martin Jaeger 0545131a99 Equalization charging phase added 2019-10-16 10:02:27 +02:00
Martin Jaeger 25e469516c DC/DC control functions cleaned up 2019-10-15 14:00:20 +02:00