Commit graph

59 commits

Author SHA1 Message Date
Thomas Kolb e6891aed78 Initialize the addon board 2023-09-16 22:48:41 +02:00
Thomas Kolb 19735ee550 overload: exponential backoff for retry
Whenever overload is detected, the time that must pass before the load is
turned on again is doubled. If the load was on for 5 minutes, the retry time is
reset to the configured value.
2023-06-18 16:43:41 +02:00
Thomas Kolb e8dff1f017 Correct timebase_ms after deep sleep
During deep sleep, the millisecond counter is stopped. To ensure correct delay
times, we add the sleep duration to the counter after wakeup.
2023-06-18 16:18:44 +02:00
Thomas Kolb bd08440584 charge_control: delay overload trigger by a configurable time 2023-06-18 16:18:13 +02:00
Thomas Kolb 2cedcb712a Implement heater control
This change controls a GPIO on the expansion connector depending on the
surrounding temperature. If external temperature is too low for
charging, the GPIO is set high, else it is set low.

In combination with the new LNSC-2420-Addon board this allows to switch
on a high-power heater connected directly to the solar panels whenever
the temperature is too low to charge the battery. Once the temperature
becomes high enough again, the heater is switched off and the battery is
charged instead.
2023-04-22 20:02:16 +02:00
Thomas Kolb 1153da6fc2 config_b26: adjust minimum voltage to 24.5V 2022-11-13 15:05:33 +01:00
Thomas Kolb a140b3ade6 Do not send BMP280 data if invalid 2022-11-13 14:35:34 +01:00
Thomas Kolb 5090b7de4a Try to make BMP280 communication more resilient
If communication times out or a NAK is received, this is now recognized
and sensor values are flagged as invalid. The communication then
restarts on the next regular cycle. This is still to be tested.
2022-11-09 20:47:13 +01:00
Thomas Kolb 4d4cc41b46 fix: actually use the new calibration factors in flash 2022-11-09 20:45:34 +01:00
Thomas Kolb 430b7c73d0 i2c_dma: removed unused include 2022-10-15 21:49:01 +02:00
Thomas Kolb 1cbe0ce410 Prevent deep sleep during BMP280 communication 2022-10-15 21:48:15 +02:00
Thomas Kolb 5c6497fb82 charge_control: block charging if external temperature is too low 2022-10-15 21:44:27 +02:00
Thomas Kolb d7b8c90cb4 Add new temperature thresholds to flash config 2022-10-15 21:42:46 +02:00
Thomas Kolb c807acec11 bmp280: add function to check for valid measurements 2022-10-15 21:41:50 +02:00
Thomas Kolb 07dd91ecc2 bmp280: read out via DMA in the background
This removes any busy waiting on the I²C from the main loop.
Initialization is still done in a blocking way.
2022-10-15 20:49:31 +02:00
Thomas Kolb 055186180f Merge branch 'main' into bmp280 2022-10-15 16:43:36 +02:00
Thomas Kolb 3dcf412a02 BMP280: Crude workaround for detecting chip presence 2022-10-08 21:49:28 +02:00
Thomas Kolb 2f0f6a01f2 Initial BMP280 integration
This version uses only blocking i2c calls, and long transfers will
probably cause frame loss. Also, if no BMP280 is present, the firmware
will not start up and hang in an endless loop instead.
2022-10-08 20:50:08 +02:00
Thomas Kolb 16619397b1 Added script for flash config upload 2022-09-25 17:35:37 +02:00
Thomas Kolb 481cf6f9f4 Use the new flash config module 2022-09-25 17:24:21 +02:00
Thomas Kolb 4ebb231346 Preparations for dedicated configuration flash page 2022-09-25 15:57:05 +02:00
Thomas Kolb 1e093978f3 config: avoid switching between sleep and active state too often
Unfortunately, the offset voltage of the opamp for charge current
measurement breaks measurement at low currents with a small shunt, so at
dusk, when currents become low, it may happen that 0 current is measured
while the battery is still being charged. This would falsely trigger the
transition to sleep state. To improve this situation, we simply keep the
charger active for a longer time.
2022-09-24 16:39:46 +02:00
Thomas Kolb 5528259517 calibration: add development device 2022-09-24 16:28:35 +02:00
Thomas Kolb 2275edb475 Update libopencm3 2022-09-14 21:35:36 +02:00
Thomas Kolb 87ddba7af7 Recalibrate using Voltcraft VC-523SE multimeter 2021-09-19 14:27:39 +02:00
Thomas Kolb 8dd5c8121f Send error state over RS485 2021-09-19 14:21:00 +02:00
Thomas Kolb 6920c548e9 Tune high-voltage charge time and reset voltage 2021-09-19 14:07:26 +02:00
Thomas Kolb 6ff8918e62 Fixed incorrect state transition due to 0-current glitch 2021-09-19 14:06:24 +02:00
Thomas Kolb 716c158716 Discharging: use averaged values for thresholds 2021-07-10 16:38:47 +02:00
Thomas Kolb 0339b521dd charge_control: add extra state to fix initial charging
Before this change, initial charging ended exactly HOLD_TIME after the
CHARGE_INITIAL state was entered. This was usually not sufficient to
reach the INITIAL_FULL voltage. Now a new state is entered once the
INITIAL_FULL voltage is reached.
2021-07-10 16:29:48 +02:00
Thomas Kolb d239a947cd Zero meas_data on startup for consistent behaviour 2021-07-01 21:15:13 +02:00
Thomas Kolb 79fe1113de charge_control: implement voltage transition 2021-07-01 21:10:13 +02:00
Thomas Kolb 49bd9247e0 Average the measurements
The measurement module now provides averaged measurements. These are
used in some places where accuracy is more important than latency (for
example for the temperature limit, where noise triggered the limit too
early).
2021-06-18 23:37:16 +02:00
Thomas Kolb 7ca6104e80 charge_control: refactoring, bug fixes
- Moved shared state transition checks to separate function
- Improved behaviour when the battery is full
2021-06-18 20:25:53 +02:00
Thomas Kolb d9bc181973 Fixed a typo 2021-06-13 14:55:43 +02:00
Thomas Kolb d94b376f00 Update fxplib (only license and documentation changed) 2021-06-13 14:45:34 +02:00
Thomas Kolb 1ad2456c8b Added pinout.txt 2021-06-12 18:45:42 +02:00
Thomas Kolb 7bdb5338a4 Added README and LICENSE documents 2021-06-12 18:40:36 +02:00
Thomas Kolb 62b63efba3 charge_control: first state transition wins 2021-06-12 17:07:16 +02:00
Thomas Kolb add925bba0 Fixed temperature measurement 2021-06-12 16:49:05 +02:00
Thomas Kolb df3211333e Properly shut down peripherals before entering deep sleep
This is most important for the LEDs and the RS485 interface. If any LED
is on when deep sleep is entered, it will stay on the whole sleep time,
drawing about 10 mA on the 3,3V rail.

