Sie sind auf Seite 1von 27

Block Architecture and the LAD / STL / FBD Editor

OB 1

FB

FB

FC

FB

FB

FB

FB

SIMATIC S7
Siemens AG 2006. All rights reserved.

FC

FC

Date:
File:

2/3/2012
PRO1_06E.1

SITRAIN Training for


Automation and Industrial Solutions

Objectives
Upon completion of this chapter the participant will ...
...

know the different types of S7 blocks

...

understand the principle of "structured programming"

...

know the meaning of the process images (PII, PIQ)

...

be able to explain the principle of cyclic program execution

...

know and be able to select the LAD, FBD and STL programming languages

...

be able to edit, save and download a block with the LAD/STL/FBD Editor

...

be able to carry out a simple program debugging with the "Monitor Block" test function

...

as an option, be able to make customizations to the LAD/FBD/STL Editor

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.2

SITRAIN Training for


Automation and Industrial Solutions

Types of Program Blocks


Operating System

DB

DB

FC

FB

SFC

FB

FC

SFB

Cycle

Time
Process

OB
Organization
Blocks

Error

Legend:
OB
FB
FC
SFB
SFC
DB

= Organization Block
= Function Block
= Function
= System Function Block
= System Function
= Data Block

SIMATIC S7
Siemens AG 2006. All rights reserved.

Maximum nesting depth:


S7-300:
8
(16 for CPU 318)
S7-400:

FB

(for each priority class,


2 to 4 additional levels for Error OBs)

FB with
Instance DB

Date:
File:

24

2/3/2012
PRO1_06E.3

SITRAIN Training for


Automation and Industrial Solutions

Program Structuring Possibilities

Linear Program

Program Partitioned into Areas

Structured Program

Recipe A

OB 1

OB 1

RecipeB
Mixer

OB 1

Pump

Outlet

Outlet

All instructions are


found in one block
(usually in Organization
Block OB 1)

SIMATIC S7
Siemens AG 2006. All rights reserved.

The instructions for the individual


functions are found in individual
blocks. OB 1 calls the individual
blocks one after the other.

Date:
File:

2/3/2012
PRO1_06E.4

Reusable functions are loaded into


individual blocks. OB 1 (or other
blocks) call these blocks and pass on
the pertinent data.

SITRAIN Training for


Automation and Industrial Solutions

Process Images
S1

K1

I 2.0

Q 4.3

PII

PIQ
User
Program

Byte 0
Byte 1
Byte 2
:
:
:

A
=

A
=

CPU Memory Area

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

:
:
I
Q
:
:
I
Q
:

2.0
4.3

Byte 0
Byte 1
Byte 2
:
:
:

6.4
4.3
CPU Memory Area

2/3/2012
PRO1_06E.5

SITRAIN Training for


Automation and Industrial Solutions

Cyclic Program Execution

Before October 1998

Startup program: Call and execution of OB 100


(once, after Power ON, for example)
Transfer PIQ to the digital output modules

Start of the cycle monitoring time

digital
input
module

CPU Cycle

Reading the input states from the digital input modules


and saving the states in the process image (PII)

Call and execution of OB1


(possible interruption by call of other OBs
for events such as time-of-day interrupt,
hardware interrupts etc. )

digital
output
module

Writing the process-image output table


(PIQ) in the digital output modules

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.6

SITRAIN Training for


Automation and Industrial Solutions

Cyclic Program Execution

After October 1998

Startup block (OB 100)


Execution once after Power ON, for example

Start of the cycle monitoring time

Output
module

CPU Cycle

Writing the process-image output table


(PIQ) to the output modules

Reading the signal states from the modules


and saving the data in the process image (PII)

Input
module

Execution of the program in OB1


(cyclic execution)
Events (time-of-day interrupt, hardware interrupts etc.)
call other OBs, FBs, FCs, etc.

Communications

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.7

SITRAIN Training for


Automation and Industrial Solutions

Inserting an S7 Block

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.8

SITRAIN Training for


Automation and Industrial Solutions

The LAD / STL / FBD Editor

Declaration Table

Code Section

Detail Window

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.9

SITRAIN Training for


Automation and Industrial Solutions

The STEP 7 Programming Languages


Function Block Diagram

Ladder Diagram

Statement List

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.10

SITRAIN Training for


Automation and Industrial Solutions

Selecting the Programming Language

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.11

SITRAIN Training for


Automation and Industrial Solutions

Programming in LAD and FBD

Insert / Cp

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.12

SITRAIN Training for


Automation and Industrial Solutions

Programming in STL

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.13

SITRAIN Training for


Automation and Industrial Solutions

Saving a Block
Current project directory with block name

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.14

SITRAIN Training for


Automation and Industrial Solutions

Calling a Block in OB1

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.15

SITRAIN Training for


Automation and Industrial Solutions

Downloading Blocks into the PLC

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.16

SITRAIN Training for


Automation and Industrial Solutions

Simple Program Debugging

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.17

SITRAIN Training for


Automation and Industrial Solutions

Downloading and Saving Modified Blocks

Open offline
offline
ffnen

Speichern
Save

ffnen
Open online

Download
Laden

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.18

SITRAIN Training for


Automation and Industrial Solutions

Exercise 1: Jogging the Conveyor Motor (FC 16)

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.19

SITRAIN Training for


Automation and Industrial Solutions

Exercise 2: Calling FC 16 in OB 1

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.20

SITRAIN Training for


Automation and Industrial Solutions

If You Want to Know More

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.21

SITRAIN Training for


Automation and Industrial Solutions

Editor Customization: "General" Tab

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.22

SITRAIN Training for


Automation and Industrial Solutions

Editor Customization: "View " Tab

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.23

SITRAIN Training for


Automation and Industrial Solutions

Editor Customization: "STL" Tab

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.24

SITRAIN Training for


Automation and Industrial Solutions

Editor Customization: "LAD/FBD" Tab

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.25

SITRAIN Training for


Automation and Industrial Solutions

Editor Customization: "Block" Tab

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.26

SITRAIN Training for


Automation and Industrial Solutions

Editor Customization: "Sources/Source Text" Tab

SIMATIC S7
Siemens AG 2006. All rights reserved.

Date:
File:

2/3/2012
PRO1_06E.27

SITRAIN Training for


Automation and Industrial Solutions