Sie sind auf Seite 1von 26

Contents Page

The STEP 7 Programming Languages ………….......................................................................... 2


Starting the LAD/STL/FBD Editor ...................................................................................................... 3
Components of the LAD/STL/FBD Editor ........................................................................................ 4
Selecting the Programming Language ............................................................................................ 5
Programming in LAD/FBD ............................................................................................................... 6
Programming in STL ...................................................................................................................... 7
Saving a Block ............................................................................................................................. 8
Calling a Block in OB1 .................................................................................................................. 9
Downloading Blocks into the PLC ……………............................................................................... 10
Simple Program Debugging ............................................................................................................ 11
Downloading and Saving Modified Blocks ....................................................................................... 12
Exercise: Selecting the Mnemonics ............................................................................................... 13
Exercise: Opening and Editing FC 1 .................................................................................................. 14
Exercise: Changing the Programming Language ............................................................................ 15
Exercise: Saving FC 1 1...................................................................................................................... 16
Exercise: Downloading a Block into the PLC .................................................................................... 17
Exercise: Calling FC 1 in OB 1 ....................................................................................................... 18
Exercise: Debugging FC 1 (in LAD) ................................................................................................. 19
Exercise: Expanding the Program in the FC 1 Block ....................................................................... 20
Editor Customization: "Editor" Tab ………..................................................................................... 21
Editor Customization : "STL" Tab ……….......................................................................................... 22
Editor Customization : "LAD/ FBD" Tab ………................................................................................ 23
Edit C
Editor Customization
t i ti : "Create
"C t Block" Bl k" Tab T b ………..…...................................................................... 24
Editor Customization : "Source Files" Tab ………. ............................................................................ 25
Editor Customization : "Symbol Selection" Tab ………...................................................................... 26

Training Center ST-7PRO1


for Automation and Drives Page 1 Editing Blocks
Introduction There are several programming languages in STEP 7 that can be used depending
on preference
f and
d kknowledge.
l d B
By adhering
dh i tto specific
ifi rules,
l th
the program can b
be
created in Statement List and can then be converted into another programming
language.

LAD Ladder Diagram is very similar to a circuit diagram. Symbols such as contacts and
coils are used. This programming language appeals to those who ‚grew up‘ with
contactors.

STL The Statement List consists of STEP 7 instructions. You can p program
g fairly
y freely
y
with STL (sometimes to the point of being unable to follow it anymore). This
programming language is preferred by programmers who are already familiar with
other programming languages.

FBD The Function Block Diagram uses “boxes” for the individual functions. The character
in the box indicates the function (e.g. & --> AND Logic Operation). This
programming language has the advantage that even a “non-programmer” such as a
process engineer can work with it. Function Block Diagram is available as of
Version 3.0 of the STEP7 Software.

Training Center ST-7PRO1


for Automation and Drives Page 2 Editing Blocks
Starting the Editor You can start the LAD/STL/FBD Editor by selecting Start -> Simatic -> STEP 7
->
> LAD,STL,FBD
LAD STL FBD - Programming
P i S7 Bl Blocks.
k
The following quicker way of starting the Editor is recommended :
1. Select the "Blocks" object in the project window of the SIMATIC Manager.
2. Double-click any block to open the Editor.

Program When using the LAD and FBD programming languages you can insert simple
Elements graphical program elements directly into the program from the toolbar.
You can click the "Program
g Elements" icon to open
p another window containing
g more
program elements. The contents of this window depend on the programming
language selected (LAD/FBD/STL).

Training Center ST-7PRO1


for Automation and Drives Page 3 Editing Blocks
Components When you start the LAD/STL/FBD Editor, two windows are automatically opened:
th declaration
the d l ti table
t bl and
d the
th code
d section.
ti The
Th user can also
l open a third
thi d "P
"Program
Elements" window.

Declaration Table The declaration table belongs to the block. It is used for declaring variables and
parameters for the block.
The declaration table is discussed in detail in the chapter ”Functions and Function
Blocks".

Code Section The code section contains the program itself


itself, divided into separate networks if
required.
Entries are checked for correct syntax.

