Main Content

Basic UDP Communication

This example shows how to transfer data over the UDP network using Simulink®.

Instrument Control Toolbox™ provides Simulink® blocks for sending and receiving data over TCP/IP and UDP networks. This example uses the UDP Send and Receive block to perform data transfer over a UDP network.

This example requires Simulink to open and run the model.

open_system('demoinstrsl_udpcommunication');

close_system('demoinstrsl_udpcommunication');

Setup

The input signal sent to the UDP Send block is a sine wave of frequency 1 radians/second. The UDP Send and Receive blocks use the 'localhost' for transferring data across two different ports. The port selected for the two UDP blocks are 51000 and 51001.

Result

The resulting sine wave is seen in the scope block connected to the UDP Receive block.

In this example, the UDP Send and Receive blocks exist in the same Simulink model and are run on the same machine. However, you can also use the UDP Send and Receive blocks in two different models and communicate across two different machines.