Commit Graph
65 Commits
Author SHA1 Message Date
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
Martin Jaeger e7317ae1d8 DC bus and terminal naming improved
- 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
2019-10-15 13:57:23 +02:00
Martin Jaeger 4b545fa882 Include git commit hash in ThingSet data objects 2019-08-08 11:19:29 +02:00
Martin Jaeger c968a6bb8a Structs renamed for new coding style (closes #42) 2019-08-08 10:16:16 +02:00
hogthrob 14faa1f0e8 Working CAN (#35)
* 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
2019-06-23 00:41:01 +02:00
hogthrob 7d02c92c7d Fix to move data_objects to flash only (#36)
Without this, the 1296 byte long data_objects is stored in RAM
(after being copied from flash)
2019-06-23 00:32:13 +02:00
hogthrob a4d5243286 Fixed Load_A not correctly reported issue (#34)
At compile time &(load.bus->current) will resolve to a different
(wrong) address than after assignment of "load_bus" to load.bus at runtime.
2019-06-22 12:52:37 +02:00
hoijui 6016c17b14 Minor code improvements from CppCheck & README updates (#32)
* 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
2019-06-22 08:04:32 +02:00
Martin Jaeger 690e204a16 Solar, bat and load power added to data objects 2019-06-18 17:04:33 +02:00
Martin Jaeger 375fcee514 New ThingSet features pub and auth included 2019-06-18 14:20:14 +02:00
Martin Jaeger dec36143dd 12V/24V detection added and bat_charger restructured 2019-05-23 22:16:41 +02:00
Martin Jaeger 7c75548193 DC bus type introduced and unit tests added 2019-05-07 18:56:04 +02:00
Martin Jaeger d9f7103e97 Starting test-driven development (TDD) with Unity
- 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
2019-05-04 11:31:37 +02:00
Martin Jaeger 90666d697b Refactoring of files and function names
- 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
2019-05-03 10:33:49 +02:00
Martin Jaeger 3fbb6df468 ThingSet version updated and data_objects.cpp adjusted 2019-05-02 10:33:02 +02:00
Martin Jaeger 2ac2d1c3ad Basic processer-in-the-loop (PIL) test features added 2019-05-02 10:22:51 +02:00