2. September 28, 2018SIMATIC S7
SIEMENS LTD EGYPT
2/13
SIEMENS
Objectives
- Know How Temp. Variables Can Be Accessed & Where It Stored.
- Understand The Declaration Table & How To Use It.
3. September 28, 2018SIMATIC S7
SIEMENS LTD EGYPT
3/13
Types of variables
The inputs and outputs in our programs
were coded directly with their actual
address assignments.
There is two types of variables:
Global Variables
• I/ O
• PII / PIQ
• M / T / C
• DB areas
Local Variables
Temporary variables:
Variables that are stored only while the
block is being executed. They can be
declared in all blocks (OB, FC, FB).
Static variables:
Variables to be retained even after the
block is executed, can only be declared in
function blocks. The instance DB
assigned to the FB is used as the storage
location for these static variables.
SIEMENS
4. September 28, 2018SIMATIC S7
SIEMENS LTD EGYPT
4/13
Temporary variables:
Temporary variables can be
used in all blocks (OB, FC,
FB). They are used to
temporarily store information
while the block is being
executed. The data are lost
when the block is exited.
The data are stored in the L
stack (local data stack). The L
stack is a separate memory
area in the CPU.
Declaration Table
Before a temporary variable
can be used in a block, it must
be declared in the block‘s
declaration table.
Type of Parameter:
The ‘in‘ declaration type
should be assigned only to
declaration types that will be
read.
The ‘out‘ declaration type for
paramaters that will be written
to within the function.
IN Parameter
OUT Parameter
SIEMENS
5. September 28, 2018SIMATIC S7
SIEMENS LTD EGYPT
5/13
Program for starting and
stopping a motor using the
input & output declaration
table parameter.
Declaration Table & Program in FC3
SIEMENS
6. September 28, 2018SIMATIC S7
SIEMENS LTD EGYPT
6/13
Calling FC3
In FC4, FC3 can be called
& it can be called in any
other FC,FB or OB
SIEMENS
7. September 28, 2018SIMATIC S7
SIEMENS LTD EGYPT
7/13
Intering Data for FC3
Calling For FC3 In FC4
SIEMENS
8. September 28, 2018SIMATIC S7
SIEMENS LTD EGYPT
8/13
Calling In OB1 For FC4
When Calling The Motor Function
FC3, FC4 Is The Function That Will Be
Called In OB1
SIEMENS
9. September 28, 2018SIMATIC S7
SIEMENS LTD EGYPT
9/13
Exercise:
1- In FC5, Write a PLC program, using declaration table to calculate the following equation:
K = 4X + 5XYZ + 2Y/3Z + 2(X+Z)
Then find the value of K at: X=1, Y=2 and Z=1
SIEMENS
10. September 28, 2018SIMATIC S7
SIEMENS LTD EGYPT
10/13
Answer of Exercise 1:
IN The Declaration Table:
IN: X,Y,Z
OUT: K
Temp: ????
The value of K at: X=1, Y=2 and Z=1
K=19
SIEMENS