Sei sulla pagina 1di 21

TRAINING MODULE PROGRAMMING IN STEP 7

Control Desk Solutions Pvt. Ltd. [Training Unit]

BASIC OF PROGRAMING
STEP 7
Document Ref: CDSPLTRG_S700E002_100

Version History:

Serial Version Highlights Version No Date


1. First release 1.0.0 21/12/2015

Document Ref: CDSPLTRG_S700E002_100 Page 1 of 21 21-Dec-15


TRAINING MODULE PROGRAMMING IN STEP 7
Control Desk Solutions Pvt. Ltd. [Training Unit]

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.

Document Ref: CDSPLTRG_S700E002_100 Page 2 of 21 21-Dec-15


TRAINING MODULE PROGRAMMING IN STEP 7
Control Desk Solutions Pvt. Ltd. [Training Unit]

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

Document Ref: CDSPLTRG_S700E002_100 Page 3 of 21 21-Dec-15


TRAINING MODULE PROGRAMMING IN STEP 7
Control Desk Solutions Pvt. Ltd. [Training Unit]

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.

1.2 General PLC architecture

Document Ref: CDSPLTRG_S700E002_100 Page 4 of 21 21-Dec-15


TRAINING MODULE PROGRAMMING IN STEP 7
Control Desk Solutions Pvt. Ltd. [Training Unit]

2. The SIMATIC Manager


2.1 Starting the SIMATIC Manager and Creating a Project

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.

Within the project, data


are stored in the
Form of objects in a
hierarchical structure

The SIMATIC station and the CPU


contain the configuration and
parameter data of the hardware

The S7 program comprises all the


blocks with the programs necessary
for controlling the machine

Document Ref: CDSPLTRG_S700E002_100 Page 5 of 21 21-Dec-15


TRAINING MODULE PROGRAMMING IN STEP 7
Control Desk Solutions Pvt. Ltd. [Training Unit]

2.2 Create a new project


Step1: Navigate to File > New

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

Document Ref: CDSPLTRG_S700E002_100 Page 6 of 21 21-Dec-15


TRAINING MODULE PROGRAMMING IN STEP 7
Control Desk Solutions Pvt. Ltd. [Training Unit]

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.

Then follow the detail steps in STEP7 BASIC MANUAL, CHAPTER 2.

Document Ref: CDSPLTRG_S700E002_100 Page 7 of 21 21-Dec-15


TRAINING MODULE PROGRAMMING IN STEP 7
Control Desk Solutions Pvt. Ltd. [Training Unit]

3. Prepare symbol table


3.1 Absolute Address

Every input and output has an absolute address predefined by the hardware configuration.

The below figure depicts the absolute address of an exemplary hardware.

Document Ref: CDSPLTRG_S700E002_100 Page 8 of 21 21-Dec-15


TRAINING MODULE PROGRAMMING IN STEP 7
Control Desk Solutions Pvt. Ltd. [Training Unit]

3.2 Symbolic Address

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.

Step1: Navigate to Symbol table as depicted in snap below.

Step2: Symbol table will open then edit the symbol table as required.

Document Ref: CDSPLTRG_S700E002_100 Page 9 of 21 21-Dec-15


TRAINING MODULE PROGRAMMING IN STEP 7
Control Desk Solutions Pvt. Ltd. [Training Unit]

Note: The above table is only for example real symbol table has no concurrence with the example
here.

Document Ref: CDSPLTRG_S700E002_100 Page 10 of 21 21-Dec-15


TRAINING MODULE PROGRAMMING IN STEP 7
Control Desk Solutions Pvt. Ltd. [Training Unit]

3.3 Types of addresses

Siemens uses the following types of addresses

1. Digital Input (I/E)


2. Digital Output (Q/A)
3. Analog Input (PIW/IW)
4. Analog Output (PQW/QW)
5. Memory Address (M)
6. Data Block Addresses (DB)

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.

Document Ref: CDSPLTRG_S700E002_100 Page 11 of 21 21-Dec-15


