24 Commits
Author SHA1 Message Date
hogthrob 2359a96bbe Provide detailed log out for rejected battery configuration requests (#127)
It also gets rid of the duplication of code between the debug output
and the actual return value calculation by folding both into the same
loop.
2022-01-25 12:56:47 +01:00
hogthrob d1ff837c5e Overvoltage limit overflow fix (#80)
The bat config calculation did calculate the absolute max voltage
too high, it was doing an unnecessary multiplication.
This triggered an issue in the voltage limit set code, which did not
handle the overflow of the 16bit limit value properly.

Both are fixed now. We limit the limit value to what the ADC is able
to deliver, so that we detect overvoltage for sure, even if the setting
is out of ADC range.
2019-11-10 17:55:43 +01:00
hogthrob 1536e176a9 Better limit for input power derating (#78)
We should use src_voltage_stop as limit,
since the input voltage start limit is basically an OC voltage
where as the stop voltage is a voltage to be measured under load.
2019-11-10 15:13:30 +01:00
hogthrob ba7d379225 Refactored adc_dma.cpp for readability (#76)
- replaced the lengthy adc value formulas with respective functions
  to ease reading
- removed unecessary casts for alert callbacks
- added static to the internal global variables in order to hide them from the
  other compilation units
2019-11-09 23:13:00 +01:00
hogthrob 5cc4921cd2 Small issue fix for OLED (#77) 2019-11-09 12:35:45 +01:00
hogthrob a600bf8a09 OLED display brightness adjust, reset improvement, SOC display and more (#75)
- OLED brightness can be set to extend life
- OLED display correctly initialized at MCU restart even without power off
  Sometimes the OLED display displays all content shifted if the MCU is
  reset without cutting the power to the display (i.e. without display reset).
- SOC is display in battery symbol showing 0 to 5 bars
- Internal temperature is displayed if no external sensor is detected (t)
- PWM value displays as "OFF" if the PWM/halfbridge is not active
2019-11-09 08:22:28 +01:00
hogthrob 71fd6519bc Fix for ADC randomly misconfigured (#74)
This issue happened because the HAL ADC configuration data structure
is allocated on the stack (which by default is not initialized,
i.e. contains potentially non-zero data). As most of this structure was
explicitly initialized only sometimes the OversampleMode setting was
not 0, in this case the ADC had no left data alignment, i.e. delivered
too low values. If it happens, the system sees very weird temperature 
and voltage/power values.
2019-11-08 07:29:04 +01:00
hogthrob bc8f74aa45 Multiple UExt objects at same time (#68)
The change permits use of multiple UExt objects at the same time,
given that these use different pins.
The current UExt code is safe to be used in combination
(OLED display and ESP32 wifi).
Future extension may require some checks to be put in place to
ensure correct configuration.
Could be achieved using preprocessor macros easily.

Uses same objectification concept we used for the ThingSet devices.
Could be merged into one if desired.
2019-11-04 09:23:37 +01:00
hogthrob bec02cb25b Switched to use power of 2 error numbers (#72)
In addition to the normal error flags we now have
ERR_ANY_ERROR which may be used to clear all errors
at once or to use in has_error to see if there is any error flag set.
2019-11-04 09:19:06 +01:00
hogthrob fd474e5350 Use methods to set/clear/query error flags (#71)
Easier to read, quicker to write (if using code
completion), no performance loss due to inlining.
2019-11-02 08:22:00 +01:00
hogthrob e67123ac62 DCDC transfer doesn't work fix for STM32F0 based boards (#66) 2019-10-27 13:57:15 +01:00
hogthrob c5fd08d836 Fix rounding issue (#60)
In some cases the old code would cause a +1/-1 step not actually changing the PWM due to rounding issues.
New code directly changes the integer value and thus avoids this issue.
2019-10-20 13:50:56 +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
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
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 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
hogthrob 3261414fcf uext_wifi compiles again (#41) 2019-07-26 07:38:06 +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
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
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