Program The contents of the "Program Elements" window depends on the programming
Elements language selected.
You can double-click elements in the list ("browser") to insert them into the program
at the cursor position.
You can also insert elements by drag&drop.
drag&drop

Training Center ST-7PRO1


for Automation and Drives Page 4 Editing Blocks
View You choose the View menu to switch from one STEP 7 programming language to
another:
th
• LAD (Ladder Diagram)
• FBD (Function Block Diagram)
• STL (Statement List).

LAD/FBD => STL You can convert program sections that have been written in the graphical
programming languages into STL. You should, however, be aware that the result of
this conversion is not always the most efficient solution in Statement List.

STL => LAD/FBD It is not always possible to convert program sections written in STL into LAD or
FBD. The sections of the program that cannot be converted are left in STL.
No sections of the program are lost on conversion.

Training Center ST-7PRO1


for Automation and Drives Page 5 Editing Blocks
Elements Frequently used LAD and FBD elements appear as icons in the toolbar. You click
th
them with
ith th
the mouse tto iinsertt th
them att the
th selected
l t d position
iti iin th
the program.

Toolbar icons in LAD:

Toolbar icons in FBD:

You can insert other program elements from the browser in the "Program Elements"
window:
• in
i any position
iti with
ith d
drag&drop
&d
• in a selected position by double-clicking the element in the browser.

Networks When you click the "New Network“ icon in the toolbar, a new network is
added after the current network.

Note If you want to insert a new network before NW1, you must select the block name
("FC1: Plant" in the example above) before you click the "New Network" icon.

Empty Box You can use the Empty Box to insert LAD or FBD elements more quickly. The
elements can be inserted directly without having to select them from the browser.

After you have selected the position in the network where you want to insert an
element, click on the “Empty Box“ icon in the toolbar.

By entering the first letters of an element name, a list with the elements which start
with these letters appears and you can make a selection.

Training Center ST-7PRO1


for Automation and Drives Page 6 Editing Blocks
Statements The user needs to know the statements for writing a program in STL. You can
obtain
bt i iinformation
f ti about
b t ththe syntax
t andd ffunctionality
ti lit from
f the
th on-line
li h
help:
l
Help -> Help on STL.
The following information is available:
"Statement List Instructions", a description of all the statements that
exist in this programming language
"Working with Statement List", a description of
Statement List View and General Syntax
Entering and Viewing Constant Data
Types of Blocks
Switch Contacts and Signal States

Program Elements When you are using the STL Editor, the "Program Elements" window contains only
a list of the existing blocks which can be called from the current block.

Networks Networks are inserted in the same way as in the LAD/FBD Editor (see previous
page).

Making Changes You use the "Insert" key to toggle between "Overwrite" and "Insert" mode.
The current setting appears in the status bar.

Training Center ST-7PRO1


for Automation and Drives Page 7 Editing Blocks
Saving a Block When you have finished editing a block, you can save it on the hard disk of the
programming
i ddevice:
i
• by selecting the menu options File -> Save or
• by clicking the disk icon in the toolbar.
.

Training Center ST-7PRO1


for Automation and Drives Page 8 Editing Blocks
Cyclic So that a newly created block is integrated in the cyclic program execution of the
E
Execution
ti CPU it mustt b
CPU, be called
ll d iin OB1
OB1.
The simplest way of inserting the block call is through the browser (see picture
above).

Training Center ST-7PRO1


for Automation and Drives Page 9 Editing Blocks
Downloading You download the blocks into the PLC with the SIMATIC Manager by:
• clicking the icon or
• selecting the menu options PLC -> Download.

Before you do this, you must select the blocks you want to download:
• All blocks: Select the "Blocks" object in the left-hand pane of the
project window.
• Several blocks: Hold down the CTRL key and select the blocks you
want.
• One block: Select the block.

Training Center ST-7PRO1


for Automation and Drives Page 10 Editing Blocks
Requirements Before you can activate the monitoring mode, you must open the block you want to
monitor
it either
ith offline
ffli or online
li withith the
th LAD/STL/FBD Editor.
Edit
Note: In order to test a block in the offline mode, it must first be downloaded
into the PLC.

Activation / There are two ways of activating/deactivating the “Monitor" test function:
Deactivation
• click the “Spectacles“ icon
• select the menu options Debug -> Monitor.

