Documentation Home Page RT-LAB Home Page
Pour la documentation en FRANÇAIS, utilisez l'outil de traduction de votre navigateur Chrome, Edge ou Safari. Voir un exemple.

Ethernet Communication Interface

Description

This document explains how to use the Ethernet communication interface to transmit/receive data. The block is using Opal-RT asynchronous process mechanisms to exchange data between the Simulink model and the process responsible of the TCP/IP or UDP/IP communication. The process is migrated on core 0 and has no effect on the real-time performance of the model.

The block is fully configurable to operate either as a TCP client or a TCP server or to operate over UDP. The source code of the asynchronous process is provided with the example model. The customer is responsible of modifying this code to add custom features to the interface.

Supported

The following is a list of the features supported by this driver:

General
  • Configurable network interface
  • Configurable number of data to send
  • Configurable number of data to receive
  • Configurable data endianness (for encoding and decoding)
  • Data encoding and decoding (U8, I8, U16, I16, U32, I32, FLOAT, DOUBLE)
  • Configurable data payload offset
  • Multiple blocks supported within the same model
TCP client
  • Configurable server IP address
  • Configurable port number
  • Data transmission
  • Data reception
TCP server
  • Configurable port number
  • Data transmission
  • Data reception
UDP
  • Configurable remote IP address
  • Configurable port number
  • Datagram broadcast

These features will be detailed in the next section.

Driver Configuration

The driver is configurable using the mask of the Simulink block.

General Configuration

Controller IDUnique identifier for asynchronous process blocks. If multiple Ethernet communication interface blocks are used, this number must be different. It should also be different than the Controller ID(s) of other(s) asynchronous process blocks in the same model if any.
Number of data to sendNumber of data to send to the remote endpoint. The size of the vector connected to the 'Data to send'input of the block must match with this number.
Type of data to sendBefore sending the data to the remote endpoint, it will be encoded according to the type selected in the dropdown list. The block supports U8, I8, U16, I16, U32, I32, FLOAT and DOUBLE data types. If different data types are required to be transmitted by the same block, the user must customize the asynchronous process source code to transmit a custom frame.
Byte offset of transmission bufferUsing this parameter, the user can specify the number of bytes that will be inserted at the beginning of the transmission buffer (payload of the UDP or TCP layer). These bytes will be filled up with null values (0). The data from the Simulink model will be added after these bytes. If the offset bytes need to have a value different than zero, the user must customize the asynchronous process source code.
Swap data endianness before transmissionIf enabled, data will be not be transmitted in host-to-network byte order (HTON) but in network-to-host byte order (NTOH).
Number of data expected to be receivedNumber of data expected to be received from the remote endpoint. The size of the vector connected to the 'Data received'output of the block must match with this number.
Type of data to receiveReceived data is decoded according to the type selected in the dropdown list. Then, this value is converted into a double precision floating point type before being returned to the Simulink model. The block supports U8, I8, U16, I16, U32, I32, FLOAT and DOUBLE data types. If different data types are required to be received by the same block, the user must customize the asynchronous process source code to receive a custom frame.
Byte offset of reception bufferUsing this parameter, the user can specify the number of bytes to skip in the payload of the TCP or UDP layer before reading the data to be returned to the model.
Swap data endianness before after receptionIf enabled, data will be converted in network-to-host byte order (NTOH) before being returned to the Simulink model. Otherwise, data will be kept in the host-to-network byte order (HTON).
Executable nameName of the executable that will be transferred to the target during the load of the model. This parameter must only be changed if the customer modified the makefile (.mk) to generate an executable with a different name than AsyncEthernet.

Communication

Network interface nameName of the physical network interface on which the communication will be done. The default value is 'eth0'.
ProtocolProtocol of the transport layer. It can be 'TCP' for reliable client/server communication or 'UDP' for connectionless communication.
TCP modeWhen the protocol is configured as TCP, the user must choose if the block will operate as a TCP client, initiating a connection with a remote TCP server, or a TCP server, waiting for a connection from a TCP client.
PortWhen the protocol is configured as a TCP client, the client will attempt to connect a remote TCP server waiting for a connection on this port number. When the protocol is configured as a TCP server, the server will wait for a connection from a remote TCP client on this port number. When the protocol is configured as UDP, the block will transmitUDP datagrams on this port number (if data configured to be transmitted) and wait for UDP datagrams on this port number(if data configured to be received).
Remote IP addressWhen the protocol is configured as a TCP client, the client will attempt to connect a remote TCP server with that IP address, waiting for a connection. When the protocol is configured as a TCP server, this field is not used. When the protocol is configured as UDP, the block will transmitUDP datagrams to this IP address (if data configured to be transmitted) and wait for UDP datagrams from this IP address(if data configured to be received). The remote IP address must be configured to 255.255.255.255 to broadcast UDP packets.


In all configurations, data can be configured to be exchanged in both directions.

Inputs/Outputs

Inputs

Data readyThis input can be used to configure the rate of the data exchange between the Simulink model and the asynchronous process execution. If this input is always 1, the asynchronous process will run as fast as possible to transmit and/or receive data. A square wave signal can be applied to this input to slow down the data transmission and reception of the asynchronous process. Please refer to asynchronous processes generic documentation for more details.
Data to sendThis input expects to receive a vector of Simulink doubles to transmit to the remote endpoint. The width of this vector must match with the 'Number of data to send' parameter configured in the block mask.

Outputs

Data receivedThis output will provide a vector of Simulink doubles received from the remote endpoint. The width of this vector must match with the 'Number of data expected to be received' parameter configured in the block mask.
StatusThis output will provide two status to the Simulink model; the first one is for the transmission and the second one is for the reception.
Transmission status
  • 0: Not connected
  • 1: Connected and transmitting
  • -1: No data configured for transmission
  • -2: Connected (TCP) and error on last transmission


  • 0: Not connected (TCP) or nothing received yet (UDP)
  • 1: Connected (TCP) and last reception successful
  • -1: No data configured for reception
  • -2: Connected (TCP) and error on last transmission (i.e unexpected number of bytes received)

Files Transfer

A Simulink callback handles the files transfer. The asynchronous process source code and makefile will be automatically transferred to the target before the compilation and the generated executable will be retransmitted to the host, once compiled. At each model load, it will be transmitted to the target to be executed.

Limitations

The actual version of the driver has the following limitations:

  • Only TCP and UDP are supported.
  • One block cannot transmit/receive data with mixed data types.
  • In UDP mode, the block cannot be configured to receive data from a given IP address and transmit data to a different one.

OPAL-RT TECHNOLOGIES, Inc. | 1751, rue Richardson, bureau 1060 | Montréal, Québec Canada H3K 1G6 | opal-rt.com | +1 514-935-2323