Jump to content

TCP communication between LabVIEW and Simulink

Recommended Posts

Hi everybody,

I'm currently trying to control a Matlab/Simulink simulation using a nice LabVIEW interface, but I'm experiencing some trouble reading the values back.

To make it simple, I send a numeric value using TCP write, Simulink processes it and then writes another numeric value back, which I read using TCP read.

I only connect to my local machine (the IP address could be "localhost", the result would be the same).

The returned value is then tested in order to display a particular picture according to it. (see attached subVI.vi)

My problem is: if I don't test the value (e.g I delete the subVI), the returned value is displayed correctly on the graph. But since I added the subVI, after reading several values (a few dozens maybe), LabVIEW won't read anything else but zero...

The data is updated by Simulink (I can monitor that in the model), but not read by LabVIEW. In the meantime, the control value sent by LabVIEW is read by Simulink, which means that the connection is still open...

I attached a picture of the main VI, but I believe the problem to be located somewhere in the subVI...

BTW I'm quite new to LabVIEW, and I'm sorry about the atrocities I might have coded in the VI :D

If anybody has an idea about what could be wrong in my VI, please let me know, any help would be much apreciated !



PS: I'm using LabVIEW 7.1

Edit : 2nd post :

It's me again,

I've done some more tests and It seems like the problem comes from the vi "read JPEG file" or maybe from "Draw Flattened Pixmap" or both. In fact, they are executed in the while loop, which slows down LabVIEW.

Could someone tell me how to store a "picture" flow (output of Draw Flattened Pixmap.vi) in a local variable so that the reading files part could be done only once ?

Thanks in advance,



Link to post

QUOTE (PJM_labview @ Dec 5 2008, 07:41 PM)

What you want to do is pre-load your images prior to really communicating with simulink (see screenshot).

Yes that's exactly what I wanted to do, thanks for your help PJM, your code works fine !

But I've still got a problem :(

The value is read and displayed, but only about 7 seconds after MatLab sent it...There seems to be a refresh rate issue under LabVIEW. When I just read the value and display it on a graph without displaying a picture, LabVIEW gets it in "real time"...That's why I thought preloading the images would do the trick...But it looks like it was only a part of the problem...

It looks like the execution of the "new picture" block requires enough processing time to delay the whole LabVIEW program (even though MatLab still works just as fast...). I tried to remove it and the graph display happened 2.5s after MatLab sent it.

The problem is : I need it !

Do you know of any way to improve that kind of speed ?



Edit : I found a way to display the pictures within a very acceptable delay by using an 8-bit color table instead of a default 24-bit when reading the jpeg files...

It's not exactly what I was dreaming of, but it's working...for the moment :D

Still, if someone knows how to speed things up, please let me know !

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.