Programming Language
Programming Language
SIMATIC S7 in compliance
with the IEC 61131-3
standard?
Unrestricted © Siemens 2020 siemens.com/controller
4
3 SIMATIC Programming with S7-Graph
5
4 Hand-on experience
5
6
5 Q&A
6
4
3 SIMATIC Programming with S7-Graph
5
4 Hand-on experience
5
6
5 Q&A
6
4
3 SIMATIC Programming with S7-Graph
5
4 Hand-on experience
5
6
5 Q&A
6
What is S7 – SCL ?
1
1.1
2
4
1.3 Compile and test
5
1.4 Source code generation
6
What is S7 – SCL ?
1
1.1
2
4
1.3 Compile and test
5
1.4 Source code generation
6
3630.0 3630.0
5290.0 5290.0
6383.0 6383.0
9215.0 9215.0
13195.0 13195.0
Code in LAD for S7-1200 Code in STL for Solution in SCL for
S7-300/400 S7-300/400
S7-1200 AND S7-1200/1500
WinAC
S7-300
S7-1500
S7-400 S7-1200 WinAC
S7-300
S7-400
What is S7 – SCL ?
1
1.1
2
4
1.3 Compile and test
5
1.4 Source code generation
6
result := expression ;
Example: switch_on := manual_on OR auto_on;
All assignments, control operations and calls are ended by ;
Combination Description Operator
Assignment Assignment :=
Parenthesis (Statement) (,)
Binary logic Negation NOT
AND AND, &
OR OR
Exclusive-OR XOR
Comparison Less than, less than or equal to, greater than, greater than or <, <=, >, >=,
equal to, equal, not equal to =, <>
Arithmetic Plus, minus (sign) +,-
Addition, Subtraction +,-
Multiplication, Division *, /, DIV,
Exponentiation MOD
**
Unrestricted © Siemens 2020
SCL in STEP 7
Direct addressing (Example)
Symbolic
„<DB-Symbol>“.<Variable-Name> „Motor“.Sollwert
addressing
In the SCL-Editor, inputs, outputs and Bit memory are always Symbolic
Example:
S7-1200
Controler S7-300
WinAC
S7-1500
S7-400
PEEK POKE
When a Rising edge is detected on the input CLK , the output Q returns signal status 1
R_TRIG CLK
Local Q
When a falling edge is detected on the input CLK , the output Q returns signal status 1
F_TRIG CLK
Local Q
Keyword Functionality
IF Condition_1 THEN
Statements_1;
ELSIF CONDITION_2 THEN STL
Statements_2;
ELSE
Last_Statements;
END_IF;
SCL
Example of use
CASE- Instruction:
STL
CASE Selection_Variable OF
CONST_1: Statements;
…..
CONST_n: Statements;
…..
SCL
ELSE
Statements;
END_CASE;
FOR Loop
START_VAR, END_VAR
For START_VAR TO END_VAR BY STEP_WIDTH DO und
Statements; STEP_WIDTH can have
END_FOR; either Data type INT or
DINT
REPEAT
WHILE Condition DO Statements;
Statements; Condition has data type
UNTIL Condition; BOOL
END_WHILE; END_REPEAT;
For a better performance, Loop index should be from a 32 Bits data type.
STL SCL
SCL
CONTINUE Instruction:
For i:= 0 TO 10 DO
After Continue, the control variable is
IF #Request THEN Continue;
incremented by the specified increment
END_IF;
immediately.
Buffer[#i] := #Value+#i;
END_FOR;
EXIT Instruction:
For i:= 0 TO 10 DO
Buffer[#i] := #Value+#i; Execution of the program is continued after the
IF #Error THEN EXIT; end of the loop (FOR Loop).
END_IF;
Further Statements…
END_FOR;
GOTO Instruction(Example):
IF #Error THEN
GOTO MARKE ; GOTO causes an immediate jump to the specified
END_IF; label and therefore to a different statement within
Further Statements the same block.
MARKE:
#Status := W#16#8081;
IF #Done THEN
RETURN exits the currently active block (OB, FB,
RETURN;
FC) and returns to the calling block
END_IF;
Further Statements
Input parameters are with := and output parameters with => typified.
STL SCL
FC without Return value
FC
FC with return value
Input parameters are with := and output parameters with => typified.
STL SCL
Calling FB as a single instance
FB Calling FB as a multi-instance
What is S7 – SCL ?
1
1.1
2
4
1.3 Compile and test
5
1.4 Source code generation
6
Functions:
▪ Created in the folder
„Watch tables“
▪ Adding tags via Drag & Drop from:
▪ Data blocks Show / hide modify columns
▪ Tag tables
Modify tags
▪ Program blocks
Monitor all
Current Position 3
3. Activate breakpoints
1. Set breakpoint with double click or Only online possible/ Test modus will be automatically
right mouse click activated
Live demo
▪ Online view of the project tree
▪ Monitoring blocks
▪ Break points
▪ Watch tables
▪ Forcing of inputs and outputs
What is S7 – SCL ?
1
1.1
2
4
1.3 Compile and test
5
1.4 Source code generation
6
My_program.SCL
My_program.SCL
External SCL source files can be easily imported into TIA Portal!
1 Import external
source file
Select .SCL File.
Also source files
from STEP 7 V5.x
3
Generate blocks from
source file
4
3 SIMATIC Programming with S7-Graph
5
4 Hand-on experience
5
6
5 Q&A
6
S7-GRAPH-sequence:
bottling plant for fruit juice
Action:
Step: transport for mixing Activate conveyer belt
(Output Q0.0)
Transition:
Mixer reached
(Input I0.0)
Action:
Step: Mixing Activate Mixer for 10s
(Output Q0.1)
Conveyer belt is empty
(I0.1) and step Mixing is
11s active
Action:
Step: Transport to „Bottling“ Activate conveyer belt
(Output Q0.2)
Bottling reached
(Input I0.2)
2.1 Introduction
2
2.2 Handling
3
4
2.3 Elements
5
2.4 Actions
5
6
5
2.5 Compile and Test
6
2.1 Introduction
2
2.2 Handling
3
4
2.3 Elements
5
2.4 Actions
5
6
5
2.5 Compile and Test
6
Definition
The actions to be executed are defined
S1 within the individual steps. There are
Transport Step
transitions between the steps. These contain
conditions for advancing to the next step.
T1 Step
Transition Steps consist of Actions which are carried
Trans
out when the step becomes active
Transition
S2 Transitions are located between the steps
Filling Step
and contain the conditions for advancing to
the next step
2.1 Introduction
2
2.2 Handling
3
4
2.3 Elements
5
2.4 Actions
5
6
5
2.5 Compile and Test
6
Programming
Editor features
language
Favorite bar
Function block
Components of a new
S7-GRAPH block
Advantages:
▪ The S7-GRAPH block cannot be overwritten in the language STL unlike STEP 7 Classic!
Permanent post-
instructions
Sequence view
Single step
▪ Steps
▪ Transitions
▪ Jumps
▪ Branches
▪ Sequence ends
▪ Interlock
▪ Supervision
▪ Actions (step) Single Step
▪ Conditions (transition)
▪ Activate messages
▪ Acknowledge necessary
▪ Alarm properties
Activate alarms
Acknowledge at HMI
Alarm properties
Properties of
alarms
Select Supervision
or Interlock …
… open properties…
… add individual
alarm text
Unrestricted © Siemens 2020
Handling
Alarms in HMI
Create Alarm classes
2.1 Introduction
2
2.2 Handling
3
4
2.3 Elements
5
2.4 Actions
5
6
5
2.5 Compile and Test
6
A transition:
Exclusive OR branch
Add alternative
branch
▪ Consist of several parallel
branches
▪ Branch
A jump
Jump
▪ Is the transit of a transition to any step
▪ within the sequence
▪ within a sequence of the same
function block
Permanent post-
The results can be used for instructions
several transitions in case of
often used conditions
2.1 Introduction
2
2.2 Handling
3
4
2.3 Elements
5
2.4 Actions
5
6
5
2.5 Compile and Test
6
▪ Activate/Deactivate other
steps of the sequencer
And consist of
▪ An interlock (optional)
▪ An event (optional)
▪ An identifier
▪ An operand, assignment or block
call
[C] S BOOL As soon as the step is active, the operand is set to “true”
[C] R BOOL As soon as the step is active, the operand is set to “false”
Constant/TIME/DWORD
Constant/TIME/DWORD
When the "TL", "TD", and "TF" timers are used, you must specify the duration. Use the following
syntax for this:
<Duration> = IWy, QWy, MWy, LWy, DBWy, DIWy; tag of type S5TIME or WORD; S5T#Constant
You have the option of linking an action with an event in order to make the execution of
the action dependent on certain conditions.
For actions with identifiers "D", "L", and "TF", the linking with events is not possible
S5 N Step 5
Step5
S1 Step 5
S0 Step 5
T5 Step 6 S1 S0
active
Trans5
Step 6
Not active
CPU cycles
S6
Step6
S5 N M0.0 Step 6 N
Step5 Step 6 S1
true
Step 5 N
Step 5 S0
T5
active
Trans5
Not active
CPU cycles
S6 N M1.0
Step6
true
During step transition are active:
T8 ▪ S0 of the predecessor
Trans8 ▪ S1 of the successor
▪ N of the successor
S2
Filling Step Within the steps, actions are formulated
Optional: Action will be only executed, if the
interlock condition is true.
2.1 Introduction
2
2.2 Handling
3
4
2.3 Elements
5
2.4 Actions
5
6
5
2.5 Compile and Test
6
Preferences for
Interface and DB
Compile in S7-300/400
and WinAC
automatically by
standard FC72/73
Semiautomatic Taskcard
„Testing“
Step mode
Manual mode
Active step
Transition satisfied
Synchronized step
Preferences for
synchronization
Before activation:
mark step
Unrestricted © Siemens 2020
Test of a S7-GRAPH sequence
Monitoring
Actions
Further test
properties
Transition
Supervision
triggered
Interlock triggered
4
3 SIMATIC Programming with S7-Graph
5
4 Hand-on experience
5
6
5 Q&A
6
S7-GRAPH-sequence:
bottling plant for fruit juice
Action:
Step: transport for mixing Activate conveyer belt
(Output Q0.0)
Transition:
Mixer reached
(Input I0.0)
Action:
Step: Mixing Activate Mixer for 10s
(Output Q0.1)
Conveyer belt is empty
(I0.1) and step Mixing is
11s active
Action:
Step: Transport to „Bottling“ Activate conveyer belt
(Output Q0.2)
Bottling reached
(Input I0.2)
4
3 SIMATIC Programming with S7-Graph
5
4 Hand-on experience
5
6
5 Q&A
6
Subject to changes and errors. The information given in this document only contains general descriptions and/or performance features which may
not always specifically reflect those described, or which may undergo modification in the course of further development of the products. The requested
performance features are binding only when they are expressly agreed upon in the concluded contract.
All product designations, product names, etc. may contain trademarks or other rights of Siemens AG, its affiliated companies or third parties.
Their unauthorized use may infringe the rights of the respective owner.
siemens.com