diff --git a/platformio.ini b/platformio.ini index 88734c9..bedc350 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,10 +9,11 @@ [platformio] -default_envs = CH_York_YVA_RTU_PHXA7 ; Select here the name of the configuration you want to download + +default_envs = CRAH_UMAS_TCP ; Select here the name of the configuration you want to download [env] -upload_port = COM4 +upload_port = COM11 [common_env_options] framework = arduino @@ -35,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 = -<*> + ;Add the specific folder path here ;---------------------------------------------------------------------------------------------------- +[env:CRAH_HTS_PLC_TCP] +platform = espressif32 +board = dfrobot_firebeetle2_esp32e +extends = common_env_options +build_flags = -D USE_MODBUS_IP +build_src_filter = -<*> + + [env:CRAH_PETRA_PAHHC_600_C6_TCP] platform = espressif32 board = dfrobot_firebeetle2_esp32e @@ -206,26 +214,6 @@ board = dfrobot_firebeetle2_esp32e extends = common_env_options build_src_filter = -<*> + -[env:PHX3_VFD_ABB_ACH580_RTU] -platform = espressif32 -board = dfrobot_firebeetle2_esp32e -extends = common_env_options -build_src_filter = -<*> + - -[env:PHX3_CRAH_LIEBERT_80_SLAB_TCP] -platform = espressif32 -board = dfrobot_firebeetle2_esp32e -extends = common_env_options -build_flags = -D USE_MODBUS_IP -build_src_filter = -<*> + - -[env:HUM_DriSteem_RTS_RX36_TCP] -platform = espressif32 -board = dfrobot_firebeetle2_esp32e -extends = common_env_options -build_flags = -D USE_MODBUS_IP -build_src_filter = -<*> + - [env:CRAH_UMAS_TCP] platform = espressif32 board = dfrobot_firebeetle2_esp32e @@ -286,4 +274,4 @@ 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 = -<*> + diff --git a/src/BMS/CDU/CDU_CoolIT_Oracle_TCP/config.h b/src/BMS/CDU/CDU_CoolIT_Oracle_TCP/config.h index 9112a8c..fbd0547 100644 --- a/src/BMS/CDU/CDU_CoolIT_Oracle_TCP/config.h +++ b/src/BMS/CDU/CDU_CoolIT_Oracle_TCP/config.h @@ -23,7 +23,7 @@ #include const char *ssid = "Oracle_SA"; /**< @brief The SSID of the WiFi network. */ const char *password = "Prime!123"; /**< @brief The password for the WiFi network. */ - IPAddress local_IP(172, 17, 38, 22); /**< @brief The static IP address for the device. */ + IPAddress local_IP(172, 17, 38, 23); /**< @brief The static IP address for the device. */ IPAddress gateway(172, 17, 38, 1); /**< @brief The gateway IP address. */ IPAddress subnet(255, 255, 255, 0); /**< @brief The subnet mask. */ diff --git a/src/BMS/CHILLER/CH_York_YVAA_RTU/State_Fail.cpp b/src/BMS/CHILLER/CH_York_YVAA_RTU/State_Fail.cpp index d3996c3..0ea3225 100644 --- a/src/BMS/CHILLER/CH_York_YVAA_RTU/State_Fail.cpp +++ b/src/BMS/CHILLER/CH_York_YVAA_RTU/State_Fail.cpp @@ -37,28 +37,28 @@ */ template<> FailState::FailState(const std::vector& activeFaults) { - addStrategy("Supply Temp", new SingleValueStrategy(80.0f, 1.0f, 1000)); - addStrategy("Return Temp", new SingleValueStrategy(80.0f, 1.0f, 1000)); - addStrategy("Ambient Temp", new SingleValueStrategy(100.0f, 1.0f, 1000)); + addStrategy("Supply Temp", new SingleValueStrategy(80.0f, 1.0f, 10000)); + addStrategy("Return Temp", new SingleValueStrategy(80.0f, 1.0f, 10000)); + addStrategy("Ambient Temp", new SingleValueStrategy(100.0f, 1.0f, 10000)); - addStrategy("System CHW Out", new SingleValueStrategy(80.0f, 1.0f, 1000)); - addStrategy("System CHW In", new SingleValueStrategy(80.0f, 1.0f, 1000)); - addStrategy("Sys 1 Condenser Temp", new SingleValueStrategy(124.0f, 1.0f, 1000)); - addStrategy("Sys 2 Condenser Temp", new SingleValueStrategy(124.0f, 1.0f, 1000)); - addStrategy("Sys 1 Oil Pressure", new SingleValueStrategy(420.0f, 1.0f, 1000)); - addStrategy("Sys 2 Oil Pressure", new SingleValueStrategy(420.0f, 1.0f, 1000)); - addStrategy("Sys 1 Suction Pressure", new SingleValueStrategy(70.0f, 1.0f, 1000)); - addStrategy("Sys 2 Suction Pressure", new SingleValueStrategy(70.0f, 1.0f, 1000)); - addStrategy("Sys 1 Discharge Pressure", new SingleValueStrategy(70.0f, 1.0f, 1000)); - addStrategy("Sys 2 Discharge Pressure", new SingleValueStrategy(70.0f, 1.0f, 1000)); - addStrategy("Sys 1 Compressor Pct FLA", new SingleValueStrategy(0.0f, 0.0f, 1000)); - addStrategy("Sys 2 Compressor Pct FLA", new SingleValueStrategy(0.0f, 0.0f, 1000)); - addStrategy("Local Leaving Temp Setpoint", new SingleValueStrategy(70.0f, 0.0f, 1000)); - addStrategy("VSD Output Frequency", new SingleValueStrategy(0.0f, 0.0f, 1000)); - addStrategy("Sys 1 Fan KW", new SingleValueStrategy(0.0f, 0.0f, 1000)); - addStrategy("Sys 2 Fan KW", new SingleValueStrategy(0.0f, 0.0f, 1000)); - addStrategy("Sys 1 Compressor KW", new SingleValueStrategy(0.0f, 0.0f, 1000)); - addStrategy("Sys 2 Compressor KW", new SingleValueStrategy(0.0f, 0.0f, 1000)); + addStrategy("System CHW Out", new SingleValueStrategy(80.0f, 1.0f, 10000)); + addStrategy("System CHW In", new SingleValueStrategy(80.0f, 1.0f, 10000)); + addStrategy("Sys 1 Condenser Temp", new SingleValueStrategy(124.0f, 1.0f, 10000)); + addStrategy("Sys 2 Condenser Temp", new SingleValueStrategy(124.0f, 1.0f, 10000)); + addStrategy("Sys 1 Oil Pressure", new SingleValueStrategy(420.0f, 1.0f, 10000)); + addStrategy("Sys 2 Oil Pressure", new SingleValueStrategy(420.0f, 1.0f, 10000)); + addStrategy("Sys 1 Suction Pressure", new SingleValueStrategy(70.0f, 1.0f, 10000)); + addStrategy("Sys 2 Suction Pressure", new SingleValueStrategy(70.0f, 1.0f, 10000)); + addStrategy("Sys 1 Discharge Pressure", new SingleValueStrategy(70.0f, 1.0f, 10000)); + addStrategy("Sys 2 Discharge Pressure", new SingleValueStrategy(70.0f, 1.0f, 10000)); + addStrategy("Sys 1 Compressor Pct FLA", new SingleValueStrategy(0.0f, 0.0f, 10000)); + addStrategy("Sys 2 Compressor Pct FLA", new SingleValueStrategy(0.0f, 0.0f, 10000)); + addStrategy("Local Leaving Temp Setpoint", new SingleValueStrategy(70.0f, 0.0f, 10000)); + addStrategy("VSD Output Frequency", new SingleValueStrategy(0.0f, 0.0f, 10000)); + addStrategy("Sys 1 Fan KW", new SingleValueStrategy(0.0f, 0.0f, 10000)); + addStrategy("Sys 2 Fan KW", new SingleValueStrategy(0.0f, 0.0f, 10000)); + addStrategy("Sys 1 Compressor KW", new SingleValueStrategy(0.0f, 0.0f, 10000)); + addStrategy("Sys 2 Compressor KW", new SingleValueStrategy(0.0f, 0.0f, 10000)); } /** diff --git a/src/BMS/CHILLER/CH_York_YVAA_RTU/State_Running.cpp b/src/BMS/CHILLER/CH_York_YVAA_RTU/State_Running.cpp index b476d17..6c3bb3c 100644 --- a/src/BMS/CHILLER/CH_York_YVAA_RTU/State_Running.cpp +++ b/src/BMS/CHILLER/CH_York_YVAA_RTU/State_Running.cpp @@ -41,30 +41,30 @@ */ template<> RunningState::RunningState() { - addStrategy("Supply Temp", new RampStrategy(67.0f, 1.0f, 1000)); - addStrategy("Return Temp", new SawStrategy(79.0f, 83.0f, 1.0f, 1000)); - addStrategy("Ambient Temp", new SingleValueStrategy(100.0f, 1.0f, 1000)); + addStrategy("Supply Temp", new RampStrategy(67.0f, 1.0f, 3000)); + addStrategy("Return Temp", new SawStrategy(79.0f, 83.0f, 1.0f, 4000)); + addStrategy("Ambient Temp", new SingleValueStrategy(100.0f, 1.0f, 5000)); - addStrategy("System CHW Out", new RampStrategy(67.0f, 1.0f, 1000)); - addStrategy("System CHW In", new RampStrategy(81.0f, 1.0f, 1000)); - addStrategy("Sys 1 Condenser Temp", new SingleValueStrategy(125.0f, 5.0f, 1000)); - addStrategy("Sys 2 Condenser Temp", new SingleValueStrategy(125.0f, 5.0f, 1000)); - addStrategy("Sys 1 Oil Pressure", new SingleValueStrategy(450.0f, 5.0f, 1000)); - addStrategy("Sys 2 Oil Pressure", new SingleValueStrategy(450.0f, 5.0f, 1000)); - addStrategy("Sys 1 Suction Pressure", new SingleValueStrategy(70.0f, 2.0f, 1000)); - addStrategy("Sys 2 Suction Pressure", new SingleValueStrategy(70.0f, 2.0f, 1000)); - addStrategy("Sys 1 Discharge Pressure", new SingleValueStrategy(375.0f, 4.0f, 1000)); - addStrategy("Sys 2 Discharge Pressure", new SingleValueStrategy(375.0f, 4.0f, 1000)); - addStrategy("Sys 1 Compressor Pct FLA", new SingleValueStrategy(93.0f, 2.0f, 1000)); - addStrategy("Sys 2 Compressor Pct FLA", new SingleValueStrategy(93.0f, 2.0f, 1000)); - addStrategy("Sys 1 Run Hours", new TotalizerStrategy(1000)); - addStrategy("Sys 2 Run Hours", new TotalizerStrategy(1000)); - addStrategy("Local Leaving Temp Setpoint", new SingleValueStrategy(70.0f, 0.0f, 1000)); - addStrategy("VSD Output Frequency", new SingleValueStrategy(59.0f, 1.0f, 1000)); - addStrategy("Sys 1 Fan KW", new SingleValueStrategy(35.0f, 2.0f, 1000)); - addStrategy("Sys 2 Fan KW", new SingleValueStrategy(23.0f, 2.0f, 1000)); - addStrategy("Sys 1 Compressor KW", new SingleValueStrategy(304.0f, 5.0f, 1000)); - addStrategy("Sys 2 Compressor KW", new SingleValueStrategy(198.0f, 5.0f, 1000)); + addStrategy("System CHW Out", new RampStrategy(67.0f, 1.0f, 3000)); + addStrategy("System CHW In", new RampStrategy(81.0f, 1.0f, 4000)); + addStrategy("Sys 1 Condenser Temp", new SingleValueStrategy(125.0f, 5.0f, 5000)); + addStrategy("Sys 2 Condenser Temp", new SingleValueStrategy(125.0f, 5.0f, 5000)); + addStrategy("Sys 1 Oil Pressure", new SingleValueStrategy(450.0f, 5.0f, 5000)); + addStrategy("Sys 2 Oil Pressure", new SingleValueStrategy(450.0f, 5.0f, 5000)); + addStrategy("Sys 1 Suction Pressure", new SingleValueStrategy(70.0f, 2.0f, 5000)); + addStrategy("Sys 2 Suction Pressure", new SingleValueStrategy(70.0f, 2.0f, 5000)); + addStrategy("Sys 1 Discharge Pressure", new SingleValueStrategy(375.0f, 4.0f, 5000)); + addStrategy("Sys 2 Discharge Pressure", new SingleValueStrategy(375.0f, 4.0f, 5000)); + addStrategy("Sys 1 Compressor Pct FLA", new SingleValueStrategy(93.0f, 2.0f, 5000)); + addStrategy("Sys 2 Compressor Pct FLA", new SingleValueStrategy(93.0f, 2.0f, 5000)); + addStrategy("Sys 1 Run Hours", new TotalizerStrategy(5000)); + addStrategy("Sys 2 Run Hours", new TotalizerStrategy(5000)); + addStrategy("Local Leaving Temp Setpoint", new SingleValueStrategy(70.0f, 0.0f, 10000)); + addStrategy("VSD Output Frequency", new SingleValueStrategy(59.0f, 1.0f, 10000)); + addStrategy("Sys 1 Fan KW", new SingleValueStrategy(35.0f, 2.0f, 10000)); + addStrategy("Sys 2 Fan KW", new SingleValueStrategy(23.0f, 2.0f, 10000)); + addStrategy("Sys 1 Compressor KW", new SingleValueStrategy(304.0f, 5.0f, 10000)); + addStrategy("Sys 2 Compressor KW", new SingleValueStrategy(198.0f, 5.0f, 10000)); } /** diff --git a/src/BMS/CHILLER/CH_York_YVAA_RTU/State_Standby.cpp b/src/BMS/CHILLER/CH_York_YVAA_RTU/State_Standby.cpp index b5309ba..c4ebf04 100644 --- a/src/BMS/CHILLER/CH_York_YVAA_RTU/State_Standby.cpp +++ b/src/BMS/CHILLER/CH_York_YVAA_RTU/State_Standby.cpp @@ -38,28 +38,27 @@ */ template<> StandbyState::StandbyState() { - addStrategy("Supply Temp", new SingleValueStrategy(80.0f, 1.0f, 1000)); - addStrategy("Return Temp", new SingleValueStrategy(80.0f, 1.0f, 1000)); - addStrategy("Ambient Temp", new SingleValueStrategy(100.0f, 1.0f, 1000)); + addStrategy("Supply Temp", new SingleValueStrategy(80.0f, 1.0f, 3000)); + addStrategy("Return Temp", new SingleValueStrategy(80.0f, 1.0f, 3000)); + addStrategy("Ambient Temp", new SingleValueStrategy(100.0f, 1.0f, 4000)); - addStrategy("System CHW Out", new SingleValueStrategy(80.0f, 1.0f, 1000)); - addStrategy("System CHW In", new SingleValueStrategy(80.0f, 1.0f, 1000)); - addStrategy("Sys 1 Condenser Temp", new SingleValueStrategy(124.0f, 1.0f, 1000)); - addStrategy("Sys 2 Condenser Temp", new SingleValueStrategy(124.0f, 1.0f, 1000)); - addStrategy("Sys 1 Oil Pressure", new SingleValueStrategy(420.0f, 1.0f, 1000)); - addStrategy("Sys 2 Oil Pressure", new SingleValueStrategy(420.0f, 1.0f, 1000)); - addStrategy("Sys 1 Suction Pressure", new SingleValueStrategy(70.0f, 1.0f, 1000)); - addStrategy("Sys 2 Suction Pressure", new SingleValueStrategy(70.0f, 1.0f, 1000)); - addStrategy("Sys 1 Discharge Pressure", new SingleValueStrategy(70.0f, 1.0f, 1000)); - addStrategy("Sys 2 Discharge Pressure", new SingleValueStrategy(70.0f, 1.0f, 1000)); - addStrategy("Sys 1 Compressor Pct FLA", new SingleValueStrategy(0.0f, 0.0f, 1000)); - addStrategy("Sys 2 Compressor Pct FLA", new SingleValueStrategy(0.0f, 0.0f, 1000)); - addStrategy("Local Leaving Temp Setpoint", new SingleValueStrategy(70.0f, 0.0f, 1000)); - addStrategy("VSD Output Frequency", new SingleValueStrategy(0.0f, 0.0f, 1000)); - addStrategy("Sys 1 Fan KW", new SingleValueStrategy(0.0f, 0.0f, 1000)); - addStrategy("Sys 2 Fan KW", new SingleValueStrategy(0.0f, 0.0f, 1000)); - addStrategy("Sys 1 Compressor KW", new SingleValueStrategy(0.0f, 0.0f, 1000)); - addStrategy("Sys 2 Compressor KW", new SingleValueStrategy(0.0f, 0.0f, 1000)); + addStrategy("System CHW Out", new SingleValueStrategy(80.0f, 1.0f, 3000)); + addStrategy("System CHW In", new SingleValueStrategy(80.0f, 1.0f, 3000)); + addStrategy("Sys 1 Condenser Temp", new SingleValueStrategy(124.0f, 1.0f, 5000)); + addStrategy("Sys 2 Condenser Temp", new SingleValueStrategy(124.0f, 1.0f, 5000)); + addStrategy("Sys 1 Oil Pressure", new SingleValueStrategy(420.0f, 1.0f, 5000)); + addStrategy("Sys 2 Oil Pressure", new SingleValueStrategy(420.0f, 1.0f, 5000)); + addStrategy("Sys 1 Suction Pressure", new SingleValueStrategy(70.0f, 1.0f, 5000)); + addStrategy("Sys 2 Suction Pressure", new SingleValueStrategy(70.0f, 1.0f, 5000)); + addStrategy("Sys 1 Discharge Pressure", new SingleValueStrategy(70.0f, 1.0f, 5000)); + addStrategy("Sys 2 Discharge Pressure", new SingleValueStrategy(70.0f, 1.0f, 5000)); + addStrategy("Sys 1 Compressor Pct FLA", new SingleValueStrategy(0.0f, 0.0f, 5000)); + addStrategy("Sys 2 Compressor Pct FLA", new SingleValueStrategy(0.0f, 0.0f, 5000)); + addStrategy("VSD Output Frequency", new SingleValueStrategy(0.0f, 0.0f, 5000)); + addStrategy("Sys 1 Fan KW", new SingleValueStrategy(0.0f, 0.0f, 5000)); + addStrategy("Sys 2 Fan KW", new SingleValueStrategy(0.0f, 0.0f, 5000)); + addStrategy("Sys 1 Compressor KW", new SingleValueStrategy(0.0f, 0.0f, 5000)); + addStrategy("Sys 2 Compressor KW", new SingleValueStrategy(0.0f, 0.0f, 5000)); } diff --git a/src/BMS/CHILLER/CH_York_YVAA_RTU/config.h b/src/BMS/CHILLER/CH_York_YVAA_RTU/config.h index 86dc254..cff73a3 100644 --- a/src/BMS/CHILLER/CH_York_YVAA_RTU/config.h +++ b/src/BMS/CHILLER/CH_York_YVAA_RTU/config.h @@ -69,12 +69,12 @@ modbusMap mb_map[] = {IR, 165, 0, "Free Cooling Valve"}, {HR, 0, 0, "Chiller Status"}, // Use in Modscan - Hard IO in SCP, Used for Arduino simulation only - {HR, 1, 0, "Chiller Temp Setpoint"}, // Use in Modscan - Hard IO in SCP, Used for Arduino simulation only + {HR, 1, 60, "Chiller Temp Setpoint"}, // Use in Modscan - Hard IO in SCP, Used for Arduino simulation only {HR, 2, 0, "Supply Temp"}, // Use in Modscan - Hard IO in SCP, Used for Arduino simulation only {HR, 3, 0, "Return Temp"}, // Use in Modscan - Hard IO in SCP, Used for Arduino simulation only - {HR, 4, 70, "System CHW Out"}, - {HR, 5, 70, "System CHW In"}, + {HR_10x, 4, 700, "System CHW Out"}, + {HR_10x, 5, 700, "System CHW In"}, {HR_10x, 7, 0, "Sys 1 Condenser Temp"}, {HR_10x, 9, 0, "Ambient Temp"}, @@ -99,7 +99,7 @@ modbusMap mb_map[] = {HR, 31, 77, "Sys 2 Operational Code"}, // 77:not running, 78:running, 82:free cooling {HR, 32, 0, "Sys 2 Fault Code"}, // 56:condenser fan VSD warning - {HR, 39, 72, "Local Leaving Temp Setpoint"}, + {HR_10x, 39, 710, "Local Leaving Temp Setpoint"}, // just an assumption {HR_10x, 49, 0, "Sys 2 Condenser Temp"}, {HR_10x, 140, 0, "Sys 1 Fan KW"}, diff --git a/src/BMS/CRAH/CRAH_HTS_PLC_TCP/README.md b/src/BMS/CRAH/CRAH_HTS_PLC_TCP/README.md new file mode 100644 index 0000000..355156f --- /dev/null +++ b/src/BMS/CRAH/CRAH_HTS_PLC_TCP/README.md @@ -0,0 +1,33 @@ +# EQUIPMENT_TYPE MANUFACTURER MODEL TCP + +## Brief Introduction +Equipment specifc details that make it different from other devices + +## List of Equipmentt +This cofiguration has been used for these models: +* **Model**: 09-15-22 +* **Model**: 09-15-23 +* **Model**: 09-15-25 + +## Hardware Prerequisites + +The code is written for an ESP8266/ESP32-style microcontroller with WiFi capabilities. +* **Microcontroller**: [Firebeetle 2 ESP32.](https://www.dfrobot.com/product-2231.html) + +--- + +## States and Strategies +Provide a brief description of what variables and strategies were used in this configuraiton + +### Standby State +* **Equipment running**: set to 0 +* **Common Alarm**: set to 0 +* **SAT temperature**: set to 85 + +### Running State +* **Equipment running**: set to 1 +* **SAT temperature**: **Ramp Strategy** set to 65 deg setpoint + +### Fail State +* **Commong Alarm**: set to 1 +* **SAT temperature**: **Ramp Strategy** set to 105 deg setpointset diff --git a/src/BMS/CRAH/CRAH_HTS_PLC_TCP/State_Fail.cpp b/src/BMS/CRAH/CRAH_HTS_PLC_TCP/State_Fail.cpp new file mode 100644 index 0000000..8bc0385 --- /dev/null +++ b/src/BMS/CRAH/CRAH_HTS_PLC_TCP/State_Fail.cpp @@ -0,0 +1,81 @@ +/** + * @file State_Fail.cpp + * @brief Implementation of the FailState class. + * @author Emmanuel Hernandez Cruz + * @date 2025-09-05 + * + * This file contains the implementation for the FailState, which defines + * the behavior of the equipment when it has entered a fault condition. + */ +#include "ModbusPoints/Modbus_Point.h" +#include "Equipment/Equipment.h" +#include "Strategies/Strategy_Ramp.h" +#include "Strategies/Strategy_SingleValue.h" +#include "Strategies/Strategy_PID.h" +#include "States/State_Standby.h" +#include "States/State_Running.h" +#include "States/State_Fail.h" +#if defined(USE_MODBUS_IP) + #include +#else + #include +#endif + +/** + * @brief Constructs a new FailState object with a list of active alarms. + * + * This constructor receives a list of alarm descriptions and creates strategies + * to set the corresponding Modbus points to a value of 1, indicating an + * active alarm. It also initializes a PID strategy for the 'CW Valve Position' + * to maintain its state during the fault. + * @param activeAlarms A vector of strings, where each string is the + * description of a Modbus point to be set as an active alarm. + */ +template<> +FailState::FailState(const std::vector& activeAlarms) { + // Simulate a failure: set common alarm and a specific fan alarm. + + +} + +/** + * @brief Executes the fail state's logic for one update cycle. + * + * This method checks the "Alarm Reset" Modbus point for a command to + * transition back to Standby, which would typically happen after a fault + * is cleared by a user. If no transition is requested, it continues to apply + * the failure strategies (e.g., keeping alarm bits active). + * + * @param equipment Pointer to the Equipment instance. + * @return A pointer to a new State if a transition should occur, otherwise nullptr. + */ +template<> +State* FailState::update(Equipment* equipment) { + // STATE control, add conditions if change to a different state is needed + Serial.println("Fail update function"); + + _applyStrategies(equipment); + return nullptr; +} + +/** + * @brief Logic to execute once when entering the fail state. + * Sets the "Alarm Common" point to 1 to indicate a general fault condition. + * @param equipment Pointer to the Equipment instance. + */ +template<> +void FailState::enterState(Equipment* equipment) { + // Logic to run when the equipment enters this state + Serial.println("Enter Fail State..."); +} + +/** + * @brief Logic to execute once when exiting the fail state. + * Clears the "Alarm Common" point to 0 before transitioning to the next state. + * @param equipment Pointer to the Equipment instance. + */ +template<> +void FailState::exitState(Equipment* equipment) { + // Cleanup logic to run when the equipment leaves this state + Serial.println("Exit Fail State..."); +} \ No newline at end of file diff --git a/src/BMS/CRAH/CRAH_HTS_PLC_TCP/State_Running.cpp b/src/BMS/CRAH/CRAH_HTS_PLC_TCP/State_Running.cpp new file mode 100644 index 0000000..b9e4a99 --- /dev/null +++ b/src/BMS/CRAH/CRAH_HTS_PLC_TCP/State_Running.cpp @@ -0,0 +1,89 @@ +/** + * @file State_Running.cpp + * @brief Implementation of the RunningState class. + * @author Emmanuel Hernandez Cruz + * @date 2025-09-05 + * + * This file contains the implementation for the RunningState, which defines + * the behavior of the equipment when it is actively running. + */ +#include "ModbusPoints/Modbus_Point.h" +#include "ModbusPoints/Modbus_FloatDecorator.h" +#include "Equipment/Equipment.h" +#include "Strategies/Strategy_Ramp.h" +#include "Strategies/Strategy_Random.h" +#include "Strategies/Strategy_Saw.h" +#include "Strategies/Strategy_SingleValue.h" +#include "Strategies/Strategy_Square.h" +#include "Strategies/Strategy_PID.h" +#include "Strategies/Strategy_Totalizer.h" +#include "States/State_Standby.h" +#include "States/State_Running.h" +#include "States/State_Fail.h" +#include "States/State.h" +#include +#include +#if defined(USE_MODBUS_IP) + #include +#else + #include +#endif + +/** + * @brief Constructs a new RunningState object. + * + * This constructor initializes behavior strategies active during the running + * state, such as a PID controller for the 'CW Valve Position' and totalizers + * for the run-hours of each EC fan. + */ +template<> +RunningState::RunningState() { +} + +/** + * @brief Executes the running state's logic for one update cycle. + * + * This method first checks for state transition commands: + * 1. It reads the "ON/OFF Command By BMS" point. If it's 0, it transitions to StandbyState. + * 2. It reads the "Fault Code" point. If it's non-zero, it transitions to FailState, + * passing the corresponding alarm description. + * + * If no transition occurs, it applies the strategies defined for the running state. + * + * @param equipment Pointer to the Equipment instance. + * @return A pointer to a new State if a transition should occur, otherwise nullptr. + */ +template<> +State* RunningState::update(Equipment* equipment) { + // STATE control, add conditions if change to a different state is needed + Serial.println("Running update function"); + + // Apply any strategies defined for the standby state + _applyStrategies(equipment); + return nullptr; +} + +/** + * @brief Logic to execute once when entering the running state. + * Sets the "Run Status" for all EC fans to 1 to indicate they are active. + * @param equipment Pointer to the Equipment instance. + */ +template<> +void RunningState::enterState(Equipment* equipment) { + // Logic to run when the equipment enters this state + Serial.println("Enter Running State..."); + // You could also update a Modbus register to show the "standby" state + +} + +/** + * @brief Logic to execute once when exiting the running state. + * Sets the "Run Status" for all EC fans to 0 before transitioning to the next state. + * @param equipment Pointer to the Equipment instance. + */ +template<> +void RunningState::exitState(Equipment* equipment) { + // Cleanup logic to run when the equipment leaves this state + Serial.println("Exit Running State..."); + +} \ No newline at end of file diff --git a/src/BMS/CRAH/CRAH_HTS_PLC_TCP/State_Standby.cpp b/src/BMS/CRAH/CRAH_HTS_PLC_TCP/State_Standby.cpp new file mode 100644 index 0000000..20029d1 --- /dev/null +++ b/src/BMS/CRAH/CRAH_HTS_PLC_TCP/State_Standby.cpp @@ -0,0 +1,85 @@ +/** + * @file State_Standby.cpp + * @brief Implementation of the StandbyState class. + * @author Emmanuel Hernandez Cruz + * @date 2025-09-05 + * + * This file contains the implementation for the StandbyState, which defines + * the behavior of the equipment when it is in an idle or standby mode. + */ +#include "ModbusPoints/Modbus_Point.h" +#include "ModbusPoints/Modbus_FloatDecorator.h" +#include "Equipment/Equipment.h" +#include "Strategies/Strategy_Ramp.h" +#include "Strategies/Strategy_Random.h" +#include "Strategies/Strategy_Saw.h" +#include "Strategies/Strategy_SingleValue.h" +#include "Strategies/Strategy_Square.h" +#include "Strategies/Strategy_PID.h" +#include "States/State_Standby.h" +#include "States/State_Running.h" +#include "States/State_Fail.h" +#include "States/State.h" +#include +#include +#if defined(USE_MODBUS_IP) + #include +#else + #include +#endif +/** + * @brief Constructs a new StandbyState object. + * + * In this state, the equipment is idle. This constructor initializes strategies + * to bring the system to a safe, idle condition. It sets a stable value for + * the SAT reading and creates ramp strategies to bring the CW valve and all + * EC fan speeds down to zero. + */ +template<> +StandbyState::StandbyState() { + // You can add initialization code here if needed + + +} + +/** + * @brief Executes the standby state's logic for one update cycle. + * + * This method applies the strategies defined for the standby state (e.g., + * ramping values to zero). + * + * @warning This method currently does not check for a command to transition to the + * Running state. This logic needs to be added to allow the unit to start. + * @return A pointer to a new State if a transition should occur, otherwise nullptr. + */ +template<> +State* StandbyState::update(Equipment* equipment) { + // STATE control, add conditions if change to a different state is needed + Serial.println("Standby update function"); + + // Apply any strategies defined for the standby state + _applyStrategies(equipment); + return nullptr; +} + +/** + * @brief Logic to execute once when entering the standby state. + * This method performs cleanup by setting all alarm points and all EC fan + * run status points to 0. + * @param equipment Pointer to the Equipment instance. + */ +template<> +void StandbyState::enterState(Equipment* equipment) { + // Logic to run when the equipment enters this state + Serial.println("Enter Standby State..."); +} + +/** + * @brief Logic to execute once when exiting the standby state. + * @param equipment Pointer to the Equipment instance. + */ +template<> +void StandbyState::exitState(Equipment* equipment) { + // Cleanup logic to run when the equipment leaves this state + Serial.println("Exit Standby State..."); +} \ No newline at end of file diff --git a/src/BMS/CRAH/CRAH_HTS_PLC_TCP/config.h b/src/BMS/CRAH/CRAH_HTS_PLC_TCP/config.h new file mode 100644 index 0000000..21a339a --- /dev/null +++ b/src/BMS/CRAH/CRAH_HTS_PLC_TCP/config.h @@ -0,0 +1,134 @@ +/** + * @file config.h + * @brief Main configuration file for the CRAH Unit (TCP) emulator. + * @author Emmanuel Hernandez Cruz + * @date 2025-09-02 + * + * This file contains two important configurations: WiFi network parameters + * and the Modbus register map for the device. + */ + +#ifndef CONFIG_H +#define CONFIG_H + +#include "core.h" +#include "Equipment/Equipment.h" + +#if defined(USE_MODBUS_IP) +/** + * @defgroup ModbusTCPConfig Modbus IP Configuration + * @brief Parameters for Modbus TCP communication. + * @{ + */ + #include + const char *ssid = "QTS_ATL_Arduino"; /**< @brief The SSID of the WiFi network. */ + const char *password = "Fayetteville123"; /**< @brief The password for the WiFi network. */ + IPAddress local_IP(172, 17, 25, 123); /**< @brief The static IP address for the device. */ + IPAddress gateway(172, 17, 25, 1); /**< @brief The gateway IP address. */ + IPAddress subnet(255, 255, 255, 0); /**< @brief The subnet mask. */ + ModbusIP mb; +#else + /** + * @defgroup ModbusRTUConfig Modbus RTU Configuration + * @brief Parameters for serial Modbus RTU communication. + * @{ + */ + #include + const int BAUDRATE = 19200; /**< @brief The serial communication speed in bits per second. */ + const int RX_PIN = 17; /**< @brief The GPIO pin used for receiving data (RX). */ + const int TX_PIN = 16; /**< @brief The GPIO pin used for transmitting data (TX). */ + const int RST_PIN = 4; /**< @brief The GPIO pin connected to the RS485 driver's DE/RE pins for direction control. */ + const int MODBUS_ID = 1; /**< @brief The unique slave ID for this device on the Modbus bus. */ + /** @} */ + + /** @brief Global instance of the Modbus RTU server. */ + ModbusRTU mb; +#endif + + + +/** + * @defgroup ModbusMapConfig Modbus Map Configuration + * @brief Defines the Modbus register map and related parameters for the emulator. + * @{ + */ +/** + * @brief The Modbus map for the Equipment device. + * This array defines all the Modbus points available on the emulated device. + * The `description` field is crucial as it's used to look up points within the application logic. + */ +modbusMap mb_map[] = +{ + {HR, 49, 0, "Total Ariflow"}, + {HR_FLOAT, 31, 0, "Airflow Effectiveness"}, + {HR_FLOAT, 33, 0, "Return Humidity"}, + {HR_FLOAT, 35, 0, "Return Air Temp"}, + {HR_FLOAT, 37, 0, "Return Dew Point"}, + {HR_FLOAT, 55, 0, "Supply Air Temp"}, + {HR_FLOAT, 27, 0, "Cooling Valve Output"}, + {HR_FLOAT, 29, 0, "Feedback Differential"}, + {HR, 23, 0, "Airflow Used"}, + {HR, 24, 0, "Available Airflow"}, + {HR_FLOAT, 47, 0, "Cooling Capacity"}, + {HR_FLOAT, 45, 0, "Net Sensible Cooling Capacity"}, + {HR_FLOAT, 43, 0, "Fan Time in Hrs"}, + {HR_FLOAT, 51, 0, "Differential Air Temp"}, + {HR_FLOAT, 39, 0, "Fan Speed"}, + {HR, 20, 0, "Heartbeat"}, + + {HR_FLOAT, 41, 0, "Air Temp Setpoint"}, + {HR_FLOAT, 25, 0, "Fan Speed Setpoint"}, + + {HR, 17, 0, "Pump Run Status"}, + {HR, 18, 0, "Pump Health"}, + {HR, 22, 0, "Pump High Float"}, + + {DI, 2, 0, "Common Alarm"}, + {DI, 12, 0, "Smoke Detected"}, + {DI, 13, 0, "Water Under Foot"}, + {DI, 14, 0, "Check Air Filter"}, + {DI, 15, 0, "Fan Issue"}, + {DI, 16, 0, "Alternate Power Source"}, + {DI, 8, 0, "Unit Status"}, + {DI, 7, 0, "Loss of Air Flow"}, + {DI, 8, 0, "Cooling State Input"}, + {DI, 6, 0, "Unit Local"}, + {HR, 4, 0, "Alarm Acknowledged"}, + + //{DI, 2, 0, "Operator Status (Input)"}, + //{COIL, 2, 0, "Operator Status (Output)"}, + //{DI, 2, 0, "Program Status (Input)"}, + //{COIL, 2, 0, "Program Status (Output)"}, + //{DI, 2, 0, "Running Status"}, + //{DI, 2, 0, "Not Ready Status"}, + //{DI, 2, 0, "Start Command (Input)"}, + //{COIL, 2, 0, "Start Command (Output)"}, + //{DI, 2, 0, "Stop Command (Input)"}, + //{COIL, 2, 0, "Stop Command (Output)"}, + //{DI, 2, 0, "Reset (Input)"}, + //{COIL, 2, 0, "Reset (Output)"}, + //{DI, 2, 0, "Start Command (Input)"}, + //{DI, 2, 0, "Stopped Status"}, + //{DI, 2, 0, "Error Status"}, + //{DI, 2, 0, "Not Ready Fail"}, + //{DI, 2, 0, "Starting Status"}, + //{DI, 2, 0, "Stopping Status"}, + // + //{HR_FLOAT, 2, 0, "Air Temp Setpoint (Output)"}, + //{HR_FLOAT, 2, 0, "Fan Speed Setpoint (Output)"}, + + +}; +//Size of modbus map used in FOR cycles, automatically calculated. + +/** + * @brief The total number of entries in the `mb_map` array. + * This is calculated at compile time and used for iterating over the map. + */ +const int map_size = sizeof(mb_map) / sizeof(mb_map[0]); + +/** @brief The main loop update interval in milliseconds. */ +int interval = 250; +/** @} */ // End of ModbusMapConfig group + +#endif // CONFIG_H diff --git a/src/BMS/CRAH/CRAH_HTS_PLC_TCP/main.cpp b/src/BMS/CRAH/CRAH_HTS_PLC_TCP/main.cpp new file mode 100644 index 0000000..286a98c --- /dev/null +++ b/src/BMS/CRAH/CRAH_HTS_PLC_TCP/main.cpp @@ -0,0 +1,86 @@ +/** + * @file main.cpp + * @brief Main execution program for the CRAH Unit (TCP) Emulator. + * @author Emmanuel Hernandez Cruz + * @date 2025-09-02 + * + * @details This file contains the main execution program for an Arduino-based emulator of a CRAH unit. + * The program uses a Wi-Fi connection to communicate via the Modbus IP protocol. + * + * The setup() function initializes the following: + * - Serial communication for debugging. + * - Wi-Fi connection using credentials from config.h. + * - A Modbus TCP server. + * - Modbus points (Coils, Holding Registers, etc.) based on a predefined map in config.h. + * + * The loop() function continuously: + * - Services the Modbus TCP server to handle incoming requests. + * - Periodically calls the main update loop for the emulated equipment, which + * manages state transitions and behavior strategies. + * + * @see config.h for Wi-Fi and Modbus configuration. + * @see Equipment.h for the main equipment logic. + * @see State.h for different equipment states. + * @see Strategies/Strategy_Behavior.h for value generation strategies. + * @see Modbus_Point.h for the base class for all Modbus points. + */ +//================================================================================================================================= +//Libraries and declaration of variables. +#include +#include "config.h" +#include "ModbusPoints/Modbus_PointFactory.h" +#if defined(USE_MODBUS_IP) + #include +#else + #include +#endif +//================================================================================================================================= +/** + * @brief Initializes the application. + * @details This function runs once at startup. It configures the serial communication, + * Wi-Fi, and the Modbus server. It also creates and initializes all the Modbus points + * based on the `mb_map` array in `config.h`. + */ +void setup() { + Serial.begin(115200); //Serial comm start + WiFi.config(local_IP, gateway, subnet); // Wifi service start + WiFi.begin(ssid, password); + while (WiFi.status() != WL_CONNECTED) { + delay(1000); + Serial.print("."); + } + Serial.println("Connected!!"); + mb.server(); //Modbus server start + Serial.println("Server Created"); + Serial.println(map_size); + for(int i = 0; i < map_size; i++){ + Modbus_Point* point = createModbus_Point(&mb, mb_map[i].category, mb_map[i].address, mb_map[i].value, mb_map[i].description); + if (point) { + point->addToModbusServer(); + EquipmentInstance.addModbus_Point(mb_map[i].description, point); + } + } + Serial.println("All modbus Points created"); + Serial.println("Setup function ended"); +} +//================================================================================================================================= +/** + * @brief The main application loop. + * @details This function runs repeatedly after setup() has completed. It performs two main actions: + * 1. It continuously services the Modbus server by calling `mb.task()` to handle + * incoming requests from a Modbus master. + * 2. At a fixed interval (defined in `config.h`), it calls `EquipmentInstance.update()` + * to run the emulator's internal state machine and behavior logic. + */ +void loop() { + mb.task(); + unsigned long currentMillis = millis(); + if (currentMillis - previousMillis >= interval) { + previousMillis = currentMillis; + unsigned long startTime = millis(); + EquipmentInstance.update(); + unsigned long endTime = millis(); + unsigned long elapsedTime = endTime - startTime; + Serial.printf("Control Execution time: %d ms\n", elapsedTime); + } +} diff --git a/src/BMS/CRAH/CRAH_UMAS_TCP/StateUtils.cpp b/src/BMS/CRAH/CRAH_UMAS_TCP/StateUtils.cpp index 8fdfcc1..f479c57 100644 --- a/src/BMS/CRAH/CRAH_UMAS_TCP/StateUtils.cpp +++ b/src/BMS/CRAH/CRAH_UMAS_TCP/StateUtils.cpp @@ -53,6 +53,120 @@ void updateControlMode(Equipment* equipment){ equipment->setModbus_Point("Control Mode Selected", Control_Mode_Selected); } +/** This function will set RA Temp, SA Temp, RA Humidity analog values to a LOW or HIGH range for testing alarms in Ignition. + * There is an associated COIL for performing each of those functions. + * There is also a NORMAL bit, which sends a one-shot to reset the associated analog value back into a normal range. + */ + +void updateAnalogs(Equipment* equipment){ + if (equipment->getModbus_Point("RA Temp NORMAL")->getValue()==1){ + equipment->setModbus_Point("Return Air Temp", 84.0f); + equipment->setModbus_Point("RA Temp Low Alarm ON", 0); + equipment->setModbus_Point("RA Temp High Alarm ON", 0); + equipment->setModbus_Point("RA Temp NORMAL", 0); + } + else if (equipment->getModbus_Point("RA Temp Low Alarm ON")->getValue() ==1){ + equipment->setModbus_Point("Return Air Temp", 60.0f); + equipment->setModbus_Point("RA Temp High Alarm ON", 0); + } + else if (equipment->getModbus_Point("RA Temp High Alarm ON")->getValue()==1){ + equipment->setModbus_Point("Return Air Temp", 110.0f); + equipment->setModbus_Point("RA Temp Low Alarm ON", 0); + } + + if (equipment->getModbus_Point("RA Humidity NORMAL")->getValue()==1){ + equipment->setModbus_Point("Return Humidity", 25.0f); + equipment->setModbus_Point("RA Humidity Low Alarm ON", 0); + equipment->setModbus_Point("RA Humidity High Alarm ON", 0); + equipment->setModbus_Point("RA Humidity NORMAL", 0); + } + else if (equipment->getModbus_Point("RA Humidity Low Alarm ON")->getValue()==1){ + equipment->setModbus_Point("Return Humidity", 5.0f); + equipment->setModbus_Point("RA Humidity High Alarm ON", 0); + } + else if (equipment->getModbus_Point("RA Humidity High Alarm ON")->getValue()==1){ + equipment->setModbus_Point("Return Humidity", 80.0f); + equipment->setModbus_Point("RA Humidity Low Alarm ON", 0); + } + + if (equipment->getModbus_Point("SA Temp NORMAL")->getValue()==1){ + equipment->setModbus_Point("Supply Air Temp", 76.0f); + equipment->setModbus_Point("SA Temp Low Alarm ON", 0); + equipment->setModbus_Point("SA Temp High Alarm ON", 0); + equipment->setModbus_Point("SA Temp NORMAL", 0); + } + else if (equipment->getModbus_Point("SA Temp Low Alarm ON")->getValue() ==1){ + equipment->setModbus_Point("Supply Air Temp", 60.0f); + equipment->setModbus_Point("SA Temp High Alarm ON", 0); + } + else if (equipment->getModbus_Point("SA Temp High Alarm ON")->getValue()==1){ + equipment->setModbus_Point("Supply Air Temp", 90.0f); + equipment->setModbus_Point("SA Temp Low Alarm ON", 0); + } + +} + +// Updates the RA Temp Alarms +void updateReturnAirTempAlarms(Equipment* equipment){ + Modbus_Point* returnAirTemp = equipment -> getModbus_Point("Return Air Temp"); + Modbus_Point* returnTempHighAlarmSP = equipment->getModbus_Point("Return Air Temp Alarm High SP"); + Modbus_Point* returnTempLowAlarmSP = equipment->getModbus_Point("Return Air Temp Alarm Low SP"); + + if (returnAirTemp->getValue() < returnTempLowAlarmSP->getValue()) { + equipment->setModbus_Point("Alarm Low Return Air Temp", 1); + equipment->setModbus_Point("Alarm High Return Air Temp", 0); + } + else if (returnAirTemp->getValue() > returnTempHighAlarmSP->getValue()) { + equipment->setModbus_Point("Alarm High Return Air Temp", 1); + equipment->setModbus_Point("Alarm Low Return Air Temp", 0); + } + else{ + equipment->setModbus_Point("Alarm High Return Air Temp", 0); + equipment->setModbus_Point("Alarm Low Return Air Temp", 0); + } + +} + +// Updates the SA Temp Alarms +void updateSupplyAirTempAlarms(Equipment* equipment){ + Modbus_Point* supplyAirTemp = equipment -> getModbus_Point("Supply Air Temp"); + Modbus_Point* supplyTempHighAlarmSP = equipment->getModbus_Point("Supply Air Temp Alarm High SP"); + Modbus_Point* supplyTempLowAlarmSP = equipment->getModbus_Point("Supply Air Temp Alarm Low SP"); + + if (supplyAirTemp->getValue() > supplyTempHighAlarmSP->getValue()) { + equipment->setModbus_Point("Alarm High Supply Temp", 1); + equipment->setModbus_Point("Alarm Low Supply Temp", 0); + } + else if (supplyAirTemp->getValue() < supplyTempLowAlarmSP->getValue()) { + equipment->setModbus_Point("Alarm Low Supply Temp", 1); + equipment->setModbus_Point("Alarm High Supply Temp", 0); + } + else{ + equipment->setModbus_Point("Alarm High Supply Temp", 0); + equipment->setModbus_Point("Alarm Low Supply Temp", 0); + } +} + +// Updates the RA Humidity Alarms +void updateReturnHumidityAlarms(Equipment* equipment){ + Modbus_Point* returnHumidity = equipment -> getModbus_Point("Return Humidity"); + Modbus_Point* returnHumHighAlarmSP = equipment->getModbus_Point("Return Humidity Alarm High SP"); + Modbus_Point* returnHumLowAlarmSP = equipment->getModbus_Point("Return Humidity Alarm Low SP"); + + if (returnHumidity->getValue() > returnHumHighAlarmSP->getValue()) { + equipment->setModbus_Point("Alarm High Return Humidity", 1); + equipment->setModbus_Point("Alarm Low Return Humidity", 0); + } + else if (returnHumidity->getValue() < returnHumLowAlarmSP->getValue()) { + equipment->setModbus_Point("Alarm Low Return Humidity", 1); + equipment->setModbus_Point("Alarm High Return Humidity", 0); + } + else{ + equipment->setModbus_Point("Alarm High Return Humidity", 0); + equipment->setModbus_Point("Alarm Low Return Humidity", 0); + } +} + /** * @brief This function will update the Alarm status DI bits according to the Alarm Commands from Coils (Modscan) * It will also update the Common Alarm: if any alarm is active, the Common alarm will also be active. @@ -75,6 +189,12 @@ void updateAlarms(Equipment* equipment){ "Alarm Condensate Pump ON", "Alarm Fire ON", "Alarm Smoke ON" }; + const std::vector alarmAnalogs = { + "Alarm High Return Air Temp", "Alarm Low Return Air Temp", "Alarm High Return Humidity", "Alarm Low Return Humidity", + "Alarm High Supply Temp", "Alarm Low Supply Temp" + }; + + // NOTE: Per UMAS hardwire signals, alarm opened in case of normal operation, closed in case of alarm condition // 0: no alarm, 1: alarm int numAlarms = 0; @@ -86,37 +206,15 @@ void updateAlarms(Equipment* equipment){ if (alarmPoint->getValue() == 1) numAlarms++; } } + // If any of the analog alarms = 1, increment counter for number of active alarms + for (int j = 0; j* alarmAnalogPoint = equipment->getModbus_Point(alarmAnalogs[j]); + if (alarmAnalogPoint) { + if (alarmAnalogPoint->getValue() == 1) numAlarms++; + } + } + // If any alarms are active, set the Common Alarm = 1, else Common Alarm = 0. + if (numAlarms >= 1) equipment->setModbus_Point("Common Alarm", 1); else equipment->setModbus_Point("Common Alarm", 0); -} - -/** - * @brief The purpose of this function is for testing the RA Temp and RA Humidity alarms (Ignition HMI display) - * User will manually set Alarms through Modscan coils, which will change RA Temp or RA Humidity accordingly. - * The RA Temp alarm limits (reference Ignition UDT) are 72, 100. - * The SA Temp alarm limits (reference Ignition UDT) are 72, 78. - * The RA Humidity alarm limits (reference Ignition UDT) are 20, 60. - * If an associated alarm coil is not active, the analog values are set to a safe, un-alarmed value. - * - * NOTE: These analog alarms will not activate the Common Alarm in the Arduino test. - * Since these alarms will be set in Ignition, will not be sent over Modbus from CRAH to Ignition. - * - * This is a function used in the update() of the Running State. - * -*/ -// Note: The Common Alarm is not configured to annunciate with these analog low/high alarms. -void updateAnalogs(Equipment* equipment){ - if (equipment->getModbus_Point("RA Temp Low Alarm ON")->getValue() ==1){ - equipment->setModbus_Point("Return Air Temp", 68.0f); - } - else if (equipment->getModbus_Point("RA Temp High Alarm ON")->getValue()==1){ - equipment->setModbus_Point("Return Air Temp", 104.0f); - } - - if (equipment->getModbus_Point("RA Humidity Low Alarm ON")->getValue()==1){ - equipment->setModbus_Point("Return Air Humidity", 15.0f); - } - else if (equipment->getModbus_Point("RA Humidity High Alarm ON")->getValue()==1){ - equipment->setModbus_Point("Return Air Humidity", 65.0f); - } } \ No newline at end of file diff --git a/src/BMS/CRAH/CRAH_UMAS_TCP/StateUtils.h b/src/BMS/CRAH/CRAH_UMAS_TCP/StateUtils.h index 23b56cb..7c49f8f 100644 --- a/src/BMS/CRAH/CRAH_UMAS_TCP/StateUtils.h +++ b/src/BMS/CRAH/CRAH_UMAS_TCP/StateUtils.h @@ -34,17 +34,14 @@ class State; * @return The selected control mode (int). */ void updateControlMode(Equipment* equipment); +void updateAnalogs(Equipment* equipment); +void updateReturnAirTempAlarms(Equipment* equipment); +void updateSupplyAirTempAlarms(Equipment* equipment); +void updateReturnHumidityAlarms(Equipment* equipment); /** * @brief Checks common alarms (non-fail alarms) and updates the Common Alarm Modbus point. * @param equipment Pointer to the Equipment instance. * @return true if any common alarm is active, false otherwise. */ -void updateAlarms(Equipment* equipment); - -/** - * @brief Checks common alarms (non-fail alarms) and updates the Common Alarm Modbus point. - * @param equipment Pointer to the Equipment instance. - * @return true if any common alarm is active, false otherwise. - */ -void updateAnalogs(Equipment* equipment); \ No newline at end of file +void updateAlarms(Equipment* equipment); \ No newline at end of file diff --git a/src/BMS/CRAH/CRAH_UMAS_TCP/State_Fail.cpp b/src/BMS/CRAH/CRAH_UMAS_TCP/State_Fail.cpp index ceeb819..5e9c124 100644 --- a/src/BMS/CRAH/CRAH_UMAS_TCP/State_Fail.cpp +++ b/src/BMS/CRAH/CRAH_UMAS_TCP/State_Fail.cpp @@ -42,16 +42,17 @@ FailState::FailState(const std::vector& activeAlarms) { addStrategy("CW Valve Position", new RampStrategy(0.0f, 5.0f, 1000)); addStrategy("Supply Air Temp", new SingleValueStrategy(74.0f, 1.0f, 1000)); addStrategy("Return Air Temp", new SingleValueStrategy(86.0f, 1.0f, 1000)); - addStrategy("Return Air Humidity", new SingleValueStrategy(35.0f, 2.0f, 1000)); - addStrategy("Speed Fan 1", new RampStrategy(0.0f, 10.0f, 1000)); - addStrategy("Speed Fan 2", new RampStrategy(0.0f, 10.0f, 1000)); - addStrategy("Speed Fan 3", new RampStrategy(0.0f, 10.0f, 1000)); - addStrategy("Speed Fan 4", new RampStrategy(0.0f, 10.0f, 1000)); - addStrategy("Speed Fan 5", new RampStrategy(0.0f, 10.0f, 1000)); - addStrategy("Speed Fan 6", new RampStrategy(0.0f, 10.0f, 1000)); - addStrategy("Speed Fan 7", new RampStrategy(0.0f, 10.0f, 1000)); - addStrategy("Speed Fan 8", new RampStrategy(0.0f, 10.0f, 1000)); - addStrategy("Speed Fan 9", new RampStrategy(0.0f, 10.0f, 1000)); + addStrategy("Return Humidity", new SingleValueStrategy(30.0f, 1.0f, 3000)); + addStrategy("Speed Fan 1", new RampStrategy(0.0f, 300.0f, 1000)); + addStrategy("Speed Fan 2", new RampStrategy(0.0f, 300.0f, 1000)); + addStrategy("Speed Fan 3", new RampStrategy(0.0f, 300.0f, 1000)); + addStrategy("Speed Fan 4", new RampStrategy(0.0f, 300.0f, 1000)); + addStrategy("Speed Fan 5", new RampStrategy(0.0f, 300.0f, 1000)); + addStrategy("Speed Fan 6", new RampStrategy(0.0f, 300.0f, 1000)); + addStrategy("Speed Fan 7", new RampStrategy(0.0f, 300.0f, 1000)); + addStrategy("Speed Fan 8", new RampStrategy(0.0f, 300.0f, 1000)); + addStrategy("Speed Fan 9", new RampStrategy(0.0f, 300.0f, 1000)); + addStrategy("Fan Speed Feedback", new RampStrategy(0.0f, 10.0f, 1000)); addStrategy("Amps Fan 1", new RampStrategy(0.0f, 4.5f, 1000)); addStrategy("Amps Fan 2", new RampStrategy(0.0f, 4.5f, 1000)); addStrategy("Amps Fan 3", new RampStrategy(0.0f, 4.5f, 1000)); @@ -81,8 +82,11 @@ State* FailState::update(Equipment* equipment) { // Still want Control Mode and Alarms to be updated while in Fail State // Ensure BMS Command is set to Off: want operator to re-start from BMS once Leak Detect Alarm is cleared. updateControlMode(equipment); - updateAlarms(equipment); updateAnalogs(equipment); + updateReturnAirTempAlarms(equipment); + updateSupplyAirTempAlarms(equipment); + updateReturnHumidityAlarms(equipment); + updateAlarms(equipment); setPointValue(equipment, "ON/OFF Command By BMS", 0); // The only way to exit the Fail State is for Leak Detect Alarm to turn off, then enter Standby State. diff --git a/src/BMS/CRAH/CRAH_UMAS_TCP/State_Running.cpp b/src/BMS/CRAH/CRAH_UMAS_TCP/State_Running.cpp index a1c8f16..9290275 100644 --- a/src/BMS/CRAH/CRAH_UMAS_TCP/State_Running.cpp +++ b/src/BMS/CRAH/CRAH_UMAS_TCP/State_Running.cpp @@ -44,15 +44,15 @@ template<> RunningState::RunningState() { addStrategy("Fan Min Speed", new SingleValueStrategy(30.0f, 0.0f, 1000)); addStrategy("Fan Max Speed", new SingleValueStrategy(100.0f, 0.0f, 1000)); - addStrategy("Speed Fan 1", new RampStrategy(0.0f, 1.0f, 200)); - addStrategy("Speed Fan 2", new RampStrategy(0.0f, 1.0f, 200)); - addStrategy("Speed Fan 3", new RampStrategy(0.0f, 1.0f, 200)); - addStrategy("Speed Fan 4", new RampStrategy(0.0f, 1.0f, 200)); - addStrategy("Speed Fan 5", new RampStrategy(0.0f, 1.0f, 200)); - addStrategy("Speed Fan 6", new RampStrategy(0.0f, 1.0f, 200)); - addStrategy("Speed Fan 7", new RampStrategy(0.0f, 1.0f, 200)); - addStrategy("Speed Fan 8", new RampStrategy(0.0f, 1.0f, 200)); - addStrategy("Speed Fan 9", new RampStrategy(0.0f, 1.0f, 200)); + addStrategy("Speed Fan 1", new RampStrategy(0.0f, 100.0f, 1000)); + addStrategy("Speed Fan 2", new RampStrategy(0.0f, 100.0f, 1000)); + addStrategy("Speed Fan 3", new RampStrategy(0.0f, 100.0f, 1000)); + addStrategy("Speed Fan 4", new RampStrategy(0.0f, 100.0f, 1000)); + addStrategy("Speed Fan 5", new RampStrategy(0.0f, 100.0f, 1000)); + addStrategy("Speed Fan 6", new RampStrategy(0.0f, 100.0f, 1000)); + addStrategy("Speed Fan 7", new RampStrategy(0.0f, 100.0f, 1000)); + addStrategy("Speed Fan 8", new RampStrategy(0.0f, 100.0f, 1000)); + addStrategy("Speed Fan 9", new RampStrategy(0.0f, 100.0f, 1000)); addStrategy("Amps Fan 1", new RampStrategy(15.0f, 2.5f, 1000)); addStrategy("Amps Fan 2", new RampStrategy(15.0f, 2.5f, 1000)); addStrategy("Amps Fan 3", new RampStrategy(15.0f, 2.5f, 1000)); @@ -71,13 +71,13 @@ RunningState::RunningState() { addStrategy("Operating Hours Fan 7", new TotalizerStrategy(1000)); addStrategy("Operating Hours Fan 8", new TotalizerStrategy(1000)); addStrategy("Operating Hours Fan 9", new TotalizerStrategy(1000)); - addStrategy("Supply Air Temp", new SawStrategy(60.0f, 100.0f, 2.2f, 1000)); // Won't initialize at lower bound; always initializes at 0 b/c FLOAT; initialize manually via Modscan - addStrategy("Return Air Humidity", new SawStrategy(25.0f, 40.0f, 1.1f, 1000)); - addStrategy("Return Air Temp", new SawStrategy(70.0f, 80.0f, 0.8f, 1000)); - addStrategy("Filter Differential Pressure", new SawStrategy(0.0f, 5.0f, 0.2f, 1000)); + addStrategy("Supply Air Temp", new SawStrategy(73.0f, 77.0f, 0.2f, 1000)); // Won't initialize at lower bound; always initializes at 0 b/c FLOAT; initialize manually via Modscan + addStrategy("Return Humidity", new SawStrategy(25.0f, 35.0f, 0.2f, 1000)); + addStrategy("Return Air Temp", new SawStrategy(80.0f, 90.0f, 0.2f, 1000)); + addStrategy("Filter Differential Pressure", new SawStrategy(0.1f, 5.1f, 0.2f, 1000)); addStrategy("CW Valve Position", new PIDStrategy("Supply Air Temp Setpoint", 1000, "Supply Air Temp")); // SAT must be greater than SAT Setpoint for this PID to work. addStrategy("CRAH Heartbeat", new SawStrategy(0.0f, 60.0f, 1.0f, 1000)); - addStrategy("Fan Speed Feedback", new RampStrategy(0.0f, 1.0f, 200)); + addStrategy("Fan Speed Feedback", new RampStrategy(0.0f, 2.0f, 200)); } /** @@ -104,8 +104,11 @@ State* RunningState::update(Equipment* equipment) int BMS_Enable_Source = getPointValue(equipment, "BMS Enable Source"); // Modscan HR 2 updateControlMode(equipment); - updateAlarms(equipment); updateAnalogs(equipment); + updateReturnAirTempAlarms(equipment); + updateSupplyAirTempAlarms(equipment); + updateReturnHumidityAlarms(equipment); + updateAlarms(equipment); // Check to see if Leak Detect alarm is active (only alarm which will make unit FAIL and turn off) --> Send to FailState bool leakDetect = getPointValue(equipment, "Alarm Leak Detect"); @@ -121,11 +124,14 @@ State* RunningState::update(Equipment* equipment) // This will update the Fan Speed Setpoint dynamically while in run mode. Fan Speed Setpoint changed through Modscan. // This functioanlity matches the UMAS SOO specifically for how it calculates Speed Setpoint. - float BMS_Speed_Setpoint = getPointValue(equipment, "Fan Speed Setpoint"); - float BMS_Speed_Setpoint_Pct = BMS_Speed_Setpoint / 100.0f; float Fan_Min_Speed = getPointValue(equipment, "Fan Min Speed"); float Fan_Max_Speed = getPointValue(equipment, "Fan Max Speed"); + float Fan_Nominal_Speed = 1900.0f; + + float BMS_Speed_Setpoint = getPointValue(equipment, "Fan Speed Setpoint"); + float BMS_Speed_Setpoint_Pct = BMS_Speed_Setpoint / 100.0f; float Fan_Speed_Setpoint = BMS_Speed_Setpoint_Pct * (Fan_Max_Speed - Fan_Min_Speed) + Fan_Min_Speed; + float Fan_Speed_Setpoint_RPM = Fan_Speed_Setpoint / 100.0f * Fan_Nominal_Speed; for (int i = 0; i < 10; i++){ std::string pointName = "Speed Fan " + std::to_string(i); Strategy_Behavior* strat = getStrategy(pointName); @@ -134,11 +140,13 @@ State* RunningState::update(Equipment* equipment) if (ramp){ if (BMS_Speed_Setpoint > 100){ Fan_Speed_Setpoint = Fan_Max_Speed; + Fan_Speed_Setpoint_RPM = Fan_Max_Speed / 100.0f * Fan_Nominal_Speed; } else if (BMS_Speed_Setpoint < 0){ - Fan_Speed_Setpoint = Fan_Min_Speed; + Fan_Speed_Setpoint = Fan_Min_Speed; + Fan_Speed_Setpoint_RPM = Fan_Min_Speed / 100.0f * Fan_Nominal_Speed; } - ramp->setTarget(Fan_Speed_Setpoint); + ramp->setTarget(Fan_Speed_Setpoint_RPM); } } } @@ -146,7 +154,7 @@ State* RunningState::update(Equipment* equipment) // Fan Speed Feedback dynamically ramp to Fan Speed Setpoint sent to Arduino Strategy_Behavior* speedFeedback = getStrategy("Fan Speed Feedback"); if (speedFeedback){ - static_cast(speedFeedback)->setTarget(BMS_Speed_Setpoint); + static_cast(speedFeedback)->setTarget(Fan_Speed_Setpoint); } // Apply any strategies defined for the standby state diff --git a/src/BMS/CRAH/CRAH_UMAS_TCP/State_Standby.cpp b/src/BMS/CRAH/CRAH_UMAS_TCP/State_Standby.cpp index 2b78791..c863fcd 100644 --- a/src/BMS/CRAH/CRAH_UMAS_TCP/State_Standby.cpp +++ b/src/BMS/CRAH/CRAH_UMAS_TCP/State_Standby.cpp @@ -41,18 +41,19 @@ StandbyState::StandbyState() { // You can add initialization code here if needed. // These strategies are applied at the end of the update function. addStrategy("CW Valve Position", new RampStrategy(0.0f, 5.0f, 1000)); - addStrategy("Supply Air Temp", new SingleValueStrategy(74.0f, 1.0f, 1000)); - addStrategy("Return Air Temp", new SingleValueStrategy(86.0f, 1.0f, 1000)); - addStrategy("Return Air Humidity", new SingleValueStrategy(35.0f, 2.0f, 1000)); - addStrategy("Speed Fan 1", new RampStrategy(0.0f, 10.0f, 1000)); - addStrategy("Speed Fan 2", new RampStrategy(0.0f, 10.0f, 1000)); - addStrategy("Speed Fan 3", new RampStrategy(0.0f, 10.0f, 1000)); - addStrategy("Speed Fan 4", new RampStrategy(0.0f, 10.0f, 1000)); - addStrategy("Speed Fan 5", new RampStrategy(0.0f, 10.0f, 1000)); - addStrategy("Speed Fan 6", new RampStrategy(0.0f, 10.0f, 1000)); - addStrategy("Speed Fan 7", new RampStrategy(0.0f, 10.0f, 1000)); - addStrategy("Speed Fan 8", new RampStrategy(0.0f, 10.0f, 1000)); - addStrategy("Speed Fan 9", new RampStrategy(0.0f, 10.0f, 1000)); + addStrategy("Supply Air Temp", new SingleValueStrategy(76.0f, 1.0f, 2000)); + addStrategy("Return Air Temp", new SingleValueStrategy(86.0f, 1.0f, 3000)); + addStrategy("Return Humidity", new SingleValueStrategy(25.0f, 1.0f, 4000)); + addStrategy("Speed Fan 1", new RampStrategy(0.0f, 300.0f, 1000)); + addStrategy("Speed Fan 2", new RampStrategy(0.0f, 300.0f, 1000)); + addStrategy("Speed Fan 3", new RampStrategy(0.0f, 300.0f, 1000)); + addStrategy("Speed Fan 4", new RampStrategy(0.0f, 300.0f, 1000)); + addStrategy("Speed Fan 5", new RampStrategy(0.0f, 300.0f, 1000)); + addStrategy("Speed Fan 6", new RampStrategy(0.0f, 300.0f, 1000)); + addStrategy("Speed Fan 7", new RampStrategy(0.0f, 300.0f, 1000)); + addStrategy("Speed Fan 8", new RampStrategy(0.0f, 300.0f, 1000)); + addStrategy("Speed Fan 9", new RampStrategy(0.0f, 300.0f, 1000)); + addStrategy("Fan Speed Feedback", new RampStrategy(0.0f, 10.0f, 1000)); addStrategy("Amps Fan 1", new RampStrategy(0.0f, 4.5f, 1000)); addStrategy("Amps Fan 2", new RampStrategy(0.0f, 4.5f, 1000)); addStrategy("Amps Fan 3", new RampStrategy(0.0f, 4.5f, 1000)); @@ -86,8 +87,11 @@ State* StandbyState::update(Equipment* equipment) int BMS_Enable_Source = getPointValue(equipment, "BMS Enable Source"); // Modscan HR 2 updateControlMode(equipment); - updateAlarms(equipment); updateAnalogs(equipment); + updateReturnAirTempAlarms(equipment); + updateSupplyAirTempAlarms(equipment); + updateReturnHumidityAlarms(equipment); + updateAlarms(equipment); // Check to see if Leak Detect alarm is active (only alarm which will make unit FAIL and turn off) --> Send to FailState bool leakDetect = getPointValue(equipment, "Alarm Leak Detect"); diff --git a/src/BMS/CRAH/CRAH_UMAS_TCP/config.h b/src/BMS/CRAH/CRAH_UMAS_TCP/config.h index 186fa3b..0fac917 100644 --- a/src/BMS/CRAH/CRAH_UMAS_TCP/config.h +++ b/src/BMS/CRAH/CRAH_UMAS_TCP/config.h @@ -23,7 +23,7 @@ #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, 62); /**< @brief The static IP address for the device. */ + IPAddress local_IP(172, 17, 32, 232); /**< @brief The static IP address for the device. */ IPAddress gateway(172, 17, 32, 1); /**< @brief The gateway IP address. */ IPAddress subnet(255, 255, 255, 0); /**< @brief The subnet mask. */ @@ -56,37 +56,55 @@ * This array defines all the Modbus points available on the emulated device. * The `description` field is crucial as it's used to look up points within the application logic. */ + + // "One-Based" Addressing for IR, HR registers + modbusMap mb_map[] = { {COIL, 0, 0, "ON/OFF Command By BMS"}, // Receive signal from PLC - {COIL, 1, 0, "Alarm Fan 1 ON"}, // Just for Arduino testing. Sets Alarm Fan 1 to 1. - {COIL, 2, 0, "Alarm Fan 2 ON"}, // Just for Arduino testing. Sets Alarm Fan 2 to 1. - {COIL, 3, 0, "Alarm Dirty Filter ON"}, // Just for Arduino testing. Sets Alarm Dirty Filter to 1. - {COIL, 4, 0, "Alarm Leak Detect ON"}, // Just for Arduino testing. Sets Alarm Fan 1 to 1. - {COIL, 5, 0, "RA Temp Low Alarm ON"}, // Just for Arduino testing. Sets RA Temp to 68F (low alarm) - {COIL, 6, 0, "RA Temp High Alarm ON"}, // Just for Arduino testing. Sets RA Temp to 104F (high alarm) - {COIL, 7, 0, "RA Humidity Low Alarm ON"}, // Just for Arduino testing. Sets RA Humidity to 15% (low alarm) - {COIL, 8, 0, "RA Humidity High Alarm ON"}, // Just for Arduino testing. Sets RA Humidity to 65% (high alarm) - {COIL, 9, 0, "Alarm Fan 3 ON"}, // Just for Arduino testing. Sets Alarm Fan 3 to 1. - {COIL, 10, 0, "Alarm Fan 4 ON"}, // Just for Arduino testing. Sets Alarm Fan 4 to 1. - {COIL, 11, 0, "Alarm Fan 5 ON"}, // Just for Arduino testing. Sets Alarm Fan 5 to 1. - {COIL, 12, 0, "Alarm Fan 6 ON"}, // Just for Arduino testing. Sets Alarm Fan 6 to 1. - {COIL, 13, 0, "Alarm Fan 7 ON"}, // Just for Arduino testing. Sets Alarm Fan 7 to 1. - {COIL, 14, 0, "Alarm Fan 8 ON"}, // Just for Arduino testing. Sets Alarm Fan 8 to 1. - {COIL, 15, 0, "Alarm Fan 9 ON"}, // Just for Arduino testing. Sets Alarm Fan 9 to 1. - {COIL, 16, 0, "Alarm Condensate Pump ON"}, // Just for Arduino testing. Sets Alarm Condensate Pump to 1. - {COIL, 17, 0, "Alarm Fire ON"}, // Just for Arduino testing. Sets Alarm Fire to 1. - {COIL, 18, 0, "Alarm Smoke ON"}, // Just for Arduino testing. Sets Alarm Smoke to 1. + {COIL, 1, 0, "Alarm Dirty Filter ON"}, // Just for Arduino testing. Sets Alarm Dirty Filter to 1. + {COIL, 2, 0, "Alarm Leak Detect ON"}, // Just for Arduino testing. Sets Alarm Fan 1 to 1. + + {COIL, 3, 0, "Alarm Fan 1 ON"}, // Just for Arduino testing. Sets Alarm Fan 1 to 1. + {COIL, 4, 0, "Alarm Fan 2 ON"}, // Just for Arduino testing. Sets Alarm Fan 2 to 1. + {COIL, 5, 0, "Alarm Fan 3 ON"}, // Just for Arduino testing. Sets Alarm Fan 3 to 1. + {COIL, 6, 0, "Alarm Fan 4 ON"}, // Just for Arduino testing. Sets Alarm Fan 4 to 1. + {COIL, 7, 0, "Alarm Fan 5 ON"}, // Just for Arduino testing. Sets Alarm Fan 5 to 1. + {COIL, 8, 0, "Alarm Fan 6 ON"}, // Just for Arduino testing. Sets Alarm Fan 6 to 1. + {COIL, 9, 0, "Alarm Fan 7 ON"}, // Just for Arduino testing. Sets Alarm Fan 7 to 1. + {COIL, 10, 0, "Alarm Fan 8 ON"}, // Just for Arduino testing. Sets Alarm Fan 8 to 1. + {COIL, 11, 0, "Alarm Fan 9 ON"}, // Just for Arduino testing. Sets Alarm Fan 9 to 1. + {COIL, 12, 0, "Alarm Condensate Pump ON"}, // Just for Arduino testing. Sets Alarm Condensate Pump to 1. + {COIL, 13, 0, "Alarm Fire ON"}, // Just for Arduino testing. Sets Alarm Fire to 1. + {COIL, 14, 0, "Alarm Smoke ON"}, // Just for Arduino testing. Sets Alarm Smoke to 1. + + {COIL, 15, 0, "RA Temp Low Alarm ON"}, // Just for Arduino testing. Sets RA Temp to 68F (low alarm) + {COIL, 16, 0, "RA Temp NORMAL"}, // Just for Arduino testing. Sets RA Temp to 68F (low alarm) + {COIL, 17, 0, "RA Temp High Alarm ON"}, // Just for Arduino testing. Sets RA Temp to 104F (high alarm) + + {COIL, 18, 0, "SA Temp Low Alarm ON"}, // Just for Arduino testing. Sets RA Temp to 68F (low alarm) + {COIL, 19, 0, "SA Temp NORMAL"}, // Just for Arduino testing. Sets RA Temp to 68F (low alarm) + {COIL, 20, 0, "SA Temp High Alarm ON"}, // Just for Arduino testing. Sets RA Temp to 104F (high alarm) + + {COIL, 21, 0, "RA Humidity Low Alarm ON"}, // Just for Arduino testing. Sets RA Humidity to 15% (low alarm) + {COIL, 22, 0, "RA Humidity NORMAL"}, // Just for Arduino testing. Sets RA Temp to 68F (low alarm) + {COIL, 23, 0, "RA Humidity High Alarm ON"}, // Just for Arduino testing. Sets RA Humidity to 65% (high alarm) {DI, 4, 0, "Alarm Leak Detect"}, {DI, 5, 0, "Alarm Dirty Filter"}, + {DI, 6, 0, "Alarm High Return Air Temp"}, // suggested default 100, operator inputs High RA Temp SP for alarm limit + {DI, 7, 0, "Alarm Low Return Air Temp"}, // suggested default 72, operator inputs Low RA Temp SP for alarm limit + {DI, 8, 0, "Alarm High Supply Temp"}, // suggested default 78, operator inputs High SA Temp SP for alarm limit + {DI, 9, 0, "Alarm Low Supply Temp"}, // suggested default 72, operator inputs Low SA Temp SP for alarm limit + {DI, 10, 0, "Alarm High Return Humidity"}, // suggested default 60, operator inputs High Return Humidity SP for alarm limit + {DI, 11, 0, "Alarm Low Return Humidity"}, // suggested default 20, operator inputs Low Return Humidity SP for alarm limit {DI, 12, 0, "Common Alarm"}, // Send to PLC {DI, 14, 0, "Alarm Condensate Pump"}, {DI, 15, 0, "Alarm Smoke"}, {DI, 16, 0, "Alarm Fire"}, {IR_FLOAT, 1, 0, "Supply Air Temp"}, - {IR_FLOAT, 3, 0, "Return Air Humidity"}, // Ignition visual only + {IR_FLOAT, 3, 0, "Return Humidity"}, // Ignition visual only {IR_FLOAT, 5, 0, "Return Air Temp"}, // Send to PLC {IR_FLOAT, 7, 0, "Filter Differential Pressure"}, // sawStrategy between 0 and 5 {IR_FLOAT, 9, 0, "CW Valve Position"}, @@ -135,17 +153,24 @@ modbusMap mb_map[] = {IR_FLOAT, 73, 0, "Amps Fan 6"}, {IR_FLOAT, 75, 0, "Amps Fan 7"}, {IR_FLOAT, 77, 0, "Amps Fan 8"}, - {IR_FLOAT, 79, 0, "Amps Fan 9"}, - {IR_FLOAT, 99, 0, "CRAH Heartbeat"}, + {IR_FLOAT, 79, 0, "Amps Fan 9"}, + {HR_FLOAT, 1, 0, "Return Air Temp Alarm High SP"}, // default: 100, set locally on unit + {HR_FLOAT, 3, 0, "Return Air Temp Alarm Low SP"}, // default: 72, set locally on unit + {HR_FLOAT, 5, 0, "Supply Air Temp Alarm High SP"}, // default: 78, set locally on unit + {HR_FLOAT, 7, 0, "Supply Air Temp Alarm Low SP"}, // default: 72, set locally on unit + {HR_FLOAT, 9, 0, "Return Humidity Alarm High SP"}, // default: 60, set locally on unit + {HR_FLOAT, 11, 0, "Return Humidity Alarm Low SP"}, // default: 20, set locally on unit {HR_FLOAT, 13, 0, "Fan Speed Setpoint"}, // Receive signal from PLC {HR_FLOAT, 17, 0, "Supply Air Temp Setpoint"}, // Receive signal from PLC + {HR_FLOAT, 19, 0, "Return Air Temp Setpoint"}, // set locally on unit {HR_FLOAT, 21, 0, "Fan Min Speed"}, // Send to PLC {HR_FLOAT, 23, 0, "Fan Max Speed"}, // Send to PLC {HR, 25, 0, "BMS Control Source"}, // Receive signal from PLC 0:Speed, 1:Room Temp {HR, 26, 2, "BMS Enable Source"}, // Receive signal from PLC 0:Keypad, 1:DI, 2:BMS {HR_FLOAT, 28, 0, "Fan Speed Feedback"}, - {HR_FLOAT, 99, 0, "PLC Heartbeat"}, // This will be seconds from PLC - if doesn't change for 15 seconds set BMS Enable Source to Local (0) + {HR, 95, 0, "CRAH Heartbeat"}, + {HR, 96, 0, "BMS Heartbeat"}, // This will be seconds from PLC - if doesn't change for 15 seconds set BMS Enable Source to Local (0) }; //Size of modbus map used in FOR cycles, automatically calculated. diff --git a/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/StateUtils.cpp b/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/StateUtils.cpp index b50dc7f..7afd68b 100644 --- a/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/StateUtils.cpp +++ b/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/StateUtils.cpp @@ -28,6 +28,120 @@ #include #endif +/** The purpose of this function is to change the RA Temp, SA Temp, RA Humidity values for the purpose of testing alarms in Ignition. + * There are LOW and HIGH coils, which when activated will set the analog to a low/high range. + * The NORMAL coil will send a one-shot to set the associated analog value back into a normal range. + * If in a RunningState, the analog value will follow it's normal function (typically a sawStrategy). + */ + +void updateAnalogs(Equipment* equipment){ + if (equipment->getModbus_Point("RA Temp NORMAL")->getValue()==1){ + equipment->setModbus_Point("Return Air Temp", 84.0f); + equipment->setModbus_Point("RA Temp Low Alarm ON", 0); + equipment->setModbus_Point("RA Temp High Alarm ON", 0); + equipment->setModbus_Point("RA Temp NORMAL", 0); + } + else if (equipment->getModbus_Point("RA Temp Low Alarm ON")->getValue() ==1){ + equipment->setModbus_Point("Return Air Temp", 60.0f); + equipment->setModbus_Point("RA Temp High Alarm ON", 0); + } + else if (equipment->getModbus_Point("RA Temp High Alarm ON")->getValue()==1){ + equipment->setModbus_Point("Return Air Temp", 110.0f); + equipment->setModbus_Point("RA Temp Low Alarm ON", 0); + } + + if (equipment->getModbus_Point("RA Humidity NORMAL")->getValue()==1){ + equipment->setModbus_Point("Return Humidity", 25.0f); + equipment->setModbus_Point("RA Humidity Low Alarm ON", 0); + equipment->setModbus_Point("RA Humidity High Alarm ON", 0); + equipment->setModbus_Point("RA Humidity NORMAL", 0); + } + else if (equipment->getModbus_Point("RA Humidity Low Alarm ON")->getValue()==1){ + equipment->setModbus_Point("Return Humidity", 5.0f); + equipment->setModbus_Point("RA Humidity High Alarm ON", 0); + } + else if (equipment->getModbus_Point("RA Humidity High Alarm ON")->getValue()==1){ + equipment->setModbus_Point("Return Humidity", 80.0f); + equipment->setModbus_Point("RA Humidity Low Alarm ON", 0); + } + + if (equipment->getModbus_Point("SA Temp NORMAL")->getValue()==1){ + equipment->setModbus_Point("Supply Air Temp", 76.0f); + equipment->setModbus_Point("SA Temp Low Alarm ON", 0); + equipment->setModbus_Point("SA Temp High Alarm ON", 0); + equipment->setModbus_Point("SA Temp NORMAL", 0); + } + else if (equipment->getModbus_Point("SA Temp Low Alarm ON")->getValue() ==1){ + equipment->setModbus_Point("Supply Air Temp", 60.0f); + equipment->setModbus_Point("SA Temp High Alarm ON", 0); + } + else if (equipment->getModbus_Point("SA Temp High Alarm ON")->getValue()==1){ + equipment->setModbus_Point("Supply Air Temp", 90.0f); + equipment->setModbus_Point("SA Temp Low Alarm ON", 0); + } +} + +//This function updates the Alarm bit for the Return Air Temp +void updateReturnAirTempAlarms(Equipment* equipment){ + Modbus_Point* returnAirTemp = equipment -> getModbus_Point("Return Air Temp"); + Modbus_Point* returnTempHighAlarmSP = equipment->getModbus_Point("Return Air Temp Alarm High SP"); + Modbus_Point* returnTempLowAlarmSP = equipment->getModbus_Point("Return Air Temp Alarm Low SP"); + + if (returnAirTemp->getValue() < returnTempLowAlarmSP->getValue()) { + equipment->setModbus_Point("Alarm Low Return Air Temp", 1); + equipment->setModbus_Point("Alarm High Return Air Temp", 0); + } + else if (returnAirTemp->getValue() > returnTempHighAlarmSP->getValue()) { + equipment->setModbus_Point("Alarm High Return Air Temp", 1); + equipment->setModbus_Point("Alarm Low Return Air Temp", 0); + } + else{ + equipment->setModbus_Point("Alarm High Return Air Temp", 0); + equipment->setModbus_Point("Alarm Low Return Air Temp", 0); + } +} + +// This function updates the Alarm bit for the Supply Air Temp +void updateSupplyAirTempAlarms(Equipment* equipment){ + Modbus_Point* supplyAirTemp = equipment -> getModbus_Point("Supply Air Temp"); + Modbus_Point* supplyTempHighAlarmSP = equipment->getModbus_Point("Supply Air Temp Alarm High SP"); + Modbus_Point* supplyTempLowAlarmSP = equipment->getModbus_Point("Supply Air Temp Alarm Low SP"); + + if (supplyAirTemp->getValue() > supplyTempHighAlarmSP->getValue()) { + equipment->setModbus_Point("Alarm High Supply Temp", 1); + equipment->setModbus_Point("Alarm Low Supply Temp", 0); + } + else if (supplyAirTemp->getValue() < supplyTempLowAlarmSP->getValue()) { + equipment->setModbus_Point("Alarm Low Supply Temp", 1); + equipment->setModbus_Point("Alarm High Supply Temp", 0); + } + else{ + equipment->setModbus_Point("Alarm High Supply Temp", 0); + equipment->setModbus_Point("Alarm Low Supply Temp", 0); + } +} + +//This function updates the Alarm bit for the Return Humidity +void updateReturnHumidityAlarms(Equipment* equipment){ + Modbus_Point* returnHumidity = equipment -> getModbus_Point("Return Humidity"); + Modbus_Point* returnHumHighAlarmSP = equipment->getModbus_Point("Return Humidity Alarm High SP"); + Modbus_Point* returnHumLowAlarmSP = equipment->getModbus_Point("Return Humidity Alarm Low SP"); + + if (returnHumidity->getValue() > returnHumHighAlarmSP->getValue()) { + equipment->setModbus_Point("Alarm High Return Humidity", 1); + equipment->setModbus_Point("Alarm Low Return Humidity", 0); + } + else if (returnHumidity->getValue() < returnHumLowAlarmSP->getValue()) { + equipment->setModbus_Point("Alarm Low Return Humidity", 1); + equipment->setModbus_Point("Alarm High Return Humidity", 0); + } + else{ + equipment->setModbus_Point("Alarm High Return Humidity", 0); + equipment->setModbus_Point("Alarm Low Return Humidity", 0); + } +} + + /** * @brief This function will update the Alarm status DI bits according to the Alarm Commands from Coils (Modscan) * It will also update the Common Alarm: if any alarm is active, the Common alarm will also be active. @@ -63,6 +177,12 @@ void updateAlarms(Equipment* equipment){ "Alarm Compressor 1B Overload ON", "Alarm Compressor 2B Overload ON" }; + const std::vector alarmAnalogs = { + "Alarm High Return Air Temp", "Alarm Low Return Air Temp", "Alarm High Return Humidity", "Alarm Low Return Humidity", + "Alarm High Supply Temp", "Alarm Low Supply Temp" + }; + + // If any Alarm Commands = 1, set the appropriate Alarm = 1 and increment counter for number of active alarms int numAlarms = 0; for (int i =0; i< alarmCommands.size() && i < alarmDescriptions.size(); ++i) { Modbus_Point* commandPoint = equipment->getModbus_Point(alarmCommands[i]); @@ -72,6 +192,14 @@ void updateAlarms(Equipment* equipment){ if (alarmPoint->getValue() == 1) numAlarms++; } } + // If any of the analog alarms = 1, increment counter for number of active alarms + for (int j = 0; j* alarmAnalogPoint = equipment->getModbus_Point(alarmAnalogs[j]); + if (alarmAnalogPoint) { + if (alarmAnalogPoint->getValue() == 1) numAlarms++; + } + } + // If any alarms are active, set the Common Alarm = 1, else Common Alarm = 0. if (numAlarms >= 1) equipment->setModbus_Point("Common Alarm", 1); else equipment->setModbus_Point("Common Alarm", 0); } diff --git a/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/StateUtils.h b/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/StateUtils.h index e2c1196..861ff6d 100644 --- a/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/StateUtils.h +++ b/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/StateUtils.h @@ -28,6 +28,11 @@ template class State; +void updateAnalogs(Equipment* equipment); +void updateReturnAirTempAlarms(Equipment* equipment); +void updateSupplyAirTempAlarms(Equipment* equipment); +void updateReturnHumidityAlarms(Equipment* equipment); + /** * @brief Checks common alarms (non-fail alarms) and updates the Common Alarm Modbus point. * @param equipment Pointer to the Equipment instance. diff --git a/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/State_Fail.cpp b/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/State_Fail.cpp index 888d1b4..68a36fb 100644 --- a/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/State_Fail.cpp +++ b/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/State_Fail.cpp @@ -34,9 +34,9 @@ template<> FailState::FailState(const std::vector& activeAlarms) { addStrategy("Fan Speed", new RampStrategy(0.0f, 10.0f, 1000)); - addStrategy("Return Humidity", new SawStrategy(0.0f, 80.0f, 5.0f, 1000)); - addStrategy("Return Air Temp", new SingleValueStrategy(80.0f, 1.0f, 1000)); - addStrategy("Supply Air Temp", new SingleValueStrategy(80.0f, 1.0f, 1000)); + addStrategy("Return Humidity", new SawStrategy(25.0f, 35.0f, 1.0f, 2000)); + addStrategy("Return Air Temp", new SingleValueStrategy(80.0f, 1.0f, 3000)); + addStrategy("Supply Air Temp", new SingleValueStrategy(76.0f, 1.0f, 3000)); addStrategy("Supply Air Flow", new RampStrategy(0.0f, 1.0f, 1000)); addStrategy("Fluid Control Valve Position 1", new RampStrategy(0.0f, 5.0f, 1000)); addStrategy("Fluid Control Valve Position 2", new RampStrategy(0.0f, 5.0f, 1000)); @@ -62,6 +62,10 @@ State* FailState::update(Equipment* equipment) { Serial.println("Fail update function"); setPointValue(equipment, "System On/Off Control", 0); // my programming logic: when clear fault, should be sent to Standby Mode + updateAnalogs(equipment); + updateReturnAirTempAlarms(equipment); + updateSupplyAirTempAlarms(equipment); + updateReturnHumidityAlarms(equipment); updateAlarms(equipment); updateDehumidifier(equipment); // Dehumidifier mode can be toggled while in FailState (for ease of Ignition HMI verification) diff --git a/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/State_Running.cpp b/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/State_Running.cpp index 33c87c7..bca9ab6 100644 --- a/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/State_Running.cpp +++ b/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/State_Running.cpp @@ -44,9 +44,10 @@ */ template<> RunningState::RunningState() { - addStrategy("Return Humidity", new SawStrategy(0.0f, 80.0f, 5.0f, 1000)); - addStrategy("Return Air Temp", new SawStrategy(66.0f, 110.0f, 2.0f, 1000)); - addStrategy("Supply Air Temp", new SawStrategy(68.0f, 86.0f, 1.0f, 1000)); + addStrategy("Return Humidity", new SawStrategy(25.0f, 35.0f, 1.0f, 2000)); + addStrategy("Return Air Temp", new SawStrategy(78.0f, 88.0f, 1.0f, 3000)); + addStrategy("Supply Air Temp", new SawStrategy(73.0f, 77.0f, 1.0f, 5000)); + addStrategy("Supply Air Flow", new SawStrategy(7.0f, 10.0f, 1.0f, 1000)); addStrategy("Fan Speed", new PIDStrategy("Return Air Temp Setpoint", 1000, "Return Air Temp")); addStrategy("Fluid Control Valve Position 1", new PIDStrategy("Supply Air Temp Setpoint", 1000, "Supply Air Temp")); @@ -72,6 +73,11 @@ template<> State* RunningState::update(Equipment* equipment) { Serial.println("Running update function"); + updateAnalogs(equipment); + updateReturnAirTempAlarms(equipment); + updateSupplyAirTempAlarms(equipment); + updateReturnHumidityAlarms(equipment); + updateAlarms(equipment); updateDehumidifier(equipment); diff --git a/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/State_Standby.cpp b/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/State_Standby.cpp index 5db3e93..cd0f010 100644 --- a/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/State_Standby.cpp +++ b/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/State_Standby.cpp @@ -40,10 +40,10 @@ template<> StandbyState::StandbyState() { addStrategy("Fan Speed", new RampStrategy(0.0f, 10.0f, 1000)); - addStrategy("Return Humidity", new SawStrategy(0.0f, 80.0f, 5.0f, 1000)); - addStrategy("Return Air Temp", new SingleValueStrategy(80.0f, 1.0f, 1000)); - addStrategy("Supply Air Temp", new SingleValueStrategy(80.0f, 1.0f, 1000)); - addStrategy("Supply Air Flow", new RampStrategy(0.0f, 1.0f, 1000)); + addStrategy("Return Humidity", new SawStrategy(25.0f, 35.0f, 1.0f, 2000)); + addStrategy("Return Air Temp", new SingleValueStrategy(80.0f, 1.0f, 3000)); + addStrategy("Supply Air Temp", new SingleValueStrategy(76.0f, 1.0f, 3000)); + addStrategy("Supply Air Flow", new RampStrategy(0.0f, 1.0f, 5000)); addStrategy("Fluid Control Valve Position 1", new RampStrategy(0.0f, 5.0f, 1000)); addStrategy("Fluid Control Valve Position 2", new RampStrategy(0.0f, 5.0f, 1000)); } @@ -67,6 +67,11 @@ State* StandbyState::update(Equipment* equipment) // STATE control, add conditions if change to a different state is needed Serial.println("Standby update function"); + updateAnalogs(equipment); + updateReturnAirTempAlarms(equipment); + updateSupplyAirTempAlarms(equipment); + updateReturnHumidityAlarms(equipment); + updateAlarms(equipment); updateDehumidifier(equipment); diff --git a/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/config.h b/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/config.h index 2aec506..695c5ac 100644 --- a/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/config.h +++ b/src/BMS/CRAH/PHX3_CRAH_LIEBERT_80_SLAB_TCP/config.h @@ -20,6 +20,7 @@ * @brief Parameters for Modbus TCP communication. * @{ */ + #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, 66); /**< @brief The static IP address for the device. */ @@ -67,7 +68,7 @@ modbusMap mb_map[] = {COIL, 6, 0, "Alarm Compressor 2A Overload ON"}, // For Arduino testing only {COIL, 7, 0, "Alarm Water Detected ON"}, // For Arduino testing only {COIL, 8, 0, "Alarm Standby Unit On ON"}, // For Arduino testing only - {COIL, 9, 0, "Alarm Room Sensor Failure ON"}, // For Arduino testing only + {COIL, 9, 0, "Alarm Room Sensor Failure ON"}, // For Arduino testing only {COIL, 10, 0, "Alarm Power Loss ON"}, // For Arduino testing only {COIL, 11, 0, "Alarm Clogged Filter ON"}, // For Arduino testing only {COIL, 12, 0, "Alarm Supply Sensor Failure ON"}, // For Arduino testing only @@ -92,6 +93,18 @@ modbusMap mb_map[] = {COIL, 30, 0, "Alarm Compressor 1B Overload ON"}, // For Arduino testing only {COIL, 31, 0, "Alarm Compressor 2B Overload ON"}, // For Arduino testing only + {COIL, 32, 0, "RA Temp Low Alarm ON"}, // For Arduino testing only - sets RA Temp = 60 + {COIL, 33, 0, "RA Temp NORMAL"}, // For Arduino testing only - sets RA Temp = 84 + {COIL, 34, 0, "RA Temp High Alarm ON"}, // For Arduino testing only - sets RA Temp = 110 + + {COIL, 35, 0, "RA Humidity Low Alarm ON"}, // For Arduino testing only - sets RA Humidity = 5 + {COIL, 36, 0, "RA Humidity NORMAL"}, // For Arduino testing only - sets RA Humidity = 25 + {COIL, 37, 0, "RA Humidity High Alarm ON"}, // For Arduino testing only - sets RA Humidity = 80 + + {COIL, 38, 0, "SA Temp Low Alarm ON"}, // For Arduino testing only - sets SA Temp = 60 + {COIL, 39, 0, "SA Temp NORMAL"}, // For Arduino testing only - sets SA Temp = 76 + {COIL, 40, 0, "SA Temp High Alarm ON"}, // For Arduino testing only - sets SA Temp = 90 + {DI, 24, 0, "Supply Fan Status"}, {DI, 25, 0, "Cooling Status"}, {DI, 26, 0, "Free Cooling Status"}, @@ -136,15 +149,36 @@ modbusMap mb_map[] = {IR, 99, 0, "Unit Status"}, // 0:off, 1:on, 2:standby {IR, 102, 0, "Fan Speed"}, - {IR_10x, 129, 0, "Return Humidity"}, - {IR_10x, 742, 0, "Return Air Temp"}, - {IR_10x, 743, 0, "Supply Air Temp"}, + {IR_10x, 129, 250, "Return Humidity"}, + {IR_10x, 742, 840, "Return Air Temp"}, + {IR_10x, 743, 760, "Supply Air Temp"}, {IR, 1465, 0, "Supply Air Flow"}, {IR, 2050, 0, "Fluid Control Valve Position 1"}, {IR, 2051, 0, "Fluid Control Valve Position 2"}, + {HR_10x, 53, 600, "Return Humidity Alarm High SP"}, + {HR_10x, 54, 200, "Return Humidity Alarm Low SP"}, + {HR, 56, 0, "RAHum Value"}, + {HR, 57, 0, "RAHumHighAlm Value"}, + {HR, 58, 0, "RAHumLowAlm Value"}, + {HR, 732, 73, "Supply Air Temp Setpoint"}, + + {HR_10x, 738, 1000, "Return Air Temp Alarm High SP"}, + {HR_10x, 739, 720, "Return Air Temp Alarm Low SP"}, + {HR, 741, 0, "RATemp Value"}, + {HR, 742, 0, "RATempHighAlm Value"}, + {HR, 743, 0, "RATempLowAlm Value"}, + + {HR, 753, 80, "Return Air Temp Setpoint"}, + {HR_10x, 754, 780, "Supply Air Temp Alarm High SP"}, + {HR_10x, 755, 720, "Supply Air Temp Alarm Low SP"}, + {HR, 757, 0, "SATemp Value"}, + {HR, 758, 0, "SATempHighAlm Value"}, + {HR, 759, 0, "SATempLowAlm Value"}, + + }; //Size of modbus map used in FOR cycles, automatically calculated. diff --git a/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/State_Fail.cpp b/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/State_Fail.cpp index 987b5fd..f5c2588 100644 --- a/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/State_Fail.cpp +++ b/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/State_Fail.cpp @@ -41,6 +41,10 @@ FailState::FailState(const std::vector& activeAlarms) { addStrategy("Output Voltage", new SingleValueStrategy(0.1f, 0.1f, 1000 )); addStrategy("DC Voltage", new SingleValueStrategy(0.1f, 0.1f, 1000 )); addStrategy("Motor Shaft Power", new SingleValueStrategy(0.1f, 0.1f, 1000 )); + + addStrategy("AI1 Scaled", new RampStrategy(0.0f, 2.0f, 1000 )); + addStrategy("AI2 Scaled", new RampStrategy(0.0f, 5.0f, 1000 )); + addStrategy("AO1 Actual", new RampStrategy(0.0f, 2.0f, 1000 )); } /** @@ -83,6 +87,7 @@ void FailState::enterState(Equipment* equipment) { setPointValue(equipment, "Nominal Speed", 1800); setPointValue(equipment, "Nominal Power", 50); setPointValue(equipment, "Run Status", 0); + setPointValue(equipment, "DI Status", 0); } /** @@ -93,5 +98,4 @@ template<> void FailState::exitState(Equipment* equipment) { // Cleanup logic to run when the equipment leaves this state Serial.println("Exit Fail State..."); - } \ No newline at end of file diff --git a/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/State_Running.cpp b/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/State_Running.cpp index 9fc5ab2..83dfa41 100644 --- a/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/State_Running.cpp +++ b/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/State_Running.cpp @@ -44,14 +44,18 @@ RunningState::RunningState() { addStrategy("Speed Feedback", new RampStrategy(1800.0f, 100.0f, 1000)); addStrategy("Motor Current", new RampStrategy(65.0f, 7.0f, 1000)); addStrategy("Motor Torque", new RampStrategy(90.0f, 10.0f, 1000)); - addStrategy("Inverter Temperature", new SquareStrategy(40.0f, 80.0f, 1000)); + addStrategy("Inverter Temperature", new RampStrategy(70.0f, 1.0f, 1000)); addStrategy("Output Frequency", new RampStrategy(60.0f, 3.0f, 1000 )); addStrategy("Output Voltage", new RampStrategy(480.0f, 15.0f, 1000 )); addStrategy("DC Voltage", new RampStrategy(678.0f, 20.0f, 1000 )); addStrategy("Motor Shaft Power", new RampStrategy(36.7f, 2.0f, 1000 )); - addStrategy("Inverter MWh counter", new TotalizerStrategy(1000)); - addStrategy("Inverter kWh counter", new TotalizerStrategy(1000)); + addStrategy("Inverter MWh counter", new TotalizerStrategy(5000)); + addStrategy("Inverter kWh counter", new TotalizerStrategy(5000)); + + addStrategy("AI1 Scaled", new RampStrategy(10.0f, 1.0f, 1000 )); + addStrategy("AI2 Scaled", new RampStrategy(20.0f, 1.0f, 1000 )); + addStrategy("AO1 Actual", new RampStrategy(10.0f, 1.0f, 1000 )); } /** @@ -87,11 +91,14 @@ State* RunningState::update(Equipment* equipmen float voltage_update = speed_pct * 480; float dc_voltage_update = speed_pct * 678; float current_update = speed_pct * speed_pct * 65; - float torque_update = speed_pct * speed_pct * 100; // This is a % of nominal motor torque + float torque_update = speed_pct * speed_pct * 100 * 10; // This is a % of nominal motor torque, x10 b/c is scaled by 100 in actual equipment, this register is only 10x float freq_update = speed_pct * 60; float power_update = speed_pct * speed_pct * speed_pct * 36.77f; // 50 hp ~ 36.77kW float currentSP = getPointValue(equipment, "Speed Cmd"); + float AI1_update = speed_pct *10; + float AI2_update = speed_pct *20; + float AO1_update = speed_pct *10; Strategy_Behavior* speedFeedback = getStrategy("Speed Feedback"); if (speedFeedback) { @@ -127,6 +134,21 @@ State* RunningState::update(Equipment* equipmen if (powerstrategy) { static_cast(powerstrategy)->setTarget(power_update); } + + Strategy_Behavior* AI1strategy = getStrategy("AI1 Scaled"); + if (AI1strategy) { + static_cast(AI1strategy)->setTarget(AI1_update); + } + + Strategy_Behavior* AI2strategy = getStrategy("AI2 Scaled"); + if (AI2strategy) { + static_cast(AI2strategy)->setTarget(AI2_update); + } + + Strategy_Behavior* AO1strategy = getStrategy("AO1 Actual"); + if (AO1strategy) { + static_cast(AO1strategy)->setTarget(AO1_update); + } // Apply any strategies defined for the standby state _applyStrategies(equipment); @@ -150,6 +172,7 @@ void RunningState::enterState(Equipment* equipment) { setPointValue(equipment, "Nominal Speed", 1800); setPointValue(equipment, "Nominal Power", 50); setPointValue(equipment, "Run Status", 1); + setPointValue(equipment, "DI Status", 1); } /** diff --git a/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/State_Standby.cpp b/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/State_Standby.cpp index 41b3048..3b5185f 100644 --- a/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/State_Standby.cpp +++ b/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/State_Standby.cpp @@ -39,6 +39,10 @@ StandbyState::StandbyState() { addStrategy("Output Voltage", new SingleValueStrategy(0.1f, 0.1f, 1000 )); addStrategy("DC Voltage", new SingleValueStrategy(0.1f, 0.1f, 1000 )); addStrategy("Motor Shaft Power", new SingleValueStrategy(0.1f, 0.1f, 1000 )); + + addStrategy("AI1 Scaled", new RampStrategy(0.0f, 2.0f, 1000 )); + addStrategy("AI2 Scaled", new RampStrategy(0.0f, 5.0f, 1000 )); + addStrategy("AO1 Actual", new RampStrategy(0.0f, 2.0f, 1000 )); } /** @@ -90,6 +94,7 @@ void StandbyState::enterState(Equipment* equipment) { setPointValue(equipment, "Nominal Speed", 1800); setPointValue(equipment, "Nominal Power", 50); setPointValue(equipment, "Run Status", 0); + setPointValue(equipment, "DI Status", 0); } /** diff --git a/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/config.h b/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/config.h index 78bff06..9aaac3f 100644 --- a/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/config.h +++ b/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/config.h @@ -6,7 +6,7 @@ * * This file contains important configurations for the Modbus RTU communication * and the specific register map for the emulated device. - * These are 32-bit modbus registers. + * These are 16-bit modbus registers. * Added "Run Status" and "Fault Status" to simulated hard IO points and send feedback to PLC during simulation. */ @@ -71,22 +71,22 @@ modbusMap mb_map[] = {HR, 112, 0, "Output Voltage"}, // 480 VAC {HR_10x, 116, 0, "Motor Shaft Power"}, // 50 hp ~ 36.77 kW {HR, 118, 0, "Inverter MWh counter"}, - {HR_10x, 119, 0, "Inverter kWh counter"}, + {HR, 119, 0, "Inverter kWh counter"}, {HR, 510, 0, "Inverter Temperature"}, // RJD: Changed from HR_10x to HR, % of fault limit {HR, 519, 0, "Diagnostic Word"}, // not used in program. Bit 9:Drive Over-Temp Alarm - {HR, 1000, 0, "DI Status"}, // not used in program. - {HR, 1211, 0, "AI1 Scaled"}, // not used in program. - {HR, 1221, 0, "AI2 Scaled"}, // not used in program. - {HR, 1310, 0, "AO1 Actual"}, // not used in program. - {HR, 1910, 0, "External Control Location"}, // not used in program. - {HR, 4600, 0, "Speed Scaling"}, // ADD: 1800 rpm - {HR, 4601, 0, "Frequency Scaling"}, // ADD: 60 Hz - {HR, 9905, 0, "Nominal Current"}, // ADD: 65 A - {HR_10x, 9906, 0, "Nominal Voltage"}, // ADD: 480 V - {HR_10x, 9907, 0, "Nominal Frequency"}, // ADD: 60 Hz - {HR, 9908, 0, "Nominal Speed"}, // ADD: 1800 rpm - {HR_10x, 9909, 0, "Nominal Power"}, // ADD: 50 hp + {HR, 1000, 0, "DI Status"}, // Bit 0: input 1, Bit 1: Input 2 + {HR, 1211, 0, "AI1 Scaled"}, // output frequency/speed reference, 0-10V + {HR, 1221, 0, "AI2 Scaled"}, // actual feedback 0-20mA + {HR, 1310, 0, "AO1 Actual"}, // output frequency 0-10V + {HR, 1910, 0, "External Control Location"}, // not used in program. Bit 13, 0:false, 1:true + {HR, 4600, 1800, "Speed Scaling"}, // 1800 rpm + {HR, 4601, 60, "Frequency Scaling"}, // 60 Hz + {HR, 9905, 65, "Nominal Current"}, // 65 A + {HR_10x, 9906, 4800, "Nominal Voltage"}, // 480 V + {HR_10x, 9907, 600, "Nominal Frequency"}, // 60 Hz + {HR, 9908, 1800, "Nominal Speed"}, // 1800 rpm + {HR_10x, 9909, 500, "Nominal Power"}, // 50 hp }; //Size of modbus map used in FOR cycles, automatically calculated. diff --git a/src/EPMS/RPP/RPP_Cortex_TCP/config.h b/src/EPMS/RPP/RPP_Cortex_TCP/config.h index 7d2233b..e15c97b 100644 --- a/src/EPMS/RPP/RPP_Cortex_TCP/config.h +++ b/src/EPMS/RPP/RPP_Cortex_TCP/config.h @@ -23,7 +23,7 @@ #include const char *ssid = "Oracle_SA"; /**< @brief The SSID of the WiFi network. */ const char *password = "Prime!123"; /**< @brief The password for the WiFi network. */ - IPAddress local_IP(172, 17, 38, 41); /**< @brief The static IP address for the device. */ + IPAddress local_IP(172, 17, 38, 51); /**< @brief The static IP address for the device. */ IPAddress gateway(172, 17, 38, 1); /**< @brief The gateway IP address. */ IPAddress subnet(255, 255, 255, 0); /**< @brief The subnet mask. */