Frequently Asked Question
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.
In the previous lesson, we learned that EthernetVariable Exchange is a custom protocol, meaning
you can define the messages to be transmittedbetween the HIL device and any external device
that has a proprietary or custom protocolover an Ethernet network.
In this lesson, we will look at an exampleof how to perform a proper setup and send
a message from a PC to a HIL device usingthe Ethernet Variable Exchange Protocol.
We will also see how to implement a clientinstance of Ethernet Variable Exchange with
a Python script in the PC to send arbitrarymessages to HIL.
The PC, in this case, could be replaced toany other external device that you wish to
communicate with the HIL device.
To get started, let's open the example ETHVE Receive Test from the Example Explorer.
This is a simple example model that showsa basic setup of an Ethernet Variable Exchange
with TCP/IP protocol, between a PC and a HILdevice.
The HIL device plays the role of Server inthis setup, with the Ethernet Variable Exchange
This means that the HIL device will startthe server in the specified port and wait
for connections from the Client, which inthis case is the Ethernet Variable Exchange
Send instance in the PC.
Let's take a look how this is configured inthe HIL device.
First, open the Ethernet Variable ExchangeSETUP component.
In the properties window, it is possible tochoose the IP address.
Make sure this IP is not used elsewhere inthe network.
You may recall that we covered this processin detail in the Modbus Client in HIL SCADA
Now, let's open the Ethernet Variable ExchangeReceive component.
Under the Network tab you can define the networkprotocol to be used: TCP or UDP.
For this Demo, TCP/IP is chosen.
The local receive port is the port which theclient will connect to in order to perform
Optionally, it is possible to configure aSource port and Source IP address, although
this isn't necessary for this simple example.
You can find out more about this in the documentationin the Materials tab.
Finally, in the Data tab it is possible toconfigure the signals to be received over
For this example, we will receive one variableof 4 bytes, real type.
It is possible to receive and send variablesand constants of real, integer, and unsigned
integer type, with 4- or 8-bytes length.
If you want to add more signals, simply includethem with the plus button by following the
procedure showed here.
Let's add a second signal called flag, keepit as a variable, choose the uint type, 4
bytes length, and click the Ok button.
You can see a new output terminal in the componentthat corresponds to the signal added.
Every signal will have an output terminaland you can verify the signal with a second
probe like this.
The probe here is used to verify the messageis received by the HIL device.
Now let's see how to setup the Ethernet VariableExchange Send instance, which represents the
client side of the communication.
You can access the Python script inside thesame folder as the model, shown here.
If you need a quick refresher on how to usePython, please feel free to check out our
Python basics lessons in the Test Automationcourse of the HIL Specialist 2.0 Specialization.
In this Python script, a Client Thread iscreated with the Server IP and port.
This Thread executes the function "write_fnc",that sends data to the HIL device using TCP/IP
Inside this function the client creates asocket, connects to the Server instance, and
sends the data specified to the server.
The data in this case is an integer from 0to 20 and is sent in an interval of 300 milliseconds.
After that, the socket is closed and the communicationis stopped.
To establish connection with the HIL deviceusing the Ethernet Variable Exchange protocol,
you need to specify the Server IP addressand port, which was declared in the Ethernet
Variable Exchange Setup/Receive componentsbefore.
Now let's compile and load the model to theHIL device and perform the communication with
the Python script.
After loading the model and opening the SCADApanel, let's add a Probe as a digital display
and run the model.
After the model is running, let's open theconsole on the PC.
Let's go to the folder where the Python scriptis located with the change directory command
and execute the script with the computer'sPython interpreter.
After executing the script, we can see thenumber received by the Server in the digital
display at the SCADA panel.
With this we've now seen how to setup an EthernetVariable Exchange connection and learned how
to properly communicate with a HIL deviceusing the TCP/IP protocol.
Thank you for your attention.