FBD/LD/IL

A combined editor enables programming in the languages FBD (Function Block Diagram), LD (Ladder Diagram) and IL (Instruction List).

The basic unit of FBD and LD programming is a network. Each network contains a structure, which can represent the following: A logical or arithmetic expression, the call of a programming block (function, function block, program etc.), a jump, or a return statement. IL does not actually require networks. However, in TwinCAT an IL program also consists of at least one network, to support conversion to FBD or LD. An IL programs should therefore also be structured with networks in mind.

See also:

Function Block Diagram (FBD)

Function Block Diagram is a graphical IEC 61131 programming language. It uses a list of networks. Each network contains a structure, which may contain logical and arithmetic expressions, function block calls, a jump, or a return statement.

The function blocks that are used are familiar from Boolean algebra. Function blocks and variables are linked with connecting lines. The signal flow in the network is from left to right. The signal flow in the editor is from top to bottom, starting with network 1.

Example:

FBD/LD/IL 1:

Ladder Diagram (LD)

Ladder Diagram (LD) is a graphical programming language, which is based on the principle of electrical circuit diagrams.

Ladder Diagram is suitable for configuring logical control circuits, and it can also be used for creating networks, similar to FBD. LD is therefore well suited for controlling calls of other program blocks.

Ladder Diagram consists of a series of networks. A network is limited on the left by a vertical line (busbar). A network contains a circuit diagram consisting of contacts, coils, optional function blocks (POUs) and connecting lines. On the left side of the network there is a contact or a series of contacts, which pass on the state ON or OFF the from left to right, corresponding to the Boolean values TRUE and FALSE. Each contact is associated with a Boolean variable. If this variable is TRUE, the state is passed on from left to right via the connecting line. Otherwise OFF is passed on. In this way, the coils in the right part of the network are assigned the value ON or OFF from the left part. Accordingly, the value TRUE or FALSE is written to in the Boolean variables assigned to them.

If the elements are connected in series, this corresponds to a logical AND link. If they are connected in parallel, it corresponds to a logical OR link. A line through an element indicates negation of the element. Negation of an input or output is indicated by a circle symbol.

Example:

FBD/LD/IL 2:

IEC 61131-3 defines a full LD instruction set, consisting of various types of contacts and coils. Contacts conduct current from left to right (according to their type). Coils store the incoming value. Contacts and coils are assigned Boolean variables. They can complement an LD network through jumps, backward jumps, markers and comments.

Instruction List (IL)

Instruction List is an IEC 61131-compliant programming language that is similar to Assembler. It supports accumulator-based programming.

An Instruction List (IL) consists of a series of statements. Each instruction starts in a new row and contains an operator and one or several comma-separated operands, depending on the type of operation. An instruction may be preceded by a marker, followed by a colon. The marker is used to identify the instruction and can be used as jump destination. A comment has to be the last element in a line. Empty lines can be added between instructions.

All IEC 61131-3 operators are supported, as well as multiple inputs, multiple outputs, negations, comments, setting/resetting of outputs and conditional/unconditional jumps.

Each instruction is primarily based on the loading of values into the accumulator (LD instruction). The corresponding operation is then executed with the parameter from the accumulator. The result of the operation is written back into the accumulator, from where it should be stored in a specific location via an ST instruction.

Instruction List supports comparison operators (EQ, GT, LT, GE, LE, NE) and jumps for programming conditional execution or loops. Jumps can be unconditional (JMP) or conditional (JMPC / JMPCN). For conditional jumps the program checks whether the value in the accumulator is TRUE or FALSE.

Example:

FBD/LD/IL 3: