UDP Blocks

UDP blocks to facilitate communication between real-time SimWB and non-real-time Simulink®.

Library

UDP Block Library: simwbUDPBlocklib

Description

SimWB UDP Blocks
The UDP Blocks are template blocks that facilitate the creation of an UDP interface between SimWB and Simulink. The From_SimWB_Host blocks receives data from the real-time host, and this data is then available for downstream Simulink blocks. The To_SimWB_Host gathers all data from Simulink and sends UDP data to the real-time host. These blocks are actually non-virtual subsystems that use blocks from the Real Time Workshop (Simulink Coder) library. You can look under the mask and view the subsystem. These UDP blocks use the Simulink UDP Blocks which are available in R2011a (Windows or Linux) and later.

Dialog Box - From_SimWB_Host

Number of Ports

Enter the number of ports for the block. Other blocks parameters change depending on this setting. The block is automatically resized to fit the number of ports.

Port Names

A cell array of port names. These names are displayed on the block and are used to generate the SimWB UDP interface. Changing the number of ports changes the port names by default.

Local IP address

This is the IP address of the system running the Simulink model in which this block is placed. This IP address will be used in the SimWB UDP interface. So that the real-time host knows where to send the UDP data. This IP address is used by the SimWB UDP interface.

Local IP port

This is the IP port of the system running the Simulink model in which this block is placed. This value defaults to 25000. The value can be in [1, 65535] range. Simulink will listen to this port for data sent by SimWB. This port number is used by the SimWB UDP interface.

Remote IP address ('0.0.0.0' to accept all)

This is the IP address of the real-time host system which will send data to the Simulink model. Specify the IP address from which to accept packets. Entering a specific IP address blocks UDP packets from any other address. To accept packets from any IP address, enter '0.0.0.0'. This value defaults to '0.0.0.0'.

Receive buffer size (bytes)

Make the reception buffer large enough to avoid data loss caused by buffer overflows. This block uses the double data type as default and, so for one output port with data type double the buffer size is automatically set to 8 bytes. Increasing the number of ports to two will automatically change the Receive buffer size to 16. The buffer size should always be set greater than the Maximum length of for Message.

Maximum length for Message

Specify the maximum length, in vector elements, of the data output vector. Set this parameter to a value equal or greater than the data size of any UDP packet. The system truncates data that exceeds this length. This block uses the double data type as default and so for one output port with a data type double the Maximum length for Message is automatically set to 8. Increasing the number of ports to two will automatically change the Maximum length for Message to 16.

Blocking time (seconds)

For each sample, wait this length of time for an UDP packet before returning control to the scheduler. This value defaults to inf, which indicates to wait indefinitely.

Sample time (seconds)

Specify how often the scheduler runs this block. Enter a value greater than zero. In real-time operation, setting this option to a large value reduces the likelihood of dropped UDP messages. This value defaults to a sample time of 0.01 s.

Output port dimensions (cell array)

Containing a cell array, each element in the array specifies the dimension that the MATLAB size function returns for the corresponding signal. Usually you use the same dimensions as you set for the corresponding Byte Pack block in the model. Entering one value means that the block applies that dimension to all data types. This field is automatically populated based on the number of ports.

Output port data types (cell array)

Specify the data types for the different input signals to the Pack block. The block supports all Simulink data types — single, double, int8, uint8, int16, uint16, int32, and uint32, and Boolean. The entry here is the same as the Input port data types parameter in the Byte Pack block in the model. You can enter one data type, and the block applies that type to all output ports. This field is automatically populated based on the number of ports.

Byte Alignment

This option specifies how to align the data types to form the input uint8 vector. Match this setting with the corresponding Byte Pack block alignment value of 1, 2, 4, or 8 bytes.

Dialog Box — To_SimWB_Host

Remote IP address ('255.255.255.255' for broadcast)

Specify the IP address or host name to which the block sends the message. To broadcast the UDP message, retain the default value, '255.255.255.255'. This will be the address of the real-time host.

Remote IP port

Specify the port to which the block sends the message. The port value must be in the [1, 65535] range. The Default value is 25000. This will be the port of the real-time host.

Input port data types (cell array)

Specify the data types for the different signals as part of the parameters. The block supports all Simulink data types except characters. Enter the data types as Simulink types in the cell array, such as 'double' or 'int32'. The order of the data type entries in the cell array must match the order in which the data arrives at the block input. This block determines the signal sizes automatically. The block always has at least one input port and only one output port.

Byte alignment

This option specifies how to align the data types to form the uint8 output vector. Select one of the values in bytes from the list. Alignment can occur on 1, 2, 4, or 8-byte boundaries depending on the value you choose. The value defaults to 1. Given the alignment value, each signal data value begins on multiples of the alignment value. The alignment algorithm ensures that each element in the output vector begins on a byte boundary specified by the alignment value. Byte alignment sets the boundaries relative to the starting point of the vector.

Related Links