LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data transfer LabView/Simulink through UDP

Solved!
Go to solution

Hello Hepta,

Thanks for the screenshots.

I found this help at MATLAB website: http://www.mathworks.com/help/toolbox/instrument/tcpipreceive.html

This describes an array format in the TCP/IP receive parameters window: [1 1]

Could you try to give in something like this?: [200 1] or [1 200]

You might get a vector of doube on the output of this block.

 

I also checked the LabVIEW file you sent and I think that part is OK.

 

Best Regards,

Tamas Szekely

0 Kudos
Message 21 of 36
(4,565 Views)

"I found this help at MATLAB website: http://www.mathworks.com/help/toolbox/instrument/t​cpipreceive.html"

 

I know the page, I've read this befor.

 

"This describes an array format in the TCP/IP receive parameters window: [1 1]

Could you try to give in something like this?: [200 1] or [1 200]

You might get a vector of doube on the output of this block."

 

Unfortunately it doesn't help. I tried it before I had wrote to You.

 

 

"I also checked the LabVIEW file you sent and I think that part is OK."

So, it seems to be hopeless :(.

Maybe you have other idea how to send this array

 

Best Regards,

Tamas Szekely

0 Kudos
Message 22 of 36
(4,560 Views)

I've been searching for solving problem and tried to connect LV server.vi with LV client vi. I figured out that tcp write has output "Bytes written". And it is necessary to configure tcp read.vi input "Bytes to read" with exactly the same value. If the value is differ  than transmission is failed, I mean data are transmitted but not converted into dbl array. The array is than not completed.

Refering to transferring data to simulink I have to some how define bytes to read in simulink but I have no idea how to do it.

 

Mayby you know, I hope so.

Best regards

0 Kudos
Message 23 of 36
(4,556 Views)

Dear Hepta,

 

Sorry for my late answer. I'll try my best to help you, however I'm not a simulink expert, so I can only guess what to do at that side, so I would like to ask you to co-operate in that part.

There is something I noticed on the first screenshot from Simulink you sent.

When you receive 200 DBL data, you can see different color lines on the OSC. It means that probably you could receive the array of data. Only the dimensions of the received array is understood by the oscilloscope graph as different channels. Maybe putting a "Transpose" or similar block into Simulink can help.

 

One more thing about writing arrays into TCP in LabVIEW:

If you connect 1 DBL value to write, it will appear as a 4 byte data at the end.

If you write an array of a DBL, it will be written as a stream. DBL1,DBL2,DBL3,DBL4. The same, if you would iterate 200 times the writing of One DBL value.

 

 

If still doesn't work fine, for troubleshooting, one thing, you can try to identify where the system fails working:

Slow down the cycle time of your simulation in Simulink (As I saw, you can provide this in the setup window of the TCP Receive block). Just to see if it works.

If it still doesn't work, lets iteratively find the problem.

As I would do this:

send 1 byte datas from LabVIEW (the type is: u8), and counting from 0,1,2,3.. You can do this by connecting the while loop iteration counter. Then receive it in simulink: Provide in the setup window: uint8

I guess, if it works, you might be able to see the values on the oscilloscope display of simulink.

 

Then you can try different data size: [1 1], [1 2], and then [2 1] ... without changing the LabVIEW code to send arrays.

 

I hope I could help you with some of my thoughts and ideas about it.

I'm looking forward to hear again from you, whether we could step forward with this problem.

 

Best Regards,

Tamas Szekely

0 Kudos
Message 24 of 36
(4,543 Views)

I've been reading like almost all of your posts and found very helpfull for my work. But I still have this problem trying to send data from Simulink to Labview via TCP/IP. In one of the forums I red it's not possible to do it when using different PC's, but I'm using just one and can't do it.  I attach the screen capture of what I'm trying to send from Simulink, is quite simple, just one double constant.

 

Simulink

So I'm just trying to send some data of type double to Labview. In Labview I've used many example of Clients, know I was trying with one published in the forum named tcp_client_simple. There I typed the direction (127.0.0.1) and run it, but after the 25 s the simulation stops because it does not found any connection. The same happened with some other files of clients and examples. But I just do not know where could be the problem. Please help me solve it. I would apprecciate any help, I'm running out of time.

 

Thanks!

0 Kudos
Message 25 of 36
(4,519 Views)

Dear Tomas,

I will like to simulate a one tank system model on simulink and use labview as the interface and front panel.can you please give me a labview vi that can communicate with the simulink model if possible

 

Osowoaji

0 Kudos
Message 26 of 36
(4,512 Views)

Hi, I was wondering if you could please upload your Labview VI for sending "double" data values from Labview to Matlab, and your Simulink code as well. I could not figure it out, thank you,

Aaron

0 Kudos
Message 27 of 36
(4,382 Views)

Attached is my VI to send data from Labview to Matlab

 

My Simulink Code is UDP Recive Binary to Unpack to Scope and also to simout

0 Kudos
Message 28 of 36
(4,380 Views)

I am asking for the VI from the very first post on page one of this forum. I need to send "double" data through UDP from Labview to Simulink. Could someone please let me know how to fix my VI or post a better one?

Thank you,

 

0 Kudos
Message 29 of 36
(4,375 Views)

Hi Ayur,

 

I am sure the VIs from the very first posts are coming from the example finder, what is the part of the NI softwares.

You can also find them with your software. It has that advantage, it will be in your native version.

 

Br,

Peter

0 Kudos
Message 30 of 36
(4,352 Views)