-
Notifications
You must be signed in to change notification settings - Fork 0
/
LLCCA_ErrAcc_1_0_1.scl
62 lines (53 loc) · 2.43 KB
/
LLCCA_ErrAcc_1_0_1.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
FUNCTION_BLOCK "LLCCA_ErrAcc"
TITLE = LLCCA_ErrAcc
{ S7_Optimized_Access := 'TRUE' }
AUTHOR : 'Jacob Holmdahl'
FAMILY : LLCCA
VERSION : 0.1
//LCC Automation AB / (c)Copyright 2024
//Released under the MIT License
VAR_INPUT
iPv { ExternalAccessible := 'False'; ExternalVisible := 'False'; ExternalWritable := 'False'} : Real; // process value
iSp { ExternalAccessible := 'False'; ExternalVisible := 'False'; ExternalWritable := 'False'} : Real; // setpoint
iReset { ExternalAccessible := 'False'; ExternalVisible := 'False'; ExternalWritable := 'False'} : Bool; // reset
END_VAR
VAR_OUTPUT
oErrAcc { ExternalWritable := 'False'} : LReal; // error accumulator output
END_VAR
VAR
statErrAcc { ExternalAccessible := 'False'; ExternalVisible := 'False'; ExternalWritable := 'False'} : LReal;
statRuntime { ExternalAccessible := 'False'; ExternalVisible := 'False'; ExternalWritable := 'False'} : LReal;
END_VAR
VAR_TEMP
tempDeltaTime : LReal;
END_VAR
BEGIN
REGION Description header
//==================================================================================
// LCC Automation AB / (c)Copyright 2024
// Released under the MIT License
//----------------------------------------------------------------------------------
// Title: LLCCA_ErrAcc
// Comment/Function: Process value to setpoint error accumulator
// Library/Family: LLCCA (Library LCC Automation AB)
// Author: Jacob Holmdahl / [email protected]
// Target System: CPU 1510SP-1
// Engineering: TIA Portal 19 update 3
// Restrictions: none
// Requirements: PLC (S7-1200 / S7-1500)
//----------------------------------------------------------------------------------
// Change log table:
// Version | Date | Author | Changes applied
//-------------|------------|------------------|------------------------------------
// 001.000.001 | 2024-11-27 | Jacob Holmdahl | First release
//==================================================================================
END_REGION
#tempDeltaTime := RUNTIME(#statRuntime);
IF #iReset THEN
#statErrAcc := 0.0;
ELSE
#statErrAcc := #statErrAcc + (ABS(#iSp - #iPv) * #tempDeltaTime);
END_IF;
// set output
#oErrAcc := #statErrAcc;
END_FUNCTION_BLOCK