IF (разные варианты)
#1
IF a=1 THEN
a:=2;
END_IF;
⇔
L #a;
L 1;
==I ;
JCN A7d0;
L 2;
T #a;
A7d0:
#2
IF a=1
THEN
a:=2;
ELSE
a:=3;
END_IF;
⇔
L #a;
L 1;
==I ;
JCN A7d1;
L 2;
T #a;
JU A7d2;
A7d1: L 3;
T #a;
A7d2:
#3
IF a=1
THEN
a:=2;
ELSIF a=1
THEN
a:=3;
END_IF;
⇔
L #a;
L 1;
==I ;
JCN A7d3;
L 2;
T #a;
JU A7d5;
A7d3: L #a;
L 1;
==I ;
JCN A7d5;
L 3;
T #a;
A7d5:
#4
IF a=1
THEN
a:=2;
ELSIF a=1
THEN
a:=3;
ELSE
a:=4;
END_IF;
⇔
L #a;
L 1;
==I ;
JCN A7d6;
L 2;
T #a;
JU A7d7;
A7d6: L #a;
L 1;
==I ;
JCN A7d8;
L 3;
T #a;
JU A7d7;
A7d8: L 4;
T #a;
A7d7:
#5
IF a=1
THEN
a:=2;
ELSIF a=1
THEN
a:=3;
ELSIF a=1
THEN
a:=4;
ELSE
a:=5;
END_IF;
⇔
L #a;
L 1;
==I ;
JCN A7d9;
L 2;
T #a;
JU A7da;
A7d9: L #a;
L 1;
==I ;
JCN A7db;
L 3;
T #a;
JU A7da;
A7db: L #a;
L 1;
==I ;
JCN A7dc;
L 4;
T #a;
JU A7da;
A7dc: L 5;
T #a;
A7da:
CASE
CASE a OF
1 :
a:=1;
2 :
a:=2;
3 :
a:=3;
ELSE:
a:=999;
END_CASE;
⇔
L #a;
L 1;
TAK ;
==I ;
T LW 4;
JC A7de;
JU A7df;
A7de: L 1;
T #a;
JU A7dd;
A7df: L 2;
L LW 4;
==I ;
JC A7e0;
JU A7e1;
A7e0: L 2;
T #a;
JU A7dd;
A7e1: L 3;
L LW 4;
==I ;
JC A7e2;
JU A7e3;
A7e2: L 3;
T #a;
JU A7dd;
A7e3: L 999;
T #a;
A7dd:
FOR
FOR a:= 1 TO 10
BY 1 DO
a:=777;
END_FOR;
⇔
L 1;
T #a;
A7e4: L #a;
L 10;
<=I ;
JCN A7e5;
L 777;
T #a;
L 1;
+I ;
T #a;
JU A7e4;
A7e5:
WHILE
WHILE a = 1 DO
a:=777;
END_WHILE;
⇔
A7e6: L #a;
L 1;
==I ;
JCN A7e7;
L 777;
T #a;
JU A7e6;
A7e7:
REPEAT
REPEAT
a:=777;
UNTIL a = 1
END_REPEAT;
⇔
A7e8: L 777;
T #a;
L #a;
L 1;
==I ;
JCN A7e8;
SCL_STL.pdf
Пример декомпиляции блока, созданного в SCL, затем загруженного в плк S7-300 из-под STEP7 и далее с удалением исходника (Source) из проекта - FB 40 [STL].txt -----> FB40 [SCL].txt
FB 40 [STL]
SET
SAVE
= L 24.1
L DB100.DBW 0
ITD
L L#224
*D
TAR2
+D
LAR1
L DID [AR1,P#20.0]
T #Line[0].MaxSpeed
TAK
T LD 30
TAK
L DID [AR1,P#24.0]
T #Line[0].ManSpeed
L DID [AR1,P#28.0]
T #Line[0].MinSpeed
L DID [AR1,P#32.0]
T #Line[0].Accuracy
L DID [AR1,P#36.0]
T #Line[0].Accelerate
L DID [AR1,P#40.0]
T #Line[0].SlowCurve
L DID [AR1,P#44.0]
T #Line[0].SlowLine
L DBW 0
L 2
==I
L DB20.DBW 10
L 1
= L 24.2
==I
A L 24.2
JCN A7d0
L DBD 52
T #Line[0].MaxSpeed
A7d0: L DB100.DBW 0
L 1
==I
JCN A7d1
L #Wheel
L #Pulses
/R
L #Encoder
DTR
*R
L 4.000000e+000
/R
T #ActValue
JU A7d2
A7d1: L #Wheel
L #Pulses
/R
L #Encoder
DTR
*R
L 4.000000e+003
/R
T #ActValue
A7d2: L #SetPoint
L #ActValue
-R
T #Difference
ABS
T #AbsValue
L #Line[0].Accuracy
L #AbsValue
>=R
JCN A7d3
SET
= #OnPos
JU A7d4
A7d3: CLR
= #OnPos
A7d4: L 2.764800e+001
L #Line[0].Accelerate
/R
L #Cycle
ITD
DTR
*R
T #Kiihdytys1
L 2.764800e+001
L #Line[1].Accelerate
/R
L #Cycle
ITD
DTR
*R
T #Kiihdytys2
CLR
A #JogFWD
NOT
A #Enable
= L 24.2
A #JogBWD
NOT
A L 24.2
JCN A7d5
L #Line[0].SlowCurve
SQRT
L 2.764800e+004
TAK
/R
T #Kerroin
L #AbsValue
L #Line[0].SlowLine
>R
JCN A7d6
L #AbsValue
SQRT
L #Kerroin
*R
T #Nopeus
JU A7d7
A7d6: L #Line[0].SlowLine
SQRT
L #Kerroin
*R
L #Line[0].SlowLine
/R
L #AbsValue
*R
T #Nopeus
A7d7: L #Difference
L 0.000000e+000
>R
JCN A7d8
L #Line[0].MaxSpeed
L 2.764800e+002
*R
T #Maksimi
JU A7d9
A7d8: L #Line[0].MinSpeed
L 2.764800e+002
*R
T #Maksimi
A7d9: L #Nopeus
L #Maksimi
>R
JCN A7da
T #Nopeus
A7da: L #Nopeus
L #Memory
>R
JCN A7db
L #Kiihdytys1
+R
T #Memory
L #Nopeus
>R
JCN A7dd
T #Memory
JU A7dd
A7db: L #Nopeus
T #Memory
A7dd: L #Difference
L 0.000000e+000
>R
JCN A7de
L #Memory
T #OhjeArvo
JU A7e0
A7de: L #Memory
NEGR
T #OhjeArvo
JU A7e0
A7d5: L 0.000000e+000
T #Nopeus
CLR
A #JogFWD
JCN A7e1
L #Line[0].ManSpeed
L 2.764800e+002
*R
T #Nopeus
A7e1: CLR
A #JogBWD
JCN A7e2
L #Line[0].ManSpeed
L -2.764800e+002
*R
T #Nopeus
A7e2: L #Nopeus
L #Memory
>R
JCN A7e3
L #Kiihdytys2
+R
T #Memory
L #Nopeus
>R
JCN A7e5
T #Memory
JU A7e5
A7e3: L #Memory
L #Kiihdytys2
-R
T #Memory
L #Nopeus
<R
JCN A7e5
T #Memory
A7e5: L #Memory
T #OhjeArvo
A7e0: L #Memory
L 0.000000e+000
==R
JCN A7e7
CLR
= #Release
JU A7e8
A7e7: SET
= #Release
A7e8: L #OhjeArvo
RND
T #Speed
CLR
A L 24.1
SAVE
BE
FB40 [SCL]
FUNCTION_BLOCK FB40
TITLE ='Positioning and ramp generator for slitting'
AUTHOR : Tuomo
FAMILY : Slitting
NAME : Slitting
VERSION : '1.0'
//reversed
VAR_INPUT
Encoder : DINT ;
SetPoint : REAL ;
Enable : BOOL ;
JogFWD : BOOL ;
JogBWD : BOOL ;
Cycle : INT ;
END_VAR
VAR_OUTPUT
ActValue : REAL ;
Speed : INT ;
OnPos : BOOL ;
Release : BOOL ;
END_VAR
VAR
Line : ARRAY [0 .. 2 ] OF STRUCT
MaxSpeed : REAL := 1.000000e+002;
ManSpeed : REAL := 3.000000e+001;
MinSpeed : REAL := 1.000000e+001;
Accuracy : REAL := 5.000000e-001;
Accelerate : REAL := 6.000000e-001;
SlowCurve : REAL := 3.000000e+002;
SlowLine : REAL := 3.000000e+001;
END_STRUCT ;
Wheel : REAL := 3.141590e+002; //Wheel perimeter
Pulses : REAL := 1.250000e+003; //Amount pulses of encoder
Difference : REAL ; //Length to go
AbsValue : REAL ; //Length to go (absolut value)
Memory : REAL ;
END_VAR
VAR_TEMP
Maksimi : REAL ;
Kiihdytys1 : REAL ;
Kiihdytys2 : REAL ;
Kerroin : REAL ;
Nopeus : REAL ;
OhjeArvo : REAL ;
END_VAR
Line[0]:=Line["Order".Line];
IF "Order".Line = 2 AND "Main".Control.LinePot = 1
THEN
Line[0].MaxSpeed:="Main".LinePot;
END_IF;
IF "Order".Line = 1
THEN
ActValue:=Wheel / Pulses * DINT_TO_REAL(Encoder) / 4.000000e+000;
ELSE
ActValue:=Wheel / Pulses * DINT_TO_REAL(Encoder) / 4.000000e+003;
END_IF;
Difference:=SetPoint - ActValue;
AbsValue:=ABS(Difference);
IF Line[0].Accuracy >= AbsValue
THEN
OnPos:=true;
ELSE
OnPos:=false;
END_IF;
Kiihdytys1:=(2.764800e+001 / Line[0].Accelerate) * INT_TO_REAL(Cycle);
Kiihdytys2:=(2.764800e+001 / Line[1].Accelerate) * INT_TO_REAL(Cycle);
IF (NOT JogFWD AND Enable) AND (NOT JogBWD)
THEN
Kerroin:=2.764800e+004/SQRT(Line[0].SlowCurve);
IF AbsValue > Line[0].SlowLine
THEN
Nopeus:= SQRT(AbsValue) * Kerroin;
ELSE
Nopeus:=SQRT(Line[0].SlowLine) * Kerroin / Line[0].SlowLine * AbsValue;
END_IF;
IF Difference > 0.0
THEN
Maksimi:=Line[0].MaxSpeed * 2.764800e+002;
ELSE
Maksimi:=Line[0].MinSpeed * 2.764800e+002;
END_IF;
IF Nopeus > Maksimi
THEN
Nopeus:=Maksimi;
END_IF;
IF Nopeus > Memory
THEN
Memory:=Memory + Kiihdytys1;
IF Memory > Nopeus
THEN
Memory:=Nopeus;
END_IF;
ELSE
Memory:=Nopeus;
END_IF;
IF Difference > 0.0
THEN
OhjeArvo:=Memory;
ELSE
OhjeArvo:=-Memory;
END_IF;
ELSE
Nopeus:=0.0;
IF JogFWD THEN Nopeus:=Line[0].ManSpeed * 2.764800e+002; END_IF;
IF JogBWD THEN Nopeus:=Line[0].ManSpeed * -2.764800e+002; END_IF;
IF Nopeus > Memory
THEN
Memory:=Memory + Kiihdytys2;
IF Memory > Nopeus THEN Memory:=Nopeus; END_IF;
ELSE
Memory:=Memory - Kiihdytys2;
IF Memory < Nopeus THEN Memory:=Nopeus; END_IF;
END_IF;
OhjeArvo:=Memory;
END_IF;
IF Memory = 0.0
THEN
Release:=false;
ELSE
Release:=true;
END_IF;
Speed:=REAL_TO_INT(OhjeArvo);
END_FUNCTION_BLOCK
|