PLC Basic STEP7
PLC Basic STEP7
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
What is STEP 7?
STEP 7 is the programming software for SIEMENS PLC S7-300, S7-400, and C7.
STEP 7 provides you with the entire functionality required for configuring,
programming, and assigning parameters to S7-300, S7-400, and C7. The
programming software gives you effective support when solving your
automation task.
Symbols
Contacts
One of the most confusing aspects of PLC programming for the first-time users
is the relationship between the devices that controls a status bit and the
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
programming function that uses a status bit. Two of the most common
programming functions are normally open (NO) contact and normally closed
(NC) contact. Symbolically, power flows through these contacts when they
are closed. The normally open contact (NO) is true (closed) when the input or
output status bit controlling the contact is 1. The normally closed contact
(NC) is true (closed) when the input or output status bit controlling the
contact is 0.
If you structure the program in such a way that you want a scan result of “1”
when a sensor is activated, in order to combine that scan result further, you
must scan the input differently for different kinds of sensors. NO contacts and
NC contacts are available to you for this purpose. An NO contact returns “1”
if scanned input is also “1”. An NC contact returns “1” if scanned input is “0”.
In this way, you can also directly scan inputs that are trigger activities when
they are “0” (zero-active input) and subsequently re-gate the scan result.
Coils
Coil represents relays that are energized when power flows to them. When a
coil is energized, it causes a corresponding output to turn on by changing the
state of the status bit controlling that output to 1. That the same output status
bit may be used to control normally open and normally closed contacts
elsewhere in the program.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Boxes
The following steps below describe the calibration and parameters of a PC-
Adapter for a PC.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Choose ‘Select’
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
3. Select the desired module e.g. choose PC-Adapter and Install (→ PC-
Adapter → Install).
Choose ‘Install’
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Choose ‘Properties’
6. Set the COM-Port and the Transmission Rate of the serial interface.
COM-Port
Transmission rate
Note: The transmission rate must be suitably adjusted for the PC adapter!
Older PC adapters (PC/MPI cable) should only be processed with a slower
transmission rate of 19200 bits/sec.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
MPI-Address of the
PC/PG
9. After the values have been configured, double click on the SIMATIC
Manager icon (→ SIMATIC Manager).
10. The plug placed from the MPI interface of the PC will appear on the MPI
interface of the CPU and switch the voltage supply of the PLC on. The MPI
interface is found behind the front flap of the CPU in the form of a 9 pin D
sub socket.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
11. When the button - Accessible Nodes is clicked and all parameters
were correctly selected, the screen will display the following picture with
a folder for the reached MPI interface. The MPI-address of the CPU is also
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Accessible Nodes
You can start up the software quite simply by double-clicking on the icon
for the SIMATIC Manager, after double-clicking icon, the SIMATIC Manager
window will appear as shown example on the next page.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
SIMATIC Manager
The SIMATIC Manager is the entry point for programming with STEP 7. It shows
a hierarchical representation of all the objects in a project, which enable you
to access all the functions you require to solve your automation task.
Title bar - the title bar contains the window title and buttons for
controlling the window.
Menu bar - contains all the menus available for the current window.
Tool bar - contains the most frequently used tasks as symbols. These
symbols are self explanatory.
Task bar - the task bar contains all open applications and windows as
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Title bar
Menu bar
Tool bar
Programming exercise
Your task is to create an automation solution for a traffic light control system.
It will be easier for you if you acquire and understand the following basic
information
Introduction
The table below shows you the STEP 7 objects that you should know for TLIGHT
programming example.
You can see from the table which symbols are assigned to the individual
objects and what they mean:
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Creating objects
You create objects as projects via the menu command File → New… these
objects can in turn contain other objects, such as programs and blocks. You
can assign these via commands in the Insert menu. Blocks contain no further
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
objects. Opening a block starts the assigned editor with which you can then
edit the contents of the block.
Representing objects
You can change the representation of the objects and set the object
properties in various dialog boxes.
You can access to all the processing functions via STEP 7 objects:
With STEP 7, you can structure a system into project. A project contains the
entire database for an automation solution. Creating a project or a project
structure is therefore an essential prerequisite for working with STEP 7.
On the next page, you will find out how to create a project and a station for
the TLIGHT sample program.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Introduction
For the TLIGHT sample program, you need a project structure in which you
can store the relevant data for this control task.
You have already learned on the previous page what a project structure look
like. Now make one yourself.
Step 1
Result
The new project with the name ‘TLIGHT is displayed. You can now insert
objects.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Write ‘TLIGHT’
Confirm
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Step 2
2. Add a station to the open project with the menu command Insert →
Station → SIMATIC 300 Station.
In the project window, click on the “+” in front of the project symbol if
the station is not displayed.
Result
The station and its name are displayed in the project window.
You have now inserted a hardware station in the project “TLIGHT”.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Result
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Click the + symbol in front of the folder project TLIGHT, then SIMATIC 300
station is shown while on the right side of the window show the hardware icon
for the station. The result is shown below.
Shown above, the station and its name are displayed in the project window.
You have now inserted a hardware station in the project “TLIGHT”.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Prerequisites
Before you can enter a new configuration and assign parameters to the CPU
of your S7-300 or S7-400, you must have created a project and selected the
object that you want to configure (here, your SIMATIC 300 or 400 station).
To make sure that there are no ‘old’ blocks in your CPU, you should perform a
memory reset before downloading the new configuration to the CPU.
Basic procedure
We aim to show you the basic procedure for configuring and assigning
parameters using the TLIGHT sample program. The figure below gives you an
overview of this procedure:
Since we have already created the TLIGHT project, we can start right away
with the memory reset of our SIMATIC 300 or 400 stations.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Introduction
Before downloading our configuration data to the CPU, the S7-300 or 400
must perform a CPU memory reset to make sure that it does not contain any
‘old’ blocks.
Resetting the CPU Memory using the key switch located in front of the CPU
module.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Step 1
Click on the menu command PLC → Display Accessible Nodes or on the tool
bar click in the SIMATIC Manager and select the MPI address of your CPU
in the subsequent dialog box to established an online connection.
Result
An online connection to your CPU now exists.
Step 2
Display the current operating mode of your CPU, in the Accessible Nodes –
MPI window, click on the “ + “ in front of the Accessible Nodes Symbol, then
click MPI = 2 (directly). Click on the menu command PLC → Operating mode.
Result
The current mode of your CPU is displayed.
Step 3
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Set the CPU to STOP by clicking ‘Stop’ button and confirm with “yes”. Exit the
dialog box by clicking on “Close”.
Result
STEP 4
Call the “Memory Reset’ function with the menu command PLC →
Clear/Reset… and confirm.
The key switch on your CPU must be in the position “RUN-P” or “STOP”.
CPU 315-2 DP left without flash memory, right with flash memory
Result
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Each CPU possesses a code switch for the switching of the mode of
operation. Certain programmed functions are allowed depending upon the
position of the code switch. The following modes of operation are possible:
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
CPU 313C-2 DP left without flash memory, right with flash memory
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Rack 0
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Below are the hardware’s of SIEMENS PLC S7-300, which we will use as a
reference for the duration of this discussion.
Please pay attention to this ordering number which you will use during PLC
hardware configuration
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Please pay attention to this ordering number which you will use during PLC
hardware configuration
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
How do you configure and assign parameters to your S7-300 and S7-400?
STEP 1
Select the SIMATIC 300 station (1) in your project and call up the
configuration table with the menu command Edit → Open Object.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Result
The configuration table appears on the screen with the working window and
the “Hardware Catalog” window containing all the available modules. If the
hardware catalog is not displayed, you can open it with “Ctrl + K” of on the
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
STEP 2
In the hardware catalog, select the mounting rack via (1)SIMATIC 300 → (2)
RACK 300 → (3)RAIL and drag and drop it into the working window or double
click the rail icon. Afterwards, a configuration table for the structure of the
RACK 0 is blended in automatically.
Result
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Now all modules which are in the material rack can be selected and inserted
in the configuration table from the hardware catalog. To perform this action,
you must click on the indicator of the respective module, hold the mouse
button and drag & drop the item into the configuration table.
STEP 3
We will begin with the power supply PS 307 2A, first select first (1st) slot on
configuration table (highlighting that slot) then proceed with (→ (1) SIMATIC
300 → (2)PS-300 → (3)PS 307 2A).
Note:
If your hardware differs from what is shown, then you must select the
appropriate modules from the catalog and insert them into the rack.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Note:
The selected module can inserted in the slot by drag & drop method or by
double clicking the icon of the module selected.
We have selected the power supply PS 307 5A with the ordering number 6ES7
307-1EA00-0AA0 base on the hardware installed on the SIEMENS PLC S7-300.
For reference of PLC S7-300 please see page 32. Ordering number please see
Short information of the selected module on the same page.
The next page show the power supply module is inserted now in the first slot
of the configuration table.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
The PS 307 5A power supply module is inserted now in the first slot.
In the next step, we drop the CPU 315-2DP into the second (2nd) slot card
location. This allows for the part number and version of the CPU to be read
off.
→ SIMATIC 300 → (1) CPU-300 → (2) CPU 315-2DP → (3) 6ES7 315-2AF01-0AB0
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Showing CPU 315-2 DP inserted in the 2nd slot of the configuration table
The next step we drag the input module for 32 inputs into the fourth (4th) slot
card location.
Select 4th slot, digital input (→ (1) SIMATIC 300 → (2) SM-300 → (3) DI-300 →
(4) SM 321 DI32XDC24V).
Note:
Slot card location number 3 (3rd) is reserved for connection modules and
must always remain empty. The part number of the module is indicated in the
footer of the catalog.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
The next step we drag the output module for 32 inputs into the fifth (5th) slot
card location.
Select 5th slot, digital output (→ (1) SIMATIC 300 → (2) SM-300 → (3) DO-300
→ (4) SM 322 DO16XDC24V/0.5A).
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Once the configuration table slots are completed, click save and compile
icon to save the hardware configuration and click the download icon
to download the hardware configuration to PLC.
Save and compile sequence shown on the next page and following next
page show the download sequence.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Introduction
The function block has an assigned memory area. If a FB is invoked (call on),
a data block (DB) can be assigned to it. The data in this instance DB can be
accessed via calls out of the FB. A FB can be assigned to different DBs.
Further FBs and FCs in a function block can be called on via block call
instruction.
DBs are used in order to provide a memory location for the data variables.
There are two types of data blocks. Shared DBs in which all OBs, FBs and FCs
read the stored data or can write data into DB themselves and Instance DBs
that are assigned to a certain FB.
System modules are finished functions that are stored in the CPU. These
blocks can be call on by the user and utilized in the program.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Every CPU puts different system modules at the user’s disposal. Which ones
exactly can be taken from the STEP 7 reference manuals?
Basic procedure
Using the TLIGHT sample program, we aim to show you the basic procedure
for programming blocks.
Program an organization block (OB1) and a function (FC1) for the TLIGHT
sample program.
Step 1
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Open the TLIGHT project in the SIMATIC Manager with the menu command
File → Open → Project …
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
The project window for the TLIGHT sample program is opened offline.
Step 2
Open the folder of the TLIGHT project down to the lowest level by clicking on
“+” and select the “Blocks” folder.
Result
Step 3
Insert a function with the name FC1 using the menu command Insert → S7
Block → FC. In the dialog box which then appears, select the programming
language you require (LAD), and confirm with “OK”.
Result
FC1 and OB1 are displayed offline in the project window of the SIMATIC
Manager.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Result
FC1 and OB1 are displayed offline in the project window of the SIMATIC
Manager.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
You can change the language setting for a block using the View menu and
can switch between STL, LAD, and FBD.
- The variable declaration table of the block in the upper half and
- The code section of the block in the lower half of the window. This is
where you write your program.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Code Section
In the code section, you enter the program for your block as STL statements
or as LAD and FBD elements in networks. The incremental STL, LAD, and FBD
editor executes a syntax check immediately after each statement or element
is entered and displays any error in red italics. Any such syntax errors must be
corrected before saving the block.
In the TLIGHT sample program, the code section consists of several networks,
which in turn contain a list of statements or a circuit.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Prerequisite
You have created OB1 and FC1 as blocks and you have assigned the
incremental LAD editor as the language editor.
If you double-click on the FC1 which has already been programmed in the
SIMATIC Manager, the assigned LAD editor is started and you can program
the block.
Don’t worry. If you make any errors in entering the LAD statements, error
messages will bring them to your attention!
Step 1
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Result
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Step 2
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Step 3
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
For our TLIGHT sample program, a timer is needed as on-delay timer. This
called S_ODT and can be found in the catalog under the point Timers. (→
Timers → S_ODT)
Note:
In order to give a time to a timer, the following syntax must be used:
S5T# 5S
S5T# is the first format and directly after it the time (here 5 seconds) is
entered. The time can also be given as milliseconds (ms), minutes (m), and
hours (H). These units can also be indicated together (e.g. S5T#3M_3S)
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Step 4
Save the complete and correctly created FC1 with the menu command File
→ Save
Result
Step 5
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
After saving all the blocks were ready to download our user program to the
PLC.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Introduction
You cannot test your program until you have downloaded it to the CPU of
your PLC, example S7-300 or S7-400.
You can download either individual blocks or complete user program to the
CPU of your programmable logic controller. Only individual blocks can be
tested.
Basic procedure
We aim to show you the basic procedure for downloading and testing using
the TLIGHT sample program. The figure below gives a task-oriented overview:
Prerequisites
The following prerequisites must be fulfilled before you can download the
user program to your PLC.
- There must be an online connection between your programming
device and your PLC.
- The program to be downloaded must have been compiled without
errors.
- The CPU of your PLC must be in STOP state.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
To test individual blocks, you must always load OB1 with all the blocks called
in it. These blocks must be in reverse call order.
For the TLIGHT sample program, download the FC1 you have created and
the OB1 to your CPU.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________
After completing the downloading the user program or the created program
title “TLIGHT”, were ready to test the program on the PLC.
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________