Commit Graph
181 Commits
Author SHA1 Message Date
Martin Jaeger b87d223dff Conformance testing script check.sh added 2019-11-21 08:34:55 +01:00
Martin Jaeger 67c5bc5504 Check for trailing whitespaces added to TravisCI
Rationale: Many editors (inclding mine) are set to automatically remove
trailing whitespaces. Updating files with trailing spaces creates distracting
additional lines in diffs.
2019-11-21 07:45:16 +01:00
Martin Jaeger 74b765e801 Trailing white spaces removed 2019-11-21 07:44:15 +01:00
Martin Jaeger 7952ac99b0 Subfolder img with OLED bitmap raw files removed 2019-11-21 07:38:32 +01:00
Martin Jäger 0086a739ad Create CONTRIBUTING.md 2019-11-11 21:43:49 +01:00
Martin Jäger a209761fd9 Create CODE_OF_CONDUCT.md 2019-11-11 21:02:26 +01:00
Martin Jaeger ad27142cd8 Fix DC/DC and PWM switch current limit control (#79) 2019-11-11 19:33:30 +01:00
Martin Jaeger ad99d0a361 Static code analysis activated in PlatformIO 2019-11-11 18:35:21 +01:00
Martin Jaeger 47954166be Fine-tuning of battery/load UV/OV alerts
- Alerts now set to +-20% of actual measured voltage
- Hysteresis for load overvoltage reconnect setpoint made configurable
- Added check for PWM switch MOSFET driver undervoltage
2019-11-11 11:38:34 +01:00
Martin Jaeger f254c77ab6 Refactoring of load control and state machine
- State machine and control merged to one function
- Load states marked as deprecated, global error flags used instead
- Reduced duplicated code and made load control function easier to read
2019-11-11 09:35:26 +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
Martin Jaeger c26c17221a Overvoltage alert improved for PWM switching
Previously, the alert was sometimes erroneously triggered in PWM charger
absorption phase (constant voltage, PWM switching). Now the overvoltage
alert is inhibited during turn-on in each PWM cycle by an interrupt.
2019-11-08 13:06:17 +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
Martin Jaeger 328215dc8e Load overvoltage detection corrected and error flag comments added 2019-11-07 16:00:51 +01:00
Martin Jaeger 4c5401d562 PWM switch max current limit control fixed 2019-11-06 10:49:40 +01:00
Martin Jaeger 2992cebb81 Fixed internal temperature data output 2019-11-06 10:17:49 +01:00
Martin Jäger b0fe567884 Merge pull request #73 from LibreSolar/adc-alerts
ADC alerts for faster over/undervoltage detection
2019-11-06 10:10:31 +01:00
Martin Jaeger 5e3181f5e5 Distinguishing between OV and UV alerts, inhibit added
- During overvoltage alerts, only power sources (PWM switch and DC/DC are
  switched off), undervoltage only switches load off
- Alert inhibit added to prevent switching off during PWM switch startup
2019-11-05 18:43:33 +01:00
Martin Jaeger 7874b8b4d6 ADC alerts and emergency stop functions added
Check for overvoltage/undervoltage conditions after each ADC reading cycle and
trigger alert (stopping DC/DC, PWM switch and load output) if limits exceeded.
2019-11-04 18:12:00 +01:00
Martin Jaeger 7412b11002 ADC filtering in separate function + unit-tests 2019-11-04 18:02:43 +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
Martin Jaeger b09f4ca809 More error flags added and defined as output data object 2019-11-01 12:58:31 +01:00
Martin Jaeger 22f9138a15 LogData renamed to DeviceStatus / dev_stat
Rationale: Logging is used for historic data, but error flags are instantaneous data. Device status
is more generic and now contains also the internal temperature measurement.
2019-11-01 09:54:01 +01:00
Martin Jaeger af4af04697 Fix initialization of load.voltage_prev 2019-11-01 08:53:51 +01:00
Martin Jaeger b974e3c1ba PWM 2420 PCB conf updated after testing 2019-11-01 08:37:08 +01:00
Martin Jaeger c70f4cb2c3 Support for custom configuration added to platformio.ini 2019-11-01 08:18:57 +01:00
Martin Jäger a147bdf81b Merge pull request #67 from LibreSolar/load-protection-improvements 2019-11-01 08:15:08 +01:00
Martin Jaeger 20bc6d124b Fix to prevent toggling between load states disabled and low SOC 2019-10-31 19:50:55 +01:00
Martin Jaeger cb0c3c8135 USB output state machine improved (see #69) 2019-10-31 16:32:03 +01:00
Martin Jaeger b98461fee4 Load off for internal overtemp implemented 2019-10-31 12:07:21 +01:00
Martin Jaeger b1a7babaff Load overcurrent model now using internal temperature 2019-10-31 11:33:18 +01:00
Martin Jaeger b0e265f3e9 NTC on PCB not used as battery temperature anymore
- MCU temperature was renamed to internal_temperature
- NTC at board edge senses temperatures far above battery / ambient temperature at high loads and is now ignored
- Battery temperature always assumed 25ÂC unless external sensor is detected
2019-10-31 11:22:03 +01:00
Martin Jaeger 5b4df98656 Load protection improvements
- Switched back to older mbed version, as update broke comparator function
- Added voltage dip detection to disconnect load if charge controller is connected to small
  battery or with bad wires and short circuit detection doesn't trigger
- Added more error flags to diagnose reasons for load disconnect
2019-10-30 17:31:16 +01:00
Martin Jaeger 975c03affd Load OC/UV recovery settings fixed 2019-10-30 15:13:58 +01:00
azeemshatp 6bc2adb793 Bootloader support for STM32L07x MCUs (#65)
A custom linker script (.ld) is added to the root project folder. platformio.ini file updated to add the new env: pwm-2420-lus-v0.3-bl and build_flags. Start address for each Application in the flash need to be is modified in this .ld file. Readme file is updated accordingly. New functions added to perform flash write operations to store the bootloader status.
2019-10-28 13:30:19 +01:00
hogthrob e67123ac62 DCDC transfer doesn't work fix for STM32F0 based boards (#66) 2019-10-27 13:57:15 +01:00
Martin Jäger f14df2bc9d Global print functions based on debug level flags added (closes #58) 2019-10-25 11:36:01 +02:00
Hogthrob 88f2accbd9 Reduced code duplication in dcdc code 2019-10-24 17:06:11 +02:00
Martin Jaeger a7239fa9bb Enabled all warnings for unit-test builds 2019-10-24 16:10:35 +02:00
Martin Jaeger 68ae3227cc Discharge and load output control improvements
- Charge/discharge control in charger class sets global error flags
- Load state machine analyzes error flags to distinguish reasons for switching load off
- Temperature errors now identified correctly (issue #59)
- Delay before load re-connect after low voltage or overcurrent event now configurable
- Unit tests added
2019-10-24 16:04:32 +02:00
Martin Jäger 2beb72f1f6 Merge pull request #62 from LibreSolar/playground
Rework of port concept and charge controller type setup
2019-10-24 15:58:19 +02:00
Martin Jaeger ba10a2882c Fixing load output and improved overvoltage config
Previous load output expected the battery port as a parameter and checked if
discharging of the battery was allowed. New implementation has own load port
and needs to check if current output (i.e. positive direction) is allowed.

Overvoltage setting is now configured via power port sink_voltage_max.
2019-10-23 13:16:04 +02:00
Martin Jaeger 42751c83c2 PowerPort member variables renamed
Previous naming with chg/dis didn't make much sense e.g. for load output or solar panels. Voltage
targets are now named with source or sink. Current limits are defined based on their direction
(negative or positive). ASCII art graphic added for better explanation of passive sign convention.
2019-10-23 10:32:48 +02:00
Martin Jaeger 515b098e85 Passing of bat voltage and current limits to other ports updated 2019-10-23 07:29:05 +02:00