diff --git a/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/README.md b/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/README.md index 8e0e849..4a7c8ed 100644 --- a/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/README.md +++ b/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/README.md @@ -1,13 +1,12 @@ # VFD ABB ACH580 RTU ## Brief Introduction -This is based on a 50hp motor, 480V, 65 FLA, 60Hz, 1800 rpm (PHX3 DC1/2) +This is based on a 50hp motor, 480V, 65 FLA, 60Hz, 1800 rpm (PHX3 DC1/2). +Modbus addresses are based on 32-bit registers. ## List of Equipment This configuration has been used for these models: -* **ACH580**: 10-23-2025 -* **Model**: 09-15-23 -* **Model**: 09-15-25 +* **ACH580**: 10-23-2025 (PHX3) ## Hardware Prerequisites @@ -19,12 +18,11 @@ The code is written for an ESP8266/ESP32-style microcontroller with WiFi capabil --- ## States and Strategies -The hardwire IO signals to/from VFD/PLC are Start Cmd, Stop Cmd, Speed Command, Speed Feedback, VFD Run Status, VFD Fault. +The hardwire IO signals to/from VFD/PLC are Start Cmd, Stop Cmd, Speed Command, Speed Feedback, Run Status, Fault Status. User needs to set the speed command (HR 150) in RPM from the PLC User needs to set the Start command (HR 151) from the PLC -It appears these registers were arbitrarily chosen for the purpose of this Arduino simulation. -The registers selected are based on FS Config file from CDR project. -Currently there is no connection on Speed Feedback, Run Status, or Fault from Arduino to PICS +It appears these hard IO registers were arbitrarily chosen for the purpose of this Arduino simulation. +The registers selected are based on FS Config file from CDR project. Run Status and Fault Status registers were added for simulation. ### Standby State * **Equipment**: Equipment parameters go back to 0 @@ -37,4 +35,6 @@ Currently there is no connection on Speed Feedback, Run Status, or Fault from Ar * **Totalizers Strategy**: Inverter kWh cnt, Hours Run ### Fail State -* Not used \ No newline at end of file +* Enters Fail State if Fault Status is set to 0. +While in Fail State, the Start/Stop command is reset to 0. +The only way to exit Fail State is if Fault Status = 1 --> Standby State. \ No newline at end of file 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 6d85f9a..f7b8919 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 @@ -1,16 +1,18 @@ /** * @file State_Fail.cpp * @brief Implementation of the FailState class. - * @author Emmanuel Hernandez Cruz - * @date 2025-09-05 + * @author Robert J Davis + * @date 2025-10-30 * * This file contains the implementation for the FailState, which defines * the behavior of the equipment when it has entered a fault condition. + * */ #include "States/State_Standby.h" #include "States/State_Fail.h" #include "ModbusPoints/Modbus_Point.h" #include "Equipment/Equipment.h" +#include "Strategies/Strategy_Ramp.h" #include "Strategies/Strategy_SingleValue.h" #include "Strategies/Strategy_PID.h" @@ -26,21 +28,28 @@ /** * @brief Constructs a new FailState object. * - * 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 valve position. + * This constructor sets the associated analog signals to the same values as Standby. */ template<> FailState::FailState(const std::vector& activeAlarms) { - // Simulate a failure: set common alarm and a specific fan alarm. + addStrategy("Motor Speed Used", new RampStrategy(0.0f, 200.0f, 1000 )); + addStrategy("Speed Feedback", new RampStrategy(0.0f, 200.0f, 1000 )); + addStrategy("Motor Speed estimated", new RampStrategy(0.0f, 200.0f, 1000 )); + addStrategy("Motor Current", new RampStrategy(0.0f, 20.0f, 1000 )); + addStrategy("Motor Torque", new RampStrategy(0.0f, 20.0f, 1000 )); + addStrategy("Inverter Temperature", new RampStrategy(0.0f, 1.0f, 1000 )); + + addStrategy("Output Frequency", new SingleValueStrategy(0.1f, 0.2f, 1000 )); + addStrategy("Output Voltage", new SingleValueStrategy(0.1f, 0.1f, 1000 )); + addStrategy("DC Voltage", new SingleValueStrategy(0.1f, 0.1f, 1000 )); + addStrategy("Output Power", new SingleValueStrategy(0.1f, 0.1f, 1000 )); } /** * @brief Executes the fail state's logic for one update cycle. * - * This method checks the "Clear Alm" 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. + * While in FailState, the Unit cannot be started and the Start/Stop command is reset to 0. + * When the fault is cleared --> Standby State. * * @param equipment Pointer to the Equipment instance. * @return A pointer to a new State if a transition should occur, otherwise nullptr. @@ -49,24 +58,30 @@ template<> State* FailState::update(Equipment* equipment) { // STATE control, add conditions if change to a different state is needed Serial.println("Fail update function"); + + int faultNotPresent = getPointValue(equipment, "Fault Status"); + if(faultNotPresent == 1){ + return new StandbyState(); + } + setPointValue(equipment, "Start/Stop", 0); _applyStrategies(equipment); return nullptr; } /** - * @brief Logic to execute once when entering the fail state. Sets the main alarm bit. + * @brief Logic to execute once when entering the fail state. Sets the Run Status to 0. * @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..."); - + setPointValue(equipment, "Run Status", 0); } /** - * @brief Logic to execute once when exiting the fail state. Clears the main alarm bit. + * @brief Logic to execute once when exiting the fail state. * @param equipment Pointer to the Equipment instance. */ template<> 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 9bdcdd9..36d586d 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 @@ -1,7 +1,7 @@ /** * @file State_Running.cpp * @brief Implementation of the RunningState class. - * @author Emmanuel Hernandez Cruz, Robert J Davis + * @author Robert J Davis * @date 2025-10-22 * * This file contains the implementation for the RunningState, which defines @@ -36,12 +36,13 @@ * @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. + * state, such as speed feedback, current, torque, hours run, etc. + * These values are based on a 50hp motor, 480V, 65 FLA, 60Hz, 1800 rpm (PHX3 DC1/2) */ template<> RunningState::RunningState() { addStrategy("Motor Speed Used", new RampStrategy(1800.0f, 100.0f, 1000)); + addStrategy("Speed Feedback", new RampStrategy(1800.0f, 100.0f, 1000)); addStrategy("Motor Speed estimated", 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)); @@ -53,18 +54,16 @@ RunningState::RunningState() { addStrategy("Output Power", new RampStrategy(36.7f, 2.0f, 1000 )); addStrategy("Inverter kWh cnt", new TotalizerStrategy(1000)); addStrategy("Hours Run", new TotalizerStrategy(1000)); - } /** * @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. + * 1. If Fault is 0 (there is a fault present) --> FailState + * 2. It reads the "Stop/Start" command point (from PLC). If it's 0, it transitions to StandbyState. * - * If no transition occurs, it applies the strategies defined for the running state. + * If no transition occurs, it updates values according to speed setpoint sent from PLC. * * @param equipment Pointer to the Equipment instance. * @return A pointer to a new State if a transition should occur, otherwise nullptr. @@ -74,6 +73,17 @@ State* RunningState::update(Equipment* equipmen // STATE control, add conditions if change to a different state is needed Serial.println("Running update function"); + // If Fault Status = 0, there is a fault --> FailState + int faultNotPresent = getPointValue(equipment, "Fault Status"); + if(faultNotPresent == 0){ + return new FailState({"Fault Status"}); + } + + int VFD_Start_Stop = getPointValue(equipment, "Start/Stop"); + if (VFD_Start_Stop == 0){ + return new StandbyState(); + } + float speed_pct = getPointValue(equipment, "Speed Cmd") / 1800.0f; // Based on Affinity Laws. Motor: 65 FLA, 480V, 60Hz, 1800 rpm, 50hp float voltage_update = speed_pct * 480; @@ -83,11 +93,6 @@ State* RunningState::update(Equipment* equipmen float freq_update = speed_pct * 60; float power_update = speed_pct * speed_pct * speed_pct * 36.77f; // 50 hp ~ 36.77kW - int VFD_Start_Stop = getPointValue(equipment, "Start/Stop"); - if (VFD_Start_Stop == 0){ - return new StandbyState(); - } - float currentSP = getPointValue(equipment, "Speed Cmd"); Strategy_Behavior* motorSpeedUsed = getStrategy("Motor Speed Used"); // 2. Check if the strategy exists @@ -96,6 +101,11 @@ State* RunningState::update(Equipment* equipmen static_cast(motorSpeedUsed)->setTarget(currentSP); } + Strategy_Behavior* speedFeedback = getStrategy("Speed Feedback"); + if (speedFeedback) { + static_cast(speedFeedback)->setTarget(currentSP); + } + // To have Motor Speed estimated slightly different - for purposes of differentiating in Ignition float rpm_est = currentSP * 0.98f; Strategy_Behavior* motorSpeedEst = getStrategy("Motor Speed estimated"); @@ -140,19 +150,19 @@ State* RunningState::update(Equipment* equipmen /** * @brief Logic to execute once when entering the running state. - * Sets the "Chiller Sts" point to indicate the unit is running. + * Sets the Run Status" point to indicate the unit is running. * @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..."); - + setPointValue(equipment, "Run Status", 1); } /** * @brief Logic to execute once when exiting the running state. - * Sets the "Chiller Sts" point to indicate the unit is no longer running. + * Sets the "Output Frequency" to 0. * @param equipment Pointer to the Equipment instance. */ template<> 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 7806142..01629e0 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 @@ -1,7 +1,7 @@ /** * @file State_Standby.cpp * @brief Implementation of the StandbyState class. - * @author Emmanuel Hernandez Cruz, Robert J Davis + * @author Robert J Davis * @date 2025-10-23 * * This file contains the implementation for the StandbyState, which defines @@ -26,30 +26,31 @@ * @brief Constructs a new StandbyState object. * * In this state, the equipment is idle. This constructor initializes several - * strategies to generate random values for various status points, simulating - * a live but non-operational unit. + * strategies to simulate a live but non-operational unit. Most values are ramped down to 0. */ template<> StandbyState::StandbyState() { - addStrategy("Output Frequency", new SingleValueStrategy(0.1f, 0.2f, 1000 )); - addStrategy("Output Voltage", new SingleValueStrategy(0.1f, 0.1f, 1000 )); - addStrategy("DC Voltage", new SingleValueStrategy(0.1f, 0.1f, 1000 )); - addStrategy("Output Power", new SingleValueStrategy(0.1f, 0.1f, 1000 )); - addStrategy("Motor Speed Used", new RampStrategy(0.0f, 200.0f, 1000 )); + addStrategy("Speed Feedback", new RampStrategy(0.0f, 200.0f, 1000 )); addStrategy("Motor Speed estimated", new RampStrategy(0.0f, 200.0f, 1000 )); addStrategy("Motor Current", new RampStrategy(0.0f, 20.0f, 1000 )); addStrategy("Motor Torque", new RampStrategy(0.0f, 20.0f, 1000 )); addStrategy("Inverter Temperature", new RampStrategy(0.0f, 1.0f, 1000 )); - + + addStrategy("Output Frequency", new SingleValueStrategy(0.1f, 0.2f, 1000 )); + addStrategy("Output Voltage", new SingleValueStrategy(0.1f, 0.1f, 1000 )); + addStrategy("DC Voltage", new SingleValueStrategy(0.1f, 0.1f, 1000 )); + addStrategy("Output Power", new SingleValueStrategy(0.1f, 0.1f, 1000 )); } /** * @brief Executes the standby state's logic for one update cycle. * - * This method checks the "Chiller On-Off" Modbus point for a command to - * transition to the Running state. If no transition is requested, it applies - * the strategies defined for the standby state. + * This method first checks for state transition commands: + * 1. If Fault is 0 (there is a fault present) --> FailState + * 2. It reads the "Start/Stop" point (from PLC). If it's 1 --> RunningState + * + * If no transition is requested, it applies the strategies defined for the standby state. * * @param equipment Pointer to the Equipment instance. * @return A pointer to a new State if a transition should occur, otherwise nullptr. @@ -58,6 +59,13 @@ template<> State* StandbyState::update(Equipment* equipment) { // STATE control, add conditions if change to a different state is needed Serial.println("Standby update function"); + + // If Fault Status = 0, there is a fault --> FailState + int faultNotPresent = getPointValue(equipment, "Fault Status"); + if(faultNotPresent == 0){ + return new FailState({"Fault Status"}); + } + int VFD_Start_Stop = getPointValue(equipment, "Start/Stop"); if (VFD_Start_Stop == 1){ return new RunningState(); @@ -69,14 +77,14 @@ State* StandbyState::update(Equipment* equipmen /** * @brief Logic to execute once when entering the standby state. - * Sets the "Chiller Sts" point to indicate the unit is not running. + * Sets the "Run Status" point to indicate the unit is not running. * @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..."); - + setPointValue(equipment, "Run 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 b2f6c3b..1389e79 100644 --- a/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/config.h +++ b/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/config.h @@ -1,11 +1,13 @@ /** * @file config.h - * @brief Main configuration file for the ABB ACH580 (VFD) emulator. - * @author Emmanuel Hernandez Cruz, Robert J Davis + * @brief Main configuration file for the ABB ACH580 VFD (RTU) emulator. + * @author Robert J Davis * @date 2025-10-22 * * 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. + * Added "Run Status" and "Fault Status" to simulated hard IO points and send feedback to PLC during simulation. */ #ifndef CONFIG_H @@ -54,36 +56,32 @@ */ modbusMap mb_map[] = { - {HR, 149, 0, "Speed Cmd"}, // expecting rpm (1800 rpm max) - {HR, 151, 0, "Start/Stop"}, - {HR, 152, 0, "HOA Command"}, - {HR, 100, 0, "Motor Speed Used"}, // RJD: 1800 rpm max - {HR, 101, 0, "Motor Speed estimated"}, // RJD: 1800 rpm max - {HR_10x, 105, 0, "Output Frequency"}, // 60 Hz @100% speed - {HR, 106, 0, "Motor Current"}, // RJD: Changed from HR_10x to HR, 65 FLA - {HR_10x, 109, 0, "Motor Torque"}, // % of nominal torque - {HR_10x, 110, 0, "DC Voltage"}, // approx 678 VDC @100% speed - {HR, 112, 0, "Output Voltage"}, // RJD: 480 VAC - {HR, 113, 0, "Output Power"}, //max 372580 // RJD: Changed from HR_10x to HR, 50 hp ~ 36.77 kW - {HR_10x, 119, 0, "Inverter kWh cnt"}, - - {HR, 502, 0, "Hours Run"}, - {HR, 510, 0, "Inverter Temperature"}, // RJD: Changed from HR_10x to HR, % of fault limit - {HR, 521, 0, "HOA Status Word"}, + {HR, 149, 1800, "Speed Cmd"}, // arbitrary register number - receive signal from PLC (hardwire IO in field); expecting rpm (1800 rpm max) + {HR, 151, 0, "Start/Stop"}, // arbitrary register number - receive signal from PLC (hardwire IO in practice) + {HR, 152, 0, "HOA Command"}, // arbitrary register number - not used in program + {HR, 154, 0, "Run Status"}, // arbitrary register number - 0:off, 1:on (simulated hardwire IO) sending feedback to PLC during simulation. + {HR, 155, 1, "Fault Status"}, // arbitrary register number - 0:faulted, 1:not faulted (simulated hardwire IO). When = 0, will turn off VFD. + {HR, 156, 0, "Speed Feedback"}, // arbitrary register number - send signal to PLC (simulated hardwire IO). Will be equal to Motor Speed Used register - {HR, 410, 0, "Last Fault"}, - {HR, 411, 0, "2nd to last Fault"}, - {HR, 412, 0, "3rd to last Fault"}, - {HR, 439, 0, "Event Word Param"}, + {HR_FLOAT, 20201, 0, "Motor Speed Used"}, // RJD: 1800 rpm max + {HR_FLOAT, 20203, 0, "Motor Speed estimated"}, // RJD: 1800 rpm max + {HR_FLOAT, 20211, 0, "Output Frequency"}, // 60 Hz @100% speed + {HR_FLOAT, 20213, 0, "Motor Current"}, // RJD: Changed from HR_10x to HR, 65 FLA + {HR_FLOAT, 20219, 0, "Motor Torque"}, // % of nominal torque + {HR_FLOAT, 20221, 0, "DC Voltage"}, // approx 678 VDC @100% speed + {HR_FLOAT, 20225, 0, "Output Voltage"}, // RJD: 480 VAC + {HR_FLOAT, 20227, 0, "Output Power"}, //max 372580 // RJD: Changed from HR_10x to HR, 50 hp ~ 36.77 kW + {HR_FLOAT, 20239, 0, "Inverter kWh cnt"}, + {HR_FLOAT, 21005, 0, "Hours Run"}, + {HR_FLOAT, 21021, 0, "Inverter Temperature"}, // RJD: Changed from HR_10x to HR, % of fault limit - {HR, 610, 0, "Status Word 1"}, - {HR, 615, 0, "Status Word 2"}, - {HR, 616, 0, "Status Word 3"}, - {HR, 617, 0, "Status Word 4"}, - {HR, 618, 0, "Status Word 5"}, - {HR, 619, 0, "Status Word 6"}, - {HR, 620, 0, "Status Word 7"}, - {HR, 621, 0, "Status Word 8"}, + {HR, 21243, 0, "HOA Status Word"}, // not used in program + {HR, 20801, 0, "Trip Fault"}, // not used in program + {HR, 20821, 0, "Last Fault"}, // not used in program + {HR, 20823, 0, "2nd to last Fault"}, // not used in program + {HR, 20825, 0, "3rd to last Fault"}, // not used in program + {HR, 21221, 0, "Main Status Word"}, // not used in program + {HR, 21231, 0, "Drive Status Word 1"}, // not used in program }; //Size of modbus map used in FOR cycles, automatically calculated. /** diff --git a/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/main.cpp b/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/main.cpp index 5dbc9f1..a77f9b2 100644 --- a/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/main.cpp +++ b/src/BMS/VFD/PHX3_VFD_ABB_ACH580_RTU/main.cpp @@ -1,11 +1,11 @@ /** * @file main.cpp - * @brief Main execution program for the Daikin Chiller (RTU) Emulator. - * @author Emmanuel Hernandez Cruz + * @brief Main execution program for the ABB ACH580 VFD (RTU) Emulator. + * @author Emmanuel Hernandez Cruz, Robert J Davis * @date 2025-09-02 * * @details This file contains the main execution program for an Arduino-based - * emulator of a Daikin Chiller unit. The program communicates via the + * emulator of a ABB ACH580 VFD unit. The program communicates via the * Modbus RTU protocol over a serial connection. * * The setup() function initializes the following: