LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I programatically perform a conditional formula in "Eval Formula Node"?

Okay, I'm stumped. I have an application where I need to evaluate a conditional programatically, and I can't do it with a Formula Node.

Basically, my user wants to be able to enter some formula which describes conditionals, such as "if this temperature goes above X degrees or this temp goes above Y degrees, then take a reading" kind of thing. Since the conditional will be saved in a file, the formula node needs to be dynamic.

I've used the "Eval Formula Node" before, which is built for this type of application...sort of. I tried it, but after trying in vain to get it to work properly, found out that it doesn't do boolean and conditionals in its parser, so it won't work.

Does anyone
have a good idea how to do this??
0 Kudos
Message 1 of 4
(3,966 Views)
Why do you even want to use the formula node at all? I don't think you "can take a reading" (i.e. interact with hardware) inside a formula node anyway.

The formula node allows conditionals, see e.g. the example in the online help (image attached).

You could also use a case structure with seperate formula node in each case.

I highly prefer to skip the formula node and use wires instead. It will be more efficient and also much easier to debug. A formula node is not "in the true spirit of LabVIEW" 😉
0 Kudos
Message 2 of 4
(3,966 Views)
I think you misunderstood my question.

I am a seasoned LabVIEW programmer,and I know you can't interact with hardware within a formula node. I was simplifying the explanation of what I'm trying to do.

My customer wants to be able to input, at his discretion, trigger points as to when data will be written to a file. Therefore, he wants to be able to enter something along the lines of:

If temp1 > 200 or temp2 > 300 then write acquisition data to a file.

I'd create a formula node to handle the conditional, with a 0 or 1 coming out of the formula node, change that to False (0) or True (1), and use that boolean to drive whether or not to write data.

However, the conditional is not the same for every test. Therefore, using the formula node l
ike you attached, is not the answer, as I stated in my first post. With that formula node, you have to pre-define the inputs, outputs, and formula; I can't do that. Therefore, I need to use a VI called "Eval Formula Node", which allows you to dynamically enter the inputs, outputs, and the formula.

The Eval Formula Node VI doesn't allow the use of conditionals (greater than, less than, equal to, OR, AND, etc), so now I don't know how to solve this.

Hard coding the wiring into LabVIEW isn't an option, since there are so many combinations that could occur, it would be impossible.
0 Kudos
Message 3 of 4
(3,966 Views)
Sorry I misunderstood. Now it's a bit more clear what you want to do.

You might just be able to use a plain string input and write your own simple parser. How complicated are the "formulas" (e.g. just one or two comparisons linked with AND or OR or complex boolean constructs with multiple levels of parenthesis, etc.)?

Most of the "Eval Forumal Node" is pure LabVIEW and it should be possible to reduce it to something that works for your problem.

Personally, I don't like to have users enter formulas. The chance of mistyped variables, syntax errors, etc. is just too big. Couldn't you have a graphical front panel, e.g. a cluster for each variable [Ring(Less|equal|greater,..); DBL(Limit); boolean(log|don't log)] or similar?
0 Kudos
Message 4 of 4
(3,966 Views)