(****** QuickLD compiler *******************************)
(****** Copyright Rockwell Automation Canada, Ltd ******)
(****** ST *********************************************)

(*************** Rung **********************************)
(*Example use of PID block PV is Plug-in 2 channel 0.  CV is Plug-in 3 channel 0. Both are wired together
Scale flow measurement*)
__STEPPRAGMA
0,1
__ENDSTEPPRAGMA
(*Label :*)(**)
__EDTB1 := TRUE ;
IF __EDTB1 THEN
TEMP := ANY_TO_REAL(_IO_X1_AI_00) ;
END_IF ;
__MO_ANY_TO_REAL_1 := __EDTB1 ;
__EDTB2 := __EDTB1 ;
IF __EDTB2 THEN
(* FB call: SCALER *)
SCALER_FT101(TEMP, 4000.0, 20000.0, 0.0, 2.0) ;
FT101_VAL := SCALER_FT101.Output ;
END_IF ;
__MO_SCALER_1 := __EDTB2 ;

(*************** Code for the end of Rung **************)
__GL __LG0001 ;


(*************** Rung **********************************)
(**)
__STEPPRAGMA
0,8
__ENDSTEPPRAGMA
(*Label :*)(**)
(* FB call: PID *)
FIC101(TRUE, FT101_VAL, FIC101_SP, FIC101_AUTO, FIC101_MANUALCV, 100.0, 0.0, FIC101_GAINS, FALSE, FALSE) ;
FY101_VAL := FIC101.CV ;

(*************** Code for the end of Rung **************)
__GL __LG0002 ;


(*************** Rung **********************************)
(*Unscale valve position*)
__STEPPRAGMA
0,19
__ENDSTEPPRAGMA
(*Label :*)(**)
__EDTB3 := TRUE ;
IF __EDTB3 THEN
(* FB call: SCALER *)
SCALER_FY101(FY101_VAL, 0.0, 100.0, 400.0, 20000.0) ;
TEMP := SCALER_FY101.Output ;
END_IF ;
__MO_SCALER_2 := __EDTB3 ;
__EDTB4 := __EDTB3 ;
IF __EDTB4 THEN
_IO_X2_AO_00 := ANY_TO_INT(TEMP) ;
END_IF ;
__MO_ANY_TO_INT_1 := __EDTB4 ;

(*************** Code for the end of Rung **************)
__GL __LG0003 ;


(*************** Rung **********************************)
(*Example use of IPIDCONTROLLER  block PV is Plug-in 2 channel 1.  CV is Plug-in 3 channel 1. Both are wired together
Scale flow measurement*)
__STEPPRAGMA
0,26
__ENDSTEPPRAGMA
(*Label :*)(**)
__EDTB5 := TRUE ;
IF __EDTB5 THEN
TEMP := ANY_TO_REAL(_IO_X1_AI_01) ;
END_IF ;
__MO_ANY_TO_REAL_2 := __EDTB5 ;
__EDTB6 := __EDTB5 ;
IF __EDTB6 THEN
(* FB call: SCALER *)
SCALER_FT102(TEMP, 400.0, 20000.0, 0.0, 2.0) ;
FT102_VAL := SCALER_FT102.Output ;
END_IF ;
__MO_SCALER_3 := __EDTB6 ;

(*************** Code for the end of Rung **************)
__GL __LG0004 ;


(*************** Rung **********************************)
(*If in auto mode, PID block feedback is the FY102 value. If in manual mode, PID block feedback is the Manual CV value.*)
__STEPPRAGMA
0,33
__ENDSTEPPRAGMA
(*Label :*)(**)
__EDTB7 := FIC102_AUTO ;
IF __EDTB7 THEN
FIC102_FEEDBK := (  FY102_VAL) ;
END_IF ;
__MO_1GAIN_1 := __EDTB7 ;

(*************** Code for the end of Rung **************)
__GL __LG0005 ;


(*************** Rung **********************************)
(**)
__STEPPRAGMA
0,36
__ENDSTEPPRAGMA
(*Label :*)(**)
__EDTB8 := NOT(FIC102_AUTO) ;
IF __EDTB8 THEN
FIC102_FEEDBK := (  FIC102_MANUALCV) ;
END_IF ;
__MO_1GAIN_2 := __EDTB8 ;

