The Modbus communications protocol is a widely-used serial communications standard for many Programmable Logic Controllers (PLCs) and other industrial control devices. Modbus can function in full-duplex RS232 mode or half-duplex RS485 mode, as well as newer implementation variants such as TCP/IP. The communication is master-slave / server-client driven.When using serial, you can set up controllers to communicate on standard Modbus networks using either of two transmission modes: ASCII or RTU. Users select the desired mode, along with the serial port communication parameters (baud rate, parity mode, etc) during configuration of each controller. The mode and serial parameters must be the same for all devices on a Modbus network. The selection of ASCII or RTU mode pertains only to standard Modbus networks. It defines the bit contents of message fields transmitted serially on those networks. It determines how information is packed into the message fields and decoded.When controllers are set up to communicate on a Modbus network using ASCII (American Standard Code for Information Interchange) mode, each eight-bit byte in a message is sent as two ASCII characters. The main advantage of this mode is that it allows time intervals of up to one second to occur between characters without causing an error.When controllers are set up to communicate on a Modbus network using RTU (Remote Terminal Unit) mode, each eight-bit byte in a message contains two four-bit hexadecimal characters. The main advantage of this mode is that its greater character density allows better data throughput than ASCII for the same baud rate. Each message must be transmitted in a continuous stream.Modbus TCP/IP allows for devices to be configured and accessed on an Ethernet network while still using the characteristics of the Modbus protocol. So you can implement a server-client architecture and have multiple clients access the same devices simultaneously, versus the peer-to-peer or master-slave connection of RS232 or RS485.Regardless of the type of protocol or mode you use, Lookout provides several Modbus drivers to implement the communications easily and quickly create an application. For more detailed information about the Modbus protocol, refer to the Modbus Organization web site.See Also:Modbus Organization
When configuring Lookout for Modbus communication, you must first determine the proper driver to use with your device. The following Modbus drivers exist in Lookout:
Each of these objects is based on the Modbus protocol but may be used in different situations, depending on the device with which you are communicating. For this tutorial, we will use the Modbus driver for communication.
The Create Modbus Secondary dialog box appears, which contains all of the parameters associated with configuring Modbus communication.
The main parameter of this dialog window is the Mode, which allows you to specify Modbus serial, Modbus Plus, or Modbus Ethernet communications. If Modbus Serial is selected, all serial port settings are listed for configuration. If Modbus Plus is selected, only the address of the device on the network must be specified. If Modbus Ethernet is selected, the IP address of the device and the Identifier, if any, must be specified.Note: To ensure that you properly configure this driver, you should understand the configuration of the device with which you will be communicating.For more information on the three different modes, as well as the other parameters listed in this dialog box, refer to the Lookout Help.
For testing purposes, identify a register of your device to which you can read/write data. You will use this register for general testing before further configuration is done.
After releasing the mouse button, select Create Control»Pot.
The New Potentiometer dialog box appears. Specify the minimum value, maximum value, and resolution that you want this object to contain. Make sure you modify the URL parameter to the register of interest. For example, to write a value to register 40120, change the URL to Modbus1.40120. Click OK to close the dialog box.
At this point, you can use the Potentiometer to write a value to the register on the device as well as read the current value of the register on the device.Note: This tutorial uses a Pot object because the 40001-49999 range of registers refers to 16-bit unsigned integers ranging from 0-65535. If the register selected referred to a Boolean, a Switch or Pushbutton object would be used.Creating a remote connection to a Modbus register allows a single-point connection to read and write a register. These remote connections are the best way to communicate between a Lookout process and a Modbus device.To learn about other methods of accessing Modbus data members, refer to the related tutorial on "Accessing Lookout Driver Object Data Members", linked at the bottom of this section.
After you test basic reading and writing and verify communication with the device, you might need to configure connections between registers and objects/expressions within your Lookout process. You might want to configure alarm conditions, implement scaling, or configure registers to be logged to a historical database. The following sections list the basic steps for each configuration option.AliasesFirst, you may choose to create aliases, or descriptive names, for your registers so that they are easier to identify in Lookout.
ScalingYou might need to configure scaling to convert the raw values of a register to the proper values based on what the data represents. For example, you might receive a value of 0-100 which represents the percentage output of a level probe, but the actual value should be 0-500 in centimeters.
Note: This is a linear scaling method from the minimum to maximum values. If you need polynomial scaling, you can use an expression in Lookout. For more information on creating expressions, refer to the Lookout Help or the Lookout Developer’s Manual, linked at the bottom of this section.Alarm ConditionsYou might want to configure alarm conditions for your registers. In this example, you might want to configure a high-priority level alarm to alert an operator if the tank level gets too high or too low.
For more information about alarm areas, priority levels, or deadbands in Lookout, refer to the Lookout Developer’s Manual.Historical LoggingYou might want to configure registers to be logged to Lookout's Citadel historical database. Lookout can monitor all configured registers and log all appropriate values to a database, efficiently storing data in making it easily accessible at a later time.
Note: Careful consider your deviation setting. If you do not specify a deviation, any change in a numeric value results in a new value being logged to disk, and you might log more data than you need. If the deviation setting is too large, very little information might be saved to disk.
For more information on historical logging, refer to the Lookout Developer’s Manual.
The final configuration should appear as follows:
Note: The description and suffix are used for descriptive purposes only and do not affect functionality.
Connections to Objects and Expressions
You need to make connections between the alias, or registers, and other objects/expressions of your Lookout process.First, create a new potentiometer to connect to a Modbus register.
The New Potentiometer dialog box appears, which contains all of the parameters associated with configuring the Pot object. The name of the new potentiometer should be Pot2.
In the middle of the dialog window you will notice the expression which states the connection being made. In this example, the expression is Modbus1.40001 = Pot2.value.Note: It is very important to understand the expression shown because these connections are unidirectional. Modbus1.40001 is equal to Pot2 and will change anytime Pot2 changes; but Pot2 will never change to coincide with 40001 if that value is changed elsewhere.For more information on connections, refer to the Lookout Developer’s Manual.
Displaying Historical TrendsAfter you set up and configure all Modbus registers in your process, you might want to monitor the data in a historical trend view on your panel. This will allow you to view the data as it is being logged to the database and also view all historical data.
The Create HyperTrend dialog box appears, which contains all of the configuration options associated with the HyperTrend object.
Note: At this point, the HyperTrend will display the Tank_Level alias. An alias or register must be logged to the historical database in order to be viewed on the HyperTrend.
In this example, the Tank_Level alias is displayed on the HyperTrend. Any changes to that alias, or to the Pot that contains a remote connection to the alias, is displayed.
If for some reason you do not see your data being displayed, reference the following KnowledgeBase linked below which may address the issue. For more information on the HyperTrend, refer to the Lookout Developer’s Manual.See Also:Lookout Developer's Manual
After configuring Lookout to communicate with your device, there may be times when you need to monitor or troubleshoot the communications. Lookout includes tools to help you investigate performance or unexpected behavior with Modbus communication.
The Modbus driver monitors Modbus Protocol Statistics. This data is held within readable data members of the Modbus object and you can see them in the Modbus Protocol Statistics dialog box. To view the dialog box, select Option»Modbus and click Statistics.Note: The Options»Modbus option is only visible in the Options menu if a Modbus object exists in your Lookout application.The following dialog appears.
The Count column contains the accumulated number of messages received from the selected device that fall into each respective category since the last time the Reset button was clicked. The percent column (%) indicates the percentage of messages received that fall into each respective category since the last time the Reset button was clicked.Refer to the Lookout support page and tutorial linked at the end of this section for more information on troubleshooting related issues.
After you have created a Modbus object and attempted to make a connection, any issue that occurs with the communications generates an alarm for that driver. The alarm information often coincides with data seen in the Protocol Statistics dialog.
Refer to the Lookout support page linked at the end of this section for the most common alarms and an explanation of the potential causes.
If you have received alarms related to garbled communication or any other of the protocol statistics, you might want to view the actual serial data sent to and from the device. To record this serial communication, configure Lookout to log the data to file by selecting Options»Serial Ports and enabling the diagnostic file settings. Also check the options for Timestamp Enable and Value in HEX to make the file more readable and useful for troubleshooting.
Note: Make sure that you are configuring the proper serial port for the Modbus device.If you are communicating with a device via Modbus Ethernet, refer to the KnowledgeBase linked at the end of this section for information on logging the communications.The example below shows Modbus data captured on the serial port. By analyzing this data and comparing it to the protocol format and the data that the device should be sending/receiving, you can troubleshoot where an issue may be occurring. For more information on the Modbus protocol and how to interpret the data, refer to the Modbus Organization web site link at the end of this section.
From the sample shown above, you will notice that the first message was generated at 15:44:24.5 (3:44pm, 24.5s). The arrow pointing to the right denotes that the communications is TO the device. If a response is received FROM the device, the arrow points left. First, the message is sent in RTU format; the default. Because the device did not respond, the message was sent in ASCII format. There is still no response from the device therefore the message continues to repeat while a “No Response from Modbus Secondary” alarm is generated.
There may be times when you are developing a Lookout application, but you do not have access to the device to which the Modbus driver will communicate. In this case, you might want to simulate the device so that the application can be tested. In this situation, a Modbus slave object can be used to simulate the device.In order to simulate the device, configure the ModbusSlave object and set up the local computer as follows:1. Connect a NULL serial cable between two COM ports on your computer.2. Create a ModbusSlave object in Lookout for one of your COM ports.3. Create a Modbus object for your other COM port with matching baud rate settings.Note: The ModbusSlave can also be set up and accessed from another computer. The other computer would also need a server version of Lookout to accomplish this configuration.
In certain situations, you might need to apply more advanced settings to your Modbus communications for proper and efficient functionality. You can access advanced Modbus options from the Create Modbus Secondary dialog.
For more detailed information on the advanced settings, refer to the Lookout Help.See Also:
For more information on Modbus communications in Lookout, refer to the Lookout Help, the Lookout Developer’s Manual, and the Lookout support web page.
Collaborate with other users in our discussion forums
A valid service agreement may be required, and support options vary by country.