You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
2.8 KiB
XML
96 lines
2.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
|
|
<POU Name="fbMAU" Id="{fedc3f65-b02c-4a18-a977-8b815cdd9288}" SpecialFunc="None">
|
|
<Declaration><![CDATA[FUNCTION_BLOCK fbMAU
|
|
VAR_INPUT
|
|
PV : INT;
|
|
SP : INT;
|
|
Manual : BOOL; // Manual Mode Active
|
|
Man_Y : REAL; // Output value in Manual mode 0..100%
|
|
Reset : BOOL; // Reset Command
|
|
END_VAR
|
|
VAR_OUTPUT
|
|
PID_Y_Value : REAL;
|
|
PID_Y : INT; // 0..100%; 0..32767
|
|
END_VAR
|
|
VAR
|
|
PID_Par: PIDParam;
|
|
PID_CTRL: CTRL_PID;
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[//
|
|
|
|
// Run PID control to calculate Duty Cycle
|
|
//
|
|
// Settings
|
|
//
|
|
|
|
PID_Par.bManual := Manual;
|
|
PID_Par.fM_In := Man_Y;
|
|
PID_Par.bReset := Reset;
|
|
PID_Par.fSetpointValue := INT_TO_REAL(SP)/10; // setpoint value
|
|
PID_Par.fActualValue := INT_TO_REAL(PV)/10; // process/actual value
|
|
//GVL.arZoneData[iZoneNo].PID.bReset := FALSE; // TRUE at this input resets the internal state variables and the controller output.
|
|
PID_Par.fCtrlCycleTime := 6.0; // LREAL controller cycle time in seconds [s]
|
|
PID_Par.fKp := Set.MAU_fKp; // 15.0 LREAL proportional gain Kp (P)
|
|
PID_Par.fTn := Set.MAU_fTn; // 100.0 LREAL integral gain Tn (I) [s]
|
|
PID_Par.fTv := Set.MAU_fTv; // 200.0 LREAL derivative gain Tv (D-T1) [s]
|
|
PID_Par.fTd := Set.MAU_fTd; // 1200.0 LREAL derivative damping time Td (D-T1) [s]
|
|
|
|
// Set Output Low and High Limits
|
|
PID_Par.fLL := 0.0;
|
|
PID_Par.fLH := 100.0;
|
|
|
|
// PID Control
|
|
//
|
|
PID_CTRL(
|
|
ACT:= PID_Par.fActualValue,
|
|
SET:= PID_Par.fSetpointValue,
|
|
SUP:= Set.MAU_PID_Noise_SUP, // 0.2°C In PID controller, if ABS(SP-PV)<SUP then output value is 0
|
|
OFS:= PID_Par.fOfs,
|
|
M_I:= PID_Par.fM_In,
|
|
MAN:= PID_Par.bManual,
|
|
RST:= PID_Par.bReset,
|
|
KP:= PID_Par.fKp,
|
|
TN:= PID_Par.fTn,
|
|
TV:= PID_Par.fTv,
|
|
LL:= PID_Par.fLL,
|
|
LH:= PID_Par.fLH,
|
|
Y=> PID_Par.fCtrlOutput,
|
|
DIFF=> PID_Par.DIFF,
|
|
LIM=> );
|
|
|
|
PID_Y_Value := PID_Par.fCtrlOutput;
|
|
|
|
PID_Y := REAL_TO_INT(SCALE_R(
|
|
X:= PID_Par.fCtrlOutput,
|
|
I_LO:= 0.0,
|
|
I_HI:= 100.0,
|
|
O_LO:= 0,
|
|
O_HI:= 32767.0)) ;
|
|
]]></ST>
|
|
</Implementation>
|
|
<LineIds Name="fbMAU">
|
|
<LineId Id="13" Count="0" />
|
|
<LineId Id="34" Count="4" />
|
|
<LineId Id="66" Count="0" />
|
|
<LineId Id="65" Count="0" />
|
|
<LineId Id="70" Count="1" />
|
|
<LineId Id="39" Count="6" />
|
|
<LineId Id="33" Count="0" />
|
|
<LineId Id="58" Count="0" />
|
|
<LineId Id="60" Count="2" />
|
|
<LineId Id="14" Count="0" />
|
|
<LineId Id="9" Count="0" />
|
|
<LineId Id="15" Count="0" />
|
|
<LineId Id="18" Count="14" />
|
|
<LineId Id="16" Count="0" />
|
|
<LineId Id="68" Count="0" />
|
|
<LineId Id="79" Count="1" />
|
|
<LineId Id="73" Count="4" />
|
|
<LineId Id="69" Count="0" />
|
|
<LineId Id="72" Count="0" />
|
|
</LineIds>
|
|
</POU>
|
|
</TcPlcObject> |