Modular PID Control ? 2.

: 2009-03-23

: komatic

: ModPID



MODPID


1.ERR_MON .
2.OVERRIDE .
3.LIMALARM .
4.LIMITER .
5.SPLT_RAN .
6.NORM .
7.DEADBAND .

MODPID. . download , .


ERR_MON .

FUNCTION_BLOCK FB107
TITLE =" error_signal monitoring"
AUTHOR : AUT_1
FAMILY : MODCONT
NAME : ERR_MON
VERSION : " 1.0"
// reverse by komatic
(*
.
.
*)
VAR_INPUT
ER_LM : REAL := 1.000000e+001; //error variable limit
ER_LMTD : REAL := 1.000000e+002; //error-signal limit during time delay
SP : REAL ; //
PV : REAL ; //
SP_DIFF : REAL := 1.000000e+001; //setpoint differenz
TM_DELAY : TIME := T#1M; //delay time of the monitoring signal
TM_RAMP : TIME := T#1M; //time constant of ramp
COM_RST : BOOL ; //
CYCLE : TIME := T#1S; //
END_VAR
VAR_OUTPUT
QER_LM : BOOL ; //error-signal limit reached
QER_LMTD : BOOL ; //error-signal limit during time delay reached
ER : REAL ; //error signal
END_VAR
VAR
stTmDelay : TIME ;
srRampV : REAL ;
srSpOld : REAL ;
END_VAR
VAR_TEMP
drEr : REAL ; //Zwischenspeicher ER
drErBtrg : REAL ; //Betrag von ER
drSpDfBg : REAL ; //Betrag der Sollwertnderung
drDek : REAL ; //Dekrement der Rampe
drTF : REAL ; //Zeitfaktor
drCycle : REAL ; //Abtastzeit in real
drTmRamp : REAL ; //Rampenzeitkonstante in real
END_VAR
BEGIN
QER_LM:=0;
QER_LMTD:=0;
IF COM_RST
THEN
drEr:=0.0;
stTmDelay:=T#0MS;
srRampV:=0.0;
srSpOld:=0.0;
ELSE
drEr:=SP - PV;
drErBtrg:=ABS(drEr);
drSpDfBg:=SP - srSpOld;
drSpDfBg:=ABS(drSpDfBg);
srSpOld:=SP;
IF drSpDfBg > SP_DIFF
THEN
stTmDelay:=TM_DELAY;
drCycle:=DINT_TO_REAL(TIME_TO_DINT(CYCLE));
drTmRamp:=DINT_TO_REAL(TIME_TO_DINT(TM_RAMP));
drTF:=drTmRamp / drCycle;
drDek:=(ER_LMTD - ER_LM) / drTF;
srRampV:=ER_LMTD;
IF drErBtrg >= srRampV THEN QER_LMTD:=1; END_IF;
ELSE
IF stTmDelay > CYCLE
THEN
stTmDelay:=stTmDelay - CYCLE;
IF drErBtrg >= ER_LMTD THEN QER_LMTD:=1; END_IF;
ELSE
IF srRampV > ER_LM
THEN
srRampV:=srRampV - drDek;
IF drErBtrg >= srRampV THEN QER_LMTD:=1; END_IF;
ELSE
IF drErBtrg>=ER_LM THEN QER_LM:=1; END_IF;
END_IF;
END_IF;
END_IF;
END_IF;
ER:=drEr;
END_FUNCTION_BLOCK

OVERRIDE .

