Date:06.12.2015 File:PRO1_11E.1 SIMATIC S7 Siemens AG 1999. All rights reserved. Information and...
-
Upload
hilary-goodman -
Category
Documents
-
view
216 -
download
2
Transcript of Date:06.12.2015 File:PRO1_11E.1 SIMATIC S7 Siemens AG 1999. All rights reserved. Information and...
Date: 21.04.23File: PRO1_11E.1
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Functions and Function Blocks
Date: 21.04.23File: PRO1_11E.2
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Introduction
Temporary Variables
• are deleted after the associated block is executed
• temporary storage in L stack
• useable in OBs / FCs / FBs
Static Variables
• are retained even after the block is executed
• permanent storage in DBs
• can only be used in FBs
Local Variables / Data
(only valid in one block)
Global Variables / Data
(valid in the entire program)
• PII / PIQ
• I/ O
• M / T / C
• DB areas
symbolicabsolute
Access
Date: 21.04.23File: PRO1_11E.3
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Temporary Variables
Date: 21.04.23File: PRO1_11E.4
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Execution
Local Data Stack Size
For S7-300:
L stack sizePriority class
256 bytes1
27
Entire size: 1.5 Kbyte
(CPU 313..316)
Entire size: 1.5 Kbyte
(CPU 313..316)
Startup (one-time execution)
Cyclic execution
256 bytes
256 bytes
256 bytes12
3
2Time-controlledexecution
Time-of-Day Interrupt
Time-Delay Interrupt
Cyclic Interrupt
Error handling in scan cycle
256 bytes16
28
26256 bytes
Event-driven execution
Hardware Interrupt
Error handling in startup
Date: 21.04.23File: PRO1_11E.5
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Byte Requirement of a Block in the Local Data Stack
rechts
Date: 21.04.23File: PRO1_11E.6
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
25
6 B
yte
s
Event
Occupation in the L stack
1
OB1
OB 1
1
Operatingsystem
Total Occupation in the Local Data Stack
FC 2
with temp.variables
OB1
FC2
FC1
3
3
OB1
FC1
4
4
OB1
FC1
6
6
FC 3
with temp.variables
OB1
FC3
FC1
5
5
FC 1
with temp.variables
2
OB1
FC1
2
7
OB1
7
Date: 21.04.23File: PRO1_11E.7
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Exercise: Use of Temporary Variables
Replace by the temporary variable
"Packages"
Date: 21.04.23File: PRO1_11E.8
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Example of a Message Display Indicating a Problem in the Process
Disturbance
LED
Acknowledge
Report Memory
Edge Mem. Bit
Disturb. Input
Acknowl.
Flash Freq.
Disturb. Input
Display
RS
&
=
>=1&QS
RP
Report Memory
Report Memory
Solution Suggestion
Task
Date: 21.04.23File: PRO1_11E.9
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Disturb.input
Report memory
Acknowledge
Edge mem.bit
Display
Flash freq.
FC 20
Call
Parameter-Assignable Blocks
A I 1.2
R M 40.0
A I 1.3
FP M 40.1
S M 40.0
A M 40.0
A M 10.3
O
ANM 40.0
A I 1.3
= Q 8.3
Non-parameter- assignable block
Formal parameters
M 40.0
M 40.1I 1.3
I 1.2 A 8.3
M 10.3
Actual parameters
A #Acknowledge
R #Report Memory
U #Disturb. input
FP #Edge mem. bit
S #Report memory
A #Report memory
A #Flashing freq.
O
AN #Reportmemory
A #Disturb. input
= #Display
Parameter-assignable block
Program
Date: 21.04.23File: PRO1_11E.10
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Declaration of the Formal Parameters
Use Graphic Display
Read only To the left of the block
Write only To the right of the block
Type of parameter
Input parameter
Output parameter
In/out parameter
Declaration
in
out
In_out Read / write To the left of the block
Formal parameters
Declaration table of the FC 20 block
Date: 21.04.23File: PRO1_11E.11
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Editing a Parameter-assignable Block
Here was, e.g., with a non-parameter-assignable FC:
• with absolute addressing: I1.3
• with symbolic addressing: “End_left"
Date: 21.04.23File: PRO1_11E.12
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Calling a Parameter-assignable Block
Network 3: First Call
Network 4: Second Call
Disturb.input
Acknowledge
Flash freq.
Report memory
Edge mem. bit
Display
M40.1
“Position error"
ENO
EN
“End left"
....
“Acknow.button"
M10.3
M40.0
FC20
Disturb.input
Acknowledge
Flash freq.
Report memory
Edge mem. bit
Display
M40.3
Q9.4
ENO
EN
“End right"
A8.1
“Acknow.button"
M10.3
M40.2
FC20
symbolic
absolute
Addressing
Symbols Local Symbols --> Formal parameters
Symbol-table
Global Symbols
Date: 21.04.23File: PRO1_11E.13
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
LAD/FBD STL
Using the EN/ENO Parameters with Block Calls
CALL FC 1 NOP 0
Example
?? . ?
FC 1
EN ENO
FC 2
EN ENO
FC 3
EN ENO =
FC 1
EN ENO?? . ?Unconditional call
A I 0.1 JNB _001
CALL FC 1 _001: A BR
= Q 9.0
FC 1EN ENOI 0.1 =
Q 9.0
Conditional call
Date: 21.04.23File: PRO1_11E.14
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Declaration table of the FC 20 block
Exercise: Creating a Parameter-assignable FC Block
Non-parameter-assignable block
Parameter-assign-able FC 20 block
A I 1.2R M 40.0A I 1.3FP M 40.1S M 40.0A M 40.0A M 10.3OAN M 40.0A I 1.3= Q
9.3(Q5.3)
A #AcknowledgeR #Report memoryA #Disturb. ...::::::::
2.
1.
Date: 21.04.23File: PRO1_11E.15
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Exercise: Calling a Parameter-assignable FC Block
Disturb. input
Report memory
Acknowledge
Edge mem. bitDisplay
Flash freq.Parameter-assignment of FC20 in the 1st. call
M 40.0
M 40.1I 1.3
I 1.2 Q 9.3 (Q 5.3)
M 10.3
FC 20
Disturb. input
Report memory
Acknowledge
Edge mem. bitDisplay
Flash freq.
M 40.2
M 40.3I 1.4
I 1.2 Q 9.4 (Q 5.4)
M 10.3
FC 20
Parameter-assignment of FC20 in the 2nd. call
Date: 21.04.23File: PRO1_11E.16
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Function Blocks (FBs)
FB 2
EN
Disturb. input
Acknowledge Display
Flash freq. ENO
DB 2
OB 1
Declaration table of the function block
Date: 21.04.23File: PRO1_11E.17
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Function Block for Message Display
Declaration table of the functionblock
Instancedata block
Date: 21.04.23File: PRO1_11E.18
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Generating Instance Data Blocks
1. Generate instance DB with FB call 2. Create new instance DB
Date: 21.04.23File: PRO1_11E.19
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
The Multiple Instance Model
DB10
The Instance Model
FB20
OB 1
Call FB20, DB10Disturb._Input:=Acknowledge:=Flash_Freq:=Display:=
DB11
FB20
Call FB20, DB11Disturb._Input:=Acknowledge:=Flash_Freq:=Display:=
DB12
FB20
Call FB20, DB12Disturb._Input:=Acknowledge:=Flash_Freq:=Display:=
The Multiple Instance Model
FB 100
DB100
Call FB100, DB100
OB 1
stat Dist_1 FB20
stat Dist_2 FB20
Parameters andstatic variablesof the 2nd. call of FB20
Call Dist_2Disturb._Input:=Acknowledge:=Flash_Freq:=Display:=
Parameters andstatic variablesof the 1st. call of FB20
Call Dist_1Disturb._Input:=Acknowledge:=Flash_Freq:=Display:=
Date: 21.04.23File: PRO1_11E.20
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Inserting/Deleting Block Parameters Later On
Save
Date: 21.04.23File: PRO1_11E.21
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Corrections when Calling Modified Blocks
When the calling block is opened:
Once with the right
Date: 21.04.23File: PRO1_11E.22
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Exercise: Editing a Function Block
Declaration table of the FB 20 block1.
Program section of FB 20A #AcknowledgeR #Report memoryA #Disturb. ...::
2.
Date: 21.04.23File: PRO1_11E.23
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Exercise: Calling a Function Block and Testing It
(Q 5.3)
(Q 5.3)
Date: 21.04.23File: PRO1_11E.24
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Converting an FC to an FB using a Source Program (1)
Date: 21.04.23File: PRO1_11E.25
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Converting an FC Block to an FB using a Source Program (2)
::
::
Date: 21.04.23File: PRO1_11E.26
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Exercise: Recognizing Types of Variables
Absolute Symbolic Temporary Static Parameter
L #Number_1
T #Max_value
T MW 40
Statement
L #Number_2
L #Intermediate_resultL “Number_1"
T #Number_2
Global Local
Date: 21.04.23File: PRO1_11E.27
SIMATIC S7Siemens AG 1999. All rights reserved.
Information and Training CenterKnowledge for Automation
Summary: Block Calls
• CALL FC1
• UC FC1
• CC FC1
STL
LAD
FBDFC1
EN
ENO
FC1EN ENO
FC1
( CALL )
FB
W/o param., w/o inst. DB
• UC FB1
• CC FB1
FB1EN
ENO
FB1EN ENO
CALL
With parameters
• CALL FC2 Par1: ... Par2: ... Par3: ...
FC2EN ENO
Par3
Par1
Par2
FC2EN
ENO
Par1
Par2
Par3
With param., with inst.DB
• CALL FB2, DB3 Par1: ... Par2: ... Par3: ...
FB2EN ENO
Par3
Par1
Par2
DB3
FB2EN
ENO
Par3
Par1
Par2
DB3
Without parametersLan-guage
FC
FC1