Skip to content

Commit

Permalink
Merge branch 'new_features_24'
Browse files Browse the repository at this point in the history
  • Loading branch information
shining-man committed May 26, 2024
2 parents 85835a8 + 0aa4d2d commit 9e03efa
Show file tree
Hide file tree
Showing 64 changed files with 5,646 additions and 2,771 deletions.
28 changes: 23 additions & 5 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
v0.5.14
- Toggeln des Triggergrundes im Log behoben
v0.6.0
Neue Funktionen/Verbesserungen bei der Laderegelung:
- Absorbtion/Float Ladespannung
- Autobalancing
- CutOff (Überarbeitet)
- Funktion "Ladesstrom reduzieren - SoC" erweitert um "Mindest Ladestrom in A" (#101)

v0.5.13
- Remove WebUI v2
- Anpassungen für HW2.4.1
Weitere neue Features/Verbesserungen:
- Neues BMS: Seplos V3 (#81)
- Neues Wechselrichter CAN-Protokoll: BYD Protocol (SolarEdge RWS)
- Passwortschutz für das WebUI (#93)
Username: bsc
Passwort: admin

- Problem beim Runden des SoC behoben (Fix 100% SOC bei Seplos) (#113)
- Kleinere Änderungen/Verbesserungen in den Menüs des WebUI (z.B. Invertermenü aufgeteilt zu bessern Übersichtlichkeit)
- Größere Änderungen im Unterbau des BSC


Wichtiger Hinweis!
Folgende Werte müssen nach dem Update kontrolliert und ggf. angepasst werden:
- Absorption Ladespannung
- Ladestrom reduzieren - SoC; Pro 1% um x A reduzieren
- Cut-Off Strom
6 changes: 4 additions & 2 deletions include/AlarmRules.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "BleHandler.h"
#include "defines.h"

class Inverter;

#define ALARM_CAUSE_DI 0
#define ALARM_CAUSE_BMS_NO_DATA 1
#define ALARM_CAUSE_BMS_CELL_VOLTAGE 2
Expand All @@ -24,8 +26,8 @@
#define ALARM_CAUSE_FAN 9
#define ALARM_VIRTUAL_TRIGGER 10

void initAlarmRules();
void runAlarmRules();
void initAlarmRules(Inverter &inverter);
void runAlarmRules(Inverter &inverter);
void changeAlarmSettings();

bool getAlarm(uint8_t alarmNr);
Expand Down
65 changes: 35 additions & 30 deletions include/BmsData.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,36 @@

struct bmsData_s
{
// N | J | J | S | J | D | S | J | G | G | S | B |
// E | b | K | e | K | A | Y | K | O | O | M | P |
// E | d | | p | | L | L | | B | B | A | N |
// Y | | | l | B | Y | C | V | E | E | R | |
// 4 | | | o | T | | I | 1 | L | L | T | |
// A | | | s | | | N | 3 | | | S | |
// | | | | | | | | R | P | H | |
// | | | | | | | | N | C | U | |
// | | | | | | | | 1 | 2 | N | |
// | | | | | | | | 5 | 0 | T | |
// | | | | | | | | 0 | 0 | | |
//---|---|---|---|---|---|---|---|---|---|---|---|
uint16_t bmsCellVoltage[BMSDATA_NUMBER_ALLDEVICES][24]; // x | x | x | x | | x | x | x | x | x | | |
//float bmsCellResistance[BMSDATA_NUMBER_ALLDEVICES][24]; // x | | | | | | | | | | | |
int16_t bmsTotalVoltage[BMSDATA_NUMBER_ALLDEVICES]; // x | x | x | x | | x | x | x | x | x | x | |
uint16_t bmsMaxCellDifferenceVoltage[BMSDATA_NUMBER_ALLDEVICES]; // x | x | x | x | | x | x | x | x | x | | |
uint16_t bmsAvgVoltage[BMSDATA_NUMBER_ALLDEVICES]; // x | x | x | x | | x | x | x | x | x | | |
int16_t bmsTotalCurrent[BMSDATA_NUMBER_ALLDEVICES]; // - | x | x | x | | x | x | - | x | x | x | |
uint16_t bmsMaxCellVoltage[BMSDATA_NUMBER_ALLDEVICES]; // x | x | x | x | | x | x | c | x | x | | |
uint16_t bmsMinCellVoltage[BMSDATA_NUMBER_ALLDEVICES]; // x | x | x | x | | x | x | c | x | x | | |
uint8_t bmsMaxVoltageCellNumber[BMSDATA_NUMBER_ALLDEVICES]; // x | | | | | x | | c | x | x | | |
uint8_t bmsMinVoltageCellNumber[BMSDATA_NUMBER_ALLDEVICES]; // x | | | | | x | | c | x | x | | |
uint8_t bmsIsBalancingActive[BMSDATA_NUMBER_ALLDEVICES]; // x | | | | | x | | x | | | | |
int16_t bmsBalancingCurrent[BMSDATA_NUMBER_ALLDEVICES]; // x | | | | | | | x | | | | |
int16_t bmsTempature[BMSDATA_NUMBER_ALLDEVICES][3]; // 2 | 3 | 3 | 3 | | 3 | 3 | x | 3 | 3 | | |
uint8_t bmsChargePercentage[BMSDATA_NUMBER_ALLDEVICES]; // - | x | x | x | | x | x | - | x | x | x | |
uint32_t bmsErrors[BMSDATA_NUMBER_ALLDEVICES]; // * | x | x | | | | x | * | x | x | | |
uint8_t bmsStateFETs[BMSDATA_NUMBER_ALLDEVICES]; // - | x | x | x | x | x | x | - | - | - | | | bit 0=FET charge, bit 1=FET discharge
unsigned long bmsLastDataMillis[BMSDATA_NUMBER_ALLDEVICES]; // x | x | x | x | x | | x | x | x | x | | |
// N | J | J | S | J | D | S | J | G | G | S | B | S |
// E | b | K | e | K | A | Y | K | O | O | M | P | e |
// E | d | | p | | L | L | | B | B | A | N | p |
// Y | | | l | B | Y | C | V | E | E | R | | l |
// 4 | | | o | T | | I | 1 | L | L | T | | o |
// A | | | s | | | N | 3 | | | S | | s |
// | | | | | | | | R | P | H | | |
// | | | | | | | | N | C | U | | v |
// | | | | | | | | 1 | 2 | N | | 3 |
// | | | | | | | | 5 | 0 | T | | |
// | | | | | | | | 0 | 0 | | | |
//---|---|---|---|---|---|---|---|---|---|---|---|---|
uint16_t bmsCellVoltage[BMSDATA_NUMBER_ALLDEVICES][24]; // x | x | x | x | | x | x | x | x | x | | | x |
//float bmsCellResistance[BMSDATA_NUMBER_ALLDEVICES][24]; // x | | | | | | | | | | | | |
int16_t bmsTotalVoltage[BMSDATA_NUMBER_ALLDEVICES]; // x | x | x | x | | x | x | x | x | x | x | | x |
uint16_t bmsMaxCellDifferenceVoltage[BMSDATA_NUMBER_ALLDEVICES]; // x | x | x | x | | x | x | x | x | x | | | x |
uint16_t bmsAvgVoltage[BMSDATA_NUMBER_ALLDEVICES]; // x | x | x | x | | x | x | x | x | x | | | x |
int16_t bmsTotalCurrent[BMSDATA_NUMBER_ALLDEVICES]; // - | x | x | x | | x | x | - | x | x | x | | x |
uint16_t bmsMaxCellVoltage[BMSDATA_NUMBER_ALLDEVICES]; // x | x | x | x | | x | x | c | x | x | | | x |
uint16_t bmsMinCellVoltage[BMSDATA_NUMBER_ALLDEVICES]; // x | x | x | x | | x | x | c | x | x | | | x |
uint8_t bmsMaxVoltageCellNumber[BMSDATA_NUMBER_ALLDEVICES]; // x | | | | | x | | c | x | x | | | x |
uint8_t bmsMinVoltageCellNumber[BMSDATA_NUMBER_ALLDEVICES]; // x | | | | | x | | c | x | x | | | x |
uint8_t bmsIsBalancingActive[BMSDATA_NUMBER_ALLDEVICES]; // x | | | | | x | | x | | | | | x |
int16_t bmsBalancingCurrent[BMSDATA_NUMBER_ALLDEVICES]; // x | | | | | | | x | | | | | |
int16_t bmsTempature[BMSDATA_NUMBER_ALLDEVICES][3]; // 2 | 3 | 3 | 3 | | 3 | 3 | x | 3 | 3 | | | x |
uint8_t bmsChargePercentage[BMSDATA_NUMBER_ALLDEVICES]; // - | x | x | x | | x | x | - | x | x | x | | x |
uint32_t bmsErrors[BMSDATA_NUMBER_ALLDEVICES]; // * | x | x | | | | x | * | x | x | | | x |
uint32_t bmsWarnings[BMSDATA_NUMBER_ALLDEVICES]; // | | | x | | | | | | | | | |
uint8_t bmsStateFETs[BMSDATA_NUMBER_ALLDEVICES]; // - | x | x | x | x | x | x | - | - | - | | | x | bit 0=FET charge, bit 1=FET discharge
unsigned long bmsLastDataMillis[BMSDATA_NUMBER_ALLDEVICES]; // x | x | x | x | x | | x | x | x | x | | | x |
uint16_t bmsCellVoltageCrc[BMSDATA_NUMBER_ALLDEVICES]; // Wird nach dem Holen Daten vom BMS berechnet
uint8_t bmsLastChangeCellVoltageCrc[BMSDATA_NUMBER_ALLDEVICES]; // Wird nach dem Holen Daten vom BMS berechnet
// // *=Teilweise; -=Nicht verfügbar; c=wird berechnet
Expand Down Expand Up @@ -95,6 +96,7 @@ void setBmsBalancingCurrent(uint8_t devNr, float value);

float getBmsTempature(uint8_t devNr, uint8_t sensorNr);
void setBmsTempature(uint8_t devNr, uint8_t sensorNr, float value);
void setBmsTempatureI16(uint8_t devNr, uint8_t sensorNr, int16_t value);

uint8_t getBmsChargePercentage(uint8_t devNr);
void setBmsChargePercentage(uint8_t devNr, uint8_t value);
Expand All @@ -109,6 +111,9 @@ uint32_t getBmsErrors(uint8_t devNr);
void setBmsErrors(uint8_t devNr, uint32_t value);
void setBmsErrors(uint8_t devNr, const BmsErrorStatus& status);

uint32_t getBmsWarnings(uint8_t devNr);
void setBmsWarnings(uint8_t devNr, uint32_t value);

uint8_t getBmsStateFETs(uint8_t devNr);
void setBmsStateFETs(uint8_t devNr, uint8_t value);
boolean getBmsStateFETsCharge(uint8_t devNr);
Expand Down Expand Up @@ -140,7 +145,7 @@ uint8_t getBmsDataBytes(uint8_t dataType);
uint8_t * getBmsSettingsReadback(uint8_t bmsNr);

bool isMultiple485bms(uint8_t bms);

bool haveAllBmsFirstData();

#ifdef LOG_BMS_DATA
void logBmsData(uint8_t bmsNr);
Expand Down
46 changes: 0 additions & 46 deletions include/Canbus.h

This file was deleted.

58 changes: 58 additions & 0 deletions include/ModbusRTU.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright (c) 2024 Tobias Himmler
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT

#ifndef INC_MDOBUSRTU_H
#define INC_MDOBUSRTU_H

#include "Arduino.h"

namespace modbusrtu
{
class ModbusRTU
{
public:
enum class fCode : uint8_t
{
READ_COIL_01 = 0x01,
//WRITE_COIL_0F = 0x0F,
READ_CMD_04 = 0x04
//WRITE_CMD_10 = 0x10
};

// Konstruktor
ModbusRTU(Stream *port, void (*callback)(uint8_t, uint8_t), uint8_t devNr);

// Destruktor
~ModbusRTU();

bool readData(uint8_t addr, fCode cmd, uint16_t startRegister, uint16_t len, uint8_t *retData);

bool getBitValue(uint16_t address, uint8_t b);
uint8_t getU8Value(uint16_t address);
uint16_t getU16Value(uint16_t address);
int16_t getI16Value(uint16_t address);

private:
Stream *mPort;
void (*mCallback)(uint8_t, uint8_t);
uint8_t mSerialPortNr;

uint16_t mStartRegAdr;
uint8_t *mRetData;
uint8_t retDataLen;

enum class modbusRxState : uint8_t
{
WAIT_START = 0x0,
RECV_DATA = 0x1
};

void buildSendMsg(uint8_t addr, fCode cmd, uint16_t startRegister, uint16_t len);
bool readSerialData();
};

} // namespace modbusrtu

#endif
6 changes: 4 additions & 2 deletions include/OTAupdater.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#include <Arduino.h>
#include <WebServer.h>
#include <WebSettings.h>
#include <webUtility.h>

class OTAupdater {
public:
bool init(WebServer *server, const char *path, bool enUpdatePage);
bool init(WebServer *server, WebSettings *webSettings, const char *path, bool enUpdatePage);

private:
bool isInit;

void delayWithHandleClient(WebServer *server, uint16_t delay_ms);
void setHttpRoutes(WebServer *server, const char *path, bool enUpdatePage);
void setHttpRoutes(WebServer *server, WebSettings *webSettings, const char *path, bool enUpdatePage);
};

extern OTAupdater otaUpdater;
20 changes: 12 additions & 8 deletions include/WebSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@
#define HTML_INPUTSELECT 9
#define HTML_INPUTCHECKBOX 10
#define HTML_INPUTMULTICHECK 11
#define HTML_INPUTMULTICHECK_COLLAPSIBLE 14
#define HTML_OPTIONGROUP 12
#define HTML_OPTIONGROUP_COLLAPSIBLE 15
#define HTML_SEPARATION 13
//Max Type = 15
#define HTML_INPUTMULTICHECK_COLLAPSIBLE 14
#define HTML_OPTIONGROUP_COLLAPSIBLE 15
#define HTML_INPUTFLOAT_1 16
#define HTML_INPUTFLOAT_2 17
#define HTML_INPUTFLOAT_3 18
//Max Type = 18

#define BACKGROUND_COLOR "#ffffff"

Expand Down Expand Up @@ -61,8 +64,8 @@ class WebSettings {
static bool getBool(uint16_t name);
static bool getBool(uint16_t name, uint8_t groupNr);

static int getIntFlash(uint16_t name, uint8_t groupNr, uint8_t dataType);
static int getIntFlash(uint16_t name, uint8_t groupNr);
static uint32_t getIntFlash(uint16_t name, uint8_t groupNr, uint8_t dataType);
static uint32_t getIntFlash(uint16_t name, uint8_t groupNr);
static float getFloatFlash(uint16_t name, uint8_t groupNr);
static float getFloatFlash(uint16_t name);
static boolean getBoolFlash(uint16_t name, uint8_t groupNr);
Expand Down Expand Up @@ -128,11 +131,11 @@ class WebSettings {
String getJsonHelp(const char *parameter, uint8_t idx, uint32_t startPos);
uint8_t getJsonType(const char *parameter, uint8_t idx, uint32_t startPos);
String getJsonDefault(const char *parameter, uint8_t idx, uint32_t startPos);
uint8_t getJsonOptionsCnt(const char *parameter, uint8_t idx, uint32_t startPos);
uint8_t getJsonArrayCnt(const char *parameter, String key, uint8_t idx, uint32_t startPos);
uint32_t getJsonOptionsMin(const char *parameter, uint8_t idx, uint32_t startPos);
uint32_t getJsonOptionsMax(const char *parameter, uint8_t idx, uint32_t startPos);
std::vector<String> getJsonOptionValues(const char *parameter, uint8_t idx, uint32_t startPos);
std::vector<String> getJsonOptionLabels(const char *parameter, uint8_t idx, uint32_t startPos);
std::vector<String> getJsonArrayValues(const char *parameter, String key, uint8_t idx, uint32_t startPos);
std::vector<String> getJsonArrayLabels(const char *parameter, String key, uint8_t idx, uint32_t startPos);
String getJsonArrValue(const char *parameter, String str_key1, String str_key2, uint8_t u8_eCnt, uint8_t idx, uint32_t startPos);

void createHtmlTextfield(char * buf, uint16_t *name, uint64_t *nameExt, String *label, const char *parameter, uint8_t idx, uint32_t startPos, const char * type, String value);
Expand All @@ -145,6 +148,7 @@ class WebSettings {
void createHtmlAddSelectOption(char * buf, String option, String label, String value);
void createHtmlStartMulti(char * buf, String *label, const char *parameter, uint8_t idx, uint32_t startPos, uint8_t u8_jsonType);
void createHtmlAddMultiOption(char * buf, uint16_t *name, uint64_t *nameExt, const char *parameter, uint8_t idx, uint32_t startPos, uint8_t option, String label, uint32_t value, uint8_t u8_dataType);
void createHtmlFloatX(char * buf, uint16_t *name, uint64_t *nameExt, String *label, const char *parameter, uint8_t idx, uint32_t startPos, int32_t value, uint8_t precision);

void (*fn_mOnButtonSave)() = NULL;
void (*fn_mOnButton1)() = NULL;
Expand Down
2 changes: 2 additions & 0 deletions include/crc.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <stdint.h>

uint16_t crc16 (uint8_t *nData, uint16_t wLength);
uint16_t crc16 (uint16_t crcIn, uint8_t *nData, uint16_t wLength);

uint32_t calcCrc32(uint8_t* pData, uint32_t DataLength);
uint32_t calcCrc32(uint32_t crcIn, uint8_t* pData, uint32_t DataLength);

Expand Down
Loading

0 comments on commit 9e03efa

Please sign in to comment.