The RS485 transceiver must be switched to RX mode, as it consumes about
30 mA from the 5V rail in TX mode.
2021-06-12 16:02:21 +02:00
Thomas Kolb 5ceb014d1b Disable RS485 driver and systick before deep sleep
- The RS485 driver consumes about 150 mW if enabled
- The systick somehow can wake up the CPU from stop mode
2021-06-12 16:02:21 +02:00
Thomas Kolb 189ea810d9 deepsleep: use libopencm3 functions instead of register access 2021-06-12 16:02:21 +02:00
Thomas Kolb 98d0c08ec3 First try to implement deep sleep
It sleeps, but never wakes up again. Also it consumes a lot of current
which suspended?!
2021-06-12 16:02:21 +02:00
Thomas Kolb fa71acfc8e main.c: remove unused #includes 2021-06-12 01:12:33 +02:00
Thomas Kolb c76918ae2a Moved clock setup to separate file 2021-06-11 23:55:10 +02:00
Thomas Kolb d2a95c4353 charge_control: removed unused code 2021-06-11 23:52:50 +02:00
Thomas Kolb ed6ac04686 Refactoring: move FSMs to separate functions 2021-06-11 22:51:02 +02:00
Thomas Kolb c504fb944c Call charge_control_init() 2021-06-11 22:35:59 +02:00
Thomas Kolb 1ad35dae2b Print (dis)charge FSM state changes 2021-06-11 22:35:07 +02:00