-
Notifications
You must be signed in to change notification settings - Fork 5
/
Pcs7AnOu.scl
371 lines (351 loc) · 11.2 KB
/
Pcs7AnOu.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
// Name: FB1870
// Symbolic Name: Pcs7AnOu
// Symbol Comment: Analog output driver
// Family: Channel
// Version: 8.7
// Author: AdvLib82
// Last modified: 12/09/2015
// Use: UDT15,UDT16,UDT18
// Size: 10878 bytes
// Signature: generiert vom SCL Übersetzer Version: SCLCOMP K05.03.08.03_02.01.00.01 release
FUNCTION_BLOCK FB11870
TITLE ='Analog output driver'
{ S7_driver := 'chn'; S7_tasklist := 'OB100' }
AUTHOR : AdvLib82
FAMILY : Channel
NAME : Pcs7AnOu
VERSION : '8.7'
VAR_INPUT
PV_In : STRUCT //process value incl. ST
Value : REAL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
Scale { S7_edit := 'para'; S7_xedit := 'High,para;Low,para;' }: STRUCT //Range of process value
High : REAL := 1.000000e+002; // High Value
Low : REAL ; // Low Value
END_STRUCT ;
PV_InUnit { S7_edit := 'para'; S7_enum := 'true' }: INT := 1342; //Unit of process value
Feature { S7_visible := 'false' }: STRUCT //Status of various features
Bit0 : BOOL ; //1 = Start Value
Bit1 : BOOL ; //Reserved
Bit2 : BOOL ; //Reserved
Bit3 : BOOL ; //Reserved
Bit4 : BOOL ; //Reserved
Bit5 : BOOL ; //Reserved
Bit6 : BOOL ; //Reserved
Bit7 : BOOL ; //Reserved
Bit8 : BOOL ; //Reserved
Bit9 : BOOL ; //Reserved
Bit10 : BOOL ; //1 = Condition Monitoring
Bit11 : BOOL ; //Reserved
Bit12 : BOOL ; //Reserved
Bit13 : BOOL ; //Reserved
Bit14 : BOOL ; //Reserved
Bit15 : BOOL ; //Reserved
Bit16 : BOOL ; //Reserved
Bit17 : BOOL ; //Reserved
Bit18 : BOOL ; //Reserved
Bit19 : BOOL ; //Reserved
Bit20 : BOOL ; //Reserved
Bit21 : BOOL ; //Reserved
Bit22 : BOOL ; //Reserved
Bit23 : BOOL ; //Reserved
Bit24 : BOOL ; //Reserved
Bit25 : BOOL ; //Reserved
Bit26 : BOOL ; //Reserved
Bit27 : BOOL ; //Reserved
Bit28 : BOOL ; //Reserved
Bit29 : BOOL ; //Reserved
Bit30 : BOOL := TRUE; //1 = Output lowest value at a block-external simulation
Bit31 : BOOL ; //Reserved
END_STRUCT ;
ScaleOff { S7_edit := 'para'; S7_visible := 'false' }: BOOL ; //1= Scale limits off
SimOn { S7_edit := 'para' }: STRUCT //1=Simulation active
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
SimPV_In { S7_edit := 'para' }: STRUCT //Simulation value
Value : REAL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
StartVal : REAL ; //Start value (phy.value e.g.mA or V)
MS_Release { S7_visible := 'true' }: STRUCT //Maintenance release
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
MS : DWORD ; //Maintenance state
MS_Ext { S7_link := 'true' }: DWORD ; //External Maintenance state
TextRef { S7_link := 'true' }: WORD ; //Text reference external messages
FlutEn { S7_edit := 'para'; S7_visible := 'false' }: BOOL ; //1=Fluttersupress enable
FlutTmIn { S7_edit := 'para'; S7_visible := 'false' }: INT ; //Fluttersupress time
END_VAR
VAR_OUTPUT
Bad : STRUCT //1=Bad process value
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
PV_Out { S7_edit := 'signal' }: WORD ; //Output value
PV_ChnST : STRUCT //Value and state of PV_Out
Value : REAL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
PV_OutUnit : INT ; //Unit of process value
ScaleOut : STRUCT //Range of process value
High : REAL := 1.000000e+002; // High Value
Low : REAL ; // Low Value
END_STRUCT ;
PV_HiAct { S7_visible := 'false' }: STRUCT //1=Input value high limit failure
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
PV_LoAct { S7_visible := 'false' }: STRUCT //1=Input value low limit failure
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
SimAct { S7_visible := 'false' }: STRUCT //1=Simulation active
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
ModErr { S7_visible := 'false' }: STRUCT //1=higher level failure
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
ErrorNum { S7_visible := 'false' }: INT := -1; //Parameter error
OosAct { S7_dynamic := 'true' }: STRUCT //Field device out of service, maintenance in pogress
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
MS_Req : STRUCT //Maintenance request
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
MS_Dev : DWORD ; //Maintenance State
END_VAR
VAR_IN_OUT
Mode : DWORD ; //Quality and mode
DataXchg : DWORD ; //Data exchange
DataXchg1 : DWORD ; //Data exchange
MS_Xchg : DWORD ; //Maintenance State exchange
END_VAR
VAR
_r : ARRAY [0 .. 7 ] OF BYTE ;
SxFirstStart : BOOL := TRUE; //First start
LastByQuality : BYTE ;
END_VAR
VAR_TEMP
Status : BOOL ; //Status
StartOn : BOOL ; //true = Startwert im Anlauf aktiv
StatusM : BOOL ; //Status Messbereichkodierung
xFeatValueAtSim : BOOL ; //1=Output de-energize value at a block-external simulation
Value : REAL ; //Wert intern
Mba : REAL ; //MeЯbereichsanpassung
Mbaa : REAL ; //MeЯbereichsanpassung bei Anlauf
ByQuality : BYTE ;
FactPh : REAL ; //Faktor Rohwertberechnung
FactPha : REAL ; //Faktor Rohwertberechnung in Anlauf
MaxVal : REAL ; //Breichsmaximum
MinVal : REAL ; //Breichsminimum
FlutTm : DWORD ; //Flatterunterdrьckungszeit
MS_AS : DWORD ; //Maintenance State AS
xConditionMonitoring : BOOL ; //1=ConditionMonitoring
END_VAR
BEGIN
IF SxFirstStart THEN
SxFirstStart:=FALSE;
ErrorNum:=0;
END_IF;
xConditionMonitoring:=Feature.Bit10;
ScaleOut.High:=Scale.High;
ScaleOut.Low:=Scale.Low;
PV_OutUnit:=PV_InUnit;
Bad.Value:=FALSE;
OosAct.Value:=((MS AND DW#16#F000000)=DW#16#5000000) OR ((MS AND DW#16#F000000)=DW#16#6000000) OR ((MS AND DW#16#F000000)=DW#16#7000000);
IF xConditionMonitoring THEN
DataXchg1:=DataXchg1 OR DW#16#1;
ELSE
DataXchg1:=DataXchg1 AND DW#16#FFFFFFFE;
END_IF;
IF MS_Release.Value THEN
DataXchg:=DataXchg OR DW#16#1;
ELSE
DataXchg:=DataXchg AND DW#16#FFFFFFFE;
END_IF;
MS_Dev:=MS;
DataXchg1:=DataXchg1 AND DW#16#FFFF;
MS_Xchg:=DW#16#0;
IF xConditionMonitoring THEN
MS_Xchg:=MS_Ext;
DataXchg1:=SHL(IN:= WORD_TO_DWORD(TextRef),N:=16) OR DataXchg1;
END_IF;
MS_Req.Value:=DWORD_TO_BOOL(SHR(IN:=DataXchg1 AND DW#16#2,N:=1))<>0;
xFeatValueAtSim:=Feature.Bit30;
IF FlutTmIn>255 THEN
FlutTmIn:=255;
END_IF;
IF FlutEn THEN
FlutTm:=SHL(IN:=INT_TO_DWORD(FlutTmIn),N:=24);
DataXchg:=DataXchg AND DW#16#FFFFFF;
DataXchg:=DataXchg OR FlutTm;
DataXchg:=DataXchg OR DW#16#2;
ELSE
DataXchg:=DataXchg AND DW#16#FFFFFD;
END_IF;
Status:=((DW#16#80000000=(Mode AND DW#16#FF000000)) OR (DW#16#20000000=(Mode AND DW#16#FF000000))) OR SimOn.Value;
ModErr.Value:=DW#16#40000000=(Mode AND DW#16#FF000000);
StartOn:=Feature.Bit0;
PV_HiAct.Value:=FALSE;
PV_LoAct.Value:=FALSE;
FactPh:=2.764800e+004;
Mba:=0.0;
MaxVal:=3.251100e+004;
StatusM:=FALSE;
CASE DWORD_TO_INT(Mode AND DW#16#FFFF) OF
262 :
FactPh:=5.529600e+004;
Mba:=-2.764800e+004;
MinVal:=-3.251200e+004;
FactPha:=5.529600e+003;
Mbaa:=0.0;
263 :
MinVal:=-6.912000e+003;
FactPha:=6.912000e+003;
Mbaa:=MinVal;
264 :
MinVal:=0.0;
FactPha:=2.764800e+004;
Mbaa:=MinVal;
265 :
FactPh:=5.529600e+004;
Mba:=-2.764800e+004;
MinVal:=-3.251200e+004;
FactPha:=2.764800e+003;
Mbaa:=0.0;
514 :
MinVal:=0.0;
FactPha:=1.382400e+004;
Mbaa:=MinVal;
515 :
MinVal:=-6.912000e+003;
FactPha:=1.728000e+003;
Mbaa:=MinVal;
516 :
FactPh:=5.529600e+004;
Mba:=-2.764800e+004;
MinVal:=-3.251200e+004;
FactPha:=1.382400e+004;
Mbaa:=0.0;
1804:
MinVal:=-6.912000e+003;
FactPha:=1.728000e+003;
Mbaa:=MinVal;
ELSE:
StatusM:=TRUE;
END_CASE;
IF SimOn.Value THEN
Value:=SimPV_In.Value;
ELSE
IF (NOT(xFeatValueAtSim)) OR (PV_In.ST<>B#16#60) THEN
Value:=PV_In.Value;
END_IF;
ByQuality:=B#16#80;
END_IF;
IF ScaleOff THEN
IF ((PV_In.ST=B#16#60) AND xFeatValueAtSim) AND (NOT(SimOn.Value)) THEN
Value:=MinVal;
ELSE
Value:=(((Value-Scale.Low)/(Scale.High-Scale.Low))*FactPh)+Mba;
END_IF;
IF OK AND (Scale.High<>Scale.Low) THEN
IF Value>MaxVal THEN
Value:=MaxVal;
ByQuality:=B#16#78;
PV_HiAct.Value:=TRUE;
END_IF;
IF (Value<MinVal) AND (NOT(StatusM)) THEN
Value:=MinVal;
ByQuality:=B#16#78;
PV_LoAct.Value:=TRUE;
END_IF;
PV_ChnST.Value:=(((Value-Mba)*(Scale.High-Scale.Low))/FactPh)+Scale.Low;
IF Status AND OK AND FactPh<>0.0 THEN
;
ELSE
ByQuality:=B#16#0;
Bad.Value:=TRUE;
OK:=TRUE;
END_IF;
ELSE
ByQuality:=B#16#0;
Bad.Value:=TRUE;
Value:=0.0;
OK:=TRUE;
END_IF;
ELSE
IF Scale.High>=Scale.Low THEN
IF ((PV_In.ST=B#16#60) AND xFeatValueAtSim) AND (NOT(SimOn.Value)) THEN
Value:=Scale.Low;
END_IF;
IF Value>Scale.High THEN
Value:=Scale.High;
ByQuality:=B#16#78;
PV_HiAct.Value:=TRUE;
END_IF;
IF Value<Scale.Low THEN
Value:=Scale.Low;
ByQuality:=B#16#78;
PV_LoAct.Value:=TRUE;
END_IF;
ELSE
IF (PV_In.ST=B#16#60) AND xFeatValueAtSim THEN
Value:=Scale.High;
END_IF;
IF Value<Scale.High THEN
Value:=Scale.High;
ByQuality:=B#16#78;
PV_HiAct.Value:=TRUE;
END_IF;
IF Value>Scale.Low THEN
Value:=Scale.Low;
ByQuality:=B#16#78;
PV_LoAct.Value:=TRUE;
END_IF;
END_IF;
PV_ChnST.Value:=Value;
Value:=(((Value-Scale.Low)/(Scale.High-Scale.Low))*FactPh)+Mba;
IF ((((OK) AND (NOT(StatusM))) AND Status) AND (Value>=Mba)) AND (Value<=(Mba+FactPh)) THEN
;
ELSE
ByQuality:=B#16#0;
Bad.Value:=TRUE;
IF StatusM THEN
PV_ChnST.Value:=0.0;
END_IF;
OK:=TRUE;
END_IF;
END_IF;
SimAct.Value:=SimOn.Value;
IF SimOn.Value THEN
ByQuality:=B#16#60;
Bad.Value:=FALSE;
ELSE
Bad.Value:=((NOT(Status)) OR Bad.Value) OR StatusM;
IF StatusM THEN
Value:=0.0;
PV_LoAct.Value:=FALSE;
PV_HiAct.Value:=FALSE;
END_IF;
IF ((Mode AND DW#16#10000)=DW#16#10000) AND StartOn THEN
Value:=(StartVal*FactPha)+Mbaa;
ByQuality:=B#16#80;
END_IF;
END_IF;
PV_Out:=INT_TO_WORD(REAL_TO_INT(Value));
Mode:=Mode AND DW#16#FFFEFFFF;
ModErr.Value:=(ModErr.Value) OR StatusM;
IF DWORD_TO_INT(MS AND DW#16#F)=6 THEN
ByQuality:=B#16#68;
ELSIF DWORD_TO_INT(MS AND DW#16#F)=5 THEN
ByQuality:=B#16#A4;
END_IF;
PV_ChnST.ST:=ByQuality;
END_FUNCTION_BLOCK