@@ -9,7 +9,7 @@
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[platformio]
|
||||
default_envs = Susol_Smart_MCCB_TCP ; Select here the name of the configuration you want to download
|
||||
default_envs = ATS_Woodward_DTSC200A_TCP ; Select here the name of the configuration you want to download
|
||||
|
||||
[env]
|
||||
upload_port = COM15
|
||||
@@ -177,4 +177,20 @@ platform = espressif32
|
||||
board = dfrobot_firebeetle2_esp32e
|
||||
extends = common_env_options
|
||||
build_flags = -D USE_MODBUS_IP
|
||||
build_src_filter = -<*> +<EPMS/PQM/PQM_PM9000_TCP>
|
||||
build_src_filter = -<*> +<EPMS/PQM/PQM_PM9000_TCP>
|
||||
|
||||
|
||||
|
||||
[env:ATS_Eaton_ATC900_RPD_TCP]
|
||||
platform = espressif32
|
||||
board = dfrobot_firebeetle2_esp32e
|
||||
extends = common_env_options
|
||||
build_flags = -D USE_MODBUS_IP
|
||||
build_src_filter = -<*> +<EPMS/ATS/ATS_Eaton_ATC900_RPD_TCP>
|
||||
|
||||
[env:ATS_Woodward_DTSC200A_TCP]
|
||||
platform = espressif32
|
||||
board = dfrobot_firebeetle2_esp32e
|
||||
extends = common_env_options
|
||||
build_flags = -D USE_MODBUS_IP
|
||||
build_src_filter = -<*> +<EPMS/ATS/ATS_Woodward_DTSC200A_TCP>
|
||||
@@ -78,14 +78,18 @@ State<ModbusIP>* RunningState<ModbusIP>::update(Equipment<ModbusIP>* equipment)
|
||||
return new StandbyState<ModbusIP>();
|
||||
}
|
||||
|
||||
float load = getPointValue(equipment, "ATS_Load");
|
||||
load = load/100;
|
||||
Strategy_Behavior* svs_Amps_A = getStrategy("Amps A");
|
||||
Strategy_Behavior* svs_Amps_B = getStrategy("Amps B");
|
||||
Strategy_Behavior* svs_Amps_C = getStrategy("Amps C");
|
||||
static_cast<SingleValueStrategy*>(svs_Amps_A)->setSetpoint(load*7500);
|
||||
static_cast<SingleValueStrategy*>(svs_Amps_B)->setSetpoint(load*7500);
|
||||
static_cast<SingleValueStrategy*>(svs_Amps_C)->setSetpoint(load*7500);
|
||||
int I_load = getPointValue(equipment, "ATS_Load");
|
||||
int I_rating = getPointValue(equipment, "ATS_Rating");
|
||||
float load = static_cast<float>(I_load);
|
||||
float rating = static_cast<float>(I_rating);
|
||||
float real_load = rating * (load/100.0f);
|
||||
Strategy_Behavior* ampsA_svs = getStrategy("S2 Amps A");
|
||||
Strategy_Behavior* ampsB_svs = getStrategy("S2 Amps B");
|
||||
Strategy_Behavior* ampsC_svs = getStrategy("S2 Amps C");
|
||||
|
||||
static_cast<SingleValueStrategy*>(ampsA_svs)->setSetpoint(real_load);
|
||||
static_cast<SingleValueStrategy*>(ampsB_svs)->setSetpoint(real_load);
|
||||
static_cast<SingleValueStrategy*>(ampsC_svs)->setSetpoint(real_load);
|
||||
|
||||
// Apply any strategies defined for the standby state
|
||||
_applyStrategies(equipment);
|
||||
@@ -73,14 +73,18 @@ State<ModbusIP>* StandbyState<ModbusIP>::update(Equipment<ModbusIP>* equipment)
|
||||
return new RunningState<ModbusIP>();
|
||||
}
|
||||
|
||||
float load = getPointValue(equipment, "ATS_Load");
|
||||
load = load/100;
|
||||
Strategy_Behavior* svs_Amps_A = getStrategy("Amps A");
|
||||
Strategy_Behavior* svs_Amps_B = getStrategy("Amps B");
|
||||
Strategy_Behavior* svs_Amps_C = getStrategy("Amps C");
|
||||
static_cast<SingleValueStrategy*>(svs_Amps_A)->setSetpoint(load*7500);
|
||||
static_cast<SingleValueStrategy*>(svs_Amps_B)->setSetpoint(load*7500);
|
||||
static_cast<SingleValueStrategy*>(svs_Amps_C)->setSetpoint(load*7500);
|
||||
int I_load = getPointValue(equipment, "ATS_Load");
|
||||
int I_rating = getPointValue(equipment, "ATS_Rating");
|
||||
float load = static_cast<float>(I_load);
|
||||
float rating = static_cast<float>(I_rating);
|
||||
float real_load = rating * (load/100.0f);
|
||||
Strategy_Behavior* ampsA_svs = getStrategy("S1 Amps A");
|
||||
Strategy_Behavior* ampsB_svs = getStrategy("S1 Amps B");
|
||||
Strategy_Behavior* ampsC_svs = getStrategy("S1 Amps C");
|
||||
|
||||
static_cast<SingleValueStrategy*>(ampsA_svs)->setSetpoint(real_load);
|
||||
static_cast<SingleValueStrategy*>(ampsB_svs)->setSetpoint(real_load);
|
||||
static_cast<SingleValueStrategy*>(ampsC_svs)->setSetpoint(real_load);
|
||||
// Apply any strategies defined for the standby state
|
||||
_applyStrategies(equipment);
|
||||
return nullptr;
|
||||
@@ -38,6 +38,17 @@
|
||||
*/
|
||||
template<>
|
||||
RunningState<ModbusIP>::RunningState() {
|
||||
|
||||
addStrategy("S2 Volts AB", new SingleValueStrategy(480.0F, 2.0f, 1000));
|
||||
addStrategy("S2 Volts BC", new SingleValueStrategy(480.0F, 2.0f, 1000));
|
||||
addStrategy("S2 Volts CA", new SingleValueStrategy(480.0F, 2.0f, 1000));
|
||||
|
||||
addStrategy("PF", new SingleValueStrategy(90.0f, 2.0f, 1000));
|
||||
|
||||
addStrategy("S2 Amps A", new SingleValueStrategy(1.0f, 5.0f, 1000));
|
||||
addStrategy("S2 Amps B", new SingleValueStrategy(1.0f, 5.0f, 1000));
|
||||
addStrategy("S2 Amps C", new SingleValueStrategy(1.0f, 5.0f, 1000));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,6 +68,39 @@ template<>
|
||||
State<ModbusIP>* RunningState<ModbusIP>::update(Equipment<ModbusIP>* equipment) {
|
||||
// STATE control, add conditions if change to a different state is needed
|
||||
Serial.println("Running update function");
|
||||
float State_Ctrl = getPointValue(equipment, "ATS_Source");
|
||||
if (State_Ctrl == 1){
|
||||
return new StandbyState<ModbusIP>();
|
||||
}
|
||||
float volts_AB = getPointValue(equipment, "S2 Volts AB");
|
||||
float volts_BC = getPointValue(equipment, "S2 Volts BC");
|
||||
float volts_AC = getPointValue(equipment, "S2 Volts CA");
|
||||
|
||||
setPointValue(equipment, "S2 Volts AN", volts_AB/1.732);
|
||||
setPointValue(equipment, "S2 Volts BN", volts_BC/1.732);
|
||||
setPointValue(equipment, "S2 Volts CN", volts_AC/1.732);
|
||||
|
||||
int I_load = getPointValue(equipment, "ATS_Load");
|
||||
int I_rating = getPointValue(equipment, "ATS_Rating");
|
||||
float load = static_cast<float>(I_load);
|
||||
float rating = static_cast<float>(I_rating);
|
||||
float real_load = rating * (load/100.0f);
|
||||
Strategy_Behavior* ampsA_svs = getStrategy("S2 Amps A");
|
||||
Strategy_Behavior* ampsB_svs = getStrategy("S2 Amps B");
|
||||
Strategy_Behavior* ampsC_svs = getStrategy("S2 Amps C");
|
||||
|
||||
static_cast<SingleValueStrategy*>(ampsA_svs)->setSetpoint(real_load);
|
||||
static_cast<SingleValueStrategy*>(ampsB_svs)->setSetpoint(real_load);
|
||||
static_cast<SingleValueStrategy*>(ampsC_svs)->setSetpoint(real_load);
|
||||
|
||||
float pf = getPointValue(equipment, "PF");
|
||||
|
||||
|
||||
float kw = (1.732f * ((volts_AB + volts_BC + volts_AC)/3.0f) * real_load * pf)/1000;
|
||||
float kva = (1.732f * ((volts_AB + volts_BC + volts_AC)/3.0f) * real_load)/1000;
|
||||
|
||||
setPointValue(equipment, "S2 kW", kw);
|
||||
setPointValue(equipment, "S2 kVA", kva);
|
||||
|
||||
// Apply any strategies defined for the standby state
|
||||
_applyStrategies(equipment);
|
||||
@@ -73,7 +117,18 @@ void RunningState<ModbusIP>::enterState(Equipment<ModbusIP>* 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
|
||||
setPointValue(equipment, "Source Active", 32);
|
||||
setPointValue(equipment, "Source Preferred", 512);
|
||||
|
||||
setPointValue(equipment, "S1 Volts AB", 0.0f);
|
||||
setPointValue(equipment, "S1 Volts BC", 0.0f);
|
||||
setPointValue(equipment, "S1 Volts CA", 0.0f);
|
||||
setPointValue(equipment, "S1 Volts AN", 0.0f);
|
||||
setPointValue(equipment, "S1 Volts BN", 0.0f);
|
||||
setPointValue(equipment, "S1 Volts CN", 0.0f);
|
||||
setPointValue(equipment, "S1 Amps A", 0.0f);
|
||||
setPointValue(equipment, "S1 Amps B", 0.0f);
|
||||
setPointValue(equipment, "S1 Amps C", 0.0f);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,8 +38,15 @@
|
||||
template<>
|
||||
StandbyState<ModbusIP>::StandbyState() {
|
||||
// You can add initialization code here if needed
|
||||
|
||||
addStrategy("S1 Volts AB", new SingleValueStrategy(480.0F, 2.0f, 1000));
|
||||
addStrategy("S1 Volts BC", new SingleValueStrategy(480.0F, 2.0f, 1000));
|
||||
addStrategy("S1 Volts CA", new SingleValueStrategy(480.0F, 2.0f, 1000));
|
||||
|
||||
addStrategy("PF", new SingleValueStrategy(90.0f, 2.0f, 1000));
|
||||
|
||||
addStrategy("S1 Amps A", new SingleValueStrategy(1.0f, 5.0f, 1000));
|
||||
addStrategy("S1 Amps B", new SingleValueStrategy(1.0f, 5.0f, 1000));
|
||||
addStrategy("S1 Amps C", new SingleValueStrategy(1.0f, 5.0f, 1000));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,9 +62,39 @@ StandbyState<ModbusIP>::StandbyState() {
|
||||
template<>
|
||||
State<ModbusIP>* StandbyState<ModbusIP>::update(Equipment<ModbusIP>* 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
|
||||
float State_Ctrl = getPointValue(equipment, "ATS_Source");
|
||||
if (State_Ctrl == 2){
|
||||
return new RunningState<ModbusIP>();
|
||||
}
|
||||
float volts_AB = getPointValue(equipment, "S1 Volts AB");
|
||||
float volts_BC = getPointValue(equipment, "S1 Volts BC");
|
||||
float volts_AC = getPointValue(equipment, "S1 Volts CA");
|
||||
|
||||
setPointValue(equipment, "S1 Volts AN", volts_AB/1.732);
|
||||
setPointValue(equipment, "S1 Volts BN", volts_BC/1.732);
|
||||
setPointValue(equipment, "S1 Volts CN", volts_AC/1.732);
|
||||
|
||||
int I_load = getPointValue(equipment, "ATS_Load");
|
||||
int I_rating = getPointValue(equipment, "ATS_Rating");
|
||||
float load = static_cast<float>(I_load);
|
||||
float rating = static_cast<float>(I_rating);
|
||||
float real_load = rating * (load/100.0f);
|
||||
Strategy_Behavior* ampsA_svs = getStrategy("S1 Amps A");
|
||||
Strategy_Behavior* ampsB_svs = getStrategy("S1 Amps B");
|
||||
Strategy_Behavior* ampsC_svs = getStrategy("S1 Amps C");
|
||||
|
||||
static_cast<SingleValueStrategy*>(ampsA_svs)->setSetpoint(real_load);
|
||||
static_cast<SingleValueStrategy*>(ampsB_svs)->setSetpoint(real_load);
|
||||
static_cast<SingleValueStrategy*>(ampsC_svs)->setSetpoint(real_load);
|
||||
|
||||
float pf = getPointValue(equipment, "PF");
|
||||
|
||||
|
||||
float kw = (1.732f * ((volts_AB + volts_BC + volts_AC)/3.0f) * real_load * pf)/1000;
|
||||
float kva = (1.732f * ((volts_AB + volts_BC + volts_AC)/3.0f) * real_load)/1000;
|
||||
|
||||
setPointValue(equipment, "S1 kW", kw);
|
||||
setPointValue(equipment, "S1 kVA", kva);
|
||||
_applyStrategies(equipment);
|
||||
return nullptr;
|
||||
}
|
||||
@@ -72,8 +109,20 @@ template<>
|
||||
void StandbyState<ModbusIP>::enterState(Equipment<ModbusIP>* equipment) {
|
||||
// Logic to run when the equipment enters this state
|
||||
Serial.println("Enter Standby State...");
|
||||
}
|
||||
setPointValue(equipment, "Source Active", 64);
|
||||
setPointValue(equipment, "Source Preferred", 1024);
|
||||
|
||||
setPointValue(equipment, "S2 Volts AB", 0.0f);
|
||||
setPointValue(equipment, "S2 Volts BC", 0.0f);
|
||||
setPointValue(equipment, "S2 Volts CA", 0.0f);
|
||||
setPointValue(equipment, "S2 Volts AN", 0.0f);
|
||||
setPointValue(equipment, "S2 Volts BN", 0.0f);
|
||||
setPointValue(equipment, "S2 Volts CN", 0.0f);
|
||||
setPointValue(equipment, "S2 Amps A", 0.0f);
|
||||
setPointValue(equipment, "S2 Amps B", 0.0f);
|
||||
setPointValue(equipment, "S2 Amps C", 0.0f);
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief Logic to execute once when exiting the standby state.
|
||||
* @param equipment Pointer to the Equipment instance.
|
||||
@@ -21,10 +21,10 @@
|
||||
* @{
|
||||
*/
|
||||
#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. */
|
||||
const char *ssid = "QTS_CDR_Arduino"; /**< @brief The SSID of the WiFi network. */
|
||||
const char *password = "123abc456"; /**< @brief The password for the WiFi network. */
|
||||
IPAddress local_IP(172, 17, 33, 241); /**< @brief The static IP address for the device. */
|
||||
IPAddress gateway(172, 17, 33, 1); /**< @brief The gateway IP address. */
|
||||
IPAddress subnet(255, 255, 255, 0); /**< @brief The subnet mask. */
|
||||
|
||||
ModbusIP mb;
|
||||
@@ -60,36 +60,35 @@
|
||||
*/
|
||||
modbusMap mb_map[] =
|
||||
{
|
||||
{HR, 15, 0, "State Control"}, //Internal to control from Modscan
|
||||
{HR, 16, 0, "Fault Code"}, //Internal Fault code from Modscan
|
||||
{HR, 50016, 0, "Alarm Word 1 Status Bits"},
|
||||
{HR, 50025, 0, "Alarm Word 2 Status Bits"},
|
||||
{HR, 50028, 0, "ATS Status Bits"},
|
||||
{HR, 50010, 0, "Power Factor"},
|
||||
{HR, 50083, 0, "Source Active Bits"},
|
||||
{HR_LONG, 50092, 0, "Source 1 Current Phase A"},
|
||||
{HR_LONG, 50095, 0, "Source 1 Current Phase B"},
|
||||
{HR_LONG, 50098, 0, "Source 1 Current Phase C"},
|
||||
{HR, 50094, 0, "Source 1 Real Power"},
|
||||
{HR_LONG, 50101, 0, "Source 1 MWh"},
|
||||
{HR, 50079, 0, "Source Preference Bits"},
|
||||
{HR_LONG, 50020, 0, "Source 1 Volts A-B"},
|
||||
{HR_LONG, 50023, 0, "Source 1 Volts A-N"},
|
||||
{HR_LONG, 50026, 0, "Source 1 Volts B-C"},
|
||||
{HR_LONG, 50029, 0, "Source 1 Volts B-N"},
|
||||
{HR_LONG, 50032, 0, "Source 1 Volts C-A"},
|
||||
{HR_LONG, 50035, 0, "Source 1 Volts C-N"},
|
||||
{HR_LONG, 50038, 0, "Source 2 Current Phase A"},
|
||||
{HR_LONG, 50041, 0, "Source 2 Current Phase B"},
|
||||
{HR_LONG, 50044, 0, "Source 2 Current Phase C"},
|
||||
{HR_LONG, 50061, 0, "Source 2 Real Power"},
|
||||
{HR_LONG, 50065, 0, "Source 2 MWh"},
|
||||
{HR_LONG, 50002, 0, "Source 2 Volts A-B"},
|
||||
{HR_LONG, 50005, 0, "Source 2 Volts A-N"},
|
||||
{HR_LONG, 50008, 0, "Source 2 Volts B-C"},
|
||||
{HR_LONG, 50011, 0, "Source 2 Volts B-N"},
|
||||
{HR_LONG, 50014, 0, "Source 2 Volts C-A"},
|
||||
{HR_LONG, 50017, 0, "Source 2 Volts C-N"},
|
||||
{HR, 9, 0, "ATS_Source"}, //Internal to control from Modscan
|
||||
{HR, 10, 0, "ATS_Load"},
|
||||
{HR, 11, 0, "ATS_Rating"}, //Internal Fault code from Modscan
|
||||
|
||||
{HR, 50009, 0, "PF"},
|
||||
{HR_LONG, 50001, 0, "S2 Volts AB"},
|
||||
{HR_LONG, 50004, 0, "S2 Volts AN"},
|
||||
{HR_LONG, 50007, 0, "S2 Volts BC"},
|
||||
{HR_LONG, 50010, 0, "S2 Volts BN"},
|
||||
{HR_LONG, 50013, 0, "S2 Volts CA"},
|
||||
{HR_LONG, 50016, 0, "S2 Volts CN"},
|
||||
{HR_LONG, 50019, 0, "S1 Volts AB"},
|
||||
{HR_LONG, 50022, 0, "S1 Volts AN"},
|
||||
{HR_LONG, 50025, 0, "S1 Volts BC"},
|
||||
{HR_LONG, 50028, 0, "S1 Volts BN"},
|
||||
{HR_LONG, 50031, 0, "S1 Volts CA"},
|
||||
{HR_LONG, 50034, 0, "S1 Volts CN"},
|
||||
{HR_LONG, 50037, 0, "S2 Amps A"},
|
||||
{HR_LONG, 50040, 0, "S2 Amps B"},
|
||||
{HR_LONG, 50043, 0, "S2 Amps C"},
|
||||
{HR_LONG, 50060, 0, "S2 kW"},
|
||||
{HR_LONG, 50064, 0, "S2 MWh"},
|
||||
{HR, 50078, 0, "Source Preferred"}, // bit 8 and bit 9
|
||||
{HR, 50082, 0, "Source Active"}, //bit2 and bit 3
|
||||
{HR_LONG, 50091, 0, "S1 Amps A"},
|
||||
{HR, 50093, 0, "S1 kW"},
|
||||
{HR_LONG, 50094, 0, "S1 Amps B"},
|
||||
{HR_LONG, 50097, 0, "S1 Amps C"},
|
||||
{HR_LONG, 50100, 0, "S1 MWh"},
|
||||
|
||||
};
|
||||
//Size of modbus map used in FOR cycles, automatically calculated.
|
||||
Reference in New Issue
Block a user