xPC Target    

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 may be found in the xPC Target Library available from the Simulink Library under xPC Target, or you can access then form the MATLAB command line, by typing

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 500 bytes (i.e., a 1x500 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. The UDP part of the xPC Target Block Library is shown below.

xPC Target 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 xPC Target or Microsoft Windows.

All the blocks are set up to work both from within Simulink and from an application running under xPC Target. However, when using a Simulink simulation and an xPC Target application to communicate, or when using two Simulink models, care must be taken. This is because a Simulink model inherently executes in non-real time and may 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.


  xPC Target UDP Blocks UDP Receive Block