LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing large arrays from labview to python scripts (and returning)

 

Hi,

 

I want to call a python script within my labview VI to process some data stored in a large array (around 48000 elements) and pass another (much smaller) array back to labview. My aim is to call the script in a loop - constantly updating and processing the data - so ideally, the method of passing the data to the script would need to be fairly efficient.

 

I've seen the System Exec.vi example here http://www.ni.com/tutorial/8493/en/

Can I pass large arrays as input arguments? Is this an efficient way of doing it?

 

I've also seen some references in various forums to using sockets to pass data between python and labview. Any examples of how to do this?

 

 

Thanks, Mike

0 Kudos
Message 1 of 4
(4,069 Views)

I posted an example using LabPython to solve a tough math problem just a little while ago.  If you can use open source toolkits, LabPython is a possibility that'll let you avoid passing data out of LabVIEW to System Exec.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 2 of 4
(4,067 Views)

 

 

Thanks jcarmody. I had a go with your example and was able to get it to work with arrays as inputs but couldn't get it to work with python packages (e.g. numpy). I get a syntax error when I try and use the import command in the scipt file.

 

Also, I could only get it to work on python 2.5. All my code is written for python 2.7 and I'm nost sure about compatibility. Will labpython work with python 2.7?

 

Thanks, Mike

0 Kudos
Message 3 of 4
(3,979 Views)

According to its creator, Rolf Kalbermatter, it should work with 2.7.  The bad news is he has dropped the project so there have been no updates for over 10 years.  See this post for more info:  http://forums.ni.com/t5/LabVIEW/Trouble-with-LabPython-Setting-up-the-Python-Server/td-p/1444082

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 4 of 4
(3,967 Views)