Main Content

Basic UDP Communication

This example shows how to transfer data over a 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 UDP Receive blocks to perform data transfer over a UDP network.

This example requires Simulink to open and run the model.

Open Model

open_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 UDP Receive blocks use the 'localhost' for transferring data. Note that the UDP Send block remote port and the UDP Receive local port are both 51001.

Result

After running the model, you can see the resulting sine wave in the Scope block connected to the UDP Receive block.

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

Close Model

close_system('demoinstrsl_udpcommunication');

See Also

Blocks