On a serial network, you can use a single driver to communicate with several devices; depending on the protocol being used, each tag’s N1 parameter is responsible for distinguishing them.
Starting with version 4.0.15, the Modicon Modbus Master driver now includes the Auto-Demotion feature, which automatically disables tags from slave devices experiencing communication failures. For more information about this functionality, please refer to the Modicon Modbus Master Driver Manual. This article is intended for other drivers or for previous versions of the Modbus driver.
Whenever there is a communication failure with a certain device (which can be expected on a large network), the driver will continue trying to read that device’s tags. Delayed or failed responses may cause application slowdowns, which can be mistakenly interpreted as a system freeze.
This article presents a sample application that disables the reading of a device’s tags when it remains in communication failure for a certain period of time. The application contains one control tag for each device; when one tag’s quality becomes bad, a counter starts checking its quality periodically. If the quality remains bad after a configured time interval, reading of all tags related to that device is disabled.
The application retrieves three I/O tags and a two-element block from different devices. The I/O driver being used in the example is Modicon Modbus Master. To simulate the devices, you can use any Modbus simulator that enables simulating more than one device with different IDs.
In this application, the driver was connected via ethernet (because of the simulator being used, which does not interfere with the proposed solution). We use MOD_RSSIM simulator, which is attached to this article and can also be downloaded from this site.
This article also features a library called desabilitaleituraemerro.lib which contains only one XObject, called xoDisable. This object contains scripts for enabling and disabling tag reads. For each device to be controlled, a new instance of xoDisable must be added to the data server (data folder).
To each new instance added to the main project, fill out the following xoDisable‘s properties:
AppDriver: driver to which the device belongs
Database: database object where “read enabled” or “read disabled” messages are recorded
IDEquip: the device’s ID on the network (N1 parameter in the I/O driver)
Table: name of the table where read events are recorded
ControlTag: checks if communication has failed. This is the only tag whose read is not disabled when in fail
PresetValue: time interval (in seconds) when communication is checked when in fail
To enable the counter tag in the xoDisable‘s instance where the device has failed (N1), you must add a script to the driver’s OnCommError event. Example:
‘Script that checks which N1 has failed and enables a counter.
if N1 = 1 then
Application.GetObject(“Data.xoDriver1”).CounterTag.Enabled = true
elseif N1 = 2 then
Application.GetObject(“Data.xoDriver2”).CounterTag.Enabled = true
end if
End Sub
To use this application, follow these procedures:
- Execute a Modbus simulator that simulates two PLCs at port 502, or the use two PLCs, whose network IDs are 1 and 2, and which contain Holding Register-type variables with addresses ranging from 1 to 5.
- Open the application in edition mode, set up the driver’s connection IP, and run the application.
- At the Modbus simulator, disable only one (control) variable of one of the PLCs, or then completely disable one of the simulating PLCs.
- Wait for Elipse E3’s timing and check whether the other tags’ reading has been disabled.
- Enable again the variable or PLC previously disabled.
- Reading will be reestablished after one good-quality variable is read.
The demo application was developed with Elipse E3 version 4.6 build 162.
