Professional Documents
Culture Documents
What is a Program
A Program is a user developed series of instructions or commands that directs the PLC to execute actions. A Programming Language provides rules for combining the instructions so that they produce the desired actions. The latest standard (IEC 61131-3) has tried to merge plc programming languages under one international standard. We now have PLCs that are programmable in function block, instruction lists, C and structured text Various Programming Languages are, Ladder Logic Function Block Structured Text Instruction List. Sequential Function Chart
The most commonly used Programming Language is LADDER LOGIC Ladder Logic is evolved from electrical ladder diagrams, which represents how electrical current flows thru the devices to complete an electrical circuit. The Ladder logic programming language is an adaptation of an electrical relay wiring diagram, also known as ladder diagram. Ladder Logic is a graphical system of symbols and terms even those not familiar with relay wiring diagram can easily learn it.
Ladder Logic
Each electrical circuit in the diagram is considered a rung. Each Rung must be connected to Power Line on Left side. Each Rung must contain at least one control instruction on Extreme Right Side. Every rung has two components It contains at least one device that is controlled It contains the condition(s) that control the device.
Ladder Logic
Connecting Objects
All contacts can be connected in sequence (AND-BOOL) All contacts can be connected in parallel (OR-BOOL) All contacts can be connected in both, parallel and sequence
Instruction List (IL) is a low level textual language which has a structure similar to a simple machine assembler. The IEC has developed IL by reviewing the many low level languages offered by PLC manufacturers. IL provides a wide range of operators that represent those most commonly found in proprietary instruction list languages of current day PLCs
Understanding IL
logical (AND...), arithmetic (ADD...), compare (GT...) operations and assignments (ST, S, R). Jumps within a section unconditioned / conditioned (JMP / JMP C, JMP CN) Functions and function blocks unconditioned / conditioned (CAL / CAL C, CAL CN)
Before invoking an FFB, it has to be declared using VAR and END_VAR. Each FFB instance must be invoked once. FFB-call:
with CAL and a list of input parameters or with CAL and Load/Save of the input parameters or by using the input operators.
Understanding IL Operators
Operator Modifier
Operand / Significance
Loads the value of the operand into the Accumulator Literal, variable, direct address from data type ANY Saves the value of the Accumulator in the operand Literal, variable, direct address from data type ANY Sets the operand to 1 if the Accumulator content is 1 Literal, variable, direct address from data type BOOL Sets the operand to 0 if the Accumulator content is 1 Literal, variable, direct address from data type BOOL Logic AND Logic OR Logic exclusive OR Addition Subtraction Multiplication Division Compare : > Compare : = Compare : <> Compare : < Jump to label FBNAME (name of instance) Invoking a FFB Executing a function Literal, variable, direct address (data type is subject to function) Editing reset operations
LD
ST
S R AND OR XOR ADD SUB MUL DIV GT EQ NE LT JMP CAL FUNCNAME )
Understanding IL Rules
When entering keywords, separators and comments, there is an immediate spell check If a keyword, a separator or a comment is detected, it is identified with a color shading. If unauthorized keywords (instructions or operators) are entered, this will be identified through color shading as well. Spaces and tabs have no effect on syntax, they can be used anywhere.
Comments FFB-Declaration
FBDs use data flow from left to right through function blocks Inputs and outputs can be inverted Function blocks can have variable argument list sizes When arguments are left off default values are used
Understanding FBDs
Execution order Value Passed without declaring Programmer Selected Instance Name
Output can be linked to multiple inputs Variable Passed by linking and declared
Basic Counters
Understanding ST
Statements must close with semicolons (;) One line may contain several statements, separated by (;)
Understanding ST Statements
The following statements are available:
VAR ... END_VAR Function Block Calls IF ... THEN ... END_IF ELSIF ... THEN Declaration of FFB's Invoking of FFBs Conditioned execution of statements Conditioned execution of statements, if the preceded expression is not fulfilled (false). Execution of statements, if expressions of preceded statements are not fulfilled (false). A list of statements with given labels. Execution, if the label is true. Repeated execution of statements up to a given number. Repeated execution of statements up to preceded condition = 0. Repeated execution of statements up to succeeded condition = 0. To terminate repeat statements (FOR, WHILE, REPEAT) before the end condition is true.
ELSE ...
CASE ... OF ... END_CASE FOR ... TO ... BY ... DO ... END_FOR WHILE...DO...END_WHILE REPEAT ... UNTIL ... END_REPEAT EXIT
Understanding ST - Operators
Operators are generic, i.e. they automatically adjust to the data type of the operand. The evaluation of an expression consists of applying the operators to the operands in the order defined by the rule of precedence of the operators.
The operator with the highest rule of precedence in an expression will be executed first.
Operators with the same precedence are executed from left to right, as described in the expression.
Understanding ST Operators
Operator
() FUNCNAME **
NOT ANY_BIT * / MOD + <
Operand
Expression ANY REAL, ANY_NUM ANY_NUM Complement ANY_NUM or TIME ANY_NUM ANY_NUM
ANY_NUM or TIME ANY_NUM or TIME ANY_ELEM
Significance
Bracketing Function editing (call) Raising to a power Negation
Multiplication Division Modulo Addition Subtraction Less than
Precedence
1 (highest) 2 3 4 4 5 5 5
6 6 7
>
< = ANY_ELEM > = ANY_ELEM = <> &, AND
ANY_ELEM
Less or equal Greater or equal ANY_ELEM ANY_ELEM ANY_BIT
Greater than
7 7 Equality Inequality Logic AND
8 8 9
XOR ANY_BIT
OR ANY_BIT
Logic exclusive OR
Logic OR
10
11
Comment FFB-Declaration AND-Function with Allocation FFB call with Allocation AND-Function with Allocation FFB call with Allocation
A Sequential Function Chart is a graphic method of representing a sequential control system by using a sequence of steps and transitions. Each step is a command or action that is either active or inactive. The flow of control passes from one step to the next through a conditional transition that is either true or false.
Step
S_2_1
SFC - Elements
Jump
S_2_1
Transition
Alternative Branch
Parallel Branch
Alternative Joint
Parallel Joint
Understanding SFC
SFC Rules
1. A Sequential Flow Chart section must have an Initial Step and only one Initial Step.
Understanding SFC
A step becomes active when the prior transition has been satisfied
A step becomes inactive when the succeeding transition has been satisfied AND the step delay time has elapsed.
None, one or multiple actions, with qualifiers, can be declared for each step.
A supervision time can be defined for each step.
Understanding SFC
SFC - Elements: The Transition A transition is the condition that transfers control from one step to another. Only transitions following active steps are solved / evaluated. When a transition is True on the next scan: The preceding step(s) is deactivated The following step(s) is activated The True transition between the steps is no longer solved The transition following the new active step is solved
Understanding SFC
SFC - Elements: The Jump The jump allows the program to continue from a different location. A jump can be used in two ways: sequence jump sequence loop
SFC Example
Start
Programming Example
Objective
Here, we want the fill motor to pump lubricating oil into the tank until the high level sensor turns on. At that point we want to turn off the motor until the level falls below the low level sensor. Then we should turn on the fill motor and repeat the process. Here we have a need for 3 I/O (i.e. Inputs/Outputs). 2 are inputs (the sensors) and 1 is an output (the fill motor). Both of our inputs will be NC (normally closed) fiber-optic level sensors. When they are NOT immersed in liquid they will be ON. When they are immersed in liquid they will be OFF.
PLC
Oil Tank
Motor
Drain
Design
Here we have a need for 3 I/O (i.e. Inputs/Outputs). 2 are inputs (the sensors) and 1 is an output (the fill motor). Both of our inputs will be NC (normally closed) fiber-optic level sensors. When they are NOT immersed in liquid they will be ON. When they are immersed in liquid they will be OFF.
Input Address :
PLC
Oil Tank
Motor
Motor : 0500
Drain
K1-1
Low High
K1-2
Aux. Contactor K1
Motor Contactor
0000
0001
1000
1000
Temp. Bit
Motor
1000
0500
Program Scan
1st Scan Start 1st Scan Complete
0000 1000
0001
1000
0000 1000
0001
1000
1000
0500
1000
0500
Motor 0500
Program Scan
2st Scan Start 2st Scan Complete
0000 1000
0001
1000
0000 1000
0001
1000
1000
0500
1000
0500
Motor 0500
Program Scan
X Scan Start X Scan Complete
0000 1000
0001
1000
0000 1000
0001
1000
1000
0500
1000
0500
Motor 0500
Program Scan
X+1 Scan Start X+1 Scan Complete
0000 1000
0001
1000
0000 1000
0001
1000
1000
0500
1000
0500
Motor 0500
Questions . . .? ? ? ?