MATLAB Examples

Communicating with Xilinx Zynq Hardware using UDP protocol

This example shows you how to send data using the UDP Ethernet protocol from a Simulink® model running on Zynq hardware to another model running on the host computer.

Contents

Introduction

In this example you will learn how to build a Simulink model and run executable on Zynq hardware that sends data to the host computer using User Datagram Protocol (UDP). A companion model running on the host computer will receive UDP data packets coming from Zynq hardware.

Prerequisites

Required Products

  • DSP System Toolbox™
  • Computer Vision System Toolbox™

Requirements

  • Xilinx ISE® Design: Suite Embedded Edition (version 14.4 or later)
  • Xilinx Zynq ZC702 Evaluation Kit
  • Xilinx Zynq ZC706 Evaluation Kit
  • ZedBoard™

Task 1 - Run UDP Communication Model on Zynq Hardware

Following figure shows an algorithmic model that detects the edges of an input image using the Sobel edge-detection method.

In this task, you will configure and run the Sobel edge-detection model that sends UDP packets to the host computer. This model also receives the threshold value from the host computer via UDP. The model is pre-configured for Xilinx Zynq ZC702 evaluation kit.

1. Open the target hardware model.

2. Double-click on the UDP Send block to open the mask. Enter the IP address of your host computer in the Remote IP address edit box. For example, if the IP address of your host computer is '192.168.1.1', enter '192.168.1.1' in the block mask. Do not change the Remote IP port parameter, as the UDP Receive block in host model (explained in Task 2) uses the same port number. Click "OK" to save and close the block mask.

3. Double-click on the Image_and_Threshold subsystem block. Next, open the mask of UDP Receive block and enter the IP address of your host computer in the Remote IP address edit box. Do not change the Local IP port parameter, as the UDP Send block in host model (explained in Task 2) uses the same port number. Click "OK" to save and close the block mask.

4. Click "Build" button on the model toolstrip or press Ctrl+B.

5. The model running on Zynq hardware will start sending UDP packets to port 25000 of your host computer and it will receive packets from port 25001 for controlling threshold of Sobel edge-detection algorithm.

Task 2 - Run UDP Communication Model on Host Computer

Following figure shows the model that will be run on host computer.

In this task, you will run the host model that receives the UDP packets sent by the model running on Zynq hardware. You will also change the threshold of the Sobel edge-detection algorithm running on Zynq hardware.

1. Open the host model.

2. Double-click on the UDP Send block to open the mask. Enter the IP address of your Zynq hardware in the Remote IP address edit box. For example, if the IP address of your Zynq hardware is '192.168.1.10', enter '192.168.1.10' in the block mask. Do not change the Remote IP port parameter, as the UDP Receive block in target hardware model (as it was explained in Task 1) uses the same port number. Click "OK" to save and close the block mask.

3. Double-click on UDP Receive block and enter the IP address of your Zynq hardware in the Remote IP address edit box. Do not change the Local IP port parameter, as the UDP Send block in target hardware model uses the same port number. Click "OK" to save and close the block mask.

4. Click the "Play" button to start simulation.

5. Double-click the Slider Gain block to vary the threshold value and observe the changes in the Video_Sobel window.

Task 3 - Stop the Model Running on Zynq Hardware

1. On MATLAB command line, execute the following

h = zynq();
stop(h,'zynq_udp_server');

Summary

This example showed how to send data from a model running on Zynq hardware to the host computer using UDP protocol. It also described how another model running on the host computer can receive the data.