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
+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
@@ -0,0 +1,582 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="600"
height="170"
viewBox="0 0 158.75 44.97918"
version="1.1"
id="svg5625"
inkscape:version="0.92.4 5da689c313, 2019-01-14"
sodipodi:docname="charge-controller-structure.svg"
inkscape:export-filename="/home/martin/test.png"
inkscape:export-xdpi="200.1694"
inkscape:export-ydpi="200.1694"
style="enable-background:new">
<defs
id="defs5619">
<marker
inkscape:stockid="DotS"
orient="auto"
refY="0"
refX="0"
id="DotS"
style="overflow:visible"
inkscape:isstock="true">
<path
id="path16850"
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
transform="matrix(0.2,0,0,0.2,1.48,0.2)"
inkscape:connector-curvature="0" />
</marker>
<marker
inkscape:stockid="DotM"
orient="auto"
refY="0"
refX="0"
id="DotM"
style="overflow:visible"
inkscape:isstock="true">
<path
id="path16847"
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
transform="matrix(0.4,0,0,0.4,2.96,0.4)"
inkscape:connector-curvature="0" />
</marker>
<marker
inkscape:stockid="DotM"
orient="auto"
refY="0"
refX="0"
id="marker7066-2"
style="overflow:visible"
inkscape:isstock="true">
<path
id="path7064-7"
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
transform="matrix(0.4,0,0,0.4,2.96,0.4)"
inkscape:connector-curvature="0" />
</marker>
<marker
inkscape:stockid="DotM"
orient="auto"
refY="0"
refX="0"
id="marker7066-2-9"
style="overflow:visible"
inkscape:isstock="true">
<path
id="path7064-7-1"
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
transform="matrix(0.4,0,0,0.4,2.96,0.4)"
inkscape:connector-curvature="0" />
</marker>
<marker
inkscape:stockid="DotM"
orient="auto"
refY="0"
refX="0"
id="marker7066-2-7"
style="overflow:visible"
inkscape:isstock="true">
<path
id="path7064-7-0"
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
transform="matrix(0.4,0,0,0.4,2.96,0.4)"
inkscape:connector-curvature="0" />
</marker>
<marker
inkscape:stockid="DotM"
orient="auto"
refY="0"
refX="0"
id="marker7066-2-3"
style="overflow:visible"
inkscape:isstock="true">
<path
id="path7064-7-6"
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
transform="matrix(0.4,0,0,0.4,2.96,0.4)"
inkscape:connector-curvature="0" />
</marker>
<marker
inkscape:stockid="DotM"
orient="auto"
refY="0"
refX="0"
id="marker7066-2-7-6"
style="overflow:visible"
inkscape:isstock="true">
<path
id="path7064-7-0-2"
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
transform="matrix(0.4,0,0,0.4,2.96,0.4)"
inkscape:connector-curvature="0" />
</marker>
<marker
inkscape:stockid="DotM"
orient="auto"
refY="0"
refX="0"
id="marker7066-2-7-6-1"
style="overflow:visible"
inkscape:isstock="true">
<path
id="path7064-7-0-2-8"
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
transform="matrix(0.4,0,0,0.4,2.96,0.4)"
inkscape:connector-curvature="0" />
</marker>
<marker
inkscape:stockid="DotM"
orient="auto"
refY="0"
refX="0"
id="marker7066-2-7-9"
style="overflow:visible"
inkscape:isstock="true">
<path
id="path7064-7-0-20"
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
transform="matrix(0.4,0,0,0.4,2.96,0.4)"
inkscape:connector-curvature="0" />
</marker>
<marker
inkscape:stockid="DotM"
orient="auto"
refY="0"
refX="0"
id="marker7066-2-7-9-9"
style="overflow:visible"
inkscape:isstock="true">
<path
id="path7064-7-0-20-2"
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
transform="matrix(0.4,0,0,0.4,2.96,0.4)"
inkscape:connector-curvature="0" />
</marker>
<marker
inkscape:stockid="DotM"
orient="auto"
refY="0"
refX="0"
id="marker7066-2-7-9-9-3"
style="overflow:visible"
inkscape:isstock="true">
<path
id="path7064-7-0-20-2-6"
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
transform="matrix(0.4,0,0,0.4,2.96,0.4)"
inkscape:connector-curvature="0" />
</marker>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
inkscape:zoom="2.0000001"
inkscape:cx="290.19529"
inkscape:cy="110.23898"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="true"
showguides="false"
inkscape:snap-grids="true"
inkscape:snap-to-guides="true"
inkscape:window-width="1916"
inkscape:window-height="1156"
inkscape:window-x="1920"
inkscape:window-y="20"
inkscape:window-maximized="0"
units="px"
scale-x="2">
<inkscape:grid
type="xygrid"
id="grid6225"
spacingx="2.6458333"
spacingy="2.6458333"
dotted="false" />
</sodipodi:namedview>
<metadata
id="metadata5622">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
<cc:license
rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
<dc:creator>
<cc:Agent>
<dc:title>Martin Jäger</dc:title>
</cc:Agent>
</dc:creator>
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Notice" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Attribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
</cc:License>
</rdf:RDF>
</metadata>
<g
inkscape:groupmode="layer"
id="layer2"
inkscape:label="Ebene 2"
style="display:inline"
transform="translate(0,-261.70842)" />
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-261.70842)">
<rect
style="display:inline;fill:none;fill-opacity:1;stroke:#6b6b6b;stroke-width:0.26458335;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;enable-background:new"
id="rect6825"
width="113.77083"
height="26.458336"
x="29.104166"
y="269.6459"
ry="0.076052353" />
<rect
style="display:inline;fill:none;fill-opacity:1;stroke:#005e85;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;enable-background:new"
id="rect6825-9-8-36-1"
width="50.270832"
height="5.2916832"
x="87.3125"
y="280.22925"
ry="0.01521052" />
<path
style="display:inline;fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker7066-2);enable-background:new"
d="M 68.79166,282.87508 H 58.208333"
id="path6950-0"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<rect
style="display:inline;fill:none;fill-opacity:1;stroke:#005e85;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;enable-background:new"
id="rect6825-9-8-36-1-2"
width="26.458338"
height="5.2916832"
x="34.395832"
y="280.22925"
ry="0.01521052" />
<path
style="display:inline;fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker7066-2-9);enable-background:new"
d="m 79.375001,282.87509 h 10.58333"
id="path6950-0-2"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="display:inline;fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker7066-2-7-6);enable-background:new"
d="m 39.687503,298.75008 -10e-7,-15.875"
id="path6950-0-9-6"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="display:inline;fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker7066-2-7);enable-background:new"
d="m 52.916666,290.8126 -10e-7,-7.9375"
id="path6950-0-9"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 52.916669,290.8126 1.5875,2.11666"
id="path2655"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1"
d="m 52.916669,293.45843 v 5.29166"
id="path2657"
inkscape:connector-curvature="0" />
<path
style="display:inline;fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker7066-2-7-6-1);enable-background:new"
d="m 95.249999,298.75008 v -15.875"
id="path6950-0-9-6-7"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="display:inline;fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker7066-2-7-9);enable-background:new"
d="m 105.83333,290.8126 v -7.9375"
id="path6950-0-9-3"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 105.83333,290.8126 1.5875,2.11666"
id="path2655-7"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1"
d="m 105.83333,293.45843 v 5.29166"
id="path2657-5"
inkscape:connector-curvature="0" />
<path
style="display:inline;fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker7066-2-7-9-9);enable-background:new"
d="m 119.0625,290.8126 v -7.9375"
id="path6950-0-9-3-8"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 119.0625,290.8126 1.5875,2.11666"
id="path2655-7-9"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1"
d="m 119.0625,293.45843 v 5.29166"
id="path2657-5-7"
inkscape:connector-curvature="0" />
<path
style="display:inline;fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker7066-2-7-9-9-3);enable-background:new"
d="m 132.29166,290.8126 v -7.9375"
id="path6950-0-9-3-8-2"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 132.29166,290.8126 1.5875,2.11666"
id="path2655-7-9-9"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1"
d="m 132.29166,293.45843 v 5.29166"
id="path2657-5-7-3"
inkscape:connector-curvature="0" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#005e85;fill-opacity:1;stroke:none;stroke-width:0.26458332;stroke-miterlimit:4;stroke-dasharray:none"
x="41.576717"
y="278.35446"
id="text3483"><tspan
sodipodi:role="line"
id="tspan3481"
x="41.576717"
y="278.35446"
style="fill:#005e85;fill-opacity:1;stroke-width:0.26458332;stroke-miterlimit:4;stroke-dasharray:none">hv_bus</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#005e85;fill-opacity:1;stroke:none;stroke-width:0.26458332;stroke-miterlimit:4;stroke-dasharray:none"
x="108.93037"
y="278.27698"
id="text3487"><tspan
sodipodi:role="line"
id="tspan3485"
x="108.93037"
y="278.27698"
style="fill:#005e85;fill-opacity:1;stroke-width:0.26458332;stroke-miterlimit:4;stroke-dasharray:none">lv_bus</tspan></text>
<g
id="g3517"
transform="matrix(1.3333333,0,0,1.3333336,12.347285,-124.27817)"
style="stroke-width:0.74999994">
<rect
ry="0.022815673"
y="301.39612"
x="42.333282"
height="7.9374866"
width="7.9375014"
id="rect6825-9-8-1"
style="display:inline;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.19843747;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;enable-background:new" />
<path
inkscape:connector-curvature="0"
id="path7008"
d="m 42.33328,309.33361 7.9375,-7.9375 v 0 0 0"
style="display:inline;fill:none;stroke:#000000;stroke-width:0.19843747px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;enable-background:new" />
<path
style="fill:none;stroke:#000000;stroke-width:0.29765621;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 43.920782,303.77737 h 1.984375"
id="path7786"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.29765621;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 43.920782,302.58674 h 1.984375"
id="path7788"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.29765621;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;enable-background:new"
d="m 46.698908,308.14294 h 1.984375"
id="path7786-1"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.29765621;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;enable-background:new"
d="m 46.698908,306.95231 h 1.984375"
id="path7788-9"
inkscape:connector-curvature="0" />
</g>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="93.662498"
y="304.04181"
id="text8274"><tspan
sodipodi:role="line"
id="tspan8272"
x="93.662498"
y="304.04181"
style="stroke-width:0.26458332">lv</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="101.59998"
y="304.04181"
id="text8278"><tspan
sodipodi:role="line"
id="tspan8276"
x="101.59998"
y="304.04181"
style="stroke-width:0.26458332">load</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="114.30003"
y="304.04181"
id="text8282"><tspan
sodipodi:role="line"
id="tspan8280"
x="114.30003"
y="304.04181"
style="stroke-width:0.26458332">pwm</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="129.1167"
y="304.04181"
id="text8286"><tspan
sodipodi:role="line"
id="tspan8284"
x="129.1167"
y="304.04181"
style="stroke-width:0.26458332">usb</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="47.095833"
y="304.04181"
id="text8290"><tspan
sodipodi:role="line"
id="tspan8288"
x="47.095833"
y="304.04181"
style="stroke-width:0.26458332">dump</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="38.099998"
y="304.04181"
id="text8294"><tspan
sodipodi:role="line"
id="tspan8292"
x="38.099998"
y="304.04181"
style="stroke-width:0.26458332">hv</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="69.453125"
y="275.73135"
id="text8298"><tspan
sodipodi:role="line"
id="tspan8296"
x="69.453125"
y="275.73135"
style="stroke-width:0.26458332">dcdc</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="8.9222355"
y="303.98309"
id="text8548"><tspan
sodipodi:role="line"
x="8.9222355"
y="303.98309"
style="stroke-width:0.26458332"
id="tspan8550">Power Ports:</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:3.88055563px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;display:inline;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332;enable-background:new"
x="29.10416"
y="268.05841"
id="text1902"><tspan
sodipodi:role="line"
id="tspan1900"
x="29.10416"
y="268.05841"
style="stroke-width:0.26458332">Charge Controller</tspan></text>
<path
style="display:inline;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new"
d="m 63.499999,282.87509 1.058323,0.66147 2.4e-5,-1.32291 z"
id="path1050-1"
inkscape:connector-curvature="0" />
<path
style="display:inline;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new"
d="m 84.666666,282.87509 -1.058323,-0.66147 -2.4e-5,1.32291 z"
id="path1050-1-3"
inkscape:connector-curvature="0" />
<path
style="display:inline;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new"
d="m 39.687499,288.16675 0.66147,-1.05832 -1.32291,-2e-5 z"
id="path1050-1-6"
inkscape:connector-curvature="0" />
<path
style="display:inline;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new"
d="m 52.916669,288.16675 0.66147,-1.05832 -1.32291,-2e-5 z"
id="path1050-1-6-1"
inkscape:connector-curvature="0" />
<path
style="display:inline;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new"
d="m 95.249999,288.16675 0.661475,-1.05832 -1.322915,-2e-5 z"
id="path1050-1-6-1-0"
inkscape:connector-curvature="0" />
<path
style="display:inline;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new"
d="m 105.83333,288.16675 0.66147,-1.05832 -1.32291,-2e-5 z"
id="path1050-1-6-1-0-6"
inkscape:connector-curvature="0" />
<path
style="display:inline;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new"
d="m 119.0625,288.16675 0.66147,-1.05832 -1.32291,-2e-5 z"
id="path1050-1-6-1-0-6-3"
inkscape:connector-curvature="0" />
<path
style="display:inline;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new"
d="m 132.29167,288.16675 0.66147,-1.05832 -1.32291,-2e-5 z"
id="path1050-1-6-1-0-6-2"
inkscape:connector-curvature="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 26 KiB

+53
View File
@@ -0,0 +1,53 @@
Charger Concepts
================
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:
- A **DC bus**, which is a connection of two or more electrical circuits such that the electric potential at each connection point can be considered equal. This can be achieved either by connecting each participant very close to each other or by using large copper cross-section such that voltage drop introduced by current flow is negligible. The voltage control targets of the bus can only be set by one of the connected ports.
- A **Power port**, which connects a DC bus with an internal or external device or sub-circuit. A port usually contains a current measurement. Its voltage is determined by the DC bus it is connected to. A port can also contain a switching element.
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).
.. 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
---------------------
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
""""""""""
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
"""""""""""""
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
""""""""""""""""
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
"""""""""""""""""""""
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
""""""""""""""
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.
.. image:: charging-stages.png
:alt: Flow-chart of the MPPT charge controller state machine
Binary file not shown.

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