From 40e9cc14a6369a9bfed1bd6e0394dbf93366c48b Mon Sep 17 00:00:00 2001 From: Emmanuel HC Date: Wed, 1 Oct 2025 09:24:27 -0500 Subject: [PATCH] PWM PM8000 and PM9000 added to library --- platformio.ini | 20 ++++++-- .../README.md | 0 .../State_Fail.cpp | 0 .../State_Running.cpp | 45 ++++++++++++++++- .../State_Standby.cpp | 17 ++++++- .../config.h | 44 +++++++++-------- .../main.cpp | 0 .../README.md | 0 .../State_Fail.cpp | 0 .../State_Running.cpp | 45 ++++++++++++++++- .../State_Standby.cpp | 17 ++++++- .../config.h | 48 ++++++++++--------- .../main.cpp | 0 13 files changed, 185 insertions(+), 51 deletions(-) rename src/EPMS/PQM/{COD_SKID_Power Meter => PQM_PM8000_TCP}/README.md (100%) rename src/EPMS/PQM/{COD_SKID_Power Meter => PQM_PM8000_TCP}/State_Fail.cpp (100%) rename src/EPMS/PQM/{COD_SKID_Power Meter => PQM_PM8000_TCP}/State_Running.cpp (60%) rename src/EPMS/PQM/{COD_SKID_Power Meter => PQM_PM8000_TCP}/State_Standby.cpp (80%) rename src/EPMS/PQM/{SWR_HSE_Power Meter => PQM_PM8000_TCP}/config.h (63%) rename src/EPMS/PQM/{COD_SKID_Power Meter => PQM_PM8000_TCP}/main.cpp (100%) rename src/EPMS/PQM/{SWR_HSE_Power Meter => PQM_PM9000_TCP}/README.md (100%) rename src/EPMS/PQM/{SWR_HSE_Power Meter => PQM_PM9000_TCP}/State_Fail.cpp (100%) rename src/EPMS/PQM/{SWR_HSE_Power Meter => PQM_PM9000_TCP}/State_Running.cpp (60%) rename src/EPMS/PQM/{SWR_HSE_Power Meter => PQM_PM9000_TCP}/State_Standby.cpp (80%) rename src/EPMS/PQM/{COD_SKID_Power Meter => PQM_PM9000_TCP}/config.h (61%) rename src/EPMS/PQM/{SWR_HSE_Power Meter => PQM_PM9000_TCP}/main.cpp (100%) diff --git a/platformio.ini b/platformio.ini index 75883ff..7c8e53d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,10 +9,10 @@ ; https://docs.platformio.org/page/projectconf.html [platformio] -default_envs = BKR_Eaton_PXR20_25 ; Select here the name of the configuration you want to download +default_envs = PQM_PM9000_TCP ; Select here the name of the configuration you want to download [env] -upload_port = COM50 +upload_port = COM15 [common_env_options] framework = arduino @@ -163,4 +163,18 @@ platform = espressif32 board = dfrobot_firebeetle2_esp32e extends = common_env_options build_flags = -D USE_MODBUS_IP -build_src_filter = -<*> + \ No newline at end of file +build_src_filter = -<*> + + +[env:PQM_PM8000_TCP] +platform = espressif32 +board = dfrobot_firebeetle2_esp32e +extends = common_env_options +build_flags = -D USE_MODBUS_IP +build_src_filter = -<*> + + +[env:PQM_PM9000_TCP] +platform = espressif32 +board = dfrobot_firebeetle2_esp32e +extends = common_env_options +build_flags = -D USE_MODBUS_IP +build_src_filter = -<*> + \ No newline at end of file diff --git a/src/EPMS/PQM/COD_SKID_Power Meter/README.md b/src/EPMS/PQM/PQM_PM8000_TCP/README.md similarity index 100% rename from src/EPMS/PQM/COD_SKID_Power Meter/README.md rename to src/EPMS/PQM/PQM_PM8000_TCP/README.md diff --git a/src/EPMS/PQM/COD_SKID_Power Meter/State_Fail.cpp b/src/EPMS/PQM/PQM_PM8000_TCP/State_Fail.cpp similarity index 100% rename from src/EPMS/PQM/COD_SKID_Power Meter/State_Fail.cpp rename to src/EPMS/PQM/PQM_PM8000_TCP/State_Fail.cpp diff --git a/src/EPMS/PQM/COD_SKID_Power Meter/State_Running.cpp b/src/EPMS/PQM/PQM_PM8000_TCP/State_Running.cpp similarity index 60% rename from src/EPMS/PQM/COD_SKID_Power Meter/State_Running.cpp rename to src/EPMS/PQM/PQM_PM8000_TCP/State_Running.cpp index b9e4a99..e60e869 100644 --- a/src/EPMS/PQM/COD_SKID_Power Meter/State_Running.cpp +++ b/src/EPMS/PQM/PQM_PM8000_TCP/State_Running.cpp @@ -38,6 +38,15 @@ */ template<> RunningState::RunningState() { + addStrategy("Volts AB", new SingleValueStrategy(480.0F, 5.0f, 1000)); + addStrategy("Volts BC", new SingleValueStrategy(480.0F, 5.0f, 1000)); + addStrategy("Volts CA", new SingleValueStrategy(480.0F, 5.0f, 1000)); + + addStrategy("PF", new SingleValueStrategy(0.9f, 0.05f, 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 +66,41 @@ 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, "Powered"); + if (State_Ctrl == 1){ + return new StandbyState(); + } + // Apply any strategies defined for the standby state + float volts_AB = getPointValue(equipment, "Volts AB"); + float volts_BC = getPointValue(equipment, "Volts BC"); + float volts_AC = getPointValue(equipment, "Volts CA"); + + setPointValue(equipment, "Volts AN", volts_AB/1.732); + setPointValue(equipment, "Volts BN", volts_BC/1.732); + setPointValue(equipment, "Volts CN", volts_AC/1.732); + + + int I_load = getPointValue(equipment, "Load"); + int I_rating = getPointValue(equipment, "Rating"); + float load = static_cast(I_load); + float rating = static_cast(I_rating); + float real_load = rating * (load/100.0f); + Strategy_Behavior* ampsA_svs = getStrategy("Amps A"); + Strategy_Behavior* ampsB_svs = getStrategy("Amps B"); + Strategy_Behavior* ampsC_svs = getStrategy("Amps C"); + + static_cast(ampsA_svs)->setSetpoint(real_load); + static_cast(ampsB_svs)->setSetpoint(real_load); + static_cast(ampsC_svs)->setSetpoint(real_load); + + float pf = getPointValue(equipment, "PF"); + + + float kw = (1.732f * ((volts_AB + volts_BC + volts_AC)/3.0f) * real_load * pf)/1000; + float kva = (1.732f * ((volts_AB + volts_BC + volts_AC)/3.0f) * real_load)/1000; + + setPointValue(equipment, "kW", kw); + setPointValue(equipment, "kVA", kva); // Apply any strategies defined for the standby state _applyStrategies(equipment); return nullptr; diff --git a/src/EPMS/PQM/COD_SKID_Power Meter/State_Standby.cpp b/src/EPMS/PQM/PQM_PM8000_TCP/State_Standby.cpp similarity index 80% rename from src/EPMS/PQM/COD_SKID_Power Meter/State_Standby.cpp rename to src/EPMS/PQM/PQM_PM8000_TCP/State_Standby.cpp index 20029d1..0600853 100644 --- a/src/EPMS/PQM/COD_SKID_Power Meter/State_Standby.cpp +++ b/src/EPMS/PQM/PQM_PM8000_TCP/State_Standby.cpp @@ -56,7 +56,10 @@ 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, "Powered"); + if (State_Ctrl == 2){ + return new RunningState(); + } // Apply any strategies defined for the standby state _applyStrategies(equipment); return nullptr; @@ -72,6 +75,18 @@ template<> void StandbyState::enterState(Equipment* equipment) { // Logic to run when the equipment enters this state Serial.println("Enter Standby State..."); + setPointValue(equipment, "Volts AB", 0.0f); + setPointValue(equipment, "Volts BC", 0.0f); + setPointValue(equipment, "Volts CA", 0.0f); + setPointValue(equipment, "Volts AN", 0.0f); + setPointValue(equipment, "Volts BN", 0.0f); + setPointValue(equipment, "Volts CN", 0.0f); + setPointValue(equipment, "PF", 0.0f); + setPointValue(equipment, "Amps A", 0.0f); + setPointValue(equipment, "Amps B", 0.0f); + setPointValue(equipment, "Amps C", 0.0f); + setPointValue(equipment, "kW", 0.0f); + setPointValue(equipment, "kVA", 0.0f); } /** diff --git a/src/EPMS/PQM/SWR_HSE_Power Meter/config.h b/src/EPMS/PQM/PQM_PM8000_TCP/config.h similarity index 63% rename from src/EPMS/PQM/SWR_HSE_Power Meter/config.h rename to src/EPMS/PQM/PQM_PM8000_TCP/config.h index 9268621..cbbabd6 100644 --- a/src/EPMS/PQM/SWR_HSE_Power Meter/config.h +++ b/src/EPMS/PQM/PQM_PM8000_TCP/config.h @@ -21,10 +21,10 @@ * @{ */ #include - const char *ssid = "wifi_name"; /**< @brief The SSID of the WiFi network. */ - const char *password = "wifi_password"; /**< @brief The password for the WiFi network. */ - IPAddress local_IP(192, 168, 1, 234); /**< @brief The static IP address for the device. */ - IPAddress gateway(192, 168, 1, 1); /**< @brief The gateway IP address. */ + const char *ssid = "QTS_CDR_Arduino"; /**< @brief The SSID of the WiFi network. */ + const char *password = "123abc456"; /**< @brief The password for the WiFi network. */ + IPAddress local_IP(172, 17, 30, 241); /**< @brief The static IP address for the device. */ + IPAddress gateway(172, 17, 30, 1); /**< @brief The gateway IP address. */ IPAddress subnet(255, 255, 255, 0); /**< @brief The subnet mask. */ ModbusIP mb; @@ -60,23 +60,25 @@ */ modbusMap mb_map[] = { - {HR, 15, 0, "State Control"}, //Internal to control from Modscan - {HR, 16, 0, "Fault Code"}, - {HR_LONG, 351, 0, "Amps Phase A"}, //Internal Fault code from Modscan - {HR_LONG, 353, 0, "Amps Phase B"}, - {HR_LONG, 355, 0, "AMPS Phase C"}, - {HR_LONG, 357, 0, "Amps N"}, - {HR_LONG, 901, 0, "Frequency"}, - {HR_LONG, 373, 0, "kVA"}, - {HR_LONG, 371, 0, "kW"}, - {HR_LONG, 601, 0, "kWh"}, - {HR, 911, 0, "Power Factor"}, - {HR_LONG, 365, 0, "Volts A-B"}, - {HR_LONG, 359, 0, "Volts A-N"}, - {HR_LONG, 367, 0, "Volts B-C"}, - {HR_LONG, 361, 0, "Volts B-N"}, - {HR_LONG, 369, 0, "Volts C-A"}, - {HR_LONG, 363, 0, "Volts C-N"}, + {HR, 9, 0, "Powered"}, + {HR, 10, 0, "Load"}, //Internal to control from Modscan + {HR, 11, 0, "Rating"}, //Internal Fault code from Modscan + + {HR_FLOAT, 2699, 0, "kWh"}, + {HR_FLOAT, 2999, 0, "Amps A"}, + {HR_FLOAT, 3001, 0, "Amps B"}, + {HR_FLOAT, 3003, 0, "Amps C"}, + {HR_FLOAT, 3005, 0, "Amps N"}, + {HR_FLOAT, 3019, 0, "Volts AB"}, + {HR_FLOAT, 3021, 0, "Volts BC"}, + {HR_FLOAT, 3023, 0, "Volts CA"}, + {HR_FLOAT, 3027, 0, "Volts AN"}, + {HR_FLOAT, 3029, 0, "Volts BN"}, + {HR_FLOAT, 3031, 0, "Volts CN"}, //May need to add moe points once I get clarification from Casne + {HR_FLOAT, 3059, 0, "kW"}, + {HR_FLOAT, 3075, 0, "kVA"}, + {HR_FLOAT, 3109, 0, "Frequency"}, + {HR_FLOAT, 3149, 0, "PF"}, }; //Size of modbus map used in FOR cycles, automatically calculated. diff --git a/src/EPMS/PQM/COD_SKID_Power Meter/main.cpp b/src/EPMS/PQM/PQM_PM8000_TCP/main.cpp similarity index 100% rename from src/EPMS/PQM/COD_SKID_Power Meter/main.cpp rename to src/EPMS/PQM/PQM_PM8000_TCP/main.cpp diff --git a/src/EPMS/PQM/SWR_HSE_Power Meter/README.md b/src/EPMS/PQM/PQM_PM9000_TCP/README.md similarity index 100% rename from src/EPMS/PQM/SWR_HSE_Power Meter/README.md rename to src/EPMS/PQM/PQM_PM9000_TCP/README.md diff --git a/src/EPMS/PQM/SWR_HSE_Power Meter/State_Fail.cpp b/src/EPMS/PQM/PQM_PM9000_TCP/State_Fail.cpp similarity index 100% rename from src/EPMS/PQM/SWR_HSE_Power Meter/State_Fail.cpp rename to src/EPMS/PQM/PQM_PM9000_TCP/State_Fail.cpp diff --git a/src/EPMS/PQM/SWR_HSE_Power Meter/State_Running.cpp b/src/EPMS/PQM/PQM_PM9000_TCP/State_Running.cpp similarity index 60% rename from src/EPMS/PQM/SWR_HSE_Power Meter/State_Running.cpp rename to src/EPMS/PQM/PQM_PM9000_TCP/State_Running.cpp index b9e4a99..e60e869 100644 --- a/src/EPMS/PQM/SWR_HSE_Power Meter/State_Running.cpp +++ b/src/EPMS/PQM/PQM_PM9000_TCP/State_Running.cpp @@ -38,6 +38,15 @@ */ template<> RunningState::RunningState() { + addStrategy("Volts AB", new SingleValueStrategy(480.0F, 5.0f, 1000)); + addStrategy("Volts BC", new SingleValueStrategy(480.0F, 5.0f, 1000)); + addStrategy("Volts CA", new SingleValueStrategy(480.0F, 5.0f, 1000)); + + addStrategy("PF", new SingleValueStrategy(0.9f, 0.05f, 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 +66,41 @@ 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, "Powered"); + if (State_Ctrl == 1){ + return new StandbyState(); + } + // Apply any strategies defined for the standby state + float volts_AB = getPointValue(equipment, "Volts AB"); + float volts_BC = getPointValue(equipment, "Volts BC"); + float volts_AC = getPointValue(equipment, "Volts CA"); + + setPointValue(equipment, "Volts AN", volts_AB/1.732); + setPointValue(equipment, "Volts BN", volts_BC/1.732); + setPointValue(equipment, "Volts CN", volts_AC/1.732); + + + int I_load = getPointValue(equipment, "Load"); + int I_rating = getPointValue(equipment, "Rating"); + float load = static_cast(I_load); + float rating = static_cast(I_rating); + float real_load = rating * (load/100.0f); + Strategy_Behavior* ampsA_svs = getStrategy("Amps A"); + Strategy_Behavior* ampsB_svs = getStrategy("Amps B"); + Strategy_Behavior* ampsC_svs = getStrategy("Amps C"); + + static_cast(ampsA_svs)->setSetpoint(real_load); + static_cast(ampsB_svs)->setSetpoint(real_load); + static_cast(ampsC_svs)->setSetpoint(real_load); + + float pf = getPointValue(equipment, "PF"); + + + float kw = (1.732f * ((volts_AB + volts_BC + volts_AC)/3.0f) * real_load * pf)/1000; + float kva = (1.732f * ((volts_AB + volts_BC + volts_AC)/3.0f) * real_load)/1000; + + setPointValue(equipment, "kW", kw); + setPointValue(equipment, "kVA", kva); // Apply any strategies defined for the standby state _applyStrategies(equipment); return nullptr; diff --git a/src/EPMS/PQM/SWR_HSE_Power Meter/State_Standby.cpp b/src/EPMS/PQM/PQM_PM9000_TCP/State_Standby.cpp similarity index 80% rename from src/EPMS/PQM/SWR_HSE_Power Meter/State_Standby.cpp rename to src/EPMS/PQM/PQM_PM9000_TCP/State_Standby.cpp index 20029d1..0600853 100644 --- a/src/EPMS/PQM/SWR_HSE_Power Meter/State_Standby.cpp +++ b/src/EPMS/PQM/PQM_PM9000_TCP/State_Standby.cpp @@ -56,7 +56,10 @@ 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, "Powered"); + if (State_Ctrl == 2){ + return new RunningState(); + } // Apply any strategies defined for the standby state _applyStrategies(equipment); return nullptr; @@ -72,6 +75,18 @@ template<> void StandbyState::enterState(Equipment* equipment) { // Logic to run when the equipment enters this state Serial.println("Enter Standby State..."); + setPointValue(equipment, "Volts AB", 0.0f); + setPointValue(equipment, "Volts BC", 0.0f); + setPointValue(equipment, "Volts CA", 0.0f); + setPointValue(equipment, "Volts AN", 0.0f); + setPointValue(equipment, "Volts BN", 0.0f); + setPointValue(equipment, "Volts CN", 0.0f); + setPointValue(equipment, "PF", 0.0f); + setPointValue(equipment, "Amps A", 0.0f); + setPointValue(equipment, "Amps B", 0.0f); + setPointValue(equipment, "Amps C", 0.0f); + setPointValue(equipment, "kW", 0.0f); + setPointValue(equipment, "kVA", 0.0f); } /** diff --git a/src/EPMS/PQM/COD_SKID_Power Meter/config.h b/src/EPMS/PQM/PQM_PM9000_TCP/config.h similarity index 61% rename from src/EPMS/PQM/COD_SKID_Power Meter/config.h rename to src/EPMS/PQM/PQM_PM9000_TCP/config.h index eff7b40..f323a0c 100644 --- a/src/EPMS/PQM/COD_SKID_Power Meter/config.h +++ b/src/EPMS/PQM/PQM_PM9000_TCP/config.h @@ -21,10 +21,10 @@ * @{ */ #include - const char *ssid = "wifi_name"; /**< @brief The SSID of the WiFi network. */ - const char *password = "wifi_password"; /**< @brief The password for the WiFi network. */ - IPAddress local_IP(192, 168, 1, 234); /**< @brief The static IP address for the device. */ - IPAddress gateway(192, 168, 1, 1); /**< @brief The gateway IP address. */ + const char *ssid = "QTS_CDR_Arduino"; /**< @brief The SSID of the WiFi network. */ + const char *password = "123abc456"; /**< @brief The password for the WiFi network. */ + IPAddress local_IP(172, 17, 30, 241); /**< @brief The static IP address for the device. */ + IPAddress gateway(172, 17, 30, 1); /**< @brief The gateway IP address. */ IPAddress subnet(255, 255, 255, 0); /**< @brief The subnet mask. */ ModbusIP mb; @@ -60,25 +60,27 @@ */ modbusMap mb_map[] = { - {HR, 15, 0, "State Control"}, //Internal to control from Modscan - {HR, 16, 0, "Fault Code"}, //Internal Fault code from Modscan - {HR_FLOAT, 3052, 0, "Unbalanced Voltage"}, - {HR_FLOAT, 3000, 0, "Amps Phase A"}, - {HR_FLOAT, 3002, 0, "AMPS Phase B"}, - {HR_FLOAT, 3004, 0, "Amps Phase C"}, - {HR_FLOAT, 3006, 0, "Amps N"}, - {HR_FLOAT, 3110, 0, "Frequency"}, - {HR_FLOAT, 3076, 0, "kVA"}, - {HR_FLOAT, 3060, 0, "kW"}, - {HR_FLOAT, 2700, 0, "kWh"}, - {HR_FLOAT, 3150, 0, "Power Factor"}, - {HR_FLOAT, 3020, 0, "Volts A-B"}, - {HR_FLOAT, 3028, 0, "Volts A-N"}, - {HR_FLOAT, 3022, 0, "Volts B-C"}, - {HR_FLOAT, 3030, 0, "Volts B-N"}, - {HR_FLOAT, 3024, 0, "Volts C-A"}, - {HR_FLOAT, 3032, 0, "Volts C-N"}, - {HR_FLOAT, 3026, 0, "Volts L-L Avg"}, //May need to add moe points once I get clarification from Casne + {HR, 9, 0, "Powered"}, + {HR, 10, 0, "Load"}, //Internal to control from Modscan + {HR, 11, 0, "Rating"}, //Internal Fault code from Modscan + + {HR_FLOAT, 2699, 0, "kWh"}, + {HR_FLOAT, 2999, 0, "Amps A"}, + {HR_FLOAT, 3001, 0, "Amps B"}, + {HR_FLOAT, 3003, 0, "Amps C"}, + {HR_FLOAT, 3005, 0, "Amps N"}, + {HR_FLOAT, 3019, 0, "Volts AB"}, + {HR_FLOAT, 3021, 0, "Volts BC"}, + {HR_FLOAT, 3023, 0, "Volts CA"}, + {HR_FLOAT, 3025, 0, "Volts LL Avg"}, + {HR_FLOAT, 3027, 0, "Volts AN"}, + {HR_FLOAT, 3029, 0, "Volts BN"}, + {HR_FLOAT, 3031, 0, "Volts CN"}, //May need to add moe points once I get clarification from Casne + {HR_FLOAT, 3051, 0, "Voltage Unbalanced"}, + {HR_FLOAT, 3059, 0, "kW"}, + {HR_FLOAT, 3075, 0, "kVA"}, + {HR_FLOAT, 3109, 0, "Frequency"}, + {HR_FLOAT, 3149, 0, "PF"}, }; //Size of modbus map used in FOR cycles, automatically calculated. diff --git a/src/EPMS/PQM/SWR_HSE_Power Meter/main.cpp b/src/EPMS/PQM/PQM_PM9000_TCP/main.cpp similarity index 100% rename from src/EPMS/PQM/SWR_HSE_Power Meter/main.cpp rename to src/EPMS/PQM/PQM_PM9000_TCP/main.cpp