IEC 61131 Standard
In 1992, the International Electrotechnical Commission (IEC) published the first edition of the IEC 61131 standard, with the aim of establishing standards for programmable controllers. This standard has been divided into several chapters, enabling the definition of criteria for each of the topics related to PLCs.
The chapters are as follows:
• 61131-1 – General information about PLCs.
• 61131-2 – Hardware requirements
• 61131-3 – Programming languages.
• 61131-4 – User orientation guide.
• 61131-5 – Communication.
This standard defines that, for a PLC to be in accordance with the standards established by it, it must have less than graphic languages and text languages for programming. Thus, and consensus among the current manufacturers work with the following languages:
• Textuals:
IL – Instruction List.
ST – Structured Text.
• Graphics:
LD – Ladder Diagram.
FBD – Function Block Diagram.
A fifth way to program some market devices is the SFC - Sequential Function Chart is the graphical sequencing of functions, which has elements to organize programs sequentially and also allows parallel control of processes.
Between these programming languages, some parameters are defined so that there really is certain compatibility between the equipments. These parameters can be set as:
a) Data - The standard predicts the following types of data:
• Bit group: binary value group (on/off).
BOOL: 1 bit.
BYTE: 8 bits.
WORD: 16 bits.
DWORD: 32 bits.
LWORD: 64 bits.
• Integers: integer and real numbers.
SINT: short integer (1 byte).
INT: integer (2 bytes).
DINT: double integer (4 bytes).
LINT: long integer (8 bytes).
U: undefined (add a U character to the type of integer to be used).
• Real: floating point, that is to say, it considers fractional in the use of the number according to IEC 559 (1982).
REAL: 4 bytes.
LREAL: 8 bytes.
• Time: duration of timers and processes.
• Date and time of day.
DATE: calendar date.
TIME_OF_DAY: local time.
DATE_AND_TIME: local date and time.
• String: characters that can be exposed in single installments - normally for the transmission of ASCII (American Standard Code for Information Interchange) characters to other devices.
WSTRING: allow the sending of several strings.
ARRAYS: multiple values stored in the same variable.
SUB RANGES: set value limits for data entry or exit - for example, signals from 4 to 20 mA.
b) Variables - They can be of the type:
• Global: It serves the entire program and not necessarily only a part of it.
• Local: only part of the program.
• I/O mapping: allocation of all inputs and outputs in relation to the predefined memory positions.
• External: assignment defined exclusively as data entry and exit points.
• Temporary: used momentarily during the execution of part of the program.
c) Configuration - Hardware resources and specific links for data processing and programs.
• Resources: memory reserve or processing indexes for certain part of the program.
• Tasks: they can continue parallel, being executed simultaneously by the PCU.
• Programs: they can be executed cyclically, at every certain period or when a certain event occurs.
d) Organization of program units - Defined by the basic functions, basic blocks and possibility of creating functions and blocks according to the need for programming.
• Standard functions such as: ADD, SQRT, SIN, COS, GT, MIN, MAX, AND, OR, among others.
• Custom functions: field in which the programmer can create functions or use more than one pre-existing function for the creation of another function in its programming.
• Function blocks: patterns equal to those presented in the functions, only in block language.
• Custom blocks: field for the elaboration or use of more than one pre-existing function in the creation of blocks. They can also be composed of blocks sold by other manufacturers or specialized companies.
• Programs: specific programs and subroutines. They can be stored in functions or blocks created by the programmer and used more than once in the current application or later in other programs.
e) External links - Opens space for the IEC 61131-5 chapter, which deals specifically with the communication formats and facilities that the standard determines as necessary for the compatibility with the standard.
Ladder Programming Language
Ladder was one of the first languages destined to the programming of PLCs, created to allow technicians and engineers of the automation area with knowledge of relay logic and none of programming managed to program the PLC. For this reason, it became the most popular language among programmers.
Basic directives
The variables associated with the elements of input, output, memory, timers and counters are called operands. The program runs logical and arithmetic operations with these operands.
In the Ladder language, the lines of contacts (instructions) have the appearance of stair steps, which can be associated with a structure of columns and lines, as shown in the image below. In each line, the instructions correspond to the program, that is, the operands process, and the result and assigned to another operating in the "Output" block, to the right.
The number of rows and columns or elements and associations that each rung supports varies according to the PLC manufacturer and may also vary according to the CPU used. In general, these limits do not represent a concern to the user in the development of the application program, because, if the limit is exceeded, the programming software presented an error message during the compilation of the program.
The operands can be divided into three classes:
• Memory (M) – They are used for storing partial results, constant values, transmission data, reference values, recipes, etc.
These operands can be freely read and written by the program.
• Inputs (I) – They are associated to the input modules. They can be read by the program, but written only by the input modules.
• Outputs (Q) – They are associated with the output modules. They can be freely read and written by the program.
The operands, in turn, are divided, initially, into five types, according to their use and number of bits:
• Bits (X) – Used for logic implementation, occupy 1 bit of memory.
• Bytes (B) – Used for the storage of ASCII characters, they occupy 8 bits.
• Words (W) – Used for storing integer numerical values, they occupy 16 bits.
• Double word (D) – Like the W type, it occupies 32 bits.
• Word long (L) of 64 bits – Like the W type, it occupies 64 bits.
Originally, in the Ladder language each instruction corresponded to the NO or NC contacts of the relays, whose status is defined by the value of the operand (of type B) associated with it. At the same time, the outputs were the coils (operandotype B). Over time, the instruction blocks began to contemplate counters, timers, arithmetic operations, etc., which demanded that the types of operands mentioned above be created.
Ladder Diagram Language
The operation of the CLP is based on a set of instructions known as a program, developed to address user routines. The signals from the sensors or transducers coupled to the machine or equipment are applied to the controller inputs. In each cycle, called scanning or scanning, there are three stages:
• Input stage – All signals coming from external media and applied to the inputs are read and transferred to a CLP internal memory unit zone, called an input image table.
• Program stage - The program is executed using the signals acquired during the input stage and deciding what the values of the digital and analog output signals will be. These values are stored in a memory region called the output image. During program execution, the output signals are not modified unless high priority inputs are activated. These entries are used for emergencies, which are not They can wait for the end of scanning. In that case, we interrupt the work of the CLP, executing a program that addresses interruption. After the interruption service, we return to the main program.
• Output stage – All output values set by the program and stored in the output image are applied to the output modules.
At the end of the three steps, the scan cycle is restarted, with the input step (cyclic operation). In some situations, for example, when using PID controllers, it becomes necessary to make the signal acquisitions (input step) at fixed intervals. In this case, at the end of the exit stage, the PLC waits for the predetermined instant to restart the scan (periodic operation).
There are several programming languages for PLC, which, using a set of symbols, blocks, figures, commands, etc., allow the programmer to manifest the relationships between the inputs and outputs of the PLC.
In the current generation of PLC, high-level languages are used, which have a series of predefined programming instructions. This approximates the high-level languages of human language, thus facilitating the work of the programmer. The so-called low-level programming languages, or in machine language, require greater skill of the programmer, which will need a good understanding of the hardware of the equipment, programming bit by bit, as is the case of assembly language.
The Ladder language reproduces the structure of an electrical diagram, in which the combination of open contacts, corresponding to the inputs, will allow to energize a certain load, which corresponds to the output.
Depending on the proximity of the Ladder language with the logic of Relays, widely used before the emergence of PLCs, this has become one of the most used languages by PLC manufacturers.
Basic instructions in Ladder
The basic or fundamental instructions in the Ladder language are:
NO Contact: normally open; The following image shows the NA contact instruction on stairs, as well as the electrical circuit and the correspondent digital logic.
Note that in the NO Contact instruction, the status of the digital output is identical to that of the digital input. So, when I1 is high level, output Q1 will be activated; and when I1 is at the low level, output Q1 is disabled. The following image shows the PLC installation circuit.
NC Contact: normally closed; The following image shows the NA contact instruction on stairs, as well as the electrical circuit and the correspondent digital logic.
Note that, in the NF Contact instruction, the state of the digital output is inverse to that of the digital input. therefore, when I1 is at a high level, output Q1 is disabled; and when I1 is at a low level, output Q1 is activated.
AND: The image shows the AND function in Ladder, as well as the electrical circuit and the corresponding digital logic.
Note that, in function E, the status of the digital output depends on the combination of the digital inputs. therefore, when I1 and I2 are simultaneously at a high level, output Q1 will be activated; and, when either of the inputs, or both, are down level, the Q1 output will be deactivated. The following image shows the CLP installation circuit for the program.
OR: The image shows the staircase OU function, as well as the electrical circuit and the corresponding digital logic.
Note that, in the OU function, the status of the digital output depends on the combination of the digital inputs. therefore, when I1 or I2, or both, are at a high level, output Q1 will be activated; and, only when I1 and I2 are simultaneously at a low level, will we have output Q1 disabled.
SET Instruction
This function forces the status of a memory or a PLC output to be activated. The following image shows the SET function in Ladder.
Note that, in the SET function, the status of the digital output depends on information from the digital input. When input I1 is high, output Q1 is high. Note that, even when I1 input returns to a low level, output Q1 will remain at a high level, necessarily using another function to deactivate the output.
RESET Instruction
This function forces the status of a memory or a PLC output to be deactivated. The following image shows the RESET function in Ladder.
Note that, in the RESET function, the status of the digital output depends on information from the digital input. When I2 input is high, Q1 output will be low.
Note that when input I2 returns to a low level, output Q1 will remain at a low level.
Positive Edge Contact Instruction
This instruction generates a pulse in the output associated with it. The pulse has the period of 1 scan (controller cycle) and starts when the input passes the logic level "0" to "1".
A program that uses this type of instruction can be seen in the following image.
The state diagram of the positive edge input (I0.0) and the simple output (Q0.0) demonstrates the application of this instruction. Observe, when the input (I0.0) and activated, or in the step of the logic level "0" to "1", a pulse with a duration of 1 scan appears in the output associated with that input. In the descent, in the passage of the logical level "1" to "0", nothing happens at the exit.
Negative Edge Contact Instruction
The negative edge contact instruction generates a pulse in the output associated with it. This pulse has the period of 1 scan and starts when the input goes from the logical level "1" to "0".
A program that uses this type of instruction can be seen in the following image.
The state diagram of the negative edge input (I0.0) and the simple output (Q0.0) demonstrates the application of this instruction. Note that, when the input (I0.0) and activated, nothing happens; however, when disconnected, in the step of the logical level "1" to "0", a pulse with a duration of 1 scan appears on the output associated with that input.
Counters
A counter aims to activate a memory or an output memory after a certain event count. The following image shows the instruction and symbology of the meter, according to IEC 1131-3.
Note that, in the counter instruction, input I1 receives pulses from external keys or sensors, sending to counter C1. In the program, C1 was parameterized for 4 accounts. After C1 receiving 4 pulses (four energies / de-energizations), the NO contact of the C1 counter closes, activating the output Q1.
The counter can be increasing, decreasing or even ascending descending (up/down). For the last purpose, the counter block is composed too much of an entry that will count down, according to the following image.
It is observed that I1 makes the account growing, I2 the account and I3 triggers the reset. The following image shows the diagram of counter times up/down.
After completing the counting cycle (4 counts), Q1 is activated, regardless of the state of I1. The output Q1 can be deactivated by resetting counter C1.
Timers
This function is intended to activate or switch off a memory or an output according to a programmed time.
It is important to note that the timers have several modes of operation, such as delay in energization, delay in de-energization, memorizable delays, etc.
The following image shows the timer instruction with its respective symbology, according to IEC 1131-3.
Next, the most basic timing modes will be displayed.
a) Delay in energization
When the timer is set for delay in (Timer On), the Q1 output will be activated a certain time after the I1 input is set high, it is turned off for 5 seconds. When I1 input is at a high level, it activates T1 timer element (parameterized in the program to 5s). After 5 seconds, the timer contact is closed by activating Q1 output.
In the image below we have the time diagram of the timer with delay energization.
Note that if the high level time of input I1 is shorter than the timer setting, Q1 output will not be triggered. Thus, for Q1 output to be triggered, it is necessary that the I1 input remains at a higher level for longer than parameterized T.
It notes, moreover, that in the delayed mode of energization, when you enterI1 there is a level drop, Q1 output turns off immediately.
b) Delay in de-energization
When the timer is set to Timer Off, Q1 output will activate immediately when input I1 is at a high level, however, when input I1 is level, Q1 output will remain triggered for time. parameterized T. In the image below we have the timer time diagram with delay on power off, where is the delay time on Q1 de-energization.
The other timing modes basically start from these two types of delay, whose configurations vary depending on the CLP.
Comparison
In programming, it is often necessary to compare two values. For this, the comparison instructions can be used. The comparators use two operands, which can be byte, word or constant. The program is carried out with operands 1 and 2 (image below). If the values meet the comparison condition and the comparator input is enabled, the comparator output will be activated, thus enabling the system output.
The comparisons that can be made are: equal, greater than, less than, greater than or equal to, less than or equal to and different.
Equal to (=)
The following image shows the comparison instruction equal to (=) in Ladder diagram.
In this example, when input I0.0 is enabled, we will have the comparison between operand 1 and operand 2. If they are equal, the result will be a logical level "1" the output will be activated. If they are different, the result will be logical level "0" and the output will turn off.
Greater than (>)
The following image shows the instruction program greater than (>) in Ladder diagram.
In this example, when input I0.0 is enabled, it will have the comparison between operand 1 and operand 2. If operand 1 is greater than operand 2, the result will have logic level "1" and the output will be activated. If operand 1 is less than operand 2, the result will have logic level "0" and the output will be turned off.
Less than (<)
The following image shows the less than instruction program that (<) in Ladder diagram.
In this example, when input I0.0 is enabled, it will have the comparison between operand 1 and operand 2. If operand 1 is smaller than operand 2, the result will have logic level "1" and the output will be activated. If operand 1 is greater than or equal to it, operating 2, the result will have logic level "0" and the output will be turned off.
Greater or equal to (≥)
The following image shows the instruction program greater than or equal to (≥) in Ladder diagram.
In this example, when input I0.0 is enabled, it will have the comparison between operand 1 and operand 2. If operand 1 is greater than or equal to operand 2, the result will have a logical level "1" and the output will be will activate. If operand 1 is smaller than operand 2, the result will have a logical level "0" and the output will be turned off.
Less than or equal to (≤)
The following image shows the instruction program less than or equal to (≤) in Ladder diagram.
In this example, when input I0.0 is enabled, you will have the comparison between operand 1 and operand 2. If operand 1 is less than or equal to operand 2, the result will be a logical level "1" and the output will be will activate. If operand 1 is greater than operand 2, the result will be logical level "0" and the output will turn off.
Different from (≠)
The following image shows the program of the different comparison instruction (≠) in Ladder diagram.
In this example, when input I0.0 is enabled, it will have the comparison between operand 1 and operand 2. If the operands are different, the result will have a logical level "1" and the output will be activated. If operand 1 is equal to operand 2, the result will have a logical level of "0" and the output will turn off.
Mathematical operations
These instructions have the function of performing arithmetic operations between two operands, placing the result in a response operand called RES.
Sum (+)
When this instruction and enabled by means of input (E), it is executed to added operands (OPR1 + OPR2), placing the result in RES, as shown in the following image.
When the input is enabled, the sum of the two operands or constants is executed and, consequently, the value passes to a third operand. Operating 1 and operating 2 are the values that will be added. The allowed addresses are: bytes, words and constants. The result is the operand that will receive the result of the sum.
Subtraction (–)
When this instruction and enabled through input (E), the subtraction of the operands (OPR1 - OPR2) is executed, placing the result in RES, as shown in the image below.
Operating 1 is the value from which the value of the second operand will be subtracted and, consequently, the result passes to a third party operating. Operating 2 is the value that will be subtracted from the first operand. The allowed addresses are: bytes, words and constants.
The result is the operand that will receive the result of the subtraction. The allowed addresses are: bytes and words
Multiplication (×)
When that instruction and enabled through the input (E), the multiplication of the operands (OPR1 × OPR2) is executed, placing the result in RES, as shown in the image below.
When the input is enabled, there is the execution of the multiplication of the two operands and, consequently, the value passes to a third operand. Operating 1 and operating 2 are the values that will be multiplied. The allowed addresses are: bytes, words and constants.
The result is the operand that will receive the result of the multiplication. The allowed addresses are: bytes and words.
Division (÷)
When this instruction is enabled by means of input (E), division of operands (OPR1 ÷ OPR2) is performed, placing the result in RES as a image below.
When the entry is enabled, if you have the division of the division of the operands and, in consequence, the value goes to a third operating. Operating 1 and operating 2 are the values that will be divided. Allowed directions are son: bytes, words and constants.
The result is the operand that will receive the result of the division. Allowed types are: bytes and words.
Special Instructions
CALL
The special function CALL is changing in the following image.
When this instruction is enabled, the program runs the subroutine indicated in CALL, after the ejecución, back to the same point of the program that called the subroutine.
JUMP
The JUMP special function changes in the following image.
When this instruction is enabled, the program, when going through the instruction, jumps to the subroutine indicated in JUMP. In this instruction, there is no return to the routine that was running; The program continues in the indicated subroutine.
MOVE
The following image shows the special MOVE function.
This instruction has two variables: MOV0 (origin) and MOV1 (destination). When input I0.0 passes from logic level "0" to "1", the MOVE instruction is enabled, transferring the value contained in variable MOV0 (origin) to variable MOV1 (destination).
Next Unregistered user. Buy the training at jats.com.br.