Use Sphinx for documentation

This change makes the API documentation look much nicer.

Also build instructions were moved from README to docs.
This commit is contained in:
Martin Jäger
2021-12-16 15:54:05 +01:00
parent ce90f7710b
commit 4568267288
38 changed files with 527 additions and 2853 deletions
+34
View File
@@ -0,0 +1,34 @@
name: Documentation
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0 # necessary to get tags
- name: Install dependencies
run: |
sudo apt install -y git make python3 python3-pip doxygen graphviz
pip3 install -r docs/requirements.txt
- name: Build documentation
run: |
cd docs
make html
- name: Deploy to gh-pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/build/html/
enable_jekyll: false
allow_empty_commit: false
force_orphan: true
publish_branch: gh-pages
-28
View File
@@ -1,28 +0,0 @@
name: Documentation
on:
push:
branches: [ main ]
jobs:
build-documentation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Doxygen Action
uses: mattnotmitt/doxygen-action@v1.1.0
with:
doxyfile-path: ./Doxyfile
working-directory: .
- name: GH Pages Deployment
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./html/
enable_jekyll: false
allow_empty_commit: false
force_orphan: true
publish_branch: gh-pages
-2536
View File
File diff suppressed because it is too large Load Diff
+5 -178
View File
@@ -14,185 +14,12 @@ Releases are created from `main` after significant updates have been introduced
A release is tagged with a version number consisting of the release year and a release count for that year (starting at zero). For back-porting of bug-fixes, a branch named after the release followed by `-branch` is created, e.g. `v21.0-branch`.
## Supported devices
## Documentation
The software is configurable to support different charge controller PCBs with STM32F072, low-power STM32L072 or most recent STM32G431 MCUs:
The firmware documentation including build instructions and API reference can be found under [libre.solar/charge-controller-firmware](https://libre.solar/charge-controller-firmware/).
| Board | Default revision | Older revisions |
|-----------------------------------------------------|------------------|-----------------|
| [Libre Solar MPPT 2420 HC](https://github.com/LibreSolar/mppt-2420-hc) | 0.2 | 0.1 |
| [Libre Solar MPPT 2420 LC](https://github.com/LibreSolar/mppt-2420-lc) | 0.10 | |
| [Libre Solar MPPT 1210 HUS](https://github.com/LibreSolar/mppt-1210-hus) | 0.7 | 0.4 |
| [Libre Solar PWM 2420 LUS](https://github.com/LibreSolar/pwm-2420-lus) | 0.3 | 0.2 |
In order to build the documentation locally you need to install Doxygen, Sphinx and Breathe and run `make html` in the `docs` folder.
## Workspace initialization
## License
This guide assumes you have already installed the Zephyr SDK and the `west` tool according to the [Zephyr documentation](https://docs.zephyrproject.org/latest/getting_started/).
Below commands initialize a new workspace and pull all required source files:
```bash
# create a new west workspace and pull the charge controller firmware
west init -m https://github.com/LibreSolar/charge-controller-firmware west-workspace
cd west-workspace/charge-controller-firmware
# pull Zephyr upstream repository and modules (may take a while)
west update
```
Afterwards, most important folders in your workspace will look like this:
```
west-workspace/ # contains .west/config
│
├── charge-controller-firmware/ # application firmware repository
│ ├── app/ # application source files
│ ├── boards/ # board specifications
│ ├── tests/ # unit test source files
│ └── west.yml # main manifest file
│
├── modules/ # modules imported by Zephyr and CC firmware
|
├── tools/ # tools used by Zephyr
│
└── zephyr/ # upstream Zephyr repository
```
If you already have a west workspace set up (e.g. for other Libre Solar firmware), you can also re-use it to avoid having many copies of upstream Zephyr and modules:
```bash
# go to your workspace directory
cd your-zephyr-workspace
# pull the charge controller firmware
git clone https://github.com/LibreSolar/charge-controller-firmware
cd charge-controller-firmware
# re-configure and update the workspace
# (to be done each time you switch between applications in same workspace)
west config manifest.path charge-controller-firmware
west update
```
## Building and flashing the application
As the `main` branch may contain unstable code, make sure to select the desired release branch (see GitHub for a list of releases and branches):
```
git switch <your-release>-branch
west update
```
The `app` subfolder contains all application source files and the CMake entry point to build the firmware, so we go into that directory first.
```
cd app
```
Initial board selection (see `boards` subfolder for correct names):
```
west build -b <board-name>@<revision>
```
The appended `@<revision>` specifies the board version according to the above table. It can be omitted if only a single board revision is available or if the default (most recent) version should be used. See also [here](https://docs.zephyrproject.org/latest/application/index.html#application-board-version) for more details regarding board revision handling in Zephyr.
Flash with specific debug probe (runner), e.g. J-Link:
```
west flash -r jlink
```
## Firmware customization
This firmware is developed to allow easy customization for individual use-cases. Below options based on the Zephyr devicetree and Kconfig systems try to allow customization without changing any of the files tracked by git, so that a `git pull` does not lead to conflicts with local changes.
### Hardware-specific changes
In Zephyr, all hardware-specific configuration is described in the [devicetree](https://docs.zephyrproject.org/latest/guides/dts/index.html).
The file `boards/arm/board_name/board_name.dts` contains the default devicetree specification (DTS) for a board. It is based on the DTS of the used MCU, which is included from the main Zephyr repository.
In order to overwrite the default devicetree specification, so-called overlays can be used. An overlay file can be specified via the west command line. If it is stored as `board_name.overlay` in the `zephyr` subfolder, it will be recognized automatically when building the firmware for that board (also with PlatformIO).
### Application firmware configuration
For configuration of the application-specific features, Zephyr uses the [Kconfig system](https://docs.zephyrproject.org/latest/guides/kconfig/index.html).
The configuration can be changed using `west build -t menuconfig` command or manually by changing the prj.conf file (see `Kconfig` file for possible options).
Similar to DTS overlays, Kconfig can also be customized per board. Create a folder `zephyr/boards` and a file `board_name.conf` in that folder. The configuration from this file will be merged with the `prj.conf` automatically.
#### Change the battery type
By default, the charge controller is configured for maintainance-free VRLA gel battery (`CONFIG_BAT_TYPE_GEL`). Possible other pre-defined options are `CONFIG_BAT_TYPE_FLOODED`, `CONFIG_BAT_TYPE_AGM`, `CONFIG_BAT_TYPE_LFP`, `CONFIG_BAT_TYPE_NMC` and `CONFIG_BAT_TYPE_NMC_HV`.
The number of cells is automatically selected by Kconfig to get 12V nominal voltage. It can also be manually specified via `CONFIG_BAT_NUM_CELLS`.
To compile the firmware with default settings for 12V LiFePO4 batteries, add the following to `prj.conf` or the board-specific `.conf` file:
```
CONFIG_BAT_TYPE_LFP=y
CONFIG_BAT_NUM_CELLS=4
```
#### Configure serial for ThingSet protocol
By default, the charge controller uses the serial interface in the UEXT connector for the [ThingSet protocol](https://libre.solar/thingset/). This allows to use WiFi modules with ESP32 without any firmware change.
Add the following configuration if you prefer to use the serial of the LS.one port or the additional debug RX/TX pins present on most boards:
```
CONFIG_UEXT_SERIAL_THINGSET=n
```
To disable regular data publication in one-second interval on ThingSet serial at startup add the following configuration:
```
CONFIG_THINGSET_SERIAL_PUB_DEFAULT=n
```
### Custom functions (separate C/C++ files)
If you want experiment with some completely new functions for the charge controller, new files should be stored in a subfolder `src/custom`.
To add the files to the firmware build, create an own CMakeLists.txt in the folder and enable the Kconfig option `CONFIG_CUSTOMIZATION`.
If you think the customization could be relevant for others, please consider sending a pull request. Integrating features into the upstream charge controller firmware guarantees that the feature stays up-to-date and that it will not accidentally break after changes in the original firmware.
## API documentation
The documentation auto-generated by Doxygen can be found [here](https://libre.solar/charge-controller-firmware/).
## Conformance testing
We are using Travis CI to perform several checks for each commit or pull-request. In order to run
the same tests locally (recommended before pushing to the server) use the script `check.sh` or ` check.bat` in the `scripts` folder:
bash scripts/check.sh # Linux
cmd scripts\check.bat # Windows
### Unit-tests
Core functions of the firmware are covered by unit-tests (located in `tests` directory). Build and run the tests with the following command:
cd tests
west build -p -b native_posix -t run
## Additional firmware documentation (docs folder)
- [Charge controller basic concepts](docs/charger-concepts.md)
- [Firmware module overview](docs/module-overview.md)
## Troubleshooting
### Errors with STM32L072 MCU using OpenOCD
The standard OpenOCD settings sometimes fail to flash firmware to this MCU, which is used in the MPPT 1210 HUS and the PWM charge controller.
Try one of these workarounds:
1. Change OpenOCD settings to `adapter_khz 500` in `openocd-path/scripts/target/stm32l0.cfg`.
2. Use other tools or debug probes such as [STM32CubeProgrammer](https://www.st.com/en/development-tools/stm32cubeprog.html) or [Segger J-Link](https://www.segger.com/products/debug-probes/j-link/).
This firmware is released under the [Apache-2.0 License](LICENSE).
+3
View File
@@ -11,6 +11,9 @@
* @file
*
* @brief DC/DC buck/boost control functions
*
* High-level functions to control the DC/DC converter. This module does not directly access any
* hardware. The PWM signal for the half bridge is generated in a separate module.
*/
#include <stdint.h>
+3
View File
@@ -13,6 +13,9 @@
* @file
*
* @brief PWM timer functions for half bridge of DC/DC converter
*
* Generates the synchronous PWM signal for the half bridge in the DC/DC converter. Depending on
* the MCU, either the advanced timer TIM1 or the basic timer TIM3 is used.
*/
/**
+3
View File
@@ -12,6 +12,9 @@
*
* @brief
* Control of status LEDs with charlieplexing
*
* Provides higher-level access to different LEDs (e.g. blinking and flickering). Internally,
* charlieplexing is used for some boards to optimize power consumption and needed pin numbers.
*/
#ifdef __cplusplus
+2
View File
@@ -11,6 +11,8 @@
* @file
*
* @brief PWM charger MOSFET switch control functions
*
* Only used for PWM solar charge controllers.
*/
#include <stdbool.h>
+12
View File
@@ -0,0 +1,12 @@
# Doxygen configuration
#
# Only contains most important options, as HTML rendering is done by Sphinx
INPUT = ../app/src
OUTPUT_DIRECTORY = build/doxygen
RECURSIVE = YES
GENERATE_HTML = NO
GENERATE_LATEX = NO
GENERATE_XML = YES
GENERATE_TREEVIEW = YES
ENABLE_PREPROCESSING = NO
+25
View File
@@ -0,0 +1,25 @@
# SPDX-License-Identifier: Apache-2.0
#
# Makefile to build documentation using Doxygen, Sphinx and Breathe
BUILDDIR = build
SPHINXBUILD = sphinx-build
SPHINXOPTS = -j auto
SPHINX_INSTALLED := $(shell command -v $(SPHINXBUILD) 2> /dev/null)
ifndef SPHINX_INSTALLED
$(error '$(SPHINXBUILD)' executable was not found. Please install from https://www.sphinx-doc.org)
endif
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(SPHINXOPTS) .
.PHONY: clean html
html:
mkdir -p build/doxygen
doxygen
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
clean:
rm -rf $(BUILDDIR)/*
+40
View File
@@ -0,0 +1,40 @@
from datetime import datetime
from pathlib import Path
import os
extensions = [
"breathe",
]
# Project
project = "Charge Controller"
author = "The Libre Solar Project"
year = datetime.now().year
copyright = f"{year} {author}"
version = os.popen("git describe --tags --abbrev=0").read()
# HTML output
html_theme = "sphinx_rtd_theme"
html_theme_options = {
"collapse_navigation": False,
"style_nav_header_background": "#005e83",
}
html_static_path = ["static"]
html_logo = "static/images/logo.png"
html_context = {
"display_github": True,
"github_user": "LibreSolar",
"github_repo": "charge-controller-firmware",
"github_version": "main/docs/",
}
html_favicon = "static/images/favicon.ico"
# Breathe
breathe_projects = {"app": "build/doxygen/xml"}
breathe_default_project = "app"
breathe_domain_by_extension = {"h": "cpp", "c": "c"}
breathe_default_members = ("members", )
+51
View File
@@ -0,0 +1,51 @@
====================================================
Libre Solar Charge Controller Firmware Documentation
====================================================
This documentation describes the firmware based on `Zephyr RTOS`_ for different Libre Solar MPPT/PWM
Charge Controllers.
The firmware is under ongoing development. Most recent version can be found on
`GitHub <https://github.com/LibreSolar/charge-controller-firmware>`_.
This documentation is licensed under the Creative Commons Attribution-ShareAlike 4.0 International
(CC BY-SA 4.0) License.
.. image:: static/images/cc-by-sa-centered.png
The full license text is available at `<https://creativecommons.org/licenses/by-sa/4.0/>`_.
.. _Zephyr RTOS: https://zephyrproject.org
.. toctree::
:caption: Overview
:hidden:
src/overview/features
src/overview/supported_hardware
src/overview/charger_concepts
.. toctree::
:caption: Development
:hidden:
src/dev/workspace_setup
src/dev/building_flashing
src/dev/customization
src/dev/unit_tests
src/dev/troubleshooting
.. toctree::
:caption: API Reference
:hidden:
src/api/bat_charger
src/api/daq
src/api/data_objects
src/api/dcdc
src/api/device_status
src/api/half_bridge
src/api/load
src/api/power_port
src/api/pwm_switch
src/api/misc
-81
View File
@@ -1,81 +0,0 @@
# Firmware modules
## Data Acquisition
Files: daq*.h/cpp
Handles current and voltage measurement through the ADC with direct memory access (DMA). As a reference for current measurement, a digital-analog-converter (DAC) is used and also configured in this module.
The measurements are filtered and afterwards stored in the different sub-component objects.
## DC/DC converter
Files: dcdc.h/cpp
High-level functions to control the DC/DC converter. This module does not directly access any hardware. The PWM signal for the half bridge is generated in a separate module (see below).
## Data Objects for ThingSet protocol
Files: data_objects.h/cpp
The charge controller uses the [ThingSet protocol](https://thingset.github.io/) for communication with external devices. Internal data that should be exposed via the protocol is defined in the Data Objects module.
## Device status
Files: device_status.h/cpp
Stores global error flags and system-level measurements that are not specific to one sub-component.
## EEPROM
Files: eeprom.h/cpp
Stores data in ThingSet protocol format in the internal or external EEPROM (depending on the board).
## Half bridge
Files: half_bridge.h/cpp
Generates the synchronous PWM signal for the half bridge in the DC/DC converter. Depending on the MCU, either the advanced timer TIM1 or the basic timer TIM3 is used.
## LEDs
Files: leds.h/cpp
Provides higher-level access to different LEDs (e.g. blinking and flickering). Internally, charlieplexing is used to optimize power consumption and needed pin numbers.
## Load Output
Files: load*.h/cpp
Load output and USB charging output functions. Hardware-access is defined in load_drv.cpp file.
## Power Port and DC bus
Files: power_port.h/cpp
Contains DcBus and PowerPort classes. See [charger concepts](charger-concepts.md) for further details.
## PWM Switch
Files: pwm_switch.h/cpp
Only used for PWM solar charge controllers. This module is currently not yet separated into hardware-level and high-level functions.
## Timer configuration in mbed firmware
- mbed us_ticker (cannot be changed)
- TIM2 for STM32F0
- TIM21 for STM32L0
- PWM generation for DC/DC half bridge (50-70 kHz)
- TIM1 for STM32F0 (advanced timer)
- TIM3 for STM32L0 (standard timer)
- ADC and DMA (1 kHz)
- TIM15 for STM32F0
- TIM6 for STM32L0
- DC/DC control function (10 Hz)
- TIM16 for STM32F0
- TIM7 for STM32L0
- LED light control
- TIM17 for STM32F0
- TIM22 for STM32L0
+5
View File
@@ -0,0 +1,5 @@
breathe
Sphinx<4
sphinx-notfound-page
sphinx-rtd-theme
sphinx-tabs
+5
View File
@@ -0,0 +1,5 @@
Battery Charger
===============
.. doxygenfile:: bat_charger.h
:project: app
+5
View File
@@ -0,0 +1,5 @@
Data Acquisition
================
.. doxygenfile:: daq.h
:project: app
+9
View File
@@ -0,0 +1,9 @@
Data Objects
============
The charge controller uses the [ThingSet protocol](https://thingset.github.io/) for communication
with external devices. Internal data that should be exposed via the protocol is defined in the
Data Objects module.
.. doxygenfile:: data_objects.h
:project: app
+5
View File
@@ -0,0 +1,5 @@
DC/DC converter
===============
.. doxygenfile:: dcdc.h
:project: app
+5
View File
@@ -0,0 +1,5 @@
Device Status
=============
.. doxygenfile:: device_status.h
:project: app
+5
View File
@@ -0,0 +1,5 @@
Half Bridge Driver
==================
.. doxygenfile:: half_bridge.h
:project: app
+5
View File
@@ -0,0 +1,5 @@
Load Output
===========
.. doxygenfile:: load.h
:project: app
+32
View File
@@ -0,0 +1,32 @@
Misc
====
Data Storage
------------
.. doxygenfile:: data_storage.h
:project: app
Hardware
--------
.. doxygenfile:: hardware.h
:project: app
Helper
------
.. doxygenfile:: helper.h
:project: app
LEDs
----
.. doxygenfile:: leds.h
:project: app
Setup
-----
.. doxygenfile:: setup.h
:project: app
+5
View File
@@ -0,0 +1,5 @@
DC Bus and Power Port
=====================
.. doxygenfile:: power_port.h
:project: app
+5
View File
@@ -0,0 +1,5 @@
PWM Switch
==========
.. doxygenfile:: pwm_switch.h
:project: app
+35
View File
@@ -0,0 +1,35 @@
Building and Flashing
=====================
As the ``main`` branch may contain unstable code, make sure to select the desired release branch
(see GitHub for a list of releases and branches):
.. code-block:: bash
git switch <your-release>-branch
west update
The ``app`` subfolder contains all application source files and the CMake entry point to build the
firmware, so we go into that directory first.
.. code-block:: bash
cd app
Initial board selection (see ``boards`` subfolder for correct names):
.. code-block:: bash
west build -b <board-name>@<revision>
The appended ``@<revision>`` specifies the board version according to the above table. It can be
omitted if only a single board revision is available or if the default (most recent) version should
be used. See also
`here <https://docs.zephyrproject.org/latest/application/index.html#application-board-version>`_
for more details regarding board revision handling in Zephyr.
Flash with specific debug probe (runner), e.g. J-Link:
.. code-block:: bash
west flash -r jlink
+89
View File
@@ -0,0 +1,89 @@
Customization
=============
This firmware is developed to allow easy customization for individual use-cases. Below options
based on the Zephyr devicetree and Kconfig systems try to allow customization without changing
any of the files tracked by git, so that a `git pull` does not lead to conflicts with local
changes.
Hardware-specific changes
-------------------------
In Zephyr, all hardware-specific configuration is described in the
`Devicetree <https://docs.zephyrproject.org/latest/guides/dts/index.html>`_.
The file ``boards/arm/board_name/board_name.dts`` contains the default devicetree specification
(DTS) for a board. It is based on the DTS of the used MCU, which is included from the main Zephyr
repository.
In order to overwrite the default devicetree specification, so-called overlays can be used. An
overlay file can be specified via the west command line. If it is stored as ``board_name.overlay``
in the ``app`` subfolder, it will be recognized automatically when building the firmware for that
board.
Application firmware configuration
----------------------------------
For configuration of the application-specific features, Zephyr uses the
`Kconfig system <https://docs.zephyrproject.org/latest/guides/kconfig/index.html>`_.
The configuration can be changed using ``west build -t menuconfig`` command or manually by changing
the prj.conf file (see ``Kconfig`` file for possible options).
Similar to DTS overlays, Kconfig can also be customized per board. Create a folder ``app/boards``
and a file ``board_name.conf`` in that folder. The configuration from this file will be merged with
the ``prj.conf`` automatically.
Change the battery type
"""""""""""""""""""""""
By default, the charge controller is configured for maintainance-free VRLA gel battery
(``CONFIG_BAT_TYPE_GEL``). Possible other pre-defined options are ``CONFIG_BAT_TYPE_FLOODED``,
``CONFIG_BAT_TYPE_AGM``, ``CONFIG_BAT_TYPE_LFP``, ``CONFIG_BAT_TYPE_NMC`` and
``CONFIG_BAT_TYPE_NMC_HV``.
The number of cells is automatically selected by Kconfig to get 12V nominal voltage. It can also
be manually specified via ``CONFIG_BAT_NUM_CELLS``.
To compile the firmware with default settings for 12V LiFePO4 batteries, add the following to
``prj.conf`` or the board-specific ``.conf`` file:
.. code-block:: bash
CONFIG_BAT_TYPE_LFP=y
CONFIG_BAT_NUM_CELLS=4
Configure serial for ThingSet protocol
""""""""""""""""""""""""""""""""""""""
By default, the charge controller uses the serial interface in the UEXT connector for the
`ThingSet protocol <https://libre.solar/thingset/>`_. This allows to use WiFi modules with ESP32
without any firmware change.
Add the following configuration if you prefer to use the serial of the additional debug RX/TX pins
present on many boards:
.. code-block:: bash
CONFIG_UEXT_SERIAL_THINGSET=n
To disable regular data publication in one-second interval on ThingSet serial at startup add the
following configuration:
.. code-block:: bash
CONFIG_THINGSET_SERIAL_PUB_DEFAULT=n
Custom functions (separate C/C++ files)
---------------------------------------
If you want experiment with some completely new functions for the charge controller, new files
should be stored in a subfolder ``src/custom``.
To add the files to the firmware build, create an own CMakeLists.txt in the folder and enable the
Kconfig option ``CONFIG_CUSTOMIZATION``.
If you think the customization could be relevant for others, please consider sending a pull request.
Integrating features into the upstream charge controller firmware guarantees that the feature stays
up-to-date and that it will not accidentally break after changes in the original firmware.
+19
View File
@@ -0,0 +1,19 @@
Troubleshoting
==============
This page contains a collection of often encountered issues and solutions.
Errors with STM32L072 MCU using OpenOCD
---------------------------------------
The standard OpenOCD settings sometimes fail to flash firmware to this MCU, which is used in the
MPPT 1210 HUS and the PWM charge controller.
Try one of these workarounds:
1. Change OpenOCD settings to ``adapter_khz 500`` in ``openocd-path/scripts/target/stm32l0.cfg``.
2. Use other tools or debug probes such as `STM32CubeProgrammer`_ or `Segger J-Link`_.
.. _STM32CubeProgrammer: https://www.st.com/en/development-tools/stm32cubeprog.html
.. _Segger J-Link: https://www.segger.com/products/debug-probes/j-link/
+22
View File
@@ -0,0 +1,22 @@
Unit Tests
==========
Core functions of the firmware are covered by unit-tests (located in ``tests`` directory). Build
and run the tests with the following command:
.. code-block:: bash
cd tests
west build -p -b native_posix -t run
Conformance testing
-------------------
We are using Continuous Integration to perform several checks for each commit or pull-request. In
order to run the same tests locally (recommended before pushing to the server) use the script
``check.sh`` or ``check.bat`` in the ``scripts`` folder:
.. code-block:: bash
./scripts/check.sh # use check.bat on Windows
+52
View File
@@ -0,0 +1,52 @@
Workspace Setup
===============
This guide assumes you have already installed the Zephyr SDK and the ``west`` tool according to the
`Zephyr documentation <https://docs.zephyrproject.org/latest/getting_started/>`_.
Below commands initialize a new workspace and pull all required source files:
.. code-block:: bash
# create a new west workspace and pull the charge controller firmware
west init -m https://github.com/LibreSolar/charge-controller-firmware west-workspace
cd west-workspace/charge-controller-firmware
# pull Zephyr upstream repository and modules (may take a while)
west update
Afterwards, most important folders in your workspace will look like this:
.. code-block:: bash
west-workspace/ # contains .west/config
│
├── charge-controller-firmware/ # application firmware repository
│ ├── app/ # application source files
│ ├── boards/ # board specifications
│ ├── tests/ # unit test source files
│ └── west.yml # main manifest file
│
├── modules/ # modules imported by Zephyr and CC firmware
|
├── tools/ # tools used by Zephyr
│
└── zephyr/ # upstream Zephyr repository
If you already have a west workspace set up (e.g. for other Libre Solar firmware), you can also
re-use it to avoid having many copies of upstream Zephyr and modules:
.. code-block:: bash
# go to your workspace directory
cd your-zephyr-workspace
# pull the charge controller firmware
git clone https://github.com/LibreSolar/charge-controller-firmware
cd charge-controller-firmware
# re-configure and update the workspace
# (to be done each time you switch between applications in same workspace)
west config manifest.path charge-controller-firmware
west update

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

@@ -1,6 +1,8 @@
# Charge controller concepts
Charger Concepts
================
## Bus and port structure
Bus and port structure
----------------------
In order to handle multiple different types of charge controllers, the power flow in the charge controller is abstracted using the two base components DC bus and Power Port:
@@ -10,34 +12,42 @@ In order to handle multiple different types of charge controllers, the power flo
The following image gives an overview of the maximum set of features for a charge controller currently considered in the firmware. It contains two DC buses: High-voltage side (typically solar panel or wind turbine) and low-voltage side (typically determined by battery voltage). Most of the power ports are connected at the low voltage side (12V or 24V).
![Charger controller bus and port structure](images/charge-controller-structure.svg)
.. image:: charge-controller-structure.svg
:alt: Charger controller bus and port structure
The image also shows the direction of positive current flow.
## Charger state machine
Charger state machine
---------------------
For general information about battery charging, please check out the [battery chapter at learn.libre.solar](https://learn.libre.solar/system/battery.html#charge-methods).
The charger module in the firmware has the following states:
### 0. Standby
0. Standby
""""""""""
Initial state of the charge controller. If the solar voltage is high enough and the battery is not full, charging in CC mode is started.
### 1. Bulk stage
1. Bulk stage
"""""""""""""
This first charging stage adds about 70 percent of the stored energy. The battery is charged with a constant current (CC), typically the maximum current the charger can supply. In case of a solar charge controller, this is where the Maximum Power Point Tracking (MPPT) takes place. As a result, the terminal voltage increases until the peak charge voltage limit is reached and topping phase is entered.
### 2. Topping stage
2. Topping stage
""""""""""""""""
During the topping (sometimes also called boost or absorption) the remaining 30 percent of the energy is continued being charged at a constant voltage (CV) while gradually decreasing the charge current until the battery is fully charged.
### 3. Equalization stage
3. Equalization stage
"""""""""""""""""""""
An additional equalization charging is beneficial for flooded lead-acid batteries only. It can be considered as a periodic controlled overcharge that brings the cells to the same charge level and removes the sulphation by increasing the voltage to a higher value than the peak charge voltage limit. The current during equlization is controlled at a very low value.
### 4. Float stage
4. Float stage
""""""""""""""
The float or trickle charging stage is the final phase upon the completion of the absorption or equalization phase which maintains the battery at full charge. During this stage, the charge voltage is reduced and held constant. The current reduces to a very low value.
![Flow-chart of the MPPT charge controller state machine](images/charging-stages.png)
.. image:: charging-stages.png
:alt: Flow-chart of the MPPT charge controller state machine

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

+2
View File
@@ -0,0 +1,2 @@
Features
========
+24
View File
@@ -0,0 +1,24 @@
Supported Hardware
==================
The software is configurable to support different charge controller PCBs with STM32F072, low-power
STM32L072 or most recent STM32G431 MCUs:
+-------------------------------+-----------+---------+-------+
| | | Revisions |
| | +---------+-------+
| Board | MCU | Default | Older |
+===============================+===========+=========+=======+
| Libre Solar `MPPT 2420 HC`_ | STM32G431 | 0.2 | 0.1 |
+-------------------------------+-----------+---------+-------+
| Libre Solar `MPPT 2420 LC`_ | STM32F072 | 0.10 | |
+-------------------------------+-----------+---------+-------+
| Libre Solar `MPPT 1210 HUS`_ | STM32L072 | 0.7 | 0.4 |
+-------------------------------+-----------+---------+-------+
| Libre Solar `PWM 2420 LUS`_ | STM32L072 | 0.3 | 0.2 |
+-------------------------------+-----------+---------+-------+
.. _MPPT 2420 HC: https://github.com/LibreSolar/mppt-2420-hc
.. _MPPT 2420 LC: https://github.com/LibreSolar/mppt-2420-lc
.. _MPPT 1210 HUS: https://github.com/LibreSolar/mppt-1210-hus
.. _PWM 2420 LUS: https://github.com/LibreSolar/pwm-2420-lus
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

-20
View File
@@ -1,20 +0,0 @@
# Zephyr cheat sheet
## West commands
Initial board selection
west build -b <board-name>
Flash with specific debug probe (runner), e.g. J-Link
west flash -r jlink
Report of used memory (RAM and flash)
west build -t rom_report
west build -t ram_report
User configuration using menuconfig
west build -t menuconfig