View The program status is displayed in different ways depending on the programming
language selected (LAD/STL/FBD).
When the monitoring function is activated, you cannot change the programming
language in which the block is viewed (LAD/FBD/STL)..

Note You will find more information about testing programs in the chapter "Test
Functions".

Training Center ST-7PRO1


for Automation and Drives Page 11 Editing Blocks
Making Corrections You can make corrections to blocks that have been opened either online or
t Blocks
to Bl k offline;
ffli h
however, nott iin th
the ttestt mode.
d
• You normally download the modified block to the PLC, test it, make further
corrections if necessary and finally save it on the hard disk when it has been
fully debugged.
• If you do not want to test the program straight away, you can just save the
changes on the hard disk to start with. The old version of the block is then
erased in this case.
• If you make corrections to a number of blocks and don't want to overwrite
the original version of the program yet yet, you can download the changed
blocks to the CPU first without saving them on the hard disk of the PG.
You can save them on the hard disk of the PG when you have tested the
whole program successfully.

Insert/Over-write The insert mode is set by default for LAD or FBD. By pressing the „Insert (Ins)“ key,
you activate the over-write mode. After that, you can, for example, modify the type
of timer for a timer (e.g. change ON delay to OFF delay), without rewiring the inputs
and outputs.

Training Center ST-7PRO1


for Automation and Drives Page 12 Editing Blocks
Remember ! You can select the language and the mnemonics you want to use in the SIMATIC
Manager.

Goal To select the desired mnemonics.

What to Do 1. Start the SIMATIC Manager, if it is not already open.


2. Select the menu options Options -> Customize.
3. Choose the language and the desired mnemonics in the “Language” tab and
confirm with “OK”.

Result You will use one of the following representations when writing your program.
Example of an STL statement with German mnemonics:
U E 1.0 // UND Eingang 1.0
Example of an STL statement with English mnemonics:
A I 1.0 // AND Input 1.0

Training Center ST-7PRO1


for Automation and Drives Page 13 Editing Blocks
Remember ! You must open the FC 1 block before you can start editing it. So that the block can
be executed,
b t d it mustt be
b called
ll d iin OB 1
1.
Goal To open FC 1, which was created in the S7 program "My Program" and to enter the
following logic operations in the code section of the block.

What to Do 1. In the SIMATIC Manager, double-click on the “Blocks” folder in the program
“My_Program” to open it.
2. Select the menu options View -> Offline
or alternatively:
2a. Click on the Offline icon in the toolbar.
3. Open FC 1 (and the LAD/STL/FBD Editor) by double-clicking its block icon.
4. Select the menu options View -> LAD in the LAD/STL/FBD Editor.
5. Enter the program shown below
in Ladder Diagram using the icons
in the toolbar.

Editing
g Tips
p To p
position the first element, move the cursor to the network line.
Position the cursor above the symbol concerned (using the mouse or the TAB key) to
enter the addresses.
You can use the TAB key to jump from one element to another.

Result I 0.0 I 0.1 Q 8.0 (Q 4.0)

Training Center ST-7PRO1


for Automation and Drives Page 14 Editing Blocks
Remember ! After you have opened a block for editing or testing, you can choose one of the
programming i llanguages LAD
LAD, STL or FBD
FBD.
If you write your program in LAD/FBD and switch to STL view, all your entries will
be converted into a list of statements. This method does not always produce the
most efficient program code.

Goal To select the programming language for editing a block.

What to Do 1. Open the FC1 block in the LAD/STL/FBD Editor.


2 Select
2. S l t your programming
i llanguage ffrom th
the View
Vi menu.

Result Your program will be displayed in one of the following programming languages:

LAD:
I 0.0 I 0.1 Q 8.0 (Q 4.0)

STL: A I 0.0
AN I 0.1
= Q 8.0 (Q4.0)

FBD:
I 0.0 &
Q 8.0 (Q4.0)
I 0.1 =

Training Center ST-7PRO1