FUNCTION_BLOCK FB117
TITLE =" override controlling"
AUTHOR : AUT_1
FAMILY : MODCONT
NAME : OVERRIDE
VERSION : " 1.0"
// reverse by komatic
(*
.
.
*)
VAR_INPUT
PID1_ON : BOOL ; // 1
PID2_ON : BOOL ; // 2
OVR_MODE : BOOL ; // FALSE/TRUE=MAX/MIN
PID1_OVR : STRUCT
PID_OUTV : REAL ; //PID
PID_SCTR : REAL ; //PID
END_STRUCT ;
PID2_OVR : STRUCT
PID_OUTV : REAL ; //PID
PID_SCTR : REAL ; //PID
END_STRUCT ;
END_VAR
VAR_OUTPUT
QPID1 : BOOL ; // 1
QPID2 : BOOL ; // 1
OVR_LMNG : STRUCT
PID_OUTV : REAL ; //PID
PID_SCTR : REAL ; //PID
END_STRUCT ;
END_VAR
VAR_TEMP
drOutv : REAL ; //Zwischenspeicher fr PID output variable
END_VAR
BEGIN
IF PID1_ON XOR PID2_ON
THEN //
IF PID1_ON
THEN
QPID1:=1;
QPID2:=0;
ELSE
QPID1:=0;
QPID2:=1;
END_IF;
ELSE //
IF OVR_MODE
THEN //
IF PID1_OVR.PID_OUTV <= PID2_OVR.PID_OUTV
THEN
QPID1:=1;
QPID2:=0;
ELSE
QPID1:=0;
QPID2:=1;
END_IF;
ELSE //
IF PID1_OVR.PID_OUTV >= PID2_OVR.PID_OUTV
THEN
QPID1:=1;
QPID2:=0;
ELSE
QPID1:=0;
QPID2:=1;
END_IF;
END_IF;
END_IF;
IF QPID1 //
THEN
OVR_LMNG.PID_OUTV:=PID1_OVR.PID_OUTV;
OVR_LMNG.PID_SCTR:=PID1_OVR.PID_SCTR;
ELSE
OVR_LMNG.PID_OUTV:=PID2_OVR.PID_OUTV;
OVR_LMNG.PID_SCTR:=PID2_OVR.PID_SCTR;
END_IF;
END_FUNCTION_BLOCK

LIMALARM .

FUNCTION_BLOCK FB111
TITLE =" limit alarm"
AUTHOR : AUT_1
FAMILY : MODCONT
NAME : LIMALARM
VERSION : " 1.0"
// reverse by komatic
(*
.
.
*)
VAR_INPUT
H_LM_ALM : REAL := 1.000000e+002; //
H_LM_WRN : REAL := 9.000000e+001; //
L_LM_WRN : REAL := 1.000000e+001; //
L_LM_ALM : REAL ; //
INV : REAL ; //
HYS : REAL := 1.000000e+000; //
COM_RST : BOOL ; //
END_VAR
VAR_OUTPUT
QH_LMALM : BOOL ; //
QH_LMWRN : BOOL ; //
QL_LMWRN : BOOL ; //
QL_LMALM : BOOL ; //
END_VAR
BEGIN
IF COM_RST
THEN
QH_LMALM:=0;
QH_LMWRN:=0;
QL_LMWRN:=0;
QL_LMALM:=0;
ELSE
IF INV >= H_LM_ALM THEN QH_LMALM:=1; END_IF;
IF INV < (H_LM_ALM - HYS) THEN QH_LMALM:=0; END_IF;
IF INV >= H_LM_WRN THEN QH_LMWRN:=1; END_IF;
IF INV < (H_LM_WRN - HYS) THEN QH_LMWRN:=0; END_IF;
IF INV <= L_LM_ALM THEN QL_LMALM:=1; END_IF;
IF INV > (L_LM_ALM + HYS) THEN QL_LMALM:=0; END_IF;
IF INV <= L_LM_WRN THEN QL_LMWRN:=1; END_IF;
IF INV > (L_LM_WRN + HYS) THEN QL_LMWRN:=0; END_IF;
END_IF;
END_FUNCTION_BLOCK

LIMITER .

