Sunteți pe pagina 1din 10

SIEMENS

DECLARATION TABLE

SIEMENS
SIMATIC S7
SIEMENS LTD EGYPT 2007 All Rights Reserved

1/13

August 21, 2013

SIEMENS

Objectives

- Know How Temp. Variables Can Be Accessed & Where It Stored. - Understand The Declaration Table & How To Use It.

SIMATIC S7
SIEMENS LTD EGYPT 2007 All Rights Reserved

2/13

August 21, 2013

SIEMENS

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.
SIMATIC S7
SIEMENS LTD EGYPT 2007 All Rights Reserved

3/13

August 21, 2013

SIEMENS

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.

IN Parameter

OUT Parameter

Declaration Table
Before a temporary variable can be used in a block, it must be declared in the blocks 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.
SIMATIC S7
SIEMENS LTD EGYPT 2007 All Rights Reserved

4/13

August 21, 2013

SIEMENS

Declaration Table & Program in FC3

Program for starting and stopping a motor using the input & output declaration table parameter.

SIMATIC S7
SIEMENS LTD EGYPT 2007 All Rights Reserved

5/13

August 21, 2013

SIEMENS

Calling FC3

In FC4, FC3 can be called & it can be called in any other FC,FB or OB

SIMATIC S7
SIEMENS LTD EGYPT 2007 All Rights Reserved

6/13

August 21, 2013

SIEMENS

Intering Data for FC3

Calling For FC3 In FC4

SIMATIC S7
SIEMENS LTD EGYPT 2007 All Rights Reserved

7/13

August 21, 2013

SIEMENS

Calling In OB1 For FC4

When Calling The Motor Function FC3, FC4 Is The Function That Will Be Called In OB1

SIMATIC S7
SIEMENS LTD EGYPT 2007 All Rights Reserved

8/13

August 21, 2013

SIEMENS

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

SIMATIC S7
SIEMENS LTD EGYPT 2007 All Rights Reserved

9/13

August 21, 2013

SIEMENS

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

SIMATIC S7
SIEMENS LTD EGYPT 2007 All Rights Reserved

10/13

August 21, 2013