modbus updates
This commit is contained in:
106
src/EPMS/ATS/ATS_800_RPD/config.h
Normal file
106
src/EPMS/ATS/ATS_800_RPD/config.h
Normal file
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* @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 <ModbusIP_ESP8266.h>
|
||||
const char *ssid = "wifi_name"; /**< @brief The SSID of the WiFi network. */
|
||||
const char *password = "wifi_password"; /**< @brief The password for the WiFi network. */
|
||||
IPAddress local_IP(192, 168, 1, 234); /**< @brief The static IP address for the device. */
|
||||
IPAddress gateway(192, 168, 1, 1); /**< @brief The gateway IP address. */
|
||||
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 <ModbusRTU.h>
|
||||
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, 15, 0, "State Control"}, //Internal to control from Modscan
|
||||
{HR, 16, 0, "Fault Code"}, //Internal Fault code from Modscan
|
||||
{IR, 6298, 0, "Alarm Status Bits"},
|
||||
{IR, 6159, 0, "Amps A"},
|
||||
{IR, 6160, 0, "Amps B"},
|
||||
{IR, 6161, 0, "Amps C"},
|
||||
{IR, 6172, 0, "Power Factor (PF)"},
|
||||
{IR, 6264, 0, "Number of Transfers"},
|
||||
{IR, 6152, 0, "Volts AB"},
|
||||
{IR, 6153, 0, "Volts BC"},
|
||||
{IR, 6154, 0, "Volts CA"},
|
||||
{IR, 6155, 0, "Source 1 Frequency"},
|
||||
{IR, 6145, 0, "Source 1 Volts AB"},
|
||||
{IR, 6146, 0, "Source 1 Volts BC"},
|
||||
{IR, 6147, 0, "Source 1 Volts CA"},
|
||||
{IR, 6156, 0, "Source 2 Frequency"},
|
||||
{IR, 6148, 0, "Source 2 Volts AB"},
|
||||
{IR, 6149, 0, "Source 2 Volts BC"},
|
||||
{IR, 6150, 0, "Source 2 Volts CA"},
|
||||
{IR_LONG, 6170, 0, "Total Apparent Power (kVA)"},
|
||||
{IR_LONG, 6166, 0, "Total Active Power (kW)"},
|
||||
{DI, 1014, 0, "Summary Alarm"},
|
||||
{DI, 1020, 0, "Transfer Inhibit"},
|
||||
{DI, 1002, 0, "Source 1 Active"},
|
||||
{DI, 1000, 0, "Source 1 Available"},
|
||||
{DI, 1004, 0, "Source 1 Preferred"},
|
||||
{DI, 1003, 0, "Source 2 Active"},
|
||||
{DI, 1001, 0, "Source 2 Available"},
|
||||
{DI, 1005, 0, "Source 2 Preferred"},
|
||||
|
||||
};
|
||||
//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
|
||||
Reference in New Issue
Block a user