From 96f68f8d43aa4dc07a56e23e7667d0ae5e169fc8 Mon Sep 17 00:00:00 2001 From: Emmanuel HC Date: Fri, 14 Nov 2025 11:24:55 -0600 Subject: [PATCH] Breaker ABB Emax 2 Configuration of Breaker ABB Emax 2 Template --- platformio.ini | 4 +- .../BKR_ABB_EMax2_TCP/State_Running.cpp | 50 ++++++++++++++++++- .../BKR_ABB_EMax2_TCP/State_Standby.cpp | 28 ++++++++++- src/EPMS/Breaker/BKR_ABB_EMax2_TCP/config.h | 44 ++++++++-------- 4 files changed, 101 insertions(+), 25 deletions(-) diff --git a/platformio.ini b/platformio.ini index 5552fe6..bf5c678 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,10 +9,10 @@ [platformio] -default_envs = GEN_CAT_GCCP_TCP ; Select here the name of the configuration you want to download +default_envs = BKR_ABB_EMax2_TCP ; Select here the name of the configuration you want to download [env] -upload_port = COM26 +upload_port = COM19 [common_env_options] framework = arduino diff --git a/src/EPMS/Breaker/BKR_ABB_EMax2_TCP/State_Running.cpp b/src/EPMS/Breaker/BKR_ABB_EMax2_TCP/State_Running.cpp index b9e4a99..6d6c693 100644 --- a/src/EPMS/Breaker/BKR_ABB_EMax2_TCP/State_Running.cpp +++ b/src/EPMS/Breaker/BKR_ABB_EMax2_TCP/State_Running.cpp @@ -38,6 +38,13 @@ */ template<> RunningState::RunningState() { + addStrategy("V_AB", new SingleValueStrategy(4800.0F, 5.0f, 1000)); + addStrategy("V_BC", new SingleValueStrategy(4800.0F, 5.0f, 1000)); + addStrategy("V_CA", new SingleValueStrategy(4800.0F, 5.0f, 1000)); + + addStrategy("Amps A", new SingleValueStrategy(1.0f, 10.0f, 1000)); + addStrategy("Amps B", new SingleValueStrategy(1.0f, 10.0f, 1000)); + addStrategy("Amps C", new SingleValueStrategy(1.0f, 10.0f, 1000)); } /** @@ -57,7 +64,48 @@ template<> State* RunningState::update(Equipment* equipment) { // STATE control, add conditions if change to a different state is needed Serial.println("Running update function"); - + float State_Ctrl = getPointValue(equipment, "PxControl"); + if (State_Ctrl == 0.0f){ + return new StandbyState(); + } + if (State_Ctrl == 1.0f){ + setBitValue(equipment, "CB_Position", 0, true); + setBitValue(equipment, "CB_Position", 12, false); + } + if (State_Ctrl == 2.0f){ + return new StandbyState(); + } + + float volts_AB = getPointValue(equipment, "V_AB"); + float volts_BC = getPointValue(equipment, "V_BC"); + float volts_AC = getPointValue(equipment, "V_CA"); + + setPointValue(equipment, "V_AN", volts_AB/1.732f); + setPointValue(equipment, "V_BN", volts_BC/1.732f); + setPointValue(equipment, "V_CN", volts_AC/1.732f); + + + int I_load = getPointValue(equipment, "PxLoad"); + int I_rating = getPointValue(equipment, "PxRating"); + float load = static_cast(I_load); + float rating = static_cast(I_rating); + float real_load = rating * (load/100.0f); + setPointValue(equipment, "Amps A", real_load * 10.0f); + setPointValue(equipment, "Amps B", real_load * 10.0f); + setPointValue(equipment, "Amps C", real_load * 10.0f); + setPointValue(equipment, "Amps G", volts_AB * 0.037f); + setPointValue(equipment, "Amps N", volts_BC * 0.034f); + + + + + float kva = (1.732f * ((volts_AB + volts_BC + volts_AC)/4.0f) * real_load * (0.92f))/100000.0f; + float kw = (1.732f * ((volts_AB + volts_BC + volts_AC)/4.0f) * real_load )/10000.0f; + + setPointValue(equipment, "kW", kw); + setPointValue(equipment, "kVA", kva); + setPointValue(equipment, "kVA2", kva); + setPointValue(equipment, "kWh", 1724.0f); // Apply any strategies defined for the standby state _applyStrategies(equipment); return nullptr; diff --git a/src/EPMS/Breaker/BKR_ABB_EMax2_TCP/State_Standby.cpp b/src/EPMS/Breaker/BKR_ABB_EMax2_TCP/State_Standby.cpp index 20029d1..51e0f25 100644 --- a/src/EPMS/Breaker/BKR_ABB_EMax2_TCP/State_Standby.cpp +++ b/src/EPMS/Breaker/BKR_ABB_EMax2_TCP/State_Standby.cpp @@ -56,7 +56,18 @@ template<> State* StandbyState::update(Equipment* equipment) { // STATE control, add conditions if change to a different state is needed Serial.println("Standby update function"); - + float State_Ctrl = getPointValue(equipment, "PxControl"); + if (State_Ctrl == 1.0f){ + return new RunningState(); + } + if (State_Ctrl == 0.0f){ + setBitValue(equipment, "CB_Position", 0, false); + setBitValue(equipment, "CB_Position", 12, false); + } + if (State_Ctrl == 2.0f){ + setBitValue(equipment, "CB_Position", 0, false); + setBitValue(equipment, "CB_Position", 12, true); + } // Apply any strategies defined for the standby state _applyStrategies(equipment); return nullptr; @@ -72,6 +83,21 @@ template<> void StandbyState::enterState(Equipment* equipment) { // Logic to run when the equipment enters this state Serial.println("Enter Standby State..."); + setPointValue(equipment, "V_AB", 0.0f); + setPointValue(equipment, "V_BC", 0.0f); + setPointValue(equipment, "V_CA", 0.0f); + setPointValue(equipment, "V_AN", 0.0f); + setPointValue(equipment, "V_BN", 0.0f); + setPointValue(equipment, "V_CN", 0.0f); + setPointValue(equipment, "Amps A", 0.0f); + setPointValue(equipment, "Amps B", 0.0f); + setPointValue(equipment, "Amps C", 0.0f); + setPointValue(equipment, "Amps G", 0.0f); + setPointValue(equipment, "Amps N", 0.0f); + setPointValue(equipment, "kW", 0.0f); + setPointValue(equipment, "k_VA", 0.0f); + setPointValue(equipment, "k_VA2", 0.0f); + setPointValue(equipment, "kWh", 0.0f); } /** diff --git a/src/EPMS/Breaker/BKR_ABB_EMax2_TCP/config.h b/src/EPMS/Breaker/BKR_ABB_EMax2_TCP/config.h index 22baf7d..7728a3c 100644 --- a/src/EPMS/Breaker/BKR_ABB_EMax2_TCP/config.h +++ b/src/EPMS/Breaker/BKR_ABB_EMax2_TCP/config.h @@ -21,10 +21,10 @@ * @{ */ #include - const char *ssid = "ArduinoWifiB"; /**< @brief The SSID of the WiFi network. */ - const char *password = "123abc456"; /**< @brief The password for the WiFi network. */ - IPAddress local_IP(172, 17, 32, 90); /**< @brief The static IP address for the device. */ - IPAddress gateway(172, 17, 32, 1); /**< @brief The gateway IP address. */ + const char *ssid = "wifi"; /**< @brief The SSID of the WiFi network. */ + const char *password = "password"; /**< @brief The password for the WiFi network. */ + IPAddress local_IP(192, 168, 1, 170); /**< @brief The static IP address for the device. */ + IPAddress gateway(192, 168, 1, 1); /**< @brief The gateway IP address. */ IPAddress subnet(255, 255, 255, 0); /**< @brief The subnet mask. */ ModbusIP mb; @@ -63,23 +63,25 @@ modbusMap mb_map[] = { // Convert from ESP8266 to traditional Modbus addressing: subtract 30001/40001. // Input Registers (3x) - Floating Point (MSB & LSB) - {IR, 40, 0, "CB_Position" }, // 300041.0 - Circuit Breaker Position - {IR, 40, 0, "CB_Trip" }, // 300041.12 - Circuit Breaker Tripped - {IR_LONG, 100, 0, "Amps_A" }, //DWORD - {IR_LONG, 102, 0, "Amps_B" }, //DWORD - {IR_LONG, 104, 0, "Amps_C" }, //DWORD - {IR_LONG, 106, 0, "Amps_N" }, //DWORD - {IR_LONG, 108, 0, "Amps_G" }, //DWORD - {IR, 150, 0, "V_AN" }, //WORD - {IR, 151, 0, "V_BN" }, //WORD - {IR, 152, 0, "V_CN" }, //WORD - {IR, 154, 0, "V_AB" }, //WORD - {IR, 155, 0, "V_BC" }, //WORD - {IR, 156, 0, "V_CA" }, //WORD - {IR_LONG, 222, 0, "k_VA" }, //LONG - {IR_LONG, 206, 0, "kW" }, //LONG - {IR_LONG, 304, 0, "kWh" }, //LONG - {IR, 253, 0, "k_VA" }, //SHORT + {HR, 9, 0, "PxControl"}, //Open-Close Cmd + {HR, 10, 0, "PxLoad"}, //Adjustble Load + {HR, 11, 0, "PxRating"}, //Max amp to calculate kw, kVA, etc + {IR, 39, 0, "CB_Position" }, // 300041.0 - Circuit Breaker Position || 300041.12 - Circuit Breaker Tripped + {IR_LONG, 99, 0, "Amps A" }, //DWORD + {IR_LONG, 101, 0, "Amps B" }, //DWORD + {IR_LONG, 103, 0, "Amps C" }, //DWORD + {IR_LONG, 105, 0, "Amps N" }, //DWORD + {IR_LONG, 107, 0, "Amps G" }, //DWORD + {IR, 149, 0, "V_AN" }, //WORD + {IR, 150, 0, "V_BN" }, //WORD + {IR, 151, 0, "V_CN" }, //WORD + {IR, 153, 0, "V_AB" }, //WORD + {IR, 154, 0, "V_BC" }, //WORD + {IR, 155, 0, "V_CA" }, //WORD + {IR_LONG, 221, 0, "k_VA" }, //LONG + {IR_LONG, 205, 0, "kW" }, //LONG + {IR_LONG, 303, 0, "kWh" }, //LONG + {IR, 252, 0, "k_VA2" }, //SHORT }; //Size of modbus map used in FOR cycles, automatically calculated.