From dc84b15e2f93e24112f5192c0e2ac41c267c8e34 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 4 Feb 2024 12:30:56 +0200 Subject: [PATCH 1/3] Add Sofar fix for voltages --- Software/src/inverter/PYLON-CAN.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Software/src/inverter/PYLON-CAN.cpp b/Software/src/inverter/PYLON-CAN.cpp index 7cb0137b..7dc060ff 100644 --- a/Software/src/inverter/PYLON-CAN.cpp +++ b/Software/src/inverter/PYLON-CAN.cpp @@ -4,6 +4,8 @@ #define SEND_0 //If defined, the messages will have ID ending with 0 (useful for some inverters) //#define SEND_1 //If defined, the messages will have ID ending with 1 (useful for some inverters) +#define INVERT_VOLTAGE //If defined, the min/max voltage frames will be inverted, \ + //useful for some inverters like Sofar that report the voltages incorrect otherwise /* Do not change code below unless you are sure what you are doing */ //Actual content messages @@ -199,6 +201,19 @@ void update_values_can_pylon() { //This function maps all the values fetched fr PYLON_4210.data.u8[7] = (StateOfHealth * 0.01); PYLON_4211.data.u8[7] = (StateOfHealth * 0.01); +#ifdef INVERT_VOLTAGE //Useful for Sofar inverters + //Minvoltage (eg 300.0V = 3000 , 16bits long) Charge Cutoff Voltage + PYLON_4220.data.u8[0] = (min_voltage & 0x00FF); + PYLON_4220.data.u8[1] = (min_voltage >> 8); + PYLON_4221.data.u8[0] = (min_voltage & 0x00FF); + PYLON_4221.data.u8[1] = (min_voltage >> 8); + + //Maxvoltage (eg 400.0V = 4000 , 16bits long) Discharge Cutoff Voltage + PYLON_4220.data.u8[2] = (max_voltage & 0x00FF); + PYLON_4220.data.u8[3] = (max_voltage >> 8); + PYLON_4221.data.u8[2] = (max_voltage & 0x00FF); + PYLON_4221.data.u8[3] = (max_voltage >> 8); +#else //Minvoltage (eg 300.0V = 3000 , 16bits long) Charge Cutoff Voltage PYLON_4220.data.u8[0] = (min_voltage >> 8); PYLON_4220.data.u8[1] = (min_voltage & 0x00FF); @@ -210,6 +225,7 @@ void update_values_can_pylon() { //This function maps all the values fetched fr PYLON_4220.data.u8[3] = (max_voltage & 0x00FF); PYLON_4221.data.u8[2] = (max_voltage >> 8); PYLON_4221.data.u8[3] = (max_voltage & 0x00FF); +#endif //In case we run into any errors/faults, we can set charge / discharge forbidden if (bms_status == FAULT) { From aecf2bbcbbb374bb7c01c3e3d61d51efb5edb96d Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 4 Feb 2024 12:55:50 +0200 Subject: [PATCH 2/3] Invert min-max --- Software/src/inverter/PYLON-CAN.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Software/src/inverter/PYLON-CAN.cpp b/Software/src/inverter/PYLON-CAN.cpp index 7dc060ff..6482a924 100644 --- a/Software/src/inverter/PYLON-CAN.cpp +++ b/Software/src/inverter/PYLON-CAN.cpp @@ -202,17 +202,17 @@ void update_values_can_pylon() { //This function maps all the values fetched fr PYLON_4211.data.u8[7] = (StateOfHealth * 0.01); #ifdef INVERT_VOLTAGE //Useful for Sofar inverters - //Minvoltage (eg 300.0V = 3000 , 16bits long) Charge Cutoff Voltage - PYLON_4220.data.u8[0] = (min_voltage & 0x00FF); - PYLON_4220.data.u8[1] = (min_voltage >> 8); - PYLON_4221.data.u8[0] = (min_voltage & 0x00FF); - PYLON_4221.data.u8[1] = (min_voltage >> 8); + //Maxvoltage (eg 400.0V = 4000 , 16bits long) Discharge Cutoff Voltage + PYLON_4220.data.u8[0] = (max_voltage & 0x00FF); + PYLON_4220.data.u8[1] = (max_voltage >> 8); + PYLON_4221.data.u8[0] = (max_voltage & 0x00FF); + PYLON_4221.data.u8[1] = (max_voltage >> 8); - //Maxvoltage (eg 400.0V = 4000 , 16bits long) Discharge Cutoff Voltage - PYLON_4220.data.u8[2] = (max_voltage & 0x00FF); - PYLON_4220.data.u8[3] = (max_voltage >> 8); - PYLON_4221.data.u8[2] = (max_voltage & 0x00FF); - PYLON_4221.data.u8[3] = (max_voltage >> 8); + //Minvoltage (eg 300.0V = 3000 , 16bits long) Charge Cutoff Voltage + PYLON_4220.data.u8[2] = (min_voltage & 0x00FF); + PYLON_4220.data.u8[3] = (min_voltage >> 8); + PYLON_4221.data.u8[2] = (min_voltage & 0x00FF); + PYLON_4221.data.u8[3] = (min_voltage >> 8); #else //Minvoltage (eg 300.0V = 3000 , 16bits long) Charge Cutoff Voltage PYLON_4220.data.u8[0] = (min_voltage >> 8); From 9c2808081dc921345dda65c9541c1b4598cd8e20 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 4 Feb 2024 18:28:33 +0200 Subject: [PATCH 3/3] Precommit fix --- Software/src/inverter/PYLON-CAN.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Software/src/inverter/PYLON-CAN.cpp b/Software/src/inverter/PYLON-CAN.cpp index 6482a924..001e8028 100644 --- a/Software/src/inverter/PYLON-CAN.cpp +++ b/Software/src/inverter/PYLON-CAN.cpp @@ -201,7 +201,7 @@ void update_values_can_pylon() { //This function maps all the values fetched fr PYLON_4210.data.u8[7] = (StateOfHealth * 0.01); PYLON_4211.data.u8[7] = (StateOfHealth * 0.01); -#ifdef INVERT_VOLTAGE //Useful for Sofar inverters +#ifdef INVERT_VOLTAGE //Useful for Sofar inverters \ //Maxvoltage (eg 400.0V = 4000 , 16bits long) Discharge Cutoff Voltage PYLON_4220.data.u8[0] = (max_voltage & 0x00FF); PYLON_4220.data.u8[1] = (max_voltage >> 8);