TRAINING MODULE PROGRAMMING IN STEP 7
Control Desk Solutions Pvt. Ltd. [Training Unit]

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.

Document Ref: CDSPLTRG_S700E002_100 Page 12 of 21 21-Dec-15


TRAINING MODULE PROGRAMMING IN STEP 7
Control Desk Solutions Pvt. Ltd. [Training Unit]

4.2 Programing objects

Siemens programing software consists of some basic objects. User can program using those
objects.

Following are the objects

1. Organization Block (OB)


2. Function (FC)
3. Function Block (FB)
4. Data Block (DB)

Organization Block (OB)

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.

Document Ref: CDSPLTRG_S700E002_100 Page 13 of 21 21-Dec-15


TRAINING MODULE PROGRAMMING IN STEP 7
Control Desk Solutions Pvt. Ltd. [Training Unit]

However user can change the OBs execution time interval & their priority from hardware
configuration. Following are the steps

Step1: Open Hardware configuration from step7 home page.

Step1: Right click on CPU and go to object properties.

Document Ref: CDSPLTRG_S700E002_100 Page 14 of 21 21-Dec-15


TRAINING MODULE PROGRAMMING IN STEP 7
Control Desk Solutions Pvt. Ltd. [Training Unit]

Step3: Go to Cyclic Interrupts tab.

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 Block (FB)

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.

While calling a FB a DB should be specified. Its act as static variable storage.

Data Block (FB)

Document Ref: CDSPLTRG_S700E002_100 Page 15 of 21 21-Dec-15


TRAINING MODULE PROGRAMMING IN STEP 7
Control Desk Solutions Pvt. Ltd. [Training Unit]

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.

Please check the CPU manual for detail.

4.3 Programming
In Step7 there are 3 basic programing languages.

Document Ref: CDSPLTRG_S700E002_100 Page 16 of 21 21-Dec-15


TRAINING MODULE PROGRAMMING IN STEP 7
Control Desk Solutions Pvt. Ltd. [Training Unit]

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.

Following is the standard program window for any type of programing.

Programing with LAD

LAD stands for LADDER. In LAD programing program looks like as follows

Document Ref: CDSPLTRG_S700E002_100 Page 17 of 21 21-Dec-15


TRAINING MODULE PROGRAMMING IN STEP 7
Control Desk Solutions Pvt. Ltd. [Training Unit]

Programing with STL

STL stands for STATEMENT LIST. In STL programing program looks like as follows

Programing with FBD

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.

Document Ref: CDSPLTRG_S700E002_100 Page 18 of 21 21-Dec-15


TRAINING MODULE PROGRAMMING IN STEP 7
Control Desk Solutions Pvt. Ltd. [Training Unit]

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.

To change view User can follow the bellow step

4.4 Call Function in OB


To execute any function FC/FB is should be called in either of execution OB. Following are the
steps to call a function/subroutine in an execution OB. Example here is with OB1 only
however user can do the same for any OB of his/her choice.

Document Ref: CDSPLTRG_S700E002_100 Page 19 of 21 21-Dec-15


TRAINING MODULE PROGRAMMING IN STEP 7
Control Desk Solutions Pvt. Ltd. [Training Unit]

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.

Programing with STL

Following are the steps to create program in STL.

Step1: Give a title of block and comment for the network.

Step2: Type the logic with standard syntax of STL.

Step3: Save the Logic.

Document Ref: CDSPLTRG_S700E002_100 Page 20 of 21 21-Dec-15


TRAINING MODULE PROGRAMMING IN STEP 7
Control Desk Solutions Pvt. Ltd. [Training Unit]

Programing with FBD

Following are the steps to create program in FBD.

Step1: Give a title of block and comment for the network.

Step2: Insert an AND box (&) and an assignment (=)...

Step3: Enter Address or Symbol name.

Step3: Save the Logic.

Document Ref: CDSPLTRG_S700E002_100 Page 21 of 21 21-Dec-15

Potrebbero piacerti anche