PWM PM8000 and PM9000 added to library

This commit is contained in:
Emmanuel HC
2025-10-01 09:24:27 -05:00
parent 80392c072f
commit 40e9cc14a6
13 changed files with 185 additions and 51 deletions

View File

@@ -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 = -<*> +<EPMS/Breaker/BKR_Eaton_PXR20_25>
build_src_filter = -<*> +<EPMS/Breaker/BKR_Eaton_PXR20_25>
[env:PQM_PM8000_TCP]
platform = espressif32
board = dfrobot_firebeetle2_esp32e
extends = common_env_options
build_flags = -D USE_MODBUS_IP
build_src_filter = -<*> +<EPMS/PQM/PQM_PM8000_TCP>
[env:PQM_PM9000_TCP]
platform = espressif32
board = dfrobot_firebeetle2_esp32e
extends = common_env_options
build_flags = -D USE_MODBUS_IP
build_src_filter = -<*> +<EPMS/PQM/PQM_PM9000_TCP>

View File

@@ -38,6 +38,15 @@
*/
template<>
RunningState<ModbusIP>::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<ModbusIP>* RunningState<ModbusIP>::update(Equipment<ModbusIP>* 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<ModbusIP>();
}
// 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<float>(I_load);
float rating = static_cast<float>(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<SingleValueStrategy*>(ampsA_svs)->setSetpoint(real_load);
static_cast<SingleValueStrategy*>(ampsB_svs)->setSetpoint(real_load);
static_cast<SingleValueStrategy*>(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;

View File

@@ -56,7 +56,10 @@ template<>
State<ModbusIP>* StandbyState<ModbusIP>::update(Equipment<ModbusIP>* 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<ModbusIP>();
}
// Apply any strategies defined for the standby state
_applyStrategies(equipment);
return nullptr;
@@ -72,6 +75,18 @@ template<>
void StandbyState<ModbusIP>::enterState(Equipment<ModbusIP>* 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);
}
/**

View File

@@ -21,10 +21,10 @@
* @{
*/
#include <ModbusIP_ESP8266.h>
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.

View File

@@ -38,6 +38,15 @@
*/
template<>
RunningState<ModbusIP>::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<ModbusIP>* RunningState<ModbusIP>::update(Equipment<ModbusIP>* 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<ModbusIP>();
}
// 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<float>(I_load);
float rating = static_cast<float>(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<SingleValueStrategy*>(ampsA_svs)->setSetpoint(real_load);
static_cast<SingleValueStrategy*>(ampsB_svs)->setSetpoint(real_load);
static_cast<SingleValueStrategy*>(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;

View File

@@ -56,7 +56,10 @@ template<>
State<ModbusIP>* StandbyState<ModbusIP>::update(Equipment<ModbusIP>* 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<ModbusIP>();
}
// Apply any strategies defined for the standby state
_applyStrategies(equipment);
return nullptr;
@@ -72,6 +75,18 @@ template<>
void StandbyState<ModbusIP>::enterState(Equipment<ModbusIP>* 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);
}
/**

View File

@@ -21,10 +21,10 @@
* @{
*/
#include <ModbusIP_ESP8266.h>
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.