From 587945cf1f117af3531d3cb999179a5b20febb13 Mon Sep 17 00:00:00 2001 From: Emmanuel HC Date: Mon, 10 Nov 2025 09:24:44 -0600 Subject: [PATCH] MVG Template created --- platformio.ini | 9 ++- src/EPMS/MVG/MVG_SC_EC_M505_TCP/README.md | 59 ++++++++++++------- .../MVG/MVG_SC_EC_M505_TCP/State_Running.cpp | 11 ++-- .../MVG/MVG_SC_EC_M505_TCP/State_Standby.cpp | 10 ++-- src/EPMS/MVG/MVG_SC_EC_M505_TCP/config.h | 10 ++-- 5 files changed, 55 insertions(+), 44 deletions(-) diff --git a/platformio.ini b/platformio.ini index 12dc711..97e5cbb 100644 --- a/platformio.ini +++ b/platformio.ini @@ -12,7 +12,7 @@ default_envs = MVG_SC_EC_M505_TCP ; Select here the name of the configuration you want to download [env] -upload_port = COM16 +upload_port = COM26 [common_env_options] framework = arduino @@ -251,7 +251,6 @@ build_src_filter = -<*> + platform = espressif32 board = dfrobot_firebeetle2_esp32e extends = common_env_options -build_flags = - -D USE_MODBUS_IP, - -D USE_LED -build_src_filter = -<*> + \ No newline at end of file +build_flags = -D USE_MODBUS_IP, +build_src_filter = -<*> + + diff --git a/src/EPMS/MVG/MVG_SC_EC_M505_TCP/README.md b/src/EPMS/MVG/MVG_SC_EC_M505_TCP/README.md index 355156f..4f156e3 100644 --- a/src/EPMS/MVG/MVG_SC_EC_M505_TCP/README.md +++ b/src/EPMS/MVG/MVG_SC_EC_M505_TCP/README.md @@ -1,33 +1,48 @@ -# EQUIPMENT_TYPE MANUFACTURER MODEL TCP +# Daikin Chiller (RTU) Emulator -## Brief Introduction -Equipment specifc details that make it different from other devices +This project is an Arduino-based emulator for a Daikin Chiller unit, communicating over Modbus RTU. It is designed to be a flexible template that can be adapted to simulate different types of chillers by modifying the configuration and state logic. -## List of Equipmentt -This cofiguration has been used for these models: -* **Model**: 09-15-22 -* **Model**: 09-15-23 -* **Model**: 09-15-25 +The emulator operates on a state machine with three core states: +* **Standby**: The chiller is idle but ready. +* **Running**: The chiller is active and operational. +* **Fail**: The chiller has encountered a fault condition. + +## Features + +* **Modbus RTU Communication**: Emulates a Modbus slave device. +* **State Machine Logic**: Simulates different operational states (Standby, Running, Fail). +* **Dynamic Value Simulation**: Uses "Strategies" (e.g., PID, Ramp) to generate realistic, changing values for Modbus points. +* **Configurable Modbus Map**: The entire Modbus register map is defined in a single, easy-to-modify file (`config.h`). +* **Extensible Design**: The structure allows for the addition of new states and behaviors. ## 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) +The code is written for an ESP8266/ESP32-style microcontroller with WiFi capabilities and at least one hardware serial port for RS485 communication. + +* **Microcontroller**: ESP8266, ESP32, or similar. +* **RS485 Transceiver**: A module like the MAX485 to interface with the Modbus RTU bus. + +## Software Dependencies + +This project relies on a Modbus library. Ensure you have the correct library installed in your Arduino IDE. + +* **Modbus Library**: The code uses a library that provides `ModbusRTU.h` and optionally `ModbusIP_ESP8266.h`. --- -## States and Strategies -Provide a brief description of what variables and strategies were used in this configuraiton +## How to Customize for a New Chiller -### Standby State -* **Equipment running**: set to 0 -* **Common Alarm**: set to 0 -* **SAT temperature**: set to 85 +To adapt this template for a new chiller, follow these steps. -### Running State -* **Equipment running**: set to 1 -* **SAT temperature**: **Ramp Strategy** set to 65 deg setpoint +### 1. Configure Device-Specific Parameters (`config.h`) -### Fail State -* **Commong Alarm**: set to 1 -* **SAT temperature**: **Ramp Strategy** set to 105 deg setpointset +Open `CH_Daikin_AWV026B_RTU/config.h`. This is the main file for device-specific settings. + +#### Modbus RTU Settings +Update the following constants for your device's serial communication setup. +```c++ +const int BAUDRATE = 19200; // The serial communication speed +const int RX_PIN = 17; // The GPIO pin for receiving data (RX) +const int TX_PIN = 16; // The GPIO pin for transmitting data (TX) +const int RST_PIN = 4; // The GPIO pin for RS485 direction control +const int MODBUS_ID = 1; // The unique slave ID for this device \ No newline at end of file diff --git a/src/EPMS/MVG/MVG_SC_EC_M505_TCP/State_Running.cpp b/src/EPMS/MVG/MVG_SC_EC_M505_TCP/State_Running.cpp index 5215ef6..f3faa44 100644 --- a/src/EPMS/MVG/MVG_SC_EC_M505_TCP/State_Running.cpp +++ b/src/EPMS/MVG/MVG_SC_EC_M505_TCP/State_Running.cpp @@ -38,6 +38,7 @@ */ template<> RunningState::RunningState() { + } /** @@ -59,7 +60,7 @@ State* RunningState::update(Equipment* equipment) Serial.println("Running update function"); float StateCtrl = getPointValue(equipment, "Px_Mode"); if (StateCtrl == 1.0f) { - return new RunningState(); + return new StandbyState(); } float W1 = getPointValue(equipment, "Px_W1"); @@ -68,6 +69,7 @@ State* RunningState::update(Equipment* equipment) float W4 = getPointValue(equipment, "Px_W4"); float W5 = getPointValue(equipment, "Px_W5"); float W6 = getPointValue(equipment, "Px_W6"); + // Apply any strategies defined for the standby state switch (static_cast(W1)){ case 0: @@ -236,10 +238,6 @@ State* RunningState::update(Equipment* equipment) setBitValue(equipment, "MVG_STS_03", 1, false); break; } - - - - // Apply any strategies defined for the standby state _applyStrategies(equipment); return nullptr; } @@ -254,7 +252,7 @@ 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 - + } /** @@ -269,4 +267,5 @@ void RunningState::exitState(Equipment* equipment) { setPointValue(equipment, "MVG_STS_01", 0); setPointValue(equipment, "MVG_STS_02", 0); setPointValue(equipment, "MVG_STS_03", 0); + } \ No newline at end of file diff --git a/src/EPMS/MVG/MVG_SC_EC_M505_TCP/State_Standby.cpp b/src/EPMS/MVG/MVG_SC_EC_M505_TCP/State_Standby.cpp index 92daf4c..6dad7d4 100644 --- a/src/EPMS/MVG/MVG_SC_EC_M505_TCP/State_Standby.cpp +++ b/src/EPMS/MVG/MVG_SC_EC_M505_TCP/State_Standby.cpp @@ -38,8 +38,7 @@ template<> StandbyState::StandbyState() { // You can add initialization code here if needed - - + } /** @@ -60,9 +59,6 @@ State* StandbyState::update(Equipment* equipment) if (StateCtrl == 2.0f) { return new RunningState(); } - - - // Apply any strategies defined for the standby state _applyStrategies(equipment); return nullptr; } @@ -77,8 +73,10 @@ 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. diff --git a/src/EPMS/MVG/MVG_SC_EC_M505_TCP/config.h b/src/EPMS/MVG/MVG_SC_EC_M505_TCP/config.h index a29ec84..3be4ccc 100644 --- a/src/EPMS/MVG/MVG_SC_EC_M505_TCP/config.h +++ b/src/EPMS/MVG/MVG_SC_EC_M505_TCP/config.h @@ -21,10 +21,10 @@ * @{ */ #include - const char *ssid = "wifi_name"; /**< @brief The SSID of the WiFi network. */ - const char *password = "wifi_password"; /**< @brief The password for the WiFi network. */ - IPAddress local_IP(192, 168, 1, 234); /**< @brief The static IP address for the device. */ - IPAddress gateway(192, 168, 1, 1); /**< @brief The gateway IP address. */ + const char *ssid = "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, 82); /**< @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. */ ModbusIP mb; @@ -70,7 +70,7 @@ modbusMap mb_map[] = {HR, 1049, 0, "MVG_STS_01"}, {HR, 1050, 0, "MVG_STS_02"}, {HR, 1051, 0, "MVG_STS_03"}, -}; +}; //Size of modbus map used in FOR cycles, automatically calculated. /**