Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
BASIC OF PROGRAMING
STEP 7
Document Ref: CDSPLTRG_S700E002_100
Version History:
Preface
This document is developed for Basic of Step-7 user or learner. Before reading this document
user or learner must have basic knowledge of SIMENS PLC & its architecture. User of this
document should have sufficient knowledge about SIEMES PLC programing and should be
familiar with STEP7 programing software.
The document is prepared in reference to the Siemens standard manuals & literatures and
practical experience. Snap shots used in this manual are taken from real time software Step7 V5.5
+ SP2.
Pictures & screen shots used in this document is from an example project which may vary from
user actual program.
Table of Contents
1. Introduction to Step7 ................................................................................................................................. 4
1.1 What You Will Learn ....................................................................................................................... 4
1.2 General PLC architecture .............................................................................................................. 4
2. The SIMATIC Manager................................................................................................................................ 5
2.1 Starting the SIMATIC Manager and Creating a Project ..................................................... 5
2.2 Create a new project ....................................................................................................................... 6
2.3 Hardware configuration ................................................................................................................ 6
3. Prepare symbol table .................................................................................................................................. 8
3.1 Absolute Address ............................................................................................................................. 8
3.2 Symbolic Address............................................................................................................................. 9
3.3 Types of addresses ....................................................................................................................... 11
4. Creating a Program ................................................................................................................................... 12
4.1 Structure of the program ........................................................................................................... 12
4.2 Programing objects ...................................................................................................................... 13
4.3 Programming .................................................................................................................................. 16
4.4 Call Function in OB ....................................................................................................................... 19
5. Example......................................................................................................................................................... 20
5.1 Binary Logic example 1 .............................................................................................................. 20
1. Introduction to Step7
1.1 What You Will Learn
Using practical exercises, we will show you how easy it is to program in Ladder Logic,
Statement List, or Function Block Diagram with STEP 7. Detailed instructions in the individual
chapters will show you step-by-step the many ways in which you can use STEP 7.
The SIMATIC Manager is the central window which becomes active when STEP 7 is started.
The default setting starts the STEP 7 Wizard, which supports you when creating a STEP 7
project. The project structure is used to store and arrange all the data and programs in order.
Step2: Provide the name of the Project & the storage location of the project. You can select
the storage path by click on the Browse button.
Note: Type of the project should be Project. The other type is Library. If you choose library
then the project will be library type, which means you can’t make hardware configuration
only you can write program. This type is only used to store the standard functions for
iterative use in different program.
2.3 Hardware
configuration
Right Click on the Project you have created in the Step7 home window. Then go to Insert New
Object.
Depending upon your hardware choose the option SIMATIC 300 Stations, SIMATIC 400
Stations or SIMATIC H Station.
Every input and output has an absolute address predefined by the hardware configuration.
All absolute addresses are represented by a meaning full process oriented symbolic name.
In the symbol table, you should assign a symbolic name and the data type to all the absolute
addresses which you will address later on in your program. These names apply to all parts of
the program and are known as global variables.
Step2: Symbol table will open then edit the symbol table as required.
Note: The above table is only for example real symbol table has no concurrence with the example
here.
First four types are direct hardware address, i.e. the address of the signal modules we
configured in the hardware.
Note: For analog addresses if the address area resides within process image area then user
should use IW/QW elsewise PIW/PQW. Here P signifies peripheral.
Memory addresses are internal to the CPU and the amount of memory address depends upon
the CPU.
Data block addresses are program registers user must define the register before using it in the
program.
4. Creating a Program
4.1 Structure of the program
All CPUs S7 300/400 have predefined call structure according to which user should write
program to make it executable by CPUs.
By means of CPUs internal Operating System (OS) all CPUs checks OB1 (Organization Block)
first in beginning of each execution cycle. Execution cycle is a periodic time. This varies from
CPU to CPU.
Except OB1 there are several time interval OBs and Hardware interrupt OBs. For detail of
those user can refer to Siemens website or manual.
Siemens programing software consists of some basic objects. User can program using those
objects.
As discussed earlier OBs are CPUs internal operation block. In general all Siemens CPUs have
OB1 (Cyclic Execution) which is called in each scan of CPU program.
There are others certain time interval OBs which are called in periodic time interval. Below
time line depicts the call sequence.
However user can change the OBs execution time interval & their priority from hardware
configuration. Following are the steps
Here all OBs supported by particular CPU are highlighted. You can change priority and
execution time.
Note: Change of standard settings need expertise knowledge. Wrong settings can lead to CPU
misbehavior. Please refer to help file by clicking help button at the bottom of the window.
Function (FC)
Functions are like a subroutine without static memory. Only local variables are assigned to it
as per CPU properties. Amount of local variable is dependent on the type of CPU. Therefore
when a function is called user must supply the all parameters where it is called.
Function blocks are like a subroutine with static memory. Along with local variables FBs are
accompanied by static variables. Amount of static variables is depended on user program.
Data blocks are actually register variables. The numbers of DB can be used in program and
length of a single DB is depended on CPU type.
4.3 Programming
In Step7 there are 3 basic programing languages.
1. LAD
2. FBD
3. STL
In all 3 types user can write program directly in OBs like OB1, OB35, OB36 etc. or user can
write specific subroutine in FC or FB and call them to desired OB. However the standard
programing practice suggests writing subroutine and then calling it in desired OB.
LAD stands for LADDER. In LAD programing program looks like as follows
STL stands for STATEMENT LIST. In STL programing program looks like as follows
FBD stands for FUNCTION BLOCK DIAGRAM. In FBD programing program looks like as
follows
User can choose either of the languages to write the program. It is also possible user can
choose multiple languages.
It is also possible to change the view to either of them. But sometimes it may happen that all
codes won’t get changed to desired view.
5. Example
5.1 Binary Logic example 1
The programming examples in the Getting Started manual are based, among other things, on
three fundamental binary logic operations.
The first binary logic operation, which you will program later on, is the AND Function. The
AND function can be best illustrated in a circuit diagram using two Keys.