LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Scripting

Hi,

 

I am new using LabVIEW and have been able to develop a vi file that controls valves and records data. It has worked fine, however now I need to modify the vi in such a way as to run a valve open/close sequence based off a script (.txt file).

 

I understand the basic principle in setting up the text file, however I am not sure how labview reads the file and determines which column in the file corresponds to which valve. I was wondering if any of you could help me with this issue; I have attached my vi and script; I need to relate the boolean array created by the for loop with the valves in the while loop. Basically I need to know how to relate the columns in the script file (with 0's and 1's for closed/open) to the valves in my vi.

 

Also,  I need to find a way to have the script set a maximum value for the pressure readings, in such a way that if the pressure gets higher than the maximum value the vi would stop and run a different sequence. 

 

I would really appreciate any help or guidance you could provide me with

 

Thank you

Download All
0 Kudos
Message 1 of 4
(2,302 Views)

-->"Basically I need to know how to relate the columns in the script file (with 0's and 1's for closed/open) to the valves in my vi."

 

First, here's a good example on reading from a text file and writing to an array:

 

https://decibel.ni.com/content/docs/DOC-16813

 

From there, once you've broken down your text file into an array, you can use the vi I've attached here to convert a single string character (0 or 1) to a boolean command (false or true, respectively).  You can use this boolean and an invoke node to set the condition of the valve switch.

 

(see: http://zone.ni.com/reference/en-XX/help/371361H-01/glang/invoke_node/ for help on invoke nodes)

 

 

-->"Also,  I need to find a way to have the script set a maximum value for the pressure readings, in such a way that if the pressure gets higher than the maximum value the vi would stop and run a different sequence."

If you index the array you create to pull those maximum values, then convert them to numeric values, you can compare that to the pressure readings using a 'less than' or 'greater than', and use the resulting boolean to stop the while loop and move on to another piece of code.  Just my initial thoughts, let me know if I can clarify anything.  And if I come up with anything more elegant I'll let you know.

 

 

[Sample Code License Disclaimer:

The attached Code is provided As Is.  It has not been tested or validated as a product, for use in a deployed application or system, or for use in hazardous environments.

You assume all risks for use of the Code and use of the Code is subject to the Sample Code License Terms which can be found at: http://ni.com/samplecodelicense.]

 

National Instruments
Message 2 of 4
(2,252 Views)

Hi Chizz,

 

Thanks for your reply and I apologize for not replying earlier. I was having some trouble reading the vi you sent me due to the fact that I possess LabVIEW 2009 and the vi you sent me was programmed in LabVIEW 2011. Is there a way to read 2011 in 2009?

 

Thanks for your help!

0 Kudos
Message 3 of 4
(2,223 Views)

Hey,

 

Sorry about that, should have asked what version you were running.  The easiest way to read it is to backsave to 2009 in 2011, which I've done and attached the '09 version here.  Let me know if you have any success!

 

Regards,

 

Chris D.

National Instruments
0 Kudos
Message 4 of 4
(2,179 Views)