From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabPython new help getting variables

Solved!
Go to solution

Hello i am really new to labview and labpython and im trying to figure some stuff out. I have been handed a huge file with lost of vi's runnint and i need to import my python code into labview.

I have a few variables that need to run inside labview and others that need to run just so it can get the data. I have a csv file which the python code grabs data from and the sets an Int with that data, then reproforms this action over and over again for each line with a 5 second delay.

I need labview to set this Int as a glabal variable which i have set up. After it sets the glabla variable it needs to recieve 2 global varables and set them as Ints in the code, finally it needs to take a boolean from the code and set it as 1 of 3 outputs.

 

Ints:

t1input = (getfrom csv)

t1output = t1input                    

t2input = (t1ooutput - leak)   //this is the Int it needs to get into the code

 

bollean

if t2input >= 50% of t1input (true/false)

if t2intpit < 50% of t1output (true/false)

if t2input < 25% of tioutput (true false)

 

Im just not sure how to set this up. all these variables are in the same code so where do i tell labpython which one i want to use ?

i am attatching the csv and pastebining the python so you can check what variables i am using. 

python code = http://pastebin.com/NHDvKsNZ

 

Like i said i have basically been handed the labview file at work and told to get this working. Please dont get annoyed at me if i dont know the basics yet.

 

0 Kudos
Message 1 of 5
(3,290 Views)

That Python script is so basic, it would make more sense to simply implement it all in LabVIEW than trying to interface it to LabVIEW through LabPython. LabPython is not meant to query variables while a script runs. Rather it is sequentual like: set variables, execute script, read variables. The execute script function only returns AFTER the script has executed.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 5
(3,257 Views)

Thank you for your answer. could you possibly refer me to some learning documentation which i can use to put this script into labview. I am working wit a small team and we are all new to labview so no one is sure on how to get a straight code into labview correctly.

0 Kudos
Message 3 of 5
(3,238 Views)

@AceScottie wrote:

Thank you for your answer. could you possibly refer me to some learning documentation which i can use to put this script into labview. I am working wit a small team and we are all new to labview so no one is sure on how to get a straight code into labview correctly.


What he meant is that you need to write what that code does using LabVIEW.

 

0 Kudos
Message 4 of 5
(3,229 Views)
Solution
Accepted by topic author AceScottie

I think you would want to do something along these lines to get the Python script ecquivalent.

 

 

Python Strings.png

 

But there are several issues here. First the Python script always interpretes the number from offset 36 in the line but the sample data obviously doesn't always start at offset 36 for the number. Also the calculation of the fractional part I don't understand at all. It could be my understanding of what the script is supposed to do or my limited Python knowledge, but I'm pretty sure it does not do anything useful with that data set as is.

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 5
(3,220 Views)