QS. Configuring and Launching Modbus OPC Server

<< Click to Display Table of Contents >>

Navigation:  Modbus Universal MasterOPC Server > Quick Start > Example 1 - Operation Check Using Simulator >

QS. Configuring and Launching Modbus OPC Server

mbul_mail Configuring a node

mbul_mail Configuring a device

mbul_mail Configuring tags

mbul_mail Switching the server to the run-time mode

Click the shortcut MasterOPC Universal Modbus Server \MasterOPC Universal Modbus Server (the group MasterOPC Universal Modbus Server is situated in that folder of the Start menu that is chosen during the product installation), and, in the server control window, click the command qs_img20 New to create a new configuration:  

qs_img21

Configuring a node

Click the root group Server at the tab Objects, click the command qs_img22 Add node from the menu, and, in the displayed dialog of node creation, set the following parameters: Node name NodeTCP, Node type TCP/IP. The main settings of a TCP/IP-type node are IP address and IP port. By default, the IP address 127.0.0.1 (an IP address of the local computer) and the port number 502 (the standard port of TCP/IP devices) are set. We will poll a local device simulator, therefore remain all parameters without changing; in real projects, you should specify an IP address of a remote controller.

qs_img23

Click the OK button – the node created is added to the Server group at the Objects tab:

qs_img24

Configuring a device

Click the group NodeTCP at the tab Objects, click the command qs_img28 Add device from the menu, and, in the displayed dialog of device creation, set the following parameters: Device name Modbus, Device type MODBUS, Request period – 1000. As a rule, a device address is 1 in Modbus TCP:

qs_img29

Click the OK button – the created device is added to the NodeTCP group at the Objects tab:

qs_img30

Configuring tags

Click the Modbus group of the NodeTCP group at the Objects tab, click the qs_img34 Add tag command from the menu, and, in the displayed dialog of tag creation,  set the name Holding Value, and the register address 12. The Word data type specified in ModRSSim is equivalent to the uint16 data type, therefore select that type in the Data type in device section. Data type in server defines a data type of the tag in OPC clients; set this parameter to uint32.

qs_img35

To complete tag creation, click the OK button - the tag is added to the device.

Konfigurirovanie_i_zapusk_Modbus_OPC_Server

The same way, create the Input Registers tag.  In settings, specify the region Input Registers, the address 6, and the data type float (both in server and device).  

Konfigurirovanie_i_zapusk_Modbus_OPC_Server1

When using tags with a data type in device Float, Int32, Uint32 or Double, it is necessary to remember that swapping the bytes can be required. In the most cases, devices demand the following byte order:

int16, uint16 - the most significant byte first

Float, Int32, UIn32 - the most significant word first

Double - the most significant double word first

The special editor is provided for each tag to swap its bytes.

Konfigurirovanie_i_zapusk_Modbus_OPC_Server2

ModRSSim uses the "High byte first" permutation both for 2-byte and 4-byte numbers, therefore we do not need to change anything.

Now create the Coils tag.

Konfigurirovanie_i_zapusk_Modbus_OPC_Server3

Thus, the tree contains 3 tags.  

Konfigurirovanie_i_zapusk_Modbus_OPC_Server4

Switching the server to the run-tine mode

If the server is configured, it can be launched (that is, switched to the run-time mode). Click the qs_img38 Save as command from the server menu, set the Example name for the created configuration in the dialog displayed, and click Save. The Example.mbp file is created in the SERVERCFG folder, and the server window displays information about a file loaded. Next, click the qs_img40 Make starting command from the server menu:

qs_img41

Note. If the Make starting command is disabled, you can run the server (see below) - this makes the configuration starting as well.  

To switch the server to the mode of execution of the Example.mbp configuration, click the qs_img42 button, and, in the menu displayed, click the qs_img43 Start button:

qs_img44

In the run-time mode, the server window displays:

At the Objects tab - the tree of devices and tags

At the Tags tab - a list of tags of the selected element (device, group, sub-device) and their current values as well as timestamps and quality specifiers  

At the Messages tab -  server messages

At the Quaries tab -  queries and device responses

At the Script messages tab - messages from script (if they are programmed)

qs_img45

As we see, tags receive values, which we have inputted to the registers of ModRSSim.

The tags Holding Value and Coils Value have the access type ReadWrite, that is, the tags support writing. To check writing values from the server window to devices simulated, double click a line of the tag Holding Value at the tab Tags in the server window – the editor of changing a value is opened, and a current tag value is displayed in that editor. Input a new value in the editor.

qs_img46

Upon the OK command, the value is written to the register of ModRSSim.

qs_img47

Now the OPC server is configured, and we can start to configure OPC clients.

According to the OPC standard, an OPC server is launched automatically when an OPC client subscribes to its values. Therefore you can close the OPC server (click the qs_img42 button again, and then click the Stop button). But you can remain the server in the run-time mode - an OPC client is successfully connected  to the server as well.

Note. If you remain the OPC server in the design-time mode, an OPC client can get a list of tags (they are added), but, when launching the client to the run-time mode, the OPC server is not launched;  the "OPC server is suspended" flag is returned in this case.