LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculating dynamic formulas with boolean operations

Using the formula evaluation VIs, you can setup a way for the user to enter the formula of his or her choice and calculate the result based on what the values are. The limitation is that these VIs don't support boolean operations like the formula node does or like manually coding the formula with a bunch of ANDs and ORs. If only the formula node could accept a formula to be entered at run-time.

 

Does anyone know of a way that will allow users to enter formulas with boolean operations, such as y = a & b, that will perform a bitwise AND, for example?

 

Thanks.

0 Kudos
Message 1 of 6
(3,392 Views)

Looks like there may be hope using VI scripting. Has anyone used VI scripting to modify a formula node before? Trying to mess with that now...

0 Kudos
Message 2 of 6
(3,379 Views)

I figure there has to be a way to get to a formula node by way of scripting.  So I started playing around.

 

See this.

 

 

Now this is just a VI that is basically operating on itself and shows the classes and properties do exist.

 

I think for your situation, you would need to dynamically create a new subVI.  Run scripting code to generate a formula node, the inputs and output node to the formula, controls and indicators to link to those nodes along with the wiring connections.  Then place the formula expression into the formula.  Then dynamically call the VI (may need to save it first) to send it your values and return the output.

 

It seems like it would be a lot of work, but certainly doable.

0 Kudos
Message 3 of 6
(3,356 Views)

At run time, it might be easier to use things like the formula waveform vi.

0 Kudos
Message 4 of 6
(3,340 Views)

It would seem a basic RPN calculator would be doable as well. Effectively create the parser itself. It isn't that difficult to do actually. Using the Scan String For Tokens VI would make this a pretty basic parser.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 6
(3,323 Views)