Added ac phase currents to inverter data and copy it to modbus interface
This commit is contained in:
444
PLC/PLC.tmc
444
PLC/PLC.tmc
File diff suppressed because one or more lines are too long
@@ -307,6 +307,10 @@ _fbModbusRead(
|
|||||||
// Modbus current inverter values
|
// Modbus current inverter values
|
||||||
GVL_MODBUS.stModbusEMSComm.stModbusReg11.diCurrentActivePower := REAL_TO_DINT(_afbStrings[_uiDebugCurrentString].stInverterData.rActACPower);
|
GVL_MODBUS.stModbusEMSComm.stModbusReg11.diCurrentActivePower := REAL_TO_DINT(_afbStrings[_uiDebugCurrentString].stInverterData.rActACPower);
|
||||||
GVL_MODBUS.stModbusEMSComm.stModbusReg11.diCurrentReactivePower := REAL_TO_DINT(_afbStrings[_uiDebugCurrentString].stInverterData.rActReactivePower);
|
GVL_MODBUS.stModbusEMSComm.stModbusReg11.diCurrentReactivePower := REAL_TO_DINT(_afbStrings[_uiDebugCurrentString].stInverterData.rActReactivePower);
|
||||||
|
GVL_MODBUS.stModbusEMSComm.stModbusReg11.diTotalACCurrentPhase1 := REAL_TO_DINT(_afbStrings[_uiDebugCurrentString].stInverterData.rActtACPhaseACurrent);
|
||||||
|
GVL_MODBUS.stModbusEMSComm.stModbusReg11.diTotalACCurrentPhase2 := REAL_TO_DINT(_afbStrings[_uiDebugCurrentString].stInverterData.rActtACPhaseBCurrent);
|
||||||
|
GVL_MODBUS.stModbusEMSComm.stModbusReg11.diTotalACCurrentPhase3 := REAL_TO_DINT(_afbStrings[_uiDebugCurrentString].stInverterData.rActtACPhaseCCurrent);
|
||||||
|
|
||||||
|
|
||||||
// Set Modbus mirror values
|
// Set Modbus mirror values
|
||||||
GVL_MODBUS.stModbusEMSComm.stModbusReg11.diSetpointActivePowerMirror := GVL_MODBUS.stModbusEMSComm.stModbusReg12.diSetpointActivePower;
|
GVL_MODBUS.stModbusEMSComm.stModbusReg11.diSetpointActivePowerMirror := GVL_MODBUS.stModbusEMSComm.stModbusReg12.diSetpointActivePower;
|
||||||
@@ -796,6 +800,7 @@ END_CASE]]></ST>
|
|||||||
<LineId Id="3125" Count="2" />
|
<LineId Id="3125" Count="2" />
|
||||||
<LineId Id="2160" Count="0" />
|
<LineId Id="2160" Count="0" />
|
||||||
<LineId Id="3081" Count="1" />
|
<LineId Id="3081" Count="1" />
|
||||||
|
<LineId Id="3128" Count="3" />
|
||||||
<LineId Id="3085" Count="0" />
|
<LineId Id="3085" Count="0" />
|
||||||
<LineId Id="3084" Count="0" />
|
<LineId Id="3084" Count="0" />
|
||||||
<LineId Id="3083" Count="0" />
|
<LineId Id="3083" Count="0" />
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ VAR
|
|||||||
_awCurrentDCValues : ARRAY[0..5] OF WORD;
|
_awCurrentDCValues : ARRAY[0..5] OF WORD;
|
||||||
|
|
||||||
// Current AC values (W, W_SF, Hz, Hz_SF, VA, VA_SF, VAr, VAr_SF, PF, PF_SF) in word array for efficient modbus reading
|
// Current AC values (W, W_SF, Hz, Hz_SF, VA, VA_SF, VAr, VAr_SF, PF, PF_SF) in word array for efficient modbus reading
|
||||||
_awCurrentACValues : ARRAY[0..9] OF WORD;
|
_awCurrentACValues : ARRAY[0..21] OF WORD;
|
||||||
|
|
||||||
// Inverter error bits
|
// Inverter error bits
|
||||||
_dwErrorBits : DWORD;
|
_dwErrorBits : DWORD;
|
||||||
@@ -169,7 +169,7 @@ VAR CONSTANT
|
|||||||
|
|
||||||
// Start of register with the current ac values
|
// Start of register with the current ac values
|
||||||
// SIZE 10
|
// SIZE 10
|
||||||
AC_VALUES_START_REGISTER : WORD := 40084;
|
AC_VALUES_START_REGISTER : WORD := 40072;
|
||||||
|
|
||||||
// Power factor register in cosine of angle
|
// Power factor register in cosine of angle
|
||||||
// Size 1, int16 (Range = -32767 .. 32767, Not implemented 0x8000)
|
// Size 1, int16 (Range = -32767 .. 32767, Not implemented 0x8000)
|
||||||
@@ -258,7 +258,7 @@ CASE _iState OF
|
|||||||
|
|
||||||
|
|
||||||
2: // IF inverter is not in STANDYB(8) STATE, send command to shutdown inverter
|
2: // IF inverter is not in STANDYB(8) STATE, send command to shutdown inverter
|
||||||
IF (_uiInverterState = 8) OR (_uiInverterState = 1) THEN
|
IF (_uiInverterState = 8) OR (_uiInverterState = 1) OR (_uiInverterState = 7) THEN
|
||||||
_iState := 3;
|
_iState := 3;
|
||||||
ELSE
|
ELSE
|
||||||
_uiPCSSetOperation := 3;
|
_uiPCSSetOperation := 3;
|
||||||
@@ -305,7 +305,7 @@ CASE _iState OF
|
|||||||
sIPAddr:= sInverterIPAddr,
|
sIPAddr:= sInverterIPAddr,
|
||||||
nTCPPort:= 502,
|
nTCPPort:= 502,
|
||||||
nUnitID:= 16#FF, // 16#FF for Modbus TCP
|
nUnitID:= 16#FF, // 16#FF for Modbus TCP
|
||||||
nQuantity:= 10,
|
nQuantity:= 22,
|
||||||
nMBAddr:= AC_VALUES_START_REGISTER,
|
nMBAddr:= AC_VALUES_START_REGISTER,
|
||||||
cbLength:= SIZEOF(_awCurrentACValues),
|
cbLength:= SIZEOF(_awCurrentACValues),
|
||||||
pDestAddr:= ADR(_awCurrentACValues),
|
pDestAddr:= ADR(_awCurrentACValues),
|
||||||
@@ -322,11 +322,15 @@ CASE _iState OF
|
|||||||
IF NOT _fbReadRegister.bError THEN
|
IF NOT _fbReadRegister.bError THEN
|
||||||
// Go back to polling state
|
// Go back to polling state
|
||||||
_iState := 5;
|
_iState := 5;
|
||||||
stCurrentValues.rActACPower := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[0]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[1])));
|
stCurrentValues.rActACCurrent := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[0]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[4])));
|
||||||
stCurrentValues.rActACFreq := LREAL_TO_REAL(WORD_TO_UINT(_awCurrentACValues[2]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[3])));
|
stCurrentValues.rActtACPhaseACurrent := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[1]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[4])));
|
||||||
stCurrentValues.rActApparentPower := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[4]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[5])));
|
stCurrentValues.rActtACPhaseBCurrent := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[2]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[4])));
|
||||||
stCurrentValues.rActReactivePower := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[6]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[7])));
|
stCurrentValues.rActtACPhaseCCurrent := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[3]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[4])));
|
||||||
stCurrentValues.rActPowerFactor := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[8]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[9])));
|
stCurrentValues.rActACPower := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[12]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[13])));
|
||||||
|
stCurrentValues.rActACFreq := LREAL_TO_REAL(WORD_TO_UINT(_awCurrentACValues[14]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[15])));
|
||||||
|
stCurrentValues.rActApparentPower := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[16]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[17])));
|
||||||
|
stCurrentValues.rActReactivePower := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[18]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[19])));
|
||||||
|
stCurrentValues.rActPowerFactor := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[20]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[21])));
|
||||||
ELSE
|
ELSE
|
||||||
// Read error register
|
// Read error register
|
||||||
_iState := 1000;
|
_iState := 1000;
|
||||||
@@ -1216,7 +1220,9 @@ _fbErrorInverterAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
|
|||||||
<LineId Id="3659" Count="0" />
|
<LineId Id="3659" Count="0" />
|
||||||
<LineId Id="2656" Count="31" />
|
<LineId Id="2656" Count="31" />
|
||||||
<LineId Id="3658" Count="0" />
|
<LineId Id="3658" Count="0" />
|
||||||
<LineId Id="2688" Count="32" />
|
<LineId Id="2688" Count="22" />
|
||||||
|
<LineId Id="3862" Count="3" />
|
||||||
|
<LineId Id="2711" Count="9" />
|
||||||
<LineId Id="2654" Count="0" />
|
<LineId Id="2654" Count="0" />
|
||||||
<LineId Id="3422" Count="2" />
|
<LineId Id="3422" Count="2" />
|
||||||
<LineId Id="3438" Count="0" />
|
<LineId Id="3438" Count="0" />
|
||||||
|
|||||||
@@ -18,6 +18,26 @@ STRUCT
|
|||||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||||
rActDCPower : REAL;
|
rActDCPower : REAL;
|
||||||
|
|
||||||
|
// Current AC current. Sum of active phases (A)
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||||
|
rActACCurrent : REAL;
|
||||||
|
|
||||||
|
// Current AC current. Phase A (A)
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||||
|
rActtACPhaseACurrent : REAL;
|
||||||
|
|
||||||
|
// Current AC current. Phase B (A)
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||||
|
rActtACPhaseBCurrent : REAL;
|
||||||
|
|
||||||
|
// Current AC current. Phase C (A)
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||||
|
rActtACPhaseCCurrent : REAL;
|
||||||
|
|
||||||
// Current AC power (W)
|
// Current AC power (W)
|
||||||
{attribute 'OPC.UA.DA' := '1'}
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||||
|
|||||||
@@ -439,7 +439,7 @@
|
|||||||
</System>
|
</System>
|
||||||
<Plc>
|
<Plc>
|
||||||
<Project GUID="{9AE64910-5EB2-4866-93FD-EFE059C38C36}" Name="PLC" PrjFilePath="PLC\PLC.plcproj" TmcFilePath="PLC\PLC.tmc" ReloadTmc="true" AmsPort="851" FileArchiveSettings="#x000e" CopyTmcToTarget="true" CopyTpyToTarget="false" SymbolicMapping="true">
|
<Project GUID="{9AE64910-5EB2-4866-93FD-EFE059C38C36}" Name="PLC" PrjFilePath="PLC\PLC.plcproj" TmcFilePath="PLC\PLC.tmc" ReloadTmc="true" AmsPort="851" FileArchiveSettings="#x000e" CopyTmcToTarget="true" CopyTpyToTarget="false" SymbolicMapping="true">
|
||||||
<Instance Id="#x08502000" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcPath="PLC\PLC.tmc" TmcHash="{3D6B0B97-5AAF-6D10-8B26-2A857823542B}">
|
<Instance Id="#x08502000" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcPath="PLC\PLC.tmc" TmcHash="{FF82F8C7-782A-594C-557E-BED8F96D6898}">
|
||||||
<Name>PLC Instance</Name>
|
<Name>PLC Instance</Name>
|
||||||
<CLSID ClassFactory="TcPlc30">{08500001-0000-0000-F000-000000000064}</CLSID>
|
<CLSID ClassFactory="TcPlc30">{08500001-0000-0000-F000-000000000064}</CLSID>
|
||||||
<Vars VarGrpType="1">
|
<Vars VarGrpType="1">
|
||||||
|
|||||||
Reference in New Issue
Block a user