-
Notifications
You must be signed in to change notification settings - Fork 1
/
FB_VD_Ventil_5.SCL
129 lines (121 loc) · 4.09 KB
/
FB_VD_Ventil_5.SCL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
(*****************************************************************************************
** **
** Copyright (c) 2019 Himmelt **
** All Rights Reserved Himmelt@SoraWorld **
** E-mail [email protected] **
** **
******************************************************************************************
** Date Version Author Decsription **
------------------------------------------------------------------------------------------
** 2019.10.14 0.3 Himmelt Add KYPxxBER and BD01E; **
** Change name to FB_VD_Ventil_5 **
** 2019.10.12 0.2 Himmelt Change Valve to Ventil **
** 2019.08.09 0.1 Himmelt Beta **
** 2019.08.08 0.0 Himmelt Alpha **
*****************************************************************************************)
FUNCTION_BLOCK FB_VD_Ventil_5
VAR_INPUT
Addr : INT := 0;
K100 : BOOL := FALSE;
KYPX1R : BOOL := FALSE;
KYPX1V : BOOL := FALSE;
KYPX2R : BOOL := FALSE;
KYPX2V : BOOL := FALSE;
KYPX3R : BOOL := FALSE;
KYPX3V : BOOL := FALSE;
KYPX4R : BOOL := FALSE;
KYPX4V : BOOL := FALSE;
KYPX5R : BOOL := FALSE;
KYPX5V : BOOL := FALSE;
Delay : TIME := T#500MS;
END_VAR
VAR
tmpKYPR : ARRAY [1..5] OF BOOL;
tmpKYPV : ARRAY [1..5] OF BOOL;
tonKYPX1R : TON;
tonKYPX1V : TON;
tonKYPX2R : TON;
tonKYPX2V : TON;
tonKYPX3R : TON;
tonKYPX3V : TON;
tonKYPX4R : TON;
tonKYPX4V : TON;
tonKYPX5R : TON;
tonKYPX5V : TON;
END_VAR
VAR_OUTPUT
BEX1R : BOOL := true;
BEX1V : BOOL := false;
BEX2R : BOOL := true;
BEX2V : BOOL := false;
BEX3R : BOOL := true;
BEX3V : BOOL := false;
BEX4R : BOOL := true;
BEX4V : BOOL := false;
BEX5R : BOOL := true;
BEX5V : BOOL := false;
BD01E : BOOL := false;
END_VAR
IF KYPX1R AND NOT KYPX1V THEN
tmpKYPR[1] := true;tmpKYPV[1] := false;BEX1V := false;
ELSIF NOT KYPX1R AND KYPX1V THEN
tmpKYPR[1] := false;tmpKYPV[1] := true;BEX1R := false;
END_IF;
IF KYPX2R AND NOT KYPX2V THEN
tmpKYPR[2] := true;tmpKYPV[2] := false;BEX2V := false;
ELSIF NOT KYPX2R AND KYPX2V THEN
tmpKYPR[2] := false;tmpKYPV[2] := true;BEX2R := false;
END_IF;
IF KYPX3R AND NOT KYPX3V THEN
tmpKYPR[3] := true;tmpKYPV[3] := false;BEX3V := false;
ELSIF NOT KYPX3R AND KYPX3V THEN
tmpKYPR[3] := false;tmpKYPV[3] := true;BEX3R := false;
END_IF;
IF KYPX4R AND NOT KYPX4V THEN
tmpKYPR[4] := true;tmpKYPV[4] := false;BEX4V := false;
ELSIF NOT KYPX4R AND KYPX4V THEN
tmpKYPR[4] := false;tmpKYPV[4] := true;BEX4R := false;
END_IF;
IF KYPX5R AND NOT KYPX5V THEN
tmpKYPR[5] := true;tmpKYPV[5] := false;BEX5V := false;
ELSIF NOT KYPX5R AND KYPX5V THEN
tmpKYPR[5] := false;tmpKYPV[5] := true;BEX5R := false;
END_IF;
tonKYPX1R(IN := tmpKYPR[1], PT := Delay);
tonKYPX1V(IN := tmpKYPV[1], PT := Delay);
tonKYPX2R(IN := tmpKYPR[2], PT := Delay);
tonKYPX2V(IN := tmpKYPV[2], PT := Delay);
tonKYPX3R(IN := tmpKYPR[3], PT := Delay);
tonKYPX3V(IN := tmpKYPV[3], PT := Delay);
tonKYPX4R(IN := tmpKYPR[4], PT := Delay);
tonKYPX4V(IN := tmpKYPV[4], PT := Delay);
tonKYPX5R(IN := tmpKYPR[5], PT := Delay);
tonKYPX5V(IN := tmpKYPV[5], PT := Delay);
IF tonKYPX1R.Q THEN
BEX1R := true;
ELSIF tonKYPX1V.Q THEN
BEX1V := true;
END_IF;
IF tonKYPX2R.Q THEN
BEX2R := true;
ELSIF tonKYPX2V.Q THEN
BEX2V := true;
END_IF;
IF tonKYPX3R.Q THEN
BEX3R := true;
ELSIF tonKYPX3V.Q THEN
BEX3V := true;
END_IF;
IF tonKYPX4R.Q THEN
BEX4R := true;
ELSIF tonKYPX4V.Q THEN
BEX4V := true;
END_IF;
IF tonKYPX5R.Q THEN
BEX5R := true;
ELSIF tonKYPX5V.Q THEN
BEX5V := true;
END_IF;
EW[Addr + 1] := 16#FFFF;// KYPxxBER
BD01E := A[Addr, 0];// KYP01EE
END_FUNCTION_BLOCK