Siemens 6AV6651-7KA01-3AA4 - S7-1200 + KTP400 Basic Starter Kit 6AV6651-7KA01-3AA4 Manuel D’Utilisation

Codes de produits
6AV6651-7KA01-3AA4
Page de 364
Programming made easy 
 
6.2 Easy-to-use programming languages 
 
Easy Book 
96
 
Manual, 03/2014, A5E02486774-AF 
6.2.3 
SCL overview 
Structured Control Language (SCL) is a high-level, PASCAL-based programming language 
for the SIMATIC S7 CPUs. SCL supports the block structure of STEP 7. You can also 
include program blocks written in SCL with program blocks written in LAD and FBD.  
SCL instructions use standard programming operators, such as for assignment (:=), 
mathematical functions (+ for addition, - for subtraction, * for multiplication, and / for division). 
SCL uses standard PASCAL program control operations, such as IF-THEN-ELSE, CASE, 
REPEAT-UNTIL, GOTO and RETURN. You can use any PASCAL reference for syntactical 
elements of the SCL programming language. Many of the other instructions for SCL, such as 
timers and counters, match the LAD and FBD instructions.  
Because SCL, like PASCAL, offers conditional processing, looping, and nesting control 
structures, you can implement complex algorithms in SCL more easily than in LAD or FBD. 
 
The following examples show different expressions for different uses: 
"C" := #A+#B; 
Assigns two local variables to a tag 
"Data_block_1".Tag := #A; 
Assignment to a data block tag 
IF #A > #B THEN "C" := #A; 
Condition for the IF-THEN statement 
"C" := SQRT (SQR (#A) + SQR (#B)); 
Parameters for the SQRT instruction 
As a high-level programming language, SCL uses standard statements for basic tasks:  
●  Assignment statement: := 
●  Mathematical functions: +, -, *, and / 
●  Addressing of global variables (tags): "<tag name>" (Tag name or data block name 
enclosed in double quotes) 
●  Addressing of local variables: #<variable name> (Variable name preceded by "#" symbol) 
●  Absolute addressing: %<absolute address>, for example %I0.0 or %MW10 
Arithmetic operators can process various numeric data types. The data type of the result is 
determined by the data type of the most-significant operands. For example, a multiplication 
operation that uses an INT operand and a REAL operand yields a REAL value for the result.  
6.2.4 
SCL program editor 
You can designate any type of block (OB, FB, or FC) to use the SCL programming language 
at the time you create the block. STEP 7 provides an SCL program editor that includes the 
following elements: 
●  Interface section for defining the parameters of the code block 
●  Code section for the program code 
●  Instruction tree that contains the SCL instructions supported by the CPU 
You enter the SCL code for your instruction directly in the code section. The editor includes 
buttons for common code constructs and comments. For more complex instructions, simply 
drag the SCL instructions from the instruction tree and drop them into your program. You can 
also use any text editor to create an SCL program and then import that file into STEP 7.