26 Commits
Author SHA1 Message Date
Martin Jäger 0756341b29 Rename src/sink_voltage_bound to _intercept
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.
2020-11-05 20:42:00 +01:00
Martin Jäger a584904470 Switch to new DT_ macros 2020-07-23 17:34:39 +02:00
Martin Jäger 81aefff168 Fix load overvoltage control for 24V systems (#96) 2020-05-21 10:09:54 +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 4e6f6c7365 Move thermal model parameters to DTS 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 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 cdb9183c11 Fix load overvoltage limit
The setting is now based on LoadOutput menber overvoltage and not
on the bus voltage bounds, which are used for charging setpoint.
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 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 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 05292c12ba ADC & DMA renamed to DAQ (data acquisition) 2020-01-27 15:13:53 +01:00
Martin Jaeger 41b4607cc7 Fix additional bug in load unit-test 2020-01-20 15:22:21 +01:00
Martin Jaeger 69747a588d Fix initialization bug in load unit-test 2020-01-20 10:41:48 +01:00
Martin Jaeger 53ae6d4608 File headers shortened using SPDX-License-Identifier 2019-12-20 11:40:10 +01:00
Martin Jaeger 47954166be Fine-tuning of battery/load UV/OV alerts
- 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
2019-11-11 11:38:34 +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 328215dc8e Load overvoltage detection corrected and error flag comments added 2019-11-07 16:00:51 +01:00
hogthrob bec02cb25b Switched to use power of 2 error numbers (#72)
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.
2019-11-04 09:19:06 +01:00
hogthrob fd474e5350 Use methods to set/clear/query error flags (#71)
Easier to read, quicker to write (if using code
completion), no performance loss due to inlining.
2019-11-02 08:22:00 +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 cb0c3c8135 USB output state machine improved (see #69) 2019-10-31 16:32:03 +01:00
Martin Jaeger b98461fee4 Load off for internal overtemp implemented 2019-10-31 12:07:21 +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 5b4df98656 Load protection improvements
- 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
2019-10-30 17:31:16 +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