SCE_EN_040-020_R1209_Startup Programming in High-Level Languages with S7-SCL and SIMATIC S7-300
Industry Sector, IA&DT
Suitable SCE trainer packages for these training curriculums
SIMATIC controllers
SIMATIC S7-300 with CPU 314C-2PN/DP
Order no.: 6ES7314-6EH04-4AB3
SIMATIC S7-300 with CPU 314C-2PN/DP (upgrade)
Order no.: 6ES7314-6EH04-4AB4
SIMATIC S7-300 with CPU 315F-2PN/DP
Order no.: ES7315-2FH14-4AB1
SIMATIC ET 200S with CPU IM151-8 F PN/DP
Order no.: 6ES7151-8FB00-4AB1
SIMATIC STEP 7 software for training
SIMATIC STEP 7 Professional V11 - Single license
Order no.: 6ES7822-1CC01-4YA5
SIMATIC STEP 7 Professional V11 - Classroom license (up to 12 users)
Order no.: 6ES7822-1AA01-4YA5
SIMATIC STEP 7 Professional V11 - Upgrade license (up to 12 users)
Order no.: 6ES7822-1AA01-4YE5
SIMATIC STEP 7 Professional V11 - Student license (up to 20 users)
Order no.: 6ES7822-1AC01-4YA5
Please note that these trainer packages may be replaced by successor trainer packages.
An overview of the currently available SCE packages is provided under: HUsiemens.com/sce/tpUH
Advanced training
Please get in touch with your regional SCE contact for information on regional Siemens SCE advanced training
siemens.com/sce/contact
Additional information regarding SCE
siemens.com/sce
Information regarding usage
This SCE training curriculum for the end-to-end automation solution Totally Integrated Automation (TIA) was
prepared for the program "Siemens Automation Cooperates with Education (SCE)" specifically for educational
purposes for public educational institutions and R&D facilities. Siemens AG does not make any guarantee
regarding its contents.
This document may only be used for initial training on Siemens products/systems. That is, it may be copied in
whole or in part and handed out to participants for use within the context of their education. Distribution and
reproduction of this curriculums and disclosure of its contents are permitted within public education and further
education institutions for educational purposes.
Any exceptions require written consent from the Siemens AG contact person: Mr. Roland Scheuerer
roland.scheuerer@siemens.com.
Offenders will be liable for damages. All rights reserved, including those relating to translation and in particular
those rights created as a result of a patent being granted or utility model being registered.
Use for industry customers is expressly prohibited. We do not consent to any commercial use of the training
curriculum.
We would like to thank Michael Dziallas Engineering and all those involved for their support in creating this
training curriculum.
2. Notes on S7-SCL Programming Language ................................................................................................ 6
3. The S7-SCL Development Environment .................................................................................................... 7
4. Example Task Tank Content ...................................................................................................................... 8
4.1 Description of task ...................................................................................................................................... 8
4.2 Assignment list / tag table ........................................................................................................................... 8
4.3 Program structure ....................................................................................................................................... 9
4.4 Interface of the block calculate_tankcontent [FC140] .............................................................................. 10
4.5 Note on solution ........................................................................................................................................ 11
5. Programming the Tank Content Calculation for SIMATIC S7-300 in S7-SCL .......................................... 12
5.1 Creating a project and configuring hardware ............................................................................................ 12
5.2 Creating a program ................................................................................................................................... 16
5.3 Test program ............................................................................................................................................ 23
5.4 Expanding the program ............................................................................................................................ 26
SCE_EN_040-020_R1209_Startup Programming in High-Level Languages with S7-SCL and SIMATIC S7-300
Industry Sector, IA&DT
Advanced functions for
PLC programming
Module 30
Basics of PLC
programming
Module 10, Module 20
PROFIBUS PROFINET
Module 60 Module 70
AS interface
Module 50
Safety technology
Module 80
Drive technology
Module 100
Process visualization
(HMI) Module 90
Sensor technology
Module 110
Plant simulation with
SIMIT Module 150
Other programming
languages
Module 40
1. Preface
The content of the SCE_EN_040-020 module is part of the 'Other Programming Languages' training
unit and represents a fast entry point for programming the SIMATIC S7 300 with the S7-SCL
programming language with the TIA Portal.
Learning objective:
This module describes the basic functions of the S7 SCL development environment. Test functions for
eliminating logical programming errors will also be shown.
Requirements:
To successfully work through this module, the following knowledge is required:
Proficiency in working with Windows
Basics of PLC programming with STEP 7 Professional V11 (e.g. modules 020- to 030-)
Basic information on programming in high-level languages, such as Pascal.
SCE_EN_040-020_R1209_Startup Programming in High-Level Languages with S7-SCL and SIMATIC S7-300
Industry Sector, IA&DT
1 PC
2 STEP 7 Professional
V11 (TIA Portal)
4 S7-300 with
CPU 315F-2 PN/DP
3 Ethernet connection
Required hardware and software
1 PC Pentium 4, 1.7 GHz 1 (XP) – 2 (Vista) GB RAM, approx. 2 GB of free hard disk space
Operating system Windows XP Professional SP3 / Windows 7 Professional / Windows 7
Enterprise / Windows 7 Ultimate / Windows 2003 Server R2 / Windows Server 2008 Premium SP1,
Business SP1, Ultimate SP1
2 Software: STEP 7 Professional V11 SP1 (Totally Integrated Automation (TIA) Portal V11)
3 Ethernet connection between the PC and CPU 315F-2 PN/DP
4 SIMATIC S7-300 PLC, e.g., CPU 315F-2PN/DP with 16DI/16DO signal module. The inputs must be
SCE_EN_040-020_R1209_Startup Programming in High-Level Languages with S7-SCL and SIMATIC S7-300
Industry Sector, IA&DT
2. Notes on S7-SCL Programming Language
S7-SCL (Structured Control Language) is a high-level programming language based on PASCAL, which
allows structured programming. The language corresponds to the SFC "Sequential Function Chart"
language specified in the standard DIN EN-61131-3 (IEC 61131-3). In addition to high-level
programming language elements, S7-SCL contains typical elements of the PLC such as inputs, outputs,
timers, bit memories, block calls etc. as language elements. It supports the block concept of STEP 7
and allows data blocks to be programmed according to standard as well as using STL, LAD and FBD. In
other words, S7-SCL supplements and extends the STEP 7 programming software with its LAD, FBD
and STL programming languages.
You do not have to create every function yourself. Instead, you can used already prepared blocks such
as system functions or system function blocks that are present in the operating system of the CPU.
Blocks that are programmed with S7-SCL can be mixed with STL, LAD and FBD. This means that a
block programmed with S7-SCL can call another block programmed in STL, LAD or FBD. In turn,
S7-SCL blocks can also be called in STL, LAD and FBD.
The test functions of S7-SCL allow searching for logical programming errors in an error-free compilation.
SCE_EN_040-020_R1209_Startup Programming in High-Level Languages with S7-SCL and SIMATIC S7-300
Industry Sector, IA&DT
S7-SCL for S7-300/400
Editor / compiler
Debugger
3. The S7-SCL Development Environment
To use and deploy S7-SCL there is a development environment that is oriented to specific features of
both S7-SCL and STEP 7. This development environment consists of an editor/compiler and a
debugger.
Editor / compiler
The S7-SCL editor is a text editor with which texts can be edited. The central task you use the editor for
is to create and edit blocks for STEP 7 programs. The syntax of the text you input with the editor is
checked thoroughly, making error-free programming simple. Syntax errors are displayed in various
colors.
The editor offers the following options:
- Programming a S7 block in the S7-SCL language.
- Convenient insertion of language elements and block calls using drag-and-drop operation.
- Direct syntax check during programming.
- Adjustment of the editor to your requirements by, for example, syntax-oriented coloring of the
various language elements.
- Checking of the finished blocks by compiling.
- Display of all errors and warnings that occur during compiling.
- Localizing of the faulty position in the block, optionally with description of error and information on
debugging.
Debugger
The S7-SCL debugger provides the option of checking how the program runs in the AS and thus finding
any possible errors.
S7-SCL offers two different test modes for this:
- Step-by-step monitoring
- Continuous monitoring
With "Step-by-step monitoring" the logical execution of the program is completed. You can execute the
program algorithm instruction for instruction and monitor in a result window how the processed tag
contents change during the process.
With "Continuous monitoring" you can test a group of instructions within a block. The values of the tags
and parameters are displayed in chronological order during the test run and - where possible - updated
cyclically.
SCE_EN_040-020_R1209_Startup Programming in High-Level Languages with S7-SCL and SIMATIC S7-300
Industry Sector, IA&DT
Name
Data type
Address
Comment
FillLevel_tank1
REAL
%MD40
in meters
Diameter_tank1
REAL
%MD44
in meters
Content_tank1
REAL
%MD48
in liters
4. Example Task Tank Content
4.1 Description of task
Our first program is one to program the calculate the content of tank.
The tank has the shape of an upright cylinder. The fill level of the content is measured by an analog
sensor. In the task, the value of the fill level should already existed standardized in the meter unit.
A function FC 140 'calculate_tank content' is to be programmed in the program. The diameter and the fill
level in meter unit are the passed parameters. Result is the tank content in the liter unit.
4.2 Assignment list / tag table
Because modern programming uses tags and not absolute addresses, the global PLC tags must be
defined here.
These global PLC tags are descriptive names with a comment for each input and output used in the
program. The global PLC tags can then be accessed later during programming via their names.
These global tags can be used in all blocks anywhere in the program.
SCE_EN_040-020_R1209_Startup Programming in High-Level Languages with S7-SCL and SIMATIC S7-300
Main organization
block [OB1]
Block called cyclically
by the operating
system. Here is the
call of the function
calculate_tankcontent
[FC140]
Function:
calculate_tankcontent
[FC140]
The actual program is
contained in this
example.
Is called by Main [OB1].
4.3 Program structure
Program execution is written in what are referred to as blocks. The Main [OB1] organization block is
provided as default. This block represents the interface to the CPU operating system and is
automatically called and cyclically processed by this operating system.
From this organization block, additional blocks can be called in turn for structured programming, such as
the function calculate_tankcontent [FC140]
This function is used to break an overall task down into subtasks. These can then be solved more easily
and tested in their functionality.