Commit Graph
126 Commits
Author SHA1 Message Date
Martin Jaeger 0399c4e877 PowerPort added to store current independent from DC bus type
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.
2019-10-20 14:52:35 +02:00
Martin Jaeger d7ed3cdd13 STM32 bootloader activation from SW via BOOT0 pin 2019-10-18 17:01:33 +02:00
Martin Jaeger 29e186624c ThingSet device renamed to interface
Reason: According to ThingSet spec, a device is a complete physical hardware device like a charge controller.
Within one device, we can have different communication interfaces that use the ThingSet protocol.
2019-10-17 10:36:48 +02:00
Martin Jaeger 6c3885e5d0 Log unit-tests added 2019-10-16 21:32:35 +02:00
Martin Jaeger f33146e9de Battery discharging control restructured
- Discharging control separated from charger state machine
- Unit-tests for discharging control added
- DC bus chg/dis_enabled flags removed, control now only based on chge/dis_current_limit values
- _current_max values renamed to _limit to make more clear that values for discharging direction must be negative
- Load output struct now stores pointer to internal and external DC bus objects
2019-10-16 16:04:21 +02:00
Martin Jaeger cce6e2a9b3 Added main.h for common includes and extern variables 2019-10-16 12:03:49 +02:00
Martin Jaeger 0545131a99 Equalization charging phase added 2019-10-16 10:02:27 +02:00
hogthrob 472fb03cc6 Small fix for building unit test on Windows (#56)
Was necessary to add -D __STDC_FORMAT_MACROS for MinGW gcc 8.1.0
2019-10-16 06:29:12 +02:00
Martin Jaeger aeeff56492 Update mbed to v5.13.4 after testing 2019-10-15 16:48:14 +02:00
Martin Jaeger 6d91e075b3 Update of DC/DC lv side targets based on bat + load 2019-10-15 16:46:24 +02:00
Martin Jaeger 25e469516c DC/DC control functions cleaned up 2019-10-15 14:00:20 +02:00
Martin Jaeger ae51d7a0d7 Unit tests for DC/DC control added 2019-10-15 13:59:48 +02:00
Martin Jaeger e7317ae1d8 DC bus and terminal naming improved
- DcBus representing actual screw terminals renamed
- Internal DC bus at DC/DC low voltage side added for correct DC/DC control
- DC/DC struct now stores pointers to HV and LV bus objects. Redundant voltage and current measurement variables removed.
- Unit tests updated

DC/DC control needs further improvements to make use of the changes
2019-10-15 13:57:23 +02:00
Martin Jaeger cb206b6864 DC/DC startup check reworked and unit-tests added 2019-10-15 13:54:05 +02:00
hogthrob 11e3a3e102 Fixed -Wno-register added to C compiler calls (#55) 2019-10-15 13:45:04 +02:00
hogthrob 6d56003c8c Unified half bridge timer handling (#53)
* As much as possible code is shared between both timer abstractions.
* Unit tests added to main implementation file (stub removed)
2019-10-15 10:34:53 +02:00
Martin Jaeger fb11fb7cb4 Fix for false PWM 2420 LUS v0.3 load current measurement 2019-10-14 10:52:19 +02:00
Martin Jaeger e94af324ee Board definitions updated for MPPT 1210 HUS v0.7 2019-10-08 15:19:05 +02:00
Martin Jaeger 4c2e05a9a1 Fix encoding in python version file generator 2019-10-08 15:15:29 +02:00
hogthrob 3fc395d333 Fix build issue with mbed 5.13 (#52) 2019-10-08 15:12:47 +02:00
hogthrob 987a6d8894 Increase Efficiency: Use MPPT mode more often (#49)
The dcdc_control now better controls which mode (boost vs. buck) is being
used when: If configured in Buck mode, boost mode is never used.

The _dcdc_control function now "knows" if it is in boost or buck mode (dcdc_dir)

The no load condition now uses the dcdc transfer power as measure, not the out current
which is not reflecting the "no dcdc load" condition correctly if a load is connected
2019-10-01 14:40:16 +02:00
Hogthrob 7e1d1374a2 Fix startup block with USB serial adapter connected
We were using the "wrong" readable method which always returned readable == true but getc on serial will block if no data is available.
2019-08-28 17:41:04 +02:00
Hogthrob 41f142c112 Readded sleep code to make it work 2019-08-28 17:40:40 +02:00
Hogthrob 4764e0a5d0 Improved command input
Now handles buffer full condition gracefully. Originally a full buffer
would have prevented any further command processing until reboot

Changed buffer types to minimize the number of explicit cast we are
using
2019-08-28 17:39:32 +02:00
Hogthrob a1098aaf71 ThingSetDevice classes
These replace the previous C impementation.
- permits any combination of thingset devices being present
- removes essentially all thingset related #ifdefs outside the actual implementation files.
- Code size is reduced. Code duplication eliminated.

The code is not final in its structure, but works with CAN and Serial.
USBSerial does not work on the F072 (L073 not tested) but this was also
the case for the C implementation.

It is required to apply the changes to the platformio.ini otherwise
the code will not compile.
2019-08-28 17:37:05 +02:00
hogthrob 01edcbcf07 Fix for #44 (Wrong DCDC power calculation) (#45)
The dcdc power has to use the dcdc current and voltage instead of the
output voltage (which can be low side - buck or high side - boost) and
the dcdc current instead of the out current. See #44 for the discussion
on this issue.
2019-08-26 07:36:13 +02:00
Martin Jaeger 3f4f52ea18 PWM switch: Bug fixed + some improvements
- Serious bug: Switch did not go below 90% duty cycle (left-over from testing code). Could result in overcharging of battery.
- Improvement: Preventing very short on/off times (duty cycles close to 0 or 1) as switching time is quite slow
- PWM frequency now configurable via PCB config (and increased from 20 to 25 Hz)
- Some unused parameters in PwmSwitch struct removed and variables renamed
- Overcurrent setting now via solar_bus
2019-08-16 11:37:25 +02:00
Martin Jaeger e51a6384fb Fixing bug in load overvoltage protection 2019-08-16 07:48:56 +02:00
Martin Jäger 152e218e60 Corrected upload protocol in platformio.ini 2019-08-08 15:58:26 +02:00
Martin Jaeger 0a2a38691b 12V/24V battery detection message updated (closes #43) 2019-08-08 11:36:13 +02:00
Martin Jaeger 4b545fa882 Include git commit hash in ThingSet data objects 2019-08-08 11:19:29 +02:00
Martin Jaeger c968a6bb8a Structs renamed for new coding style (closes #42) 2019-08-08 10:16:16 +02:00
hogthrob 3261414fcf uext_wifi compiles again (#41) 2019-07-26 07:38:06 +02:00
Jordan Silverman 45e29e1c82 Merge pull request #40 from LibreSolar/lvd-improvements
Load voltage thresholds adjusted and inhibit added
2019-07-17 14:42:09 +01:00
Martin Jaeger 4bc3f8bd1e Load voltage thresholds adjusted and inhibit added
During tests, the deep discharge counter increased by several 100 counts per day under certain circumstances, most probably because of quite small battery making the voltage toggle between disconnect and reconnect voltage. This commit suggests several improvements.

- Load reconnect voltage increased
- Don't reconnect before waiting at least 1h (lvd_timestamp in load.cpp)
- SOC filter calculation slightly changed to make sure 100% is reached fast enough.
2019-07-12 18:55:13 +02:00
Martin Jaeger 17b044d941 Improve SOC and load LED behavior at low SOC
This commit prevents that the SOC bar shows 2 LEDs already even though the load is still switched of because of low voltage.
2019-07-11 17:50:40 +02:00
Martin Jaeger 3a2af7ccc7 Rewrite of LED module (closes #28) 2019-07-11 17:19:06 +02:00
Martin Jaeger cf5366c2ba Fix usable_capacity estimation to prevent wrong values before first full charge 2019-07-11 13:11:34 +02:00
Martin Jaeger 5e48d5e7c5 Update to PlatformIO 4.0 2019-07-10 21:15:22 +02:00
Martin Jaeger 7300406b94 DC/DC test function and dead time config added
- The DC/DC test function slowly ramps up the duty cycle to 50% to allow defined measurements of gate driver, switch node etc. with an oscilloscope (without disturbance by the MPPT algorithm)

- The dead-time between HS and LS gate on/off is now configurable for each PCB and not fixed to 300 ns for all PCBs anymore.
2019-07-05 11:01:35 +02:00
hogthrob 7ee248cf81 Reduced codesize: Switch to newlib-nano; Travis deploy on LibreSolar only (#37)
* Reduced codesize: Switch to newlib-nano

Figured out how to switch to newlib-nano in a simple way.
Reduced build size by about 29k. Applied this to all STM32 builds.
Please test with the STM32L072 hardware, I don't have one of those,
only STM32F072

Also "upgraded" the compiler accepted language standard to gnu c++11 (from gnu++98).

And finally defined that all floating point constants are to be treated
as "floats" and not as double (which is the default). Reduces the number
of implicit double promotions almost to the required minimum.

In some places the double functions are applied to floats which also
causes some unwanted time and code growth. But this is not fixed yet.

* Change travis to try to deploy only on "master" repo

* Fixed typo

gnu++11 was not really enabled, due to copy'n'paste typo.
2019-07-01 14:30:11 +02:00
Martin Jaeger 26ae254ec4 Fixing load overvoltage protection (closes #27) 2019-06-25 09:14:57 +02:00
hogthrob 14faa1f0e8 Working CAN (#35)
* Minor fix in documentation

* Make CAN compile again

* Now able to disable uart_serial

* Boots and runs CAN

Requires matching thingset-cpp library
The placement of the ts_can.process_asap/process_1s is a little hack,
but I did want to add even more ifdefs in the main method.
Renaming the functions could do the trick.
BTW, serial and CAN thingset can be run at the same time, no problems.

* Some cleanups in the CAN interface
2019-06-23 00:41:01 +02:00
hogthrob 7d02c92c7d Fix to move data_objects to flash only (#36)
Without this, the 1296 byte long data_objects is stored in RAM
(after being copied from flash)
2019-06-23 00:32:13 +02:00
hogthrob a4d5243286 Fixed Load_A not correctly reported issue (#34)
At compile time &(load.bus->current) will resolve to a different
(wrong) address than after assignment of "load_bus" to load.bus at runtime.
2019-06-22 12:52:37 +02:00
hoijui 6016c17b14 Minor code improvements from CppCheck & README updates (#32)
* log.h: fix signature of log_update_min_max_values

looks like it was changed in log.cpp, but not adjusted in log.h,
somewhen in the past

* adc_dma: only define variables if they are really required

* reduce scope of variables in interface_can.cpp

* `changed` was reassigned a value before the old one was used

* README: reformat flashing troubleshooting section

* README: punctuation fixes

* README: add troubleshooting tip for bad connection between nucleo and MPPT
2019-06-22 08:04:32 +02:00
hogthrob 32005a5642 Reduce stack usage: Make logo stored in flash, fix oled (#33)
This way the OLED display does not overwrite useful data since
the stack on the F072RB in mbed is just 1k and the logog is also 1k.
Also fixed minor issue in OLED display code (refactoring not done).
2019-06-22 07:29:40 +02:00
Martin Jäger b3aada7d4e Merge pull request #31 from hogthrob/master
Fixed NMC battery configuration calculation
2019-06-20 07:43:39 +02:00
Hogthrob f26fdce41f Fixed NMC battery configuration calculation
Now num_cell multiplier is used in all required places.
2019-06-20 07:26:39 +02:00
Martin Jaeger 690e204a16 Solar, bat and load power added to data objects 2019-06-18 17:04:33 +02:00