Skip to Main Content Skip to Search
Product Documentation

UDP Communication Setup

The infrastructure provided in the xPC Target Library for UDP communication consists mainly of two blocks — a Send block and a Receive block. These blocks are in the xPC Target Library, available from the Simulink Library under xPC Target. You can also access them from the MATLAB command line by typing

xpclib

The blocks are located under the UDP heading in the library. The Send block takes as input a vector of type uint8, which it sends. This is limited to a length of about 1450 bytes (i.e., a 1 by 1450 vector). Similarly, the Receive block outputs a vector of uint8. To convert arbitrary Simulink data types into this vector of uint8, a Pack block is provided, while an Unpack block is provided to convert a vector of uint8s back into arbitrary Simulink data types.

You can have up to 32 UDP blocks in any given model (Send and Receive blocks combined in any order).

The xPC Target block library includes a Byte Reversal block for communication with big-endian architecture systems. You do not need this block if you are communicating between 80x86-based PC systems running either the xPC Target or Microsoft® Windows® software.

All the blocks are set up to work both from within the Simulink environment and from an application running under the xPC Target system. However, you must be careful when using a Simulink simulation and an xPC Target application to communicate, or when using two Simulink models. This is because a Simulink model executes in nonreal time and can be several times faster or slower than real time. The sample time of the send and receive blocks and the sample time of the Simulink model must be set so that the communication can proceed properly.

Note the following:

See the UDP Data Streaming Demo for a demonstration of how to perform UDP data streaming with the xPC Target system.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS