0
votes

I'm working on a project that requires a value be passed in real-time between Matlab's Simulink and Labview on networked systems (currently running Matlab 2010b and Labview 7.0). I've been trying to do this with UDP Send/Receive functions in either program, however Labview only seems to deal in Strings with UDP/TCP-IP. Simulink only reads int/double values from UDP ports.

Is there a way for me to convert these values AFTER the read-in operation, or otherwise get around the type restriction? Any advice (or alternative ways to pass a value between the two programs) would really be appreciated. Unfortunate, due to hardware restrictions, I'm stuck with these program versions.

Thanks!

1

1 Answers

5
votes

The TCP/UDP functions in LV use strings because it's a convenient way to represent an array of bytes, which is what a TCP stream basically is. You can take the data and convert it so that it's usable. Assuming Simulink encodes values the same way (simple binary for ints, IEEE754 representation for floats), then you can simply use the type cast or flatten to/unflatten from string functions to convert the data. You might need to change the order of the bytes to account for endianess.

You can look at the TCP examples in LV and the documentation on flattened data to understand more on how this works.

As a side point, UDP is lossy and is mainly suitable if you need to broadcast or get data quickly, like when streaming video. If the data is important, you should use TCP.