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.
Libre Solar Charge Controller Firmware
Firmware based on ARM mbed framework for the Libre Solar MPPT/PWM solar charge controllers
Supported devices
The software is configurable to support different charge controller PCBs with either STM32F072 (including CAN support) or low-power STM32L072/3 MCUs.
- Libre Solar MPPT 12/24V 20A with CAN (v0.10)
- Libre Solar MPPT 12V 10A with USB (v0.2 and v0.4)
- Libre Solar PWM 12/24V 20A
Building and flashing the firmware
This firmware is developed using the ARM mbed OS embedded framework which has easy-to-understand C++ syntax (similar to Arduino) and thus enhances community based software development.
If used together with Visual Studio Code and PlatformIO, starting firmware development is only a matter of a few clicks:
-
Install Visual Studio Code and PlatformIO to build the firmware.
-
Copy
src/config.h_templatetosrc/config.h, and adjust basic settings.config.his ignored by git, so your changes are kept after software updates usinggit pull. -
Select the correct board in
platformio.iniby removing the comment before the board name under[platformio] -
Connect the board via a programmer. See the Libre Solar website for further project-agnostic instructions.
-
Press the upload button at the bottom left corner in VS Code.
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:
-
Change OpenOCD settings to
set WORKAREASIZE 0x1000in the file~/.platformio/packages/tool-openocd/scripts/board/st_nucleo_l073rz.cfg. -
Use ST-Link tools. For Windows there is a GUI tool. Under Linux, uncomment the
upload_commandline inplatformio.ini. -
Use other debuggers and tools, e.g. Segger J-Link.
Connection failures
If flashing fails like this in PlatformIO:
Error: init mode failed (unable to connect to the target)
in procedure 'program'
** OpenOCD init failed **
shutdown command invoked
or with ST-Link:
$ st-flash write .pio/build/mppt-1210-hus-v0.4/firmware.bin 0x08000000
st-flash 1.5.1
2019-06-21T18:13:03 INFO common.c: Loading device parameters....
2019-06-21T18:13:03 WARN common.c: unknown chip id! 0x5fa0004
check the connection between the programmer (for example the ST-Link of the Nucleo board) and the charge controller.
API documentation
The documentation auto-generated by Doxygen can be found here.
Unit tests
In order to run the unit tests, you need a PlatformIO Plus account. Run tests with the following command:
platformio test -e unit-test-native