Frequently Asked Question

Video: 7.5.2. ETH VE setup example
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!

00:00:03

In the previous lesson, we learned that EthernetVariable Exchange is a custom protocol, meaning

00:00:09

you can define the messages to be transmittedbetween the HIL device and any external device

00:00:13

that has a proprietary or custom protocolover an Ethernet network.

00:00:20

In this lesson, we will look at an exampleof how to perform a proper setup and send

00:00:24

a message from a PC to a HIL device usingthe Ethernet Variable Exchange Protocol.

00:00:29

We will also see how to implement a clientinstance of Ethernet Variable Exchange with

00:00:34

a Python script in the PC to send arbitrarymessages to HIL.

00:00:38

The PC, in this case, could be replaced toany other external device that you wish to

00:00:42

communicate with the HIL device.

00:00:45

To get started, let's open the example ETHVE Receive Test from the Example Explorer.

00:00:55

This is a simple example model that showsa basic setup of an Ethernet Variable Exchange

00:01:00

with TCP/IP protocol, between a PC and a HILdevice.

00:01:04

The HIL device plays the role of Server inthis setup, with the Ethernet Variable Exchange

00:01:09

Receive component.

00:01:10

This means that the HIL device will startthe server in the specified port and wait

00:01:14

for connections from the Client, which inthis case is the Ethernet Variable Exchange

00:01:18

Send instance in the PC.

00:01:21

Let's take a look how this is configured inthe HIL device.

00:01:23

First, open the Ethernet Variable ExchangeSETUP component.

00:01:28

In the properties window, it is possible tochoose the IP address.

00:01:32

Make sure this IP is not used elsewhere inthe network.

00:01:35

You may recall that we covered this processin detail in the Modbus Client in HIL SCADA

00:01:39

lesson.

00:01:40

Now, let's open the Ethernet Variable ExchangeReceive component.

00:01:45

Under the Network tab you can define the networkprotocol to be used: TCP or UDP.

00:01:50

For this Demo, TCP/IP is chosen.

00:01:53

The local receive port is the port which theclient will connect to in order to perform

00:01:57

requests.

00:01:58

Optionally, it is possible to configure aSource port and Source IP address, although

00:02:03

this isn't necessary for this simple example.

00:02:06

You can find out more about this in the documentationin the Materials tab.

00:02:11

Finally, in the Data tab it is possible toconfigure the signals to be received over

00:02:16

the network.

00:02:17

For this example, we will receive one variableof 4 bytes, real type.

00:02:21

It is possible to receive and send variablesand constants of real, integer, and unsigned

00:02:27

integer type, with 4- or 8-bytes length.

00:02:30

If you want to add more signals, simply includethem with the plus button by following the

00:02:34

procedure showed here.

00:02:36

Let's add a second signal called flag, keepit as a variable, choose the uint type, 4

00:02:41

bytes length, and click the Ok button.

00:02:44

You can see a new output terminal in the componentthat corresponds to the signal added.

00:02:48

Every signal will have an output terminaland you can verify the signal with a second

00:02:52

probe like this.

00:02:56

The probe here is used to verify the messageis received by the HIL device.

00:03:05

Now let's see how to setup the Ethernet VariableExchange Send instance, which represents the

00:03:10

client side of the communication.

00:03:12

You can access the Python script inside thesame folder as the model, shown here.

00:03:19

If you need a quick refresher on how to usePython, please feel free to check out our

00:03:23

Python basics lessons in the Test Automationcourse of the HIL Specialist 2.0 Specialization.

00:03:29

In this Python script, a Client Thread iscreated with the Server IP and port.

00:03:34

This Thread executes the function "write_fnc",that sends data to the HIL device using TCP/IP

00:03:40

protocol.

00:03:41

Inside this function the client creates asocket, connects to the Server instance, and

00:03:46

sends the data specified to the server.

00:03:48

The data in this case is an integer from 0to 20 and is sent in an interval of 300 milliseconds.

00:03:54

After that, the socket is closed and the communicationis stopped.

00:03:58

To establish connection with the HIL deviceusing the Ethernet Variable Exchange protocol,

00:04:03

you need to specify the Server IP addressand port, which was declared in the Ethernet

00:04:08

Variable Exchange Setup/Receive componentsbefore.

00:04:14

Now let's compile and load the model to theHIL device and perform the communication with

00:04:18

the Python script.

00:04:21

After loading the model and opening the SCADApanel, let's add a Probe as a digital display

00:04:25

and run the model.

00:04:26

After the model is running, let's open theconsole on the PC.

00:04:30

Let's go to the folder where the Python scriptis located with the change directory command

00:04:34

and execute the script with the computer'sPython interpreter.

00:05:01

After executing the script, we can see thenumber received by the Server in the digital

00:05:05

display at the SCADA panel.

00:05:08

With this we've now seen how to setup an EthernetVariable Exchange connection and learned how

00:05:12

to properly communicate with a HIL deviceusing the TCP/IP protocol.

00:05:17

Thank you for your attention.

Please Wait!

Please wait... it will take a second!