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: 

How to configure test conditions from a file?

We have a generic test setup that reads channels from a configuration file and sets up the cards appropriately.  This is all fine and good.  Next we want to specify the test conditions in the configuration file.  The test conditions can be arbitrary, like "ch1 > 3.14 for more than 50 ms and any 2 of ch2, ch3, ch4 are > 123.45 for more than 25 ms."  I REALLY don't want to invent yet another expression language.  I thought about using MathScript but then I thought, why not use a VI?  Can I reference a VI that captures all the test-specific conditions and call it programmatically on the RT PXI target?  Is this even a good idea?  Has anyone run into a similar problem?

 

Thanks.

 

0 Kudos
Message 1 of 17
(2,994 Views)

Hello,

 

You can definitely create such a VI. Using Open VI Reference, you can remotely reference a VI and pass to it the channels and voltages that you wish. Please reply if you have questions.

National Instruments
0 Kudos
Message 2 of 17
(2,947 Views)
OK, are there examples of this?  But just because I CAN doesn't mean I SHOULD.  The down-side of the VI approach is that it requires the end-user to have a LabView development license to create their test condition VIs.  We're delivering our system to our customer and until now had no requirement that they need a LabView license.
0 Kudos
Message 3 of 17
(2,945 Views)

Why not just store the test parameters in a .CSV file then read the file with the Read Spreadsheet File.VI?

 

Anyone can create a .CSV with any text editor just seperate the values with commas.

 

value1,value2,value3

 

Just make sure you set the Read Spreadsheet File.VI delimiter input to a comma (,)

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 17
(2,935 Views)

OK, how do I represent an arbitrary expression tree with a CSV file?

 

0 Kudos
Message 5 of 17
(2,928 Views)

It depends on how much string parsing you want to do and how flexable it needs to be.

 

Right off teh top of my head I would say you could do something like this:

 

for say "ch1 > 3.14 for more than 50 ms and any 2 of ch2, ch3, ch4 are > 123.45 for more than 25 ms." in the csv file you could have

 

ch1,>,3.14,50ms,ch2,>,123.45,25ms,ch2,>,123.45,25,ms,ch3,>,123.45,25ms,ch4,>,123.45,25ms

 

Then use Read Spreadsheet File.VI set to read a string.

 

That will output a string array with each element containing each value that is seperated by the commas.

 

Then you index the array elements and convert them to numbers as needed for input to your vi's

 

Use the fields elements containg the < or > to select cases fo comparing as needed

Message Edited by RTSLVU on 01-30-2009 02:13 PM
========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 6 of 17
(2,924 Views)

Oh sure.  I don't need a CSV for that -- I can store the test condition as a string in my config file.  But as you point out, it involves writing a grammar parser in VI.  I'd really rather not if I don't have to.  I'm looking into using MathScript ...

 

0 Kudos
Message 7 of 17
(2,920 Views)

OK, it seemed like the Eval Multivariable Scalar was going to be the solution I wanted.  I thought I could feed it a string like "(a > 2.3) || (b < 3.14)" but it apparently doesn't like boolean expressions.  I keep getting "wrong variable name."  I get this error for something as simple as "a && b".  How can I get the eval to use a boolean expression?

 

0 Kudos
Message 8 of 17
(2,897 Views)

Hello,

 

You could build an executable out of your VI to give to your client, then you can just provide them with a LabVIEW runtime Installer so that they can run it without having LabVIEW and there is no need for a license.

 

This can be done in your project explorer window if you right click Build Specifications and select new Installer and new Exe.

 

 

National Instruments
0 Kudos
Message 9 of 17
(2,869 Views)

As much as I'd like to charge the customer every time they want to change their test conditions, I don't think that will be an acceptable solution to them.  The idea is to empower them to go off an do tests by themselves.  Besides, I tried out the VI approach and uncovered an issue.  The VIs must all have the same input/output connectors (of course), which means I need to pass in an array of all the channel values.  The problem is that from one test to the next, the number of channels may change while the test condition might not.  So either there needs to be a new test condition VI with the indices changed (error prone) or the VI needs to look up the channel index by name every time it's called (at 100 Hz).

 
0 Kudos
Message 10 of 17
(2,858 Views)