Reading data into SIMULINK/MATLAB over UDP

7 views (last 30 days)
I am trying to read data into my SIMULINK model using the UDP receive block in the Instrument Control Blockset (I have also tried the UDP block from the Signal Processing Blockset). Within my local network, I have a device that is broadcasting data over the network using UDP protocol. I believe that I have entered all the parameters in the UDP block correctly and yet MATLAB does not seem to be able to communicate with the device. I have also tried using the tmtool in Matlab with a similar result. I created an interface object for the device and tried receiving data while it was broadcasting but I still do not receive any data. I have performed the following checks: 1) I pinged the IP of the device from the computer where MATLAB and it responds fine 2) Using wireshark, I could see that the device was broadcasting the data.
If you go to the URL below, you can see a snapshot from Wireshark. It shows the destination IP (set up for broadcast), the source IP, and the port numbers.
Can someone help configure the SIMULINK blocks (or the tmtool in MATLAB) so that I can receive the data being broadcast?
Thank you very much for your help.
Juri

Accepted Answer

Andres
Andres on 3 Aug 2011
If your network configuration works fine and you are sure of it you should check your data configuration
The data type that you had choose is really significat when getting a correct output. Make sure that both data types match and also check the endian type chose (better try Littel Endian frist)

More Answers (1)

Arnaud Miege
Arnaud Miege on 5 Apr 2011
If creating a UDP object in MATLAB does not work, then it's no surprise that the Simulink approach does not work either.
What are the settings of the UDP Receive block? Have you tried clicking on the button " Verify address and port connectivity "? Does it work?
Also, have you looked at the documentation Creating a UDP Object and Writing and Reading Data?
HTH,
Arnaud
  2 Comments
Juri Minxha
Juri Minxha on 18 Apr 2011
Hi Arnaud, I am pretty sure that I am setting things up correctly. I seem to get data, the problem is that it is all 0s. The amount of data also seems to be correct but for some reason the entries are not. Did you get a chance to look a the image in the link above? It's a wireshark snapshot. Give that, what two ports am I binding with the UDP object?
Thanks for your input!
Juri
Arnaud Miege
Arnaud Miege on 18 Apr 2011
Yes, I saw the snapshot, but that doesn't tell me much. It would be much more useful to know how the blocks are configured and what you get when you try "verify address and port connectivity" in the UDP Receive block. You can probably leave the local port to -1 (automatic) and the port needs to match what's on the host you're connecting to. Is the data encoded in any way, does it need to be decoded? You can also look at what's coming out of the status output.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!