(*************** Code for the end of Rung **************)
__GL __LG0006 ;


(*************** Rung **********************************)
(**)
__STEPPRAGMA
0,39
__ENDSTEPPRAGMA
(*Label :*)(**)
__EDTB9 := TRUE ;
IF __EDTB9 THEN
(* FB call: IPIDCONTROLLER *)
FIC102(FT102_VAL, FIC102_SP, FIC102_FEEDBK, FIC102_AUTO, FIC102_INITIALIZE, FIC102_GAINS, FIC102_AUTOTUNE, FIC102_ATPARAMS, 0) ;
FIC102_OUT := FIC102.Output ;
FIC102_OUTGAINS := FIC102.OutGains ;
END_IF ;
__MO_IPIDCONTROLLER_1 := __EDTB9 ;

(*************** Code for the end of Rung **************)
__GL __LG0007 ;


(*************** Rung **********************************)
(*Unscale valve position*)
__STEPPRAGMA
0,50
__ENDSTEPPRAGMA
(*Label :*)(**)
__EDTB10 := TRUE ;
IF __EDTB10 THEN
FY102_VAL := MV_Limit(0.0, FIC102_OUT, 100.0) ;
END_IF ;
__MO_MV_LIMIT_1 := __EDTB10 ;
__EDTB11 := __EDTB10 ;
IF __EDTB11 THEN
(* FB call: SCALER *)
SCALER_FY102(FY102_VAL, 0.0, 100.0, 4000.0, 20000.0) ;
TEMP := SCALER_FY102.Output ;
END_IF ;
__MO_SCALER_4 := __EDTB11 ;
__EDTB12 := __EDTB11 ;
IF __EDTB12 THEN
_IO_X2_AO_01 := ANY_TO_INT(TEMP) ;
END_IF ;
__MO_ANY_TO_INT_2 := __EDTB12 ;

(*************** Code for the end of Rung **************)
__GL __LG0008 ;


(*************** Rung **********************************)
(*Transfer auto-tune results*)
__STEPPRAGMA
0,57
__ENDSTEPPRAGMA
(*Label :*)(**)
__EDTB13 := FIC102_AT_TRANSFERGAINS ;
IF __EDTB13 THEN
FIC102_GAINS.PROPORTIONALGAIN := (  FIC102_OUTGAINS.PROPORTIONALGAIN) ;
END_IF ;
__MO_1GAIN_3 := __EDTB13 ;
__EDTB14 := __EDTB13 ;
IF __EDTB14 THEN
FIC102_GAINS.TIMEINTEGRAL := (  FIC102_OUTGAINS.TIMEINTEGRAL) ;
END_IF ;
__MO_1GAIN_4 := __EDTB14 ;
__EDTB15 := __EDTB14 ;
IF __EDTB15 THEN
FIC102_GAINS.DERIVATIVEGAIN := (  FIC102_OUTGAINS.DERIVATIVEGAIN) ;
END_IF ;
__MO_1GAIN_5 := __EDTB15 ;
__EDTB16 := __EDTB15 ;
IF __EDTB16 THEN
FIC102_GAINS.TIMEDERIVATIVE := (  FIC102_OUTGAINS.TIMEDERIVATIVE) ;
END_IF ;
__MO_1GAIN_6 := __EDTB16 ;

(*************** Code for the end of Rung **************)
__GL __LG0009 ;


(*************** Code for the end of File **************)
__GL __LG0000 ;



(*************** Local Symbols table *******************)
(* __EDTB1 *)
(* __EDTB2 *)
(* __EDTB3 *)
(* __EDTB4 *)
(* __EDTB5 *)
(* __EDTB6 *)
(* __EDTB7 *)
(* __EDTB8 *)
(* __EDTB9 *)
(* __EDTB10 *)
(* __EDTB11 *)
(* __EDTB12 *)
(* __EDTB13 *)
(* __EDTB14 *)
(* __EDTB15 *)
(* __EDTB16 *)

