Posts

Showing posts from 2020

IEC61131-3 coding rules and guidelines series - Part1: Variable naming

Image
Every programming language has its own coding rules and guidelines. Industrial Automation programming is no different.  However, documentation covering Industrial automation programming coding rules and best practices is very few. The software in the industrial environments becomes more and more important, the software projects become larger, and the costs of errors increase.  In order to deal with the complexity of larger programs, a modern approach to software development processes should be followed supporting a structured approach.  Also, we need to increase the efficiency in coding via re-use of pre-defined functionalities and to help better understand the program over the life cycle. The aim of this series is to share the coding guidelines and rules that are based on IEC61131-3 standard and based on my 16 years of experience deploying automation solutions throughout different market sectors. Part1: Naming rules for variables 1.1 Physical addresses to be avoided

Introduction to IEC61131-3 programming languages

Image
IEC 61131-3 is set to standardize programming languages for industrial automation that is independent of any platform brand or automation vendor IEC 61131-3 is the third part of the IEC 61131 family which consists of nine parts as follows: Part 1: General Overview Part 2 Equipment Requirements & Tests Part 3 Programming Languages Part 4 User Guidelines Part 5 Communications Part 6 Functional Safety Part 7 Fuzzy Control Programming Part 8 Application Guidelines Part 9 Communication Interface IEC 61131-3 defines five programming languages for industrial automation: Ladder Diagram (LD) Function Block Diagram (FBD) Structured text (ST) Instruction List (IL) Sequential Function Chart (SFC) Even though ladder diagram (LD) was initially developed for programmable logic controllers (PLC) and Function block diagram (FBD) was originally developed for distributed control system (DCS), a PLC is no longer limited to Ladder Diagram (LD) and DCS is not limited to fun

Introduction to sequential function chart (SFC)

Image
The Sequential Function Chart (SFC) is the basic design tool for sequential control applications.  The IEC 61131-3 SFC language is derived from the IEC 848 function chart  standard.  SFC describes graphically the sequential behavior of a  control program Elements of a sequential function chart The general form of the function chart is shown below. The function chart has  the following major parts: Steps of the sequential operation Transition conditions to move to the next step Actions of each step Initial step The initial step is indicated by the double-line rectangle. The initial step is the initial state of the program when the controller is first powered up or when the operator resets the operation. Steps The steps of the operation are shown as an ordered set of labeled steps (rectangles) on the left side of the diagram. Unless shown by an arrow, the progression of the steps proceeds from top to bottom. Transition conditions The tr

Introduction to Instruction List (IL)

Image
The Instruction List (IL) language defined by IEC 61131-3 is a low-level language comparable to the assembly language programming of microprocessors.  The IL  language has a set of instructions to handle variable assignment, conditional statements,  simple arithmetic, and function block calling.  The IL and ST languages share many of  the same elements. Namely, the definition of variables and direct physical PLC  addresses are identical for both languages. Instructions As illustrated below table, an instruction list is composed of a sequence of instructions.  Each instruction shall begin on a new line and shall contain an operator with optional modifiers, and, if necessary for the particular operation, one or more operands separated by commas.  Operands can be any of the data representations for variables. The instruction can be preceded by an identifying label followed by a colon (:).  A comment, if present, shall be the last element on a line. Empty lines c

Introduction to structure text (ST)

Image
The Structured Text (ST) language defined by IEC 61131-3 is a high-level language whose syntax is similar to Pascal. In general, ST is useful for implementing calculation intensive  functions and other functions that are difficult to implement in the other  languages. The ST language has a complete set of constructs to handle variable  assignment, conditional statements, iteration, and function block calling. Expressions An expression is a construct which, when evaluated, yields a value corresponding to one of the data types. Expressions are composed of operators and operands. An operand shall be a, a variable, a function invocation, or another expression. The operators of the ST language are summarized in below table.  The evaluation of an expression consists of applying the operators to the operands in a sequence defined by the operator precedence shown in below table.  The operator with highest precedence in an expression shall be applied first, followed by the

Introduction to function block diagram (FBD)

Image
The Function Block Diagram (FBD) language is graphical programming  language complying with IEC61131-3 An FBD is a set of interconnected blocks  displaying the flow of signals between blocks. It is similar to a ladder logic diagram,  except that function blocks replace contact and coils are the output of function blocks. Elements of function block diagram A typical function block diagram is composed as follows: Horizontal and vertical lines Functions and function blocks Variables Parametrization Below is a sample of a FBD program: The “&” block is a logical AND block, and the >=1 block is a logical OR block.  The number of  inputs for each block can be increased.  The circle at the lower input of the rightmost &  block is a logical inversion, equivalent to the NC relay contact.  The FBD  has an implicit feedback path, because the EX101 output of the rightmost & block is  also an input to the leftmost & block. The EX101 variable is called