UDP Communication Setup

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

slrtlib

The blocks are located under the Real-Time UDP heading in the library. The UDP Send block takes as input a vector of type uint8, which it sends. The UDP Receive block outputs a vector of uint8. To convert arbitrary Simulink data types into this vector of uint8, use a Byte Packing block. To convert a vector of uint8s back into arbitrary Simulink data types, use a Byte Unpacking block.

If you are using a dedicated Ethernet port for UDP communication, use a UDP Configure block to configure the Ethernet interface.

You can have up to 32 UDP blocks in a model—UDP Send and UDP Receive blocks combined in arbitrary order, plus the optional UDP Configure block.

To communicate with big-endian architecture systems, use the Byte Reversal/Change Endianess block. Your model does not need this block for communicating between 80x86-based computer systems running either the Simulink Real-Time kernel or the Microsoft® Windows® operating system.

The blocks work from within the Simulink environment and from a real-time application running under the Simulink Real-Time system. Be cautious about transmitting data between a Simulink simulation and a real-time application, or using two Simulink models. A Simulink model is not a real-time model and can run several times faster or slower than a real-time application. Set the sample time of the UDP Send and UDP Receive blocks and the sample time of the Simulink model so that the blocks can communicate.

  • You cannot configure two UDP Receive blocks with the same local port. For example, two UDP Receive blocks cannot have the same local port and different IP addresses.

  • You cannot configure two UDP Send blocks with the same local port. For example, two UDP Send blocks cannot have the same local port and different IP addresses.

See Also

| | | |

Related Topics