LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way the user can change the equation in the formular node from the front panel on the fly, dynamically?

Is there a way the user can change the equation in the formular node from the front panel on the fly, dynamically?
0 Kudos
Message 1 of 7
(3,997 Views)
Sorry, I don't think so. That would be pretty cool if you could create a property node for a formula node and then enter a formula on the front panel and use it to update the formula. But you can't create a property node for a formula node and the only way of modifying the formula is by typing it into the formula node on the diagram. And you can't modify a diagram of a running VI.
You could create a VI which is only a formula node with the maximum number of inputs and outputs you expect. Have a button on the calling VI to Edit Formula. When the button is pressed, use a VI server to display the front panel on the formula VI, display a dialog box telling the user how to display the diagram of the formula VI, then stop the calling VI. (You can't edit a sub-VI while t
he calling VI is running). The user will then need to rerun the calling VI to use the new formula.
You might be able to do something by calling MatLab or something like that to get an interactive formula window.
0 Kudos
Message 2 of 7
(3,997 Views)
You could try the Eval Formula Node.vi from the Mathematics / Fomula functions. This should give you what you need but it may only be available in the advanced analysis package from the full Labview.
Message 3 of 7
(3,997 Views)
YES!!! This can be done. I have done this when making a generic data system, and I wanted the user to be able to put in any kind of curve for converting to engineering units.

The trick, however, is that you don't use the traditional formula node from the Structures palette. You use the Mathematics->Formula->Eval Formula Node VI. If you look at this VI, it has inputs for the variable names for input, the variable names for output, and then the formula; then an input for the acutal physical values of the inputs, and an output for the calculated value.

For my application, I had one input, voltage, which I called "x"; I had one output, which I called "y"; therefore, the user could input "y=3*x+5;" for the formula, and when the voltage was input to
the VI, 3 times the voltage + 5 would be the output. Slick, huh?

Therefore, since there is an input for the formula, you can pick anything you want, and it's dynamic!

Mark
Message 4 of 7
(3,997 Views)
Very cool! I stand corrected. I'm still learning something new every day.
0 Kudos
Message 5 of 7
(3,997 Views)
Splendid, thanks for everyones input.
0 Kudos
Message 6 of 7
(3,997 Views)
As others suggested, you can use G-Math VIs that are supplied with LV for this purpose, but note that you will meet a lot of restrictions if you need something more complex than simplest equations. As an alternative, I would suggest you to look at CalcExpress toolkit. It contains formula parser and script processor that accept formulas/scripts as string parameter (you can change it at runtime). It can operate on real and complex scalars, strings and arrays thereof. Operators and functions are polymorphic just as LV functions. Scripts can involve loops and branches. Variables of a script can be easily shared with other parts of an application. It provides more than 200 functions and allows you to add new ones (implemented as VI!), etc., etc... You can find more informa
tion and download an evaluation at:
http://www.kshif.com/calcexpress/
0 Kudos
Message 7 of 7
(3,997 Views)