Setting up the Modbus RTU Channel
For SmartServer 3.4 to 4.1, see Setting up the Modbus RTU Channel (Release 3.4 to 4.1).
For SmartServer 3.3 and prior, see Setting up the Modbus RTU Channel (Release 3.3 and Prior).
This section consists of the following:
Modbus RTU Channel Overview
The SmartServer IoT Starter Kit includes an Advantech ADAM-4150 DIO module. This module includes LEDs that indicate the state of the module’s digital outputs. A pair of switches to the right of the module are connected to inputs DI-0 and DI-1 as shown in the figure below. Two of the wires loop back connecting outputs DO-0 to DI-2, and DO-1 to DI-3.
Get started setting up the Modbus RTU channel following the steps in the section below: Getting Started with Modbus RTU Channel Setup.
Getting Started with Modbus RTU Channel Setup
The ADAM-4150 module initially communicates using Advantech’s proprietary serial protocol. The communication interface can be upgraded to support Modbus RTU using an ADAM 4000/5000 utility and and USB to RS-485 converter. This utility is available for download at https://support.advantech.com/support/DownloadSRDetail_New.aspx?SR_ID=1-9HOC2&Doc_Source=Download.
An easier option leverages the programming support of the SmartServer IoT. A small node.js application is provided to accomplish this task. Follow these steps:
Install winscp.exe and putty.exe on your PC if you do not already have these programs.
Use winscp.exe to create the following folder on the SmartServer IoT (you should be connected with the SmartServer apollo username and password):
/var/apollo/data/apps/adam-setup
Transfer adam-setup.zip from the SmartServer GitHub Repository Starter Kit archive → Modbus RTU Channel folder to the SmartServer IoT folder that was created in the previous step.
Use PuTTY to connect to the SmartServer SSH console.
Enter the following command:
cd /var/apollo/data/apps/adam-setup
Enter the following command:
unzip adam-setup.zip
Enter the following command:
rm adam-setup.zip
Power down the ADAM-4150 module by unplugging the bottom power supply connector.
Move the configuration switch from the Normal to Init position.
Power up the ADAM-4150 module by plugging in the bottom power supply connector. With the following step, the ADAM-4150 module to setup to use Modbus address 01 and to communicate at 19200 Baud, no parity, and one stop bit.
Enter the following command to configures the ADAM-4150 module to use a 19200 Baud serial Modbus at address 01:
node adamConfig.js 01 7
A result similar to the following appears:Power down the ADAM-4150 module by unplugging the bottom power supply connector.
Move the configuration switch from the Init to Normal position. If you neglect to move the switch to the Normal position, the module will not use the Modbus settings that were just programmed.
Power up the ADAM-4150 module by plugging in the bottom power supply connector.
Continue setting up the Modbus RTU channel following the steps in the section below: Setting the RS-485 Configuration UI.
Configuring the RS-485 Settings
To configure RS-485 settings, perform the following steps:
Open the SmartServer Configuration page as described in Accessing the SmartServer IoT Configuration Page (log in as user apollo with the password that appears on the SmartServer IoT). The Network tab appears as the default SmartServer Configuration page. Once the network settings are configured for the SmartServer system, then the System tab will appear as the default.
SmartServer IoT Network TabSmartServer IoT System TabClick the RS-485 tab. See (Optional) Add a Modbus RTU Interface for more information.
Configure your RS-485 1 settings to match those shown in the figure below. When you configured the ADAM-4150 module at Modbus address 01, you also set the serial bit rate it would use to communicate. The above instructions set the baud rate to 19200. The module's serial frame does not use parity and looks for only 1 stop bit.
Click Update.
Continue setting up the Modbus RTU channel following the steps in the section below: Creating a Modbus Device.
Creating a Modbus Device
Now that the ADAM-4150 module is prepared to be accessed as a Modbus RTU device, with Modbus address of 01 and a 19200 Baud serial connection, the device can be added to the SmartServer IoT. To create a Modbus device, perform the following steps:
Open the SmartServer CMS by clicking the CMS tab on the Configuration UI, or by entering the following URL:
https://[SmartServer IP address]/cms/#/login
Click the Import / Export button (
) on the main CMS dashboard. With SmartServer 3.6 and prior, you can also use the Import Device Types button (
) on the Device Types widget to load the DTP file.
The Import / Export dialog appears.Select the ADAM-4150v20.dtp from the SmartServer GitHub Repository Starter Kit archive → Modbus RTU Channel folder and place it in the Drop files to import area.
Click IMPORT.
Notification messages (similar to the one shown below) will appear indicating that device types are being uploaded and the CPU usage on the main CMS page will show increased activity.When the device types file has finished loading, click CANCEL to close the Import / Export dialog.
Go to the Devices widget, EDGE DEVICES tab, which will be used to add a Modbus device to the system.
Click the Create button (
) to add the Modbus device, setting the following fields as shown in the figure below:
Name: DIO
UID: 01:1
Integration method: Manual assignment
Driver: Modbus
Device type: ADAM-4150
Click SAVE. The DIO device is added to the Devices widget.
Click the Action button (
) for the DIO device and select the Provision action.
Within a few seconds, the DIO device fill should change from blue to green indicating that the device has be successfully provisioned. If the provision fails, confirm that the Modbus channel on RS-485-1 is set for 19200, no parity, and one stop bit as described in the previous section Setting the RS-485 Configuration UI.
Begin using the DIO module following the steps in the section below: Interacting with the DIO Module.
Interacting with the DIO Module
Using the Datapoint Properties Widget
The ADAM-4150v20.dtp package defines the interface to access the digital input and output of the ADAM-4150 device using Modbus RTU and the RS-485-1 channel. This package includes a .dla file that provides Modbus driver instructions for monitoring the data and presenting the data events to the rest of the system. The Adam-4150V20.dla.csv file is contained ADAM-4150v20.dtp archive that was imported in the process of Creating Modbus a Devices.
Follow the steps below to take a closer look at how this works.
Go to the Datapoint Properties widget. Click the Expand button (
) for a better view of this widget. To reduce the scope of data that appears on the Datapoints widget, set the filter to narrow down the display to Modbus driver.
Notice that the Monitored attribute is set to On as shown below.
To edit datapoint properties for Datapoint DI_0, click the Action button (
) and select the Edit action.
The Edit Datapoint Properties view appears.Click the MONITORING AND LOGGING CONFIGURATION tab.
As shown in the figure below, the Monitored Yes option should be enabled. Since the Modbus driver can only poll datapoints, for the values to be monitored continuously, the Polled (Monitoring Method) option should also be enabled. Poll Interval (Seconds) is set to 2 and Publish Minimum Delta Value is set to On Any Change.
These settings are important because the event traffic that would be created with 14 datapoints being polled every 2 seconds would needlessly consume CPU cycles. Therefore, if you are not using some of the inputs or outputs in your system, you should disable monitoring for the associated datapoints. This optimization is not required for a small demonstration panel.Exit fullscreen mode for the Datapoint Properties widget by clicking the Collapse button (
).
Using the Datapoints Widget
Notice in the figure below that DI_0 is connected to the top switch and DI_1 is connected to the middle switch. The outputs DO_0 and DO_1 connect to inputs DI_2 and DI_3 respectively.
In the steps that follow, you will use the Datapoints widget to monitor and interact with these points. Follow the steps below to take a closer look at how this works.
Go to the Datapoints widget. Click the Expand button (
) for a better view of this widget. To reduce the scope of data that appears on the Datapoints widget, set the filter to narrow down the display to Modbus driver.
Since monitoring is enabled for the DIO module points, polling done by the Datapoints widget is redundant and not necessary. Therefore, before getting started with the Datapoints widget, you will need to change the Poll Interval (Seconds) on the Datapoint Properties widget from 2s to 0s. With Poll Interval (Seconds) set to 0s on the Datapoint Properties widget, the Refresh button () on the Datapoints widget (shown in the figure below) can be used to force a get of the current value.
Select the checkmark next to each of the following six datapoints: DI_0, DI_1, DI_2, DI_3, DO_0, and DO_1 (the checkmark changes from blue to yellow). Use the scroll bar as needed to select all of the desired devices.
Click the Action button (
) on the Datapoints widget and select the Show Selected Datapoints action.
The Datapoints display is updated with only the six selected datapoints.
The action of the switches on the Starter Kit, and the modification of DO_0 and DO_1 values in the Datapoints widget, will be reflected within the 2s poll interval that is defined in the Adam-4150V20.dla.csv file. This file is contained in the ADAM-4150v20.dtp archive that was imported in the process of Creating Modbus a Device.Exit fullscreen mode for the Datapoints widget by clicking the Collapse button (
).
You have succeeded integrating a simple Modbus RTU device with the SmartServer IoT. Success requires device setup and serial frame compatibility. As with all RS-485 based devices, it is important to pay attention to the communication wire polarity, and the inclusion of the common ground. Go to Creating Devices to set up other devices.