Search code examples
labview

Mathematical equations to create a virtual channel in LabVIEW


I need some help in creating a VI that generates virtual or calculated channels based on several channels I measure.

e.g. I measure voltage on several AI, lets say, ch A,B,C,D,E were B,C and E represent current on a shunt and would like to calculate a the power of the system

Q[A] = B+C
R[W] = A*Q
S[W] = D*E
T[W] = R+S

I would like to load the equations externally from a configuration file that may vary from one project to another equations would come in a format of a string Q=A+B , R= A*Q ..... *(during a run equation and channel count don't change - only when loading config).

The main issues that I am facing is that the inputs to each equation may have dependencies on virtual channels that do not have data yet

Was trying to use: formula nodes/ Math scripts: https://zone.ni.com/reference/en-XX/help/371361R-01/lvconcepts/formula_nodes/ https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000x30HCAQ&l=en-IL

All data that should be chunked into a data stream (continues sampling) that can be presented on a Chart/Graph and saved to CSV/TDMS

  • do I need some additional packages?

I have tried the following based on the the example given - getting strange result

enter image description here

enter image description here


Solution

  • Answer

    The elements you are looking for are not the Formula/Math Nodes but rather the:

    Formula Parsing VIs

    Parsing Nodes in the menu

    Using these VIs you are able to pass a calculation in the form of a string and an array of variable names and then evaluate the formula. This allows for run-time variable scripting, where most other nodes require compile time formula evaluation (With the exception of the python node).

    Example

    Example of using a very simple program to evaluate two different calculations using the same values and variables. Front panel of evaluation Block diagram of evaluation