Breaker ABB Emax 2

Configuration of Breaker ABB Emax 2 Template
This commit is contained in:
Emmanuel HC
2025-11-14 11:24:55 -06:00
parent bd3814aca7
commit 96f68f8d43
4 changed files with 101 additions and 25 deletions

View File

@@ -9,10 +9,10 @@
[platformio] [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] [env]
upload_port = COM26 upload_port = COM19
[common_env_options] [common_env_options]
framework = arduino framework = arduino

View File

@@ -38,6 +38,13 @@
*/ */
template<> template<>
RunningState<ModbusIP>::RunningState() { RunningState<ModbusIP>::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<ModbusIP>* RunningState<ModbusIP>::update(Equipment<ModbusIP>* equipment) { State<ModbusIP>* RunningState<ModbusIP>::update(Equipment<ModbusIP>* equipment) {
// STATE control, add conditions if change to a different state is needed // STATE control, add conditions if change to a different state is needed
Serial.println("Running update function"); Serial.println("Running update function");
float State_Ctrl = getPointValue(equipment, "PxControl");
if (State_Ctrl == 0.0f){
return new StandbyState<ModbusIP>();
}
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<ModbusIP>();
}
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<float>(I_load);
float rating = static_cast<float>(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 // Apply any strategies defined for the standby state
_applyStrategies(equipment); _applyStrategies(equipment);
return nullptr; return nullptr;

View File

@@ -56,7 +56,18 @@ template<>
State<ModbusIP>* StandbyState<ModbusIP>::update(Equipment<ModbusIP>* equipment) { State<ModbusIP>* StandbyState<ModbusIP>::update(Equipment<ModbusIP>* equipment) {
// STATE control, add conditions if change to a different state is needed // STATE control, add conditions if change to a different state is needed
Serial.println("Standby update function"); Serial.println("Standby update function");
float State_Ctrl = getPointValue(equipment, "PxControl");
if (State_Ctrl == 1.0f){
return new RunningState<ModbusIP>();
}
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 // Apply any strategies defined for the standby state
_applyStrategies(equipment); _applyStrategies(equipment);
return nullptr; return nullptr;
@@ -72,6 +83,21 @@ template<>
void StandbyState<ModbusIP>::enterState(Equipment<ModbusIP>* equipment) { void StandbyState<ModbusIP>::enterState(Equipment<ModbusIP>* equipment) {
// Logic to run when the equipment enters this state // Logic to run when the equipment enters this state
Serial.println("Enter Standby 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);
} }
/** /**

View File

@@ -21,10 +21,10 @@
* @{ * @{
*/ */
#include <ModbusIP_ESP8266.h> #include <ModbusIP_ESP8266.h>
const char *ssid = "ArduinoWifiB"; /**< @brief The SSID of the WiFi network. */ const char *ssid = "wifi"; /**< @brief The SSID of the WiFi network. */
const char *password = "123abc456"; /**< @brief The password for the WiFi network. */ const char *password = "password"; /**< @brief The password for the WiFi network. */
IPAddress local_IP(172, 17, 32, 90); /**< @brief The static IP address for the device. */ IPAddress local_IP(192, 168, 1, 170); /**< @brief The static IP address for the device. */
IPAddress gateway(172, 17, 32, 1); /**< @brief The gateway IP address. */ IPAddress gateway(192, 168, 1, 1); /**< @brief The gateway IP address. */
IPAddress subnet(255, 255, 255, 0); /**< @brief The subnet mask. */ IPAddress subnet(255, 255, 255, 0); /**< @brief The subnet mask. */
ModbusIP mb; ModbusIP mb;
@@ -63,23 +63,25 @@ modbusMap mb_map[] = {
// Convert from ESP8266 to traditional Modbus addressing: subtract 30001/40001. // Convert from ESP8266 to traditional Modbus addressing: subtract 30001/40001.
// Input Registers (3x) - Floating Point (MSB & LSB) // Input Registers (3x) - Floating Point (MSB & LSB)
{IR, 40, 0, "CB_Position" }, // 300041.0 - Circuit Breaker Position {HR, 9, 0, "PxControl"}, //Open-Close Cmd
{IR, 40, 0, "CB_Trip" }, // 300041.12 - Circuit Breaker Tripped {HR, 10, 0, "PxLoad"}, //Adjustble Load
{IR_LONG, 100, 0, "Amps_A" }, //DWORD {HR, 11, 0, "PxRating"}, //Max amp to calculate kw, kVA, etc
{IR_LONG, 102, 0, "Amps_B" }, //DWORD {IR, 39, 0, "CB_Position" }, // 300041.0 - Circuit Breaker Position || 300041.12 - Circuit Breaker Tripped
{IR_LONG, 104, 0, "Amps_C" }, //DWORD {IR_LONG, 99, 0, "Amps A" }, //DWORD
{IR_LONG, 106, 0, "Amps_N" }, //DWORD {IR_LONG, 101, 0, "Amps B" }, //DWORD
{IR_LONG, 108, 0, "Amps_G" }, //DWORD {IR_LONG, 103, 0, "Amps C" }, //DWORD
{IR, 150, 0, "V_AN" }, //WORD {IR_LONG, 105, 0, "Amps N" }, //DWORD
{IR, 151, 0, "V_BN" }, //WORD {IR_LONG, 107, 0, "Amps G" }, //DWORD
{IR, 152, 0, "V_CN" }, //WORD {IR, 149, 0, "V_AN" }, //WORD
{IR, 154, 0, "V_AB" }, //WORD {IR, 150, 0, "V_BN" }, //WORD
{IR, 155, 0, "V_BC" }, //WORD {IR, 151, 0, "V_CN" }, //WORD
{IR, 156, 0, "V_CA" }, //WORD {IR, 153, 0, "V_AB" }, //WORD
{IR_LONG, 222, 0, "k_VA" }, //LONG {IR, 154, 0, "V_BC" }, //WORD
{IR_LONG, 206, 0, "kW" }, //LONG {IR, 155, 0, "V_CA" }, //WORD
{IR_LONG, 304, 0, "kWh" }, //LONG {IR_LONG, 221, 0, "k_VA" }, //LONG
{IR, 253, 0, "k_VA" }, //SHORT {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. //Size of modbus map used in FOR cycles, automatically calculated.