/** * @file config.h * @brief Main configuration file for the UMAS CRAH Unit (TCP) emulator - used at PHX3 DC1 * @author Robert J Davis * @date 2025-10-01 * * 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 = "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, 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. */ 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. */ // "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 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 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"}, {IR, 26, 0, "Alarm Fan 1"}, {IR, 30, 0, "Alarm Fan 2"}, {IR, 34, 0, "Alarm Fan 3"}, {IR, 38, 0, "Alarm Fan 4"}, {IR, 42, 0, "Alarm Fan 5"}, {IR, 46, 0, "Alarm Fan 6"}, {IR, 50, 0, "Alarm Fan 7"}, {IR, 54, 0, "Alarm Fan 8"}, {IR, 58, 0, "Alarm Fan 9"}, {IR, 27, 0, "Run Status Fan 1"}, // Send to PLC {IR, 31, 0, "Run Status Fan 2"}, // Send to PLC {IR, 35, 0, "Run Status Fan 3"}, // Send to PLC {IR, 39, 0, "Run Status Fan 4"}, // Send to PLC {IR, 43, 0, "Run Status Fan 5"}, // Send to PLC {IR, 47, 0, "Run Status Fan 6"}, // Send to PLC {IR, 51, 0, "Run Status Fan 7"}, // Send to PLC {IR, 55, 0, "Run Status Fan 8"}, // Send to PLC {IR, 59, 0, "Run Status Fan 9"}, // Send to PLC {IR, 25, 0, "Speed Fan 1"}, {IR, 29, 0, "Speed Fan 2"}, {IR, 33, 0, "Speed Fan 3"}, {IR, 37, 0, "Speed Fan 4"}, {IR, 41, 0, "Speed Fan 5"}, {IR, 45, 0, "Speed Fan 6"}, {IR, 49, 0, "Speed Fan 7"}, {IR, 53, 0, "Speed Fan 8"}, {IR, 57, 0, "Speed Fan 9"}, {IR, 28, 0, "Operating Hours Fan 1"}, {IR, 32, 0, "Operating Hours Fan 2"}, {IR, 36, 0, "Operating Hours Fan 3"}, {IR, 40, 0, "Operating Hours Fan 4"}, {IR, 44, 0, "Operating Hours Fan 5"}, {IR, 48, 0, "Operating Hours Fan 6"}, {IR, 52, 0, "Operating Hours Fan 7"}, {IR, 56, 0, "Operating Hours Fan 8"}, {IR, 60, 0, "Operating Hours Fan 9"}, {IR, 61, 0, "Control Mode Selected"}, // 0: BMS+Speed, 1: BMS+Room Temp, 2: Return Temp {IR_FLOAT, 63, 0, "Amps Fan 1"}, {IR_FLOAT, 65, 0, "Amps Fan 2"}, {IR_FLOAT, 67, 0, "Amps Fan 3"}, {IR_FLOAT, 69, 0, "Amps Fan 4"}, {IR_FLOAT, 71, 0, "Amps Fan 5"}, {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"}, {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, 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. /** * @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