for Automation and Drives Page 15 Editing Blocks
Remember ! After you have created a program block, you should save it on diskette or on the
hard
h d di
disk
k tto preventt it ffrom b
being
i llost.
t YYou d
do thi
this with
ith th
the normall Wi
Windows
d "S
"Save““
facility, using one of the two methods shown above.
If you use the menu options File => Save As, you must specify the project,
program and block name you want to use.
After you have saved the block, you can select, in the SIMATIC Manager, the
project/program directory in which the block was saved. When the block is
displayed, you can use the SIMATIC Manager like the "Explorer“ to copy the block
to several CPUs or to move it somewhere else.

Goal To save a program block.

What to Do 1. Select the menu options File -> Save or click the “Save” icon
or
2. Select the menu options File -> Save As and enter the details.

Result 1. The program block is saved with the block name you specified when you
opened itit.
2. With Save As, the program block is saved with the new name you enter.

Note When you save a program it is not copied to the CPU.


(You do this with the Download option)

Training Center ST-7PRO1


for Automation and Drives Page 16 Editing Blocks
Remember ! After you have created and edited a block, you must transfer it to the CPU in order
tto be
b able
bl tto ttestt it.
it
You can download the just opened block into the PLC with the LAD/STL/FBD
Editor.
With the SIMATIC Manager, you can download blocks without opening them.

Goal To download a block (FC 1) with the LAD/STL/FBD Editor.

What to Do With the LAD/STL/FBD Editor open


p ....
1. Select the menu options PLC -> Download or click on the “Download”
icon

2. Answer the question in the dialog box:

If you answer “Yes", the block already in the CPU will be overwritten and lost. If
you answer "No", the old block will remain in the CPU and the new one will not be
downloaded.
Choose “Yes" for this exercise, so that you can then test the block you have
edited.

Result Your new program block is written to the CPU.

Training Center ST-7PRO1


for Automation and Drives Page 17 Editing Blocks
Remember ! The FC 1 function must be called in OB 1 so that it can be executed cyclically.

Goal To call FC 1 in the organization block OB 1.

What to Do 1. In the LAD/STL/FBD Editor, open the OB 1 block from the S7 Program
"My Program".
2. Select a location in the rung of Network 1.
3. Open the "Program Elements" browser by clicking on the icon.

4. Open the "FC Blocks" entry in the browser and using the mouse drag FC 1
to Network 1 in OB 1.
5. Save the FC 1 block.
6. Download the block to the CPU.

Result The OB 1 block is cyclically executed in the CPU; and therefore also the FC 1
function.

Training Center ST-7PRO1


for Automation and Drives Page 18 Editing Blocks
Remember ! To monitor the program execution of a block, it must be open online or offline. If
the block
th bl k iis open offline,
ffli it mustt b
be d
downloaded
l d d tto th
the PLC bbefore
f you can ttestt itit.
Display If the result of a check is positive, the relevant symbol is displayed with solid lines.
If not, it is displayed with dashed lines.
If the RLO=1, the rung is shown as a solid line. If not, it appears as a dashed line.
You can change the thickness and color of the lines in the LAD/STL/FBD Editor
by selecting the menu options Options => Customize => LAD/FBD.

Goal To test a block while it is being


g executed in the CPU.

What to Do 1. Open FC 1 offline.


2. Select the menu options Debug -> Monitor or click on the
“spectacles” icon

Result Depending on the switch settings at inputs I 0.0 and I 0.1, you will see one of the
displays shown in the slide.

Training Center ST-7PRO1


for Automation and Drives Page 19 Editing Blocks
Remember ! You can only make program corrections after the program status has been
completed.
l t d S
So th
thatt th
the program corrections
ti can ttake
k effect,
ff t you have
h to
t download
d l d
the block once more to the CPU.

Goal To expand and test the program in FC 1.

What to Do 1. Deactivate the program status by clicking on the “spectacles“ icon.


2. Select the location between the first and the second contact.
3. Insert a branch using the icon
4. Insert a contact in the parallel branch.
5. Close the parallel branch using the icon
6. Save the block.
7. Download the block in the CPU.
8. Test the block with the test function "Program Status".

Result The output can also be controlled with the condition in the parallel branch.

Training Center ST-7PRO1


for Automation and Drives Page 20 Editing Blocks
Text You select the font and the size of the text to be used for programming here.

View You can display blocks:


