PLCs (Programmable Logic Controllers), one of the indispensable elements of industrial automation, are one of the main tools used today to regulate and control complex production processes. PLC programming is the process of creating the instructions that determine the functioning of these intelligent devices. In this article, we will cover this important topic that forms the basis of PLC programming, with a special focus on the MODBUS RTU Master and MODBUS RTU Slave protocols utilized in the Mikrodev MP110 and MP211 PLC Series. Mikrodev’s wide range of programming features and especially the MODBUS protocol blocks offer various possibilities for multi-functionality and effective communication in industrial automation applications. Now let’s delve into the details of these specific topics.
What is PLC Programming?
PLC Programming is basically the creation of instructions that determine how a PLC will work. As we mentioned in our blog article titled “What is a PLC?“, PLCs are automatic control devices used in industrial environments. They are used to control machines and processes using input and output devices.
PLC programming allows the user to specify how they want the PLC to work. Programs consist of instructions that define the user’s inputs and outputs. They also define logical operations that determine how the PLC will operate.
How PLC Programming Works?
As we mentioned in our PLC FAQs blog, PLCs are usually programmed through a program that is created on a computer and then loaded into the controller. Most PLC programming software traditionally supports Ladder Diagram or “C” programming. Ladder Logic is a traditional programming language that represents logical steps with diagrams that read from left to right.
Among PLC programming languages, the most common are generally considered to be Ladder Logic and Structured Text. Ladder Logic is a ladder-like programming language designed in a manner similar to the schematic representation of electronic circuits. On the other hand, Structured Text is a structured programming language with a structure similar to the C language.
Mikrodev MP110 and MP211 PLC Series Programming Features
Mikrodev MP110 Series PLC (Micro Level Controller) and MP211 Series PLC (Medium and Large Level Controller) products have many protocol features that allow multi-functional and multi-programming. MP110 and MP211 PLC series have logic gate blocks, input and output blocks, calibration blocks, delay/pulse timers, mathematical operation blocks, counter blocks, gsm blocks, data event recording blocks, register/variable blocks, MODBUS protocol blocks, MQTT blocks, communication blocks, controller blocks, system blocks, multi-plexer blocks, motion control blocks, serial communication blocks, string blocks, calendar blocks and macro blocks.
MODBUS PROTOCOL BLOCKS in Mikrodev’s MP110 and MP211 PLC Series
MODBUS, a widely used communication protocol in industrial automation, provides a common language for different instruments to communicate and offers end-to-end communication.
MODBUS Protocol Blocks in Mikrodev PLC products have different programming features and capacities. Mikrodev MP110 and MP211 series PLC devices have MODBUS RTU Master, MODBUS RTU Slave, MODBUS TCP MODBUS, MODBUS TCP Slave, MODBUS Gateway, MODBUS Word Reader, MODBUS Float Reader, MODBUS Long Reader, MODBUS Word Printer, MODBUS Float Printer, MODBUS Long Printer, MODBUS Read/Write Table and MODBUS Status Block programming capacities.
Now let’s take a brief look at the details of MODBUS RTU Master and MODBUS RTU Slave protocols:
MODBUS RTU MODBUS MASTER & MODBUS RTU SLAVE
MODBUS RTU MASTER CONNECTIONS
Ser: Serial port block input
It is the block input which will be connected to the communication port.
#MRM0: Blok output
Block’s output connection
Tx: Tx value output
It is the output connection where the number of requests sent is read
Err: Number of errors in submitted requests
It is the output connection where the error count of sent requests is read
Sta: Connection state output
State of the last executed request
MODBUS RTU Master Custom Settings
Modbus RTU Master block enables Modbus RTU Master protocol to be activated via the communication port input connected via the physical interface. In standard MODBUS applications, MODBUS RTU Master operates on RS485 or RS232 serial ports. Since there can only be one MODBUS RTU Master on an RS485 line, only one MODBUS RTU Master block can be opened on each serial channel. In devices with multiple RS485 ports, individual MODBUS RTU Master blocks are added for each port.
The MODBUS RTU Master block is used to read or assign values over the MODBUS communication protocol. The activated protocol is completed with request sending blocks connected to the MODBUS RTU Master block. In the MODBUS protocol, requests can usually be grouped as read or write. The MODBUS RTU Master block cooperates with the Serial Port Block and the MODBUS Word Reader / MODBUS Word Printer Blocks.
When MODBUS request blocks are triggered for reading or writing, requests are added to the request queue in the MODBUS RTU Master block. Requests waiting in the request queue in the MODBUS RTU Master block are pulled in sequence if the RS485 line is free, sent to the line and wait for a response. If a reply is received within the response waiting time, the reply is processed; if not, the request is canceled and the error counter is incremented by one. The waiting time is defined in the special settings section in the MODBUS RTU Master block.
MODBUS messages are instantaneous read and write requests and do not contain timestamp information. Therefore the request queue in the MODBUS RTU Master block has an intelligent mechanism by storing write or read requests of the same point only in the last added request queue.
During online monitoring, the “MODBUS Slave” utility is used to view values or assign new values via the MODBUS communication protocol.
For example; The device has enabled the MODBUS protocol on the serial port. As MODBUS RTU Master, the device performs read and write operations by sending requests to slave devices on the line. In order to read or write values via MODBUS communication, a logical (1) signal must be given to the “Ttk” inputs on the MODBUS Word Printer and MODBUS Word Reader blocks. In order to read or write values in MODBUS protocol, a utility program called MODBUS Poll is used.
MODBUS RTU SLAVE CONNECTIONS
Ser: Block input
The block input to which the communication port is connected.
Add: Modbus ID input
Used to identify the Modbus ID address externally
Out: Block output
Output connection of the block.
Tx: Tx value output
It is the output connection which indicates the number of requests sent.
Err: Error value output
It is the output connection which indicates the error count of the submitted requests
Sta: Connection status output
Indicates the success state of the last executed request.
The MODBUS RTU Slave block enables the MODBUS Slave protocol on the communication port input connected via a physical interface. This block is used to read values through the Program via the MODBUS communication protocol. The MODBUS RTU Slave block is connected to the “Ser” input via the serial communication port. The activated MODBUS RTU Slave device responds to requests from the designated communication port and has its own MODBUS Identification Number (ID). All blocks in the logic project and MODBUS addresses in the variable address table will be accessed by this channel and protocol settings.
Special configurations of the Serial Port block are specified above. For example, it is desired to receive data from the Analog Register block via MODBUS RTU communication. The MODBUS RTU Slave block is connected to the output of the Serial Port block and in this way the device operates in the server mode in which it is programmed. MODBUS Poll utility is used to receive the data transmitted through the program over MODBUS communication.
In this article, we summarized the features and advantages of MODBUS RTU Master and MODBUS RTU Slave communication protocols in Mikrodev PLC devices. As can be seen, Mikrodev MP110 and MP211 PLC Series provide multi-functional and flexible solutions in industrial automation applications by offering a wide range of programming. MODBUS RTU Master and MODBUS RTU Slave, which are among the MODBUS protocol blocks, work over serial communication and provide effective communication for data exchange and control in industrial automation systems. MODBUS RTU is a protocol that is parameter-based, keeps chronological records with time information and is preferred where precise control is required. Mikrodev PLC products work integrated with these protocols to provide reliable and efficient performance in industrial applications. By means of that, users can develop flexible and optimized solutions for various industrial needs.