Anda di halaman 1dari 10

* KT On SCL BASICS

KISHORE RAJU P
Z003X84P

Unrestricted
* BASIC STRUCTURE OF SCL
PARAMETER… // Defining types of Blocks
Variables.//Defining variables
.
.
End _Variables
Begin SOP // operations to be carried
.
.
.
.
End_SOP
END_PARAMETER.

PARAMETER: Here Parameters are nothing but the types of blocks which we are going
to design(FB,FC,OB,DB..)
SOP: Sequence of Operation
Variables: types of variables which is required to execute the SOP
TYPES OF BLOCKS & STRUCTURES
 Function block (FB)  Data block (DB)
Structure Structure
FUNCTION_BLOCK fb_name DATA_BLOCK db_name
... ...
END_FUNCTION_BLOCK END_DATA_BLOCK

 Function (FC)
Structure  Shared data type (UDT)
FUNCTION fc_name : function Structure
type TYPE udt_name
... ...
END_FUNCTION END_TYPE
 Organization block (OB)
Structure
ORGANIZATION_BLOCK ob_name
...
END_ORGANIZATION_BLOCK
VARIABLES & BLOCK PARAMETERS
VARIABLES BLOCK PARAMETERS
Input parameters:
Static Variables:
these are the Parameters which will only accept
these are the variables whose values are the value when the particular block is called and is of
retained through out the blocks in project type Read_only.0
Defining static variables: Defining Input Parameters:
VAR_INPUT 
VAR     MY_DB : BLOCK_DB ;
RUN  :INT;     CONTROLLER : DWORD ;
MEASARR  :ARRAY [1..10] OF REAL;     TIMEOFDAY : TIME_OF_DAY ;
END_VAR
SWITCH  :BOOL;
Output Parameters:
END_VAR
Output parameters transfer the current output
Temporary Variables: values to the calling block. Data can be written to and
these are the variables whose values are read from them.
strictly confined to a particular function/case Defining Output Parameters:
in which these values are created/defined. VAR_OUTPUT  
    SETPOINTS: ARRAY [1..10] of INT ;
Defining Temporary Variables: END_VAR
VAR_TEMP In_Out Parameters:
  BUFFER 1 : ARRAY [1..10] OF INT ; In/out parameters adopt current input values
   AUX1, AUX2 : REAL ; when a block is called. After processing the value, they
END_VAR receive the result and return it to the calling block
Defining In_Out Parameters:
VAR_IN_OUT  
    SETTING : INT ;
END_VAR
DATA TYPES IN DEFINING VARIABLES
 A data type is the combination of value ranges and operations in a single unit.

Elementary Data Types Complex Data Types User Defined Data Types
 Bit Data Types  Date_and_time
These user defined types will
Ex:DATE_AND_TIME#1995-10-20-12:20:30.10
BOOL   1 bit DT#1995-10-20-12:20:30.10
be retained through out the
BYTE 8 bits  STRING programming out side the block but
Ex: VAR
where as the remaining data types
WORD 16 bits
     Text1    : String [123]; will not be able to do so.
DWORD 32 bits      Text2    : String;
END_VAR
 Character Types
The string will take a 254 characters and 2
CHAR 8 bits bytes for a block.
In text1 it will take 123 characters while in
 Numeric Types Text2 it will occupy total 254 characters.
INT 16 bits  ARRAY
DINT 32 bits Ex: VAR
    CONTROLLER1 :
REAL 32 bits     ARRAY[1..3,1..4] OF INT:= -54, 736, -83, 77,
                                  -1289, 10362, 385, 2,
 Time Types                                   60, -37, -7, 103 ;
    CONTROLLER2 : ARRAY[1..10] OF REAL ;
TIME (T) 32 bits END_VAR
DATE (D) 16 bits Here controller1 is a multi-Dimensional and
Controller2 is a one dimensional Array
TIME_OF_DAY (TOD) 32 bits
 STRUCT
S5TIME (S5T) 16 bits The STRUCT is a data type of consisting different
types of data types in a single area.
Ex: VAR
    MOTOR : STRUCT
         DATA : STRUCT
              LOADCURR : REAL ;
             VOLTAGE : INT := 5 ;
         END_STRUCT ;
     END_STRUCT ;
END_VAR
SHARED DATA
Memory Area of CPU Memory Area of Loadable
These are the areas where you no need to call These are the areas where you can call the certain
any of the memories/data you can access directly. blocks for the data usage.
Ex: inputs,outputs,in_out,Timers and Counters. Ex: data block
 There are three different types of addressing for  There are three different types of addressing for
sharing this CPU. sharing the data block
 Absolute Accessing  Absolute Accessing
EX: STATUSBYTE :=IB10; Ex: STATUSBYTE :=DB101.DB10;
STATUS_3 :=I1.1; STATUS_3 :=DB30.D1.1;
MEASVAL :=IW20; MEASVAL :=DB25.DW20;
Symbolic Addressing Indexed Accessing
Ex: Ex: STATUS_1:= DB11.DW[COUNTER];
MEASVAL_1 := Motor_contact_1; STATUS_2:= DB12.DX[WNO, BITNO];
Status_Motor1 := Input1 ; STATUS_1:= Database1.DW[COUNTER];
STATUS_2:= Database2.DX[WNO, BITNO];
Indexed Addressing STATUS_1:= WORD_TO_BLOCK_DB(INDEX).DW[COUNTER];
Ex: Symbolic Accessing
MEASVAL_1 :=IW[COUNTER]; Ex: RESWORD_A := DB10.Result.RES2;
OUTLABEL :=I[BYTENO, BITNO]; RESWORD_B := DB20.RES2;
RESWORD_C := DB30.RES2;
OPERATIONS & SYNTAX’S
Unary plus : (+)
Unary minus : (-) Power : (**)
Unary
Arithmetic
Multiplication : (*)
Assignment :( : = ) Division : (/)
Modulo function: (MOD)
Integer division : (DIV)
Addition : (+)
Subtraction : (-)
Basic Arithmetic

Less than : (<)


Greater than : (>)
OPERATIONS Less than or equal to : (<=)
Greater than or equal to : (>=)
Equal to : (==)
Not equal to : (<>)
Comparison
And : ( AND or &)
Exclusive or : ( XOR)
Or : (OR)
Negation : (NOT)
Logical

Parentheses : ( )
CONTROL STATEMENTS

Control Statement

It is used to terminate
the loop execution
Selective Loops Program
Statement Jump

IF CASE FOR WHILE REPEAT CONTINUE EXIT GOTO

CASE TW OF REPEAT
    1 :         ; FOR IF A > B THEN
  :   GOTO LAB1 ;
2: ; : : ELSIF A > C
ELSE: END_REPEAT ; : THEN
  : WHILE
Exit;   GOTO LAB2 ;
END_CASE ; : END_IF ;
End_FOR;
:
IF …… END_WHILE;
WHILE
THEN
    : FOR …. :
ELSIF   IF ….. :
   : THEN COTINUE;
ELSE    END_IF;
:
    : END_FOR;
END_WHILE
END_IF ; ;
STANDARD FUNCTIONS IN SCL-S7

Standard Functions

Data Type Conversion Numeric Standard Bit String Func String Processing Values Selecting

Syntax:
ROL(IN:=BYTE#
2#1101_0011,
N:=5);
 Zeros will
be replaced
while using
Shift
Operation
THANK YOU