FUNCTION_BLOCK FB112
TITLE =" limiter"
AUTHOR : AUT_1
FAMILY : MODCONT
NAME : LIMITER
VERSION : " 1.0"
// reversed by komatic
(*
. .
*)
VAR_INPUT
INV : REAL ; //
H_LM : REAL := 1.000000e+002; //
L_LM : REAL ; //
COM_RST : BOOL ; //
END_VAR
VAR_OUTPUT
OUTV : REAL ; //output variable
QH_LM : BOOL ; //high limit reached
QL_LM : BOOL ; //low limit reached
END_VAR
BEGIN
IF COM_RST //
THEN
QH_LM:=0; //
QL_LM:=0;
OUTV:=0.0;
ELSE
IF INV >= H_LM //
THEN
QL_LM:=0;
QH_LM:=1; //
OUTV:=H_LM; //
ELSE
QH_LM:=0;
IF INV <= L_LM //
THEN
QL_LM:=1; //
OUTV:=L_LM; //
ELSE
QL_LM:=0;
OUTV:=INV; //
END_IF;
END_IF;
END_IF;
END_FUNCTION_BLOCK

SPLT_RAN .

FUNCTION_BLOCK FB124
TITLE =" split ranging"
AUTHOR : AUT_1
FAMILY : MODCONT
NAME : SPLT_RAN
VERSION : " 1.0"
// reversed by komatic
(*
.
.
*)
VAR_INPUT
INV : REAL ; //
STR_INV : REAL ; // INV
EDR_INV : REAL := 5.000000e+001; // INV
STR_OUTV : REAL ; // OUTV
EDR_OUTV : REAL := 1.000000e+002; // OUTV
END_VAR
VAR_OUTPUT
SPL_LMNG : STRUCT
PID_OUTV : REAL ; //PID
PID_SCTR : REAL ; //PID
END_STRUCT ;
END_VAR
BEGIN
IF INV <= STR_INV
THEN
SPL_LMNG.PID_OUTV:=STR_OUTV;
ELSIF INV >= EDR_INV
THEN
SPL_LMNG.PID_OUTV:=EDR_OUTV;
ELSE
SPL_LMNG.PID_OUTV:=(((EDR_OUTV - STR_OUTV) * INV) / (EDR_INV - STR_INV) + STR_OUTV) -
((EDR_OUTV - STR_OUTV) * STR_INV) / (EDR_INV - STR_INV);
END_IF;
END_FUNCTION_BLOCK

NORM .

FUNCTION_BLOCK FB116
TITLE =" physical norm"
AUTHOR : AUT_1
FAMILY : MODCONT
NAME : NORM
VERSION : " 1.0"
// reverse by komatic
(*
. . .
*)
VAR_INPUT
INV : REAL ; //
IN_HVAL : REAL := 1.000000e+002; //
OUT_HVAL : REAL := 1.000000e+002; //
IN_LVAL : REAL ; //
OUT_LVAL : REAL ; //
END_VAR
VAR_OUTPUT
OUTV : REAL ; //
END_VAR
BEGIN
OUTV:=(((OUT_HVAL - OUT_LVAL) * INV / (IN_HVAL - IN_LVAL)) + OUT_LVAL) -
(OUT_HVAL - OUT_LVAL) * IN_LVAL / (IN_HVAL - IN_LVAL);
END_FUNCTION_BLOCK

DEADBAND .

FUNCTION_BLOCK FB105
TITLE =" dead band"
AUTHOR : AUT_1
FAMILY : MODCONT
NAME : DEADBAND
VERSION : " 1.0"
// reverse by komatic
(*
.
*)
VAR_INPUT
INV : REAL ; //
DEADB_W : REAL := 1.000000e+000; //dead band width
DEADB_O : REAL ; //dead band offset
END_VAR
VAR_OUTPUT
OUTV : REAL ; //
END_VAR
BEGIN
IF INV < (DEADB_O - DEADB_W)
THEN
OUTV:=INV + DEADB_W - DEADB_O;
ELSIF INV > (DEADB_O + DEADB_W)
THEN
OUTV:=INV - DEADB_W - DEADB_O;
ELSE
OUTV:=0.0;
END_IF;
END_FUNCTION_BLOCK

, .





: 5035

: microteam    : 2013-05-31

, . FB116 NORM, , : OUTV:=((INV - IN_LVAL) / (IN_HVAL - IN_LVAL)) * (OUT_HVAL - OUT_LVAL) + OUT_LVAL;

: microteam    : 2013-05-31

, ( ).

: microteam    : 2013-06-01

FB116 , .

:

(4000 max):

: