Frequently Asked Question

Video: 7.2.3. Modbus Client
Last Updated 2 years ago


Press "Ctrl + F" to find the keyword of your interest.

If you wish to have a direct link access to the video timestamps, please follow these instructions.

Found this video helpful? Why not take the whole HIL Specialist course? A Certificate is waiting for you for free at HIL Academy.

Would you or your organization benefit from having these videos narrated in your native language? Contact us and let us know if you wish to contribute.

TRANSCRIPT

00:00:02

Hello everyone. Now let s have a look at how to configure and implement the Modbus TCP  

00:00:07

Client component on the HIL device. For that, let s open the Modbus Client  

00:00:11

setup model under the communications protocol tab in the Example Explorer. 

00:00:18

The Modbus Client component, which can be found in the Library Explorer under the Communication tab,  

00:00:24

implements the Modbus TCP Client Master functionality. You can simply drag and  

00:00:29

drop the component as shown here.If you double click the component,  

00:00:35

a dialog window opens with different properties that we can define. 

00:00:39

The first property is the client setup. Here all network configuration for the client is defined,  

00:00:45

such as IP address, Netmask, and gateway. It is important to choose a free IP for the client, and  

00:00:52

it should differ from the server one. We went over this process in detail in the previous lesson,  

00:00:57

and we will be covering this again in the lesson on the HIL SCADA application of Modbus Client.  

00:01:02

For now, the default address should work for us.The Server setup is also defined here. In  

00:01:09

this section, you must enter the target Server IP address and port.  

00:01:13

The Slave ID is also important when using the component together with Modbus RTU. 

00:01:20

Here you can also define a request timeout, which is the time that the Client waits for a Server  

00:01:25

response before triggering a timeout event. This is useful for detecting when a connection  

00:01:30

between the Server and Client has failed.In the Request information properties window,  

00:01:35

we can define all the requests performed by the client. Here we can add them one by one  

00:01:39

from the user interface by clicking in the add button as shown here. 

00:01:45

Then, we need to define a name for each request, the function code performed, the starting address  

00:01:50

of each request, the number of addresses to read or write, the transmit type, and the period. For  

00:01:56

transmit type, we can choose between three types, on event, on timer and on event and on timer. 

00:02:03

Timer requests will be performed once at the start of every chosen transmit period,  

00:02:08

while event requests will be performed after every event change that meets pre-defined conditions.  

00:02:13

On event and on timer requests will be performed on both events, when programed time reaches its  

00:02:18

value or when an event trigger is detected at the respective input terminal of the component. 

00:02:25

Let s have a look at how you can add and configure requests in the user interface. Let s add an extra  

00:02:30

request to this example to write to a single register and let s call it HIL specialist.  

00:02:35

The write address should not overlap with the ones already defined for holding registers,  

00:02:39

so let s define register 110, and the request will be on timer every 2000 milliseconds. 

00:02:46

By hitting the OK button all the changes are saved to the component. 

00:02:50

Now we can see an extra input terminal with the name HIL specialist appeared on the component,  

00:02:55

thanks to the change we made previously. You can connect any signal processing terminal  

00:03:00

or SCADA input to this port.In our case, let s connect a  

00:03:03

constant component with a value of 10, for example, to write it to the Modbus Server. 

00:03:11

Now we can see that for every request, there is a terminal in the component.  

00:03:15

Write requests are inputs from the model to the component and read requests are outputs  

00:03:19

from the component to the model. This means that when the Modbus client performs a read  

00:03:24

request to the Server it will send the values to the model while write requests are sent  

00:03:28

from the model to the targeted Modbus Server.Also, for every on event transmit type request,  

00:03:34

there will be an input terminal which represents the event that will trigger the request. 

00:03:38

In this demonstration, we have SCADA inputs for coils inputs and holding register inputs.  

00:03:44

These components let us send values from the SCADA to the Modbus Client component, which will perform  

00:03:49

a writing request to the Modbus Server.Similarly, SCADA inputs are placed at  

00:03:56

each of the event input terminals, so we can trigger these events directly from SCADA. 

00:04:01

At the right side of the component, you can see that probes are connected to the output terminals.  

00:04:06

These probes read the value from the Modbus Server, and so you can them in the SCADA panel. 

00:04:12

In order to perform communication with the Modbus Client in this model,  

00:04:16

we can use any external Modbus Server device. For this example, we will use the Modbus Slave  

00:04:22

software from Modbus Tools, a Modbus Server simulator that run on windows PC. You can  

00:04:28

find a link to this tool in the Materials Tab.Let s compile and load the model to HIL SCADA. 

00:04:37

After opening the pre-built SCADA panel,  

00:04:40

we need to properly setup the Modbus Server on the Modbus Slave application. 

00:04:44

Let s open the Modbus Slave software and go to the Setup tab. 

00:04:50

From here, we need to choose the Slave ID that matches the value we defined for  

00:04:54

the Modbus Client. Each slave in a network is assigned a unique unit address from 1 to 247.  

00:05:00

When the master, or client, requests data, the first byte it sends is the Slave address.  

00:05:06

This way each slave knows after the first byte whether or not to ignore the message. 

00:05:12

The next step is to select the desired Function code,  

00:05:15

which in this case is holding register , and type in the address and quantity of registers. 

00:05:23

After that, let s go to Connection, choose to connect, and select the Trial period  

00:05:28

option. A dialog window with the holding registers will appear. In this dialog,  

00:05:33

we need to type the desired numbers into it and hit enter. Let s try 10, 20, 30, 40, and 50. 

00:05:54

Now let s return to the Modbus Client in HIL SCADA.  

00:05:57

We can see the values displayed in the Holding values subpanel. 

00:06:02

Let s follow the same process for coils. Since coils are on-event triggers,  

00:06:07

let s press the button event in the read coils section on the SCADA panel.  

00:06:11

Now we should see the LEDs turn into red. 

00:06:48

We can also write to the Modbus Server coil registers by simply changing the Slave setup  

00:06:52

from the slave definition properties under the Slave tab of the Modbus Server application.  

00:06:57

Then we can select the coil status and type the right address and number, like shown here. 

00:07:08

Now let s go back to SCADA, change the values of the Coil register values,  

00:07:13

and click the button event. When we return to the Modbus Server application,  

00:07:17

we can see the registers are updated.Now we ve covered how to setup the Modbus Client  

00:07:23

component in Schematic Editor. In the next lesson, we ll look at another implementation of Modbus  

00:07:29

Client using SCADA API. Thank you for watching and see you in the next lesson!

Please Wait!

Please wait... it will take a second!