• with symbolic or absolute addressing
• with or without symbol information
• with or without block and network comments
• in the language in which they were written or in a preset language
(LAD/STL/FBD).

Data Blocks You can display data blocks in the following views:
• declaration view or
• data view .

New Block You use the “STL”, “LAD”, “FBD” buttons to select the language in which you want
to write a new block.
Multi-instance function blocks are discussed in an advanced p
programming
g g course.

Training Center ST-7PRO1


for Automation and Drives Page 21 Editing Blocks
Status Fields When you monitor the status of a block in STL, only the status fields you activate in
thi dialog
this di l bbox will
ill b
be di
displayed.
l d
The following options are available:
• Status Bit The status bit is displayed.
• RLO The result of logic operation (RLO) is displayed.
• Standard Status A timer word, counter word or the contents of ACCU 1 are
displayed - depending on the operation used.
• Address The address registers are used with indirect addressing.
Registers *)
• Accumulator 2 The contents of ACCU 2 are displayed.
• DB Registers *) The contents of the relevant data block register are
displayed.
• Indirect * ) This display is only possible with memory-indirect
addressing.
• Status Word The status word is displayed.
• Default The “Default” button selects the standard system setting for
the Status field.
The status bit, RLO and standard status are displayed.
• Activate New Breakpoints Immediately
This option is only relevant for the the test function
“Breakpoint”.
Note*) The topics “Indirect Addressing” , “DB Registers” and the structure of the status
word are discussed in an advanced programming course.

Training Center ST-7PRO1


for Automation and Drives Page 22 Editing Blocks
Layout Here you select the print format:
• DIN A4 Portrait
• DIN A4 Landscape
• maximum size.

Width of Address You can set the limit for the maximum number of characters in an address name
Field to a number between 10 and 24. This changes the width of the program element in
LAD and FBD. With symbolic representation, a line break takes place according to
the Width of Address Field.

Element The program elements can be displayed in different ways:


Representation • 2-dimensional or
• 3-dimensional.

Line/Color You use this box to choose how you want the following to be displayed
• Selected Element (color)
• Contacts (line)
• Status Fulfilled (color and line)
• Status Not Fulfilled (color and line)

Type Check When you edit a block, the type of address entered in bit logic instructions is always
checked.
You can deactivate the Type Check for Addresses for comparisons, mathematical
operations etc. ( for experienced users only! ).

Training Center ST-7PRO1


for Automation and Drives Page 23 Editing Blocks
Generate When you modify blocks and save them, the reference data is automatically
R f
Reference D
Data
t updated,
d t d if th
the “G
“Generate
t Reference
R f D
Data"
t " option
ti ini the
th “Create
“C t Block"
Bl k" tabt b is
i
checked.
If this option is not checked, the reference data is not updated at first. But the next
time you open the “Displaying S7 Reference Data" window, you must decide
whether you want to update the reference data and for which blocks.
Note: The topic "Reference Data" is discussed in detail in the Chapter
“Troubleshooting".

Include The "Include


Include System Attribute S7
S7_server
server" option is only relevant in conjunction
System Attribute... with a process control system (PCS7) and is not dealt with in this course.

Store Process The "Store Process Diagnostics Data" option is only relevant when using the
Diagnostics Data "PDIAG" option package and is not dealt with in this course.

Training Center ST-7PRO1


for Automation and Drives Page 24 Editing Blocks
Note Compiling source code blocks is discussed in more detail in the Chapter “Functions
and
dFFunction
ti BlBlocks".
k "

Training Center ST-7PRO1


for Automation and Drives Page 25 Editing Blocks
Note Here you select the structure of the symbol selection list.
Y can activate
You ti t and d deactivate
d ti t the
th display
di l off th the lilistt when
h you make
k entries
t i using
i
the menu options View -> Display ->Symbol Selection in the Program Editor.
If the Symbol Selection is activated, a list with the current symbols from the symbol
table is displayed when you enter variables in LAD and FBD. In the list that is
displayed, the symbol is marked that is best suited to the character chain at the
cursor position. It can be accepted by pressing the Return key.

Training Center ST-7PRO1


for Automation and Drives Page 26 Editing Blocks

Das könnte Ihnen auch gefallen