This commit is contained in:
Emmanuel HC
2025-10-30 16:53:26 -05:00
parent 1e4cf1394b
commit 12e397c855
3 changed files with 137 additions and 146 deletions

View File

@@ -10,7 +10,7 @@
[platformio]
default_envs = BKR_Susol_ACB_TCP ; Select here the name of the configuration you want to download
default_envs = CRAH_PETRA_PAHHC_600_C6_TCP ; Select here the name of the configuration you want to download
[env]
upload_port = COM50
@@ -36,6 +36,13 @@ extends = common_env_options
build_flags = -D USE_MODBUS_IP ;Importat configuration, this flags is used to configure the program
build_src_filter = -<*> +<Base_TCP> ;Add the specific folder path here
;----------------------------------------------------------------------------------------------------
[env:CRAH_PETRA_PAHHC_600_C6_TCP]
platform = espressif32
board = dfrobot_firebeetle2_esp32e
extends = common_env_options
build_flags = -D USE_MODBUS_IP
build_src_filter = -<*> +<BMS/CRAH/CRAH_PETRA_PAHHC_600_C6_TCP>
[env:POD_MBB_Power_Meter_TCP]
platform = espressif32
board = dfrobot_firebeetle2_esp32e

View File

@@ -38,16 +38,26 @@
*/
template<>
RunningState<ModbusIP>::RunningState() {
addStrategy("CW Valve Position", new PIDStrategy("RAT Setpoint", 1000, "RAT"));
addStrategy("Operating Hours EC Fan #1", new TotalizerStrategy(10000));
addStrategy("Operating Hours EC Fan #2", new TotalizerStrategy(10000));
addStrategy("Operating Hours EC Fan #3", new TotalizerStrategy(10000));
addStrategy("Operating Hours EC Fan #4", new TotalizerStrategy(10000));
addStrategy("Operating Hours EC Fan #5", new TotalizerStrategy(10000));
addStrategy("Operating Hours EC Fan #6", new TotalizerStrategy(10000));
addStrategy("Operating Hours EC Fan #7", new TotalizerStrategy(10000));
addStrategy("Operating Hours EC Fan #8", new TotalizerStrategy(10000));
addStrategy("Operating Hours EC Fan #9", new TotalizerStrategy(10000));
addStrategy("CW Valve Position", new PIDStrategy("SAT Setpoint", 2000, "SAT Reading"));
addStrategy("SAT Reading", new SingleValueStrategy(0.0f, 3.0f, 1000));
addStrategy("Speed EC Fan #1", new RampStrategy(0.0f, 500.0f, 1000));
addStrategy("Speed EC Fan #2", new RampStrategy(0.0f, 500.0f, 1000));
addStrategy("Speed EC Fan #3", new RampStrategy(0.0f, 500.0f, 1000));
addStrategy("Speed EC Fan #4", new RampStrategy(0.0f, 500.0f, 1000));
addStrategy("Speed EC Fan #5", new RampStrategy(0.0f, 500.0f, 1000));
addStrategy("Speed EC Fan #6", new RampStrategy(0.0f, 500.0f, 1000));
addStrategy("Speed EC Fan #7", new RampStrategy(0.0f, 500.0f, 1000));
addStrategy("Speed EC Fan #8", new RampStrategy(0.0f, 500.0f, 1000));
addStrategy("Speed EC Fan #9", new RampStrategy(0.0f, 500.0f, 1000));
addStrategy("Operating Hours EC Fan #1", new TotalizerStrategy(1100));
addStrategy("Operating Hours EC Fan #2", new TotalizerStrategy(1200));
addStrategy("Operating Hours EC Fan #3", new TotalizerStrategy(1300));
addStrategy("Operating Hours EC Fan #4", new TotalizerStrategy(1250));
addStrategy("Operating Hours EC Fan #5", new TotalizerStrategy(1350));
addStrategy("Operating Hours EC Fan #6", new TotalizerStrategy(1450));
addStrategy("Operating Hours EC Fan #7", new TotalizerStrategy(1150));
addStrategy("Operating Hours EC Fan #8", new TotalizerStrategy(1180));
addStrategy("Operating Hours EC Fan #9", new TotalizerStrategy(1340));
}
/**
@@ -74,63 +84,36 @@ State<ModbusIP>* RunningState<ModbusIP>::update(Equipment<ModbusIP>* equipment)
return new StandbyState<ModbusIP>();
}
Modbus_Point<ModbusIP>* faultCode = equipment->getModbus_Point("Fault Code");
int faultCodeValue = faultCode ? faultCode->getValue() : 0;
switch (faultCodeValue){
case 1:
return new FailState<ModbusIP>({"Alarm SAT Sensor Fault"});
case 2:
return new FailState<ModbusIP>({"Alarm RAH Sensor Fault"});
case 3:
return new FailState<ModbusIP>({"Alarm RAT Sensor Fault"});
case 4:
return new FailState<ModbusIP>({"Alarm Filter DP Sensor Fault"});
case 5:
return new FailState<ModbusIP>({"Alarm Flooding"});
case 6:
return new FailState<ModbusIP>({"Alarm Dirty Filter"});
case 7:
return new FailState<ModbusIP>({"Alarm High RAT"});
case 8:
return new FailState<ModbusIP>({"Alarm Low RAT"});
case 9:
return new FailState<ModbusIP>({"Alarm High SAT"});
case 10:
return new FailState<ModbusIP>({"Alarm Low SAT"});
case 11:
return new FailState<ModbusIP>({"Alarm High RAH"});
case 12:
return new FailState<ModbusIP>({"Alarm Low RAH"});
case 13:
return new FailState<ModbusIP>({"Alarm Phase Failure"});
case 14:
return new FailState<ModbusIP>({"Alarm Condensate Pump"});
case 15:
return new FailState<ModbusIP>({"Alarm Smoke"});
case 16:
return new FailState<ModbusIP>({"Alarm Fire"});
case 17:
return new FailState<ModbusIP>({"Alarm EC Fan #1"});
case 18:
return new FailState<ModbusIP>({"Alarm EC Fan #2"});
case 19:
return new FailState<ModbusIP>({"Alarm EC Fan #3"});
case 20:
return new FailState<ModbusIP>({"Alarm EC Fan #4"});
case 21:
return new FailState<ModbusIP>({"Alarm EC Fan #5"});
case 22:
return new FailState<ModbusIP>({"Alarm EC Fan #6"});
case 23:
return new FailState<ModbusIP>({"Alarm EC Fan #7"});
case 24:
return new FailState<ModbusIP>({"Alarm EC Fan #8"});
case 25:
return new FailState<ModbusIP>({"Alarm EC Fan #9"});
default:
break;
}
float rat = getPointValue(equipment, "RAT");
setPointValue(equipment, "RAT Reading", rat);
float speed = getPointValue(equipment, "Setting EC Fan Speed");
Strategy_Behavior* fan1_rs = getStrategy("Speed EC Fan #1");
static_cast<RampStrategy*>(fan1_rs)->setTarget(4200.0f * (speed /100.0f));
Strategy_Behavior* fan2_rs = getStrategy("Speed EC Fan #2");
static_cast<RampStrategy*>(fan2_rs)->setTarget(4200.0f * (speed /100.0f));
Strategy_Behavior* fan3_rs = getStrategy("Speed EC Fan #3");
static_cast<RampStrategy*>(fan3_rs)->setTarget(4200.0f * (speed /100.0f));
Strategy_Behavior* fan4_rs = getStrategy("Speed EC Fan #4");
static_cast<RampStrategy*>(fan4_rs)->setTarget(4200.0f * (speed /100.0f));
Strategy_Behavior* fan5_rs = getStrategy("Speed EC Fan #5");
static_cast<RampStrategy*>(fan5_rs)->setTarget(4200.0f * (speed /100.0f));
Strategy_Behavior* fan6_rs = getStrategy("Speed EC Fan #6");
static_cast<RampStrategy*>(fan6_rs)->setTarget(4200.0f * (speed /100.0f));
Strategy_Behavior* fan7_rs = getStrategy("Speed EC Fan #7");
static_cast<RampStrategy*>(fan7_rs)->setTarget(4200.0f * (speed /100.0f));
Strategy_Behavior* fan8_rs = getStrategy("Speed EC Fan #8");
static_cast<RampStrategy*>(fan8_rs)->setTarget(4200.0f * (speed /100.0f));
Strategy_Behavior* fan9_rs = getStrategy("Speed EC Fan #9");
static_cast<RampStrategy*>(fan9_rs)->setTarget(4200.0f * (speed /100.0f));
float value = getPointValue(equipment, "CW Valve Position");
Serial.printf("CW Valve Position: %0.2f\n", value);
float sat_setpoint = getPointValue(equipment, "SAT Setpoint");
Strategy_Behavior* sat_svs = getStrategy("SAT Reading");
static_cast<SingleValueStrategy*>(sat_svs)->setSetpoint(sat_setpoint);
// Apply any strategies defined for the standby state
_applyStrategies(equipment);
return nullptr;

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, 33, 11); /**< @brief The static IP address for the device. */
IPAddress gateway(172, 17, 33, 1); /**< @brief The gateway IP address. */
IPAddress subnet(255, 255, 255, 0); /**< @brief The subnet mask. */
ModbusIP mb;
@@ -60,81 +60,82 @@
*/
modbusMap mb_map[] =
{
{HR, 15, 0, "State Control"}, //Internal to control from Modscan
{HR, 16, 0, "Fault Code"},
{HR_FLOAT, 18, 0, "RAT"}, //Internal Fault code from Modscan
{HR_FLOAT, 1, 0, "SAT Setpoint"},
{HR_FLOAT, 681, 0, "RAT Setpoint"},
{HR_FLOAT, 111, 0, "High RAT Limit"},
{HR_FLOAT, 114, 0, "Low RAT Limit"},
{HR_FLOAT, 118, 0, "High SAT Limit"},
{HR_FLOAT, 122, 0, "Low SAT Limit"},
{HR_FLOAT, 685, 0, "High RAH Limit"},
{HR_FLOAT, 689, 0, "Low RAH Limit"},
{HR, 5, 0, "Setting the EC Fan Max Speed"},
{HR, 695, 0, "Setting the EC Fan Min Speed"},
{HR_FLOAT, 693, 0, "Setting Room Temp"},
{HR, 691, 0, "Setting EC Fan Speed "},
{DI, 146, 0, "Alarm SAT Sensor Fault"},
{DI, 1246, 0, "Alarm RAH Sensor Fault"},
{DI, 1245, 0, "Alarm RAT Sensor Fault"},
{DI, 1250, 0, "Alarm Filter DP Sensor Fault"},
{DI, 51, 0, "Alarm Flooding"},
{DI, 1096, 0, "Alarm Dirty Filter"},
{DI, 1367, 0, "Alarm High RAT"},
{DI, 1099, 0, "Alarm Low RAT"},
{DI, 118, 0, "Alarm High SAT"},
{DI, 122, 0, "Alarm Low SAT"},
{DI, 1307, 0, "Alarm High RAH"},
{DI, 1308, 0, "Alarm Low RAH"},
{DI, 1342, 0, "Alarm Common"},
{DI, 148, 0, "Alarm Phase Failure"},
{DI, 1370, 0, "Alarm Condensate Pump"},
{DI, 1368, 0, "Alarm Smoke"},
{DI, 1369, 0, "Alarm Fire"},
{DI, 131, 0, "Alarm EC Fan #1"},
{DI, 132, 0, "Alarm EC Fan #2"},
{DI, 133, 0, "Alarm EC Fan #3"},
{DI, 134, 0, "Alarm EC Fan #4"},
{DI, 135, 0, "Alarm EC Fan #5"},
{DI, 136, 0, "Alarm EC Fan #6"},
{DI, 1360, 0, "Alarm EC Fan #7"},
{DI, 1361, 0, "Alarm EC Fan #8"},
{DI, 1362, 0, "Alarm EC Fan #9"},
{DI, 138, 0, "Run Status EC Fan #1"},
{DI, 139, 0, "Run Status EC Fan #2"},
{DI, 140, 0, "Run Status EC Fan #3"},
{DI, 141, 0, "Run Status EC Fan #4"},
{DI, 142, 0, "Run Status EC Fan #5"},
{DI, 143, 0, "Run Status EC Fan #6"},
{DI, 1363, 0, "Run Status EC Fan #7"},
{DI, 1364, 0, "Run Status EC Fan #8"},
{DI, 1365, 0, "Run Status EC Fan #9"},
{IR_FLOAT, 99, 0, "SAT Reading"},
{IR_FLOAT, 70, 0, "RAH Reading"},
{IR_FLOAT, 101, 0, "RAT Reading"},
{IR_FLOAT, 106, 0, "Filter DP Reading"},
{IR_FLOAT, 496, 0, "CW Valve Position"},
{IR, 53, 0, "Speed EC Fan #1"},
{IR, 228, 0, "Speed EC Fan #2"},
{IR, 229, 0, "Speed EC Fan #3"},
{IR, 230, 0, "Speed EC Fan #4"},
{IR, 231, 0, "Speed EC Fan #5"},
{IR, 232, 0, "Speed EC Fan #6"},
{IR, 678, 0, "Speed EC Fan #7"},
{IR, 679, 0, "Speed EC Fan #8"},
{IR, 680, 0, "Speed EC Fan #9"},
{IR, 274, 0, "Operating Hours EC Fan #1"},
{IR, 233, 0, "Operating Hours EC Fan #2"},
{IR, 244, 0, "Operating Hours EC Fan #3"},
{IR, 235, 0, "Operating Hours EC Fan #4"},
{IR, 236, 0, "Operating Hours EC Fan #5"},
{IR, 245, 0, "Operating Hours EC Fan #6"},
{IR, 486, 0, "Operating Hours EC Fan #7"},
{IR, 487, 0, "Operating Hours EC Fan #8"},
{IR, 488, 0, "Operating Hours EC Fan #9"},
{COIL, 301, 0, "ON/OFF Command By BMS"},
{COIL, 302, 0, "Enable Off By Supervisory"},
{HR, 13, 0, "Delta"},
{HR, 14, 0, "State Control"}, //Internal to control from Modscan
{HR, 15, 0, "Fault Code"},
{HR_FLOAT, 17, 0, "RAT"}, //Internal Fault code from Modscan
{HR_FLOAT, 0, 0, "SAT Setpoint"},
{HR_FLOAT, 680, 0, "RAT Setpoint"},
{HR_FLOAT, 110, 0, "High RAT Limit"},
{HR_FLOAT, 113, 0, "Low RAT Limit"},
{HR_FLOAT, 117, 0, "High SAT Limit"},
{HR_FLOAT, 121, 0, "Low SAT Limit"},
{HR_FLOAT, 684, 0, "High RAH Limit"},
{HR_FLOAT, 688, 0, "Low RAH Limit"},
{HR, 4, 0, "Setting the EC Fan Max Speed"},
{HR, 694, 0, "Setting the EC Fan Min Speed"},
{HR_FLOAT, 692, 0, "Setting Room Temp"},
{HR_FLOAT, 690, 0, "Setting EC Fan Speed"},
{DI, 145, 0, "Alarm SAT Sensor Fault"},
{DI, 1245, 0, "Alarm RAH Sensor Fault"},
{DI, 1244, 0, "Alarm RAT Sensor Fault"},
{DI, 1249, 0, "Alarm Filter DP Sensor Fault"},
{DI, 50, 0, "Alarm Flooding"},
{DI, 1095, 0, "Alarm Dirty Filter"},
{DI, 1366, 0, "Alarm High RAT"},
{DI, 1098, 0, "Alarm Low RAT"},
{DI, 117, 0, "Alarm High SAT"},
{DI, 121, 0, "Alarm Low SAT"},
{DI, 1306, 0, "Alarm High RAH"},
{DI, 1307, 0, "Alarm Low RAH"},
{DI, 1341, 0, "Alarm Common"},
{DI, 147, 0, "Alarm Phase Failure"},
{DI, 1369, 0, "Alarm Condensate Pump"},
{DI, 1367, 0, "Alarm Smoke"},
{DI, 1368, 0, "Alarm Fire"},
{DI, 130, 0, "Alarm EC Fan #1"},
{DI, 131, 0, "Alarm EC Fan #2"},
{DI, 132, 0, "Alarm EC Fan #3"},
{DI, 133, 0, "Alarm EC Fan #4"},
{DI, 134, 0, "Alarm EC Fan #5"},
{DI, 135, 0, "Alarm EC Fan #6"},
{DI, 1359, 0, "Alarm EC Fan #7"},
{DI, 1360, 0, "Alarm EC Fan #8"},
{DI, 1361, 0, "Alarm EC Fan #9"},
{DI, 137, 0, "Run Status EC Fan #1"},
{DI, 138, 0, "Run Status EC Fan #2"},
{DI, 139, 0, "Run Status EC Fan #3"},
{DI, 140, 0, "Run Status EC Fan #4"},
{DI, 141, 0, "Run Status EC Fan #5"},
{DI, 142, 0, "Run Status EC Fan #6"},
{DI, 1362, 0, "Run Status EC Fan #7"},
{DI, 1363, 0, "Run Status EC Fan #8"},
{DI, 1364, 0, "Run Status EC Fan #9"},
{IR_FLOAT, 98, 0, "SAT Reading"},
{IR_FLOAT, 69, 0, "RAH Reading"},
{IR_FLOAT, 100, 0, "RAT Reading"},
{IR_FLOAT, 105, 0, "Filter DP Reading"},
{IR_FLOAT, 495, 0, "CW Valve Position"},
{IR, 52, 0, "Speed EC Fan #1"},
{IR, 227, 0, "Speed EC Fan #2"},
{IR, 228, 0, "Speed EC Fan #3"},
{IR, 229, 0, "Speed EC Fan #4"},
{IR, 230, 0, "Speed EC Fan #5"},
{IR, 231, 0, "Speed EC Fan #6"},
{IR, 677, 0, "Speed EC Fan #7"},
{IR, 678, 0, "Speed EC Fan #8"},
{IR, 679, 0, "Speed EC Fan #9"},
{IR, 273, 0, "Operating Hours EC Fan #1"},
{IR, 232, 0, "Operating Hours EC Fan #2"},
{IR, 243, 0, "Operating Hours EC Fan #3"},
{IR, 234, 0, "Operating Hours EC Fan #4"},
{IR, 235, 0, "Operating Hours EC Fan #5"},
{IR, 244, 0, "Operating Hours EC Fan #6"},
{IR, 485, 0, "Operating Hours EC Fan #7"},
{IR, 486, 0, "Operating Hours EC Fan #8"},
{IR, 487, 0, "Operating Hours EC Fan #9"},
{COIL, 300, 0, "ON/OFF Command By BMS"},
{COIL, 301, 0, "Enable Off By Supervisory"},
{COIL, 264, 0, "Alarm Reset"}
};
//Size of modbus map used in FOR cycles, automatically calculated.