Eval formula node expression​s

Hi
What are the acceptable formula inputs for the Eval Formula Node VI?
The help files do not mention much. It took me a long time to work out that 2*pi needed to be written pi(2).
I would also like to know if I can perform 'if' statements and what the correct syntax is.
My application uses two inputs (an integer and a voltage reading), a formula that the user enters (eval formula node vi), and an output number (DBL).
UniSA, Mawson Lakes, South Australia - LV 8.6.1
Attachments:
FormulaNodeExampleLV8_6.vi ‏12 KB

Hi mikie121
Take a look here. The  syntax, operators, and functions links will be what you are looking for.
Joe Daily
National Instruments
Applications Engineer
may the G be with you ....

Similar Messages

  • Why do in-line conditiona​l expression​s work in Formula Node but not in 'Eval Formula Node.vi'?

    'Eval Formula Node.vi' and a standard Formula node seem identical in most respects in terms of their functionality, however I'm stumped by the case of inline conditional expressions. 
    I'd like to read in a string in the syntax "(expr)?(expr)expr)" from a text file and recieve the output as a double.
    The subVI seemed like the perfect tool since I was already using it to interpret a number of other calculations within the text file, however in this case the behavior is not as expected.
    Has anyone else ever tried this? is there a different syntax needed between the two tools?
    Are there other features of the Formula Note not replicated by this VI?  (so I can avoid them in future)?
    For simplicity I've attached a little demo of the behavior.
    I am currently working in 2010, which I know is getting on in years.
    If the behavior is improved in later versions, that may be a good excuse to upgrade :-) 
    Thanks,
    Elaine R.
    Attachments:
    Conditional Formula Node demo.vi ‏13 KB

    .aCe. wrote:
    Eval formula Node does not do any conditional expressions as far as I am aware.
    That is right. It's a rather dirty hacked VI library to do some formula evalution and has many limitations in comparison to the Formula Node including no support for conditional operator as well as some others. In addition it can also error on some more complex bracketed expressions.
    It is an old example VI that was never revisited and probably never will be as writing a new one from scratch would be easier. But considering that the Formula Node and Mathscript and other possibilities exist, this is not likely going to happen soon.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Why do I receive Error -23088 when using the Eval Formula Node.vi (LV6.1)?

    Hi,
    I want to evaluate formulas like x=v>20; with that vi. When typing the
    same formula into an normal Formula Node I get the correct answer. When
    changing the formula into x=v+20; the eval Formula node.vi works fine.
    But whenever I try to resolve a boolean function like that mentioned
    above, I receive that f****n Error! Why this? What can I do? Is the Eval
    ... .vi less powerfull than the normal node?
    Thanks for your help,
    Daniel

    Joel A wrote:
    > I think the boolean (binary) ops are the only difference between the two nodes.  I pulled this from the help:
    > Formula Node and Expression Node Functions
    >
    > The following list contains the names of the Formula Node and Expression Node functions, and their descriptions. Except for the binary functions, you also can use these functions with <a href="gmath.chm::/Parser_VIs.html" target="_blank">Formula VIs</a>. All function names must be lowercase. You also can use <a href="mk:@MSITStore:C:\Program%20Files\National%20Instruments\LabVIEW%208.0\help\lvhowto.chm::/Precedence_of_Operators_in.html" target="_blank">operators</a> and the pi constant in Formula and Expression Nodes.
    > Start at the help above, and see if you can find any helpful information.
    > &nbsp;
    > &nbsp;
    > J
    Thanks for help,
    I solved the problem by using the "Parse Arithmetic Expression.llb" from
    examples. You can modify it and add the operators you need..

  • Really need Min(a,b) and Max(a,b) function in "Eval formula node"

    Hi all,
    I've been using the 'Eval formula node" to let the user of my app configure his own calculations,
    but now I've found out that the "Eval formula node" doesn't support these functions.
    e.g        y= min (a,b)
    or         y = max (a+3, c-4)
    I considered adding them myself to the Eval formula node's subvi's,
    but franckly I've never seen such complex subvi's :-)
    Is pretty urgent. Any ideas?

    MegKB wrote:
    Maybe the MathScript node is the way to go now, as long as you want to install MatLab.
    The MathScript node does NOT need Matlab.  It runs Matlab-like code, but it is totally inside of LabVIEW.  There is a Matlab node that uses ActiveX to run Matlab.  For that you need to have Matlab installed.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • 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??

    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" ;-)
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    FormulaNode.gif ‏2 KB

  • Eval formula node vi cannot work with simple math functions

    Hi I have problem using eval formula node.
    And it produces error.
    The formula is AI0=AI0-AI6; AI1=AI1-AI6; AI2=AI2-AI6; AI3=AI3-AI6; AI4=AI4-AI6; AI5=AI5-AI6;
    Pls see the attached. I am using LV 7.1
    Pls help. Will be grateful for your help
    Clement
    Solved!
    Go to Solution.
    Attachments:
    eval_formula_test.vi ‏29 KB

    Yes, the problem are your variable names.
    Can you give us a bit of background why you want to do such a complicated and inefficient method for such a simple operation. The same could be done trivally with exactly three primitives (index array, array subset, subtract) and no purple at all.
    LabVIEW Champion . Do more with less code and in less time .

  • フォーミュラノード解析(Eval Formula Node.vi)について

    LabVEW2013
    Eval Formula Node.viに式を与えて計算させようとすると「エラーコード-23087が不明位置で発生」しました。
    同じ式をフォーミュラノードに与えると正常に計算し結果が出ました。
    2日ほど試行錯誤して、変数名に大文字が含まれるとParse Formula String.viが構文解析に失敗することがわかりました。
    mu=T1+P1;
    はエラーになりますが、
    mu=t1+p1;
    はエラーになりません。
    大文字が含まれる変数名も受け入れる様に改良されることを望みます。
    解決済!
    解決策の投稿を見る。

    これは仕様なのでしかたがないと思います。
    http://zone.ni.com/reference/ja-XX/help/371361J-0112/gmath/variables/
    http://zone.ni.com/reference/en-XX/help/371361K-01/gmath/variables/
    フォーミュラ解析VIで使用できるのは、以下の変数のみです。
    メモ  これらの変数は、「非線形カーブフィット」VIのフォーミュラ文字列の説明の指定にも使用されます。
    a, a0, ..., a9
    b, b0, ..., b9
    z, z0, ..., z9
    変数名と関数名には小文字だけを使用できます。大文字はエラーとして解釈されます。
    指数表記法のすべての数値では、1E-1の規約(大文字のE)を使用します。1e–1 を使用すると、エラーメッセージが表示されます。
    下記の製品および機能の提案で投稿すると実際にLabVIEWを開発しているエンジニアが意見を見てくれますよ。
    http://forums.ni.com/t5/LabVIEW-Idea-Exchange/idb-p/labviewideas

  • フォーミュラノード解析(Eval Formula Node.vi)で使える関数について

    LabVIEW2013
    http://forums.ni.com/t5/NI%E8%A3%BD%E5%93%81%E3%83%87%E3%82%A3%E3%82%B9%E3%82%AB%E3%83%83%E3%82%B7%E...
    の続きみたいな感じで、たぶん仕様を理解できていないのかも知れません。
    フォーミュラノード解析でxのz乗をプログラムしたいのですが、
    y=pow(x,z);
    とするとエラー(-23095)「関数が無効です」となってしまいます。
    xのz乗をプログラムするにはどの様にしたら良いでしょうか?
    解決済!
    解決策の投稿を見る。

    うぉ、ありがとうございます。
    c言語ライク→ハット→ビットごとの排他的論理和と思っておりました。
    演算子は懐かしのBASICライク?
     排他的論理和はどうやって記述するのだろう?
    どうもmod, maxなど引数をふたつ取る関数はエラーになるっぽいことがわかりました。
    ためしに
    y=x%z;
    と書いて見たらエラーになりました・・・
    計算式そのものをパラメータとして設定したいという要望があり、「Eval Formula Node」が使えると
    思ったのですが、悩まし過ぎます。

  • Eval Formula Node variable names

    I am using the Evaluate Formula node to allow programatic changes to formula
    in my data acquisiiton VI. Has anyone built any code to enable using full
    descriptive names as variables, instead of the a0 to z9 that this VI limits
    you to?

    You can replace full decriptive names with short names like a0...z9 using Substitute Variables.vi, which you will find at 'Mathmatics'->'Formula'->'Advanced Formula Analysis'.

  • Eval Formula Node VI in exe version

    Hi everyone, The
    node function I have used without problem in my applications, the problem
    arises when I generate an executable of my application, the text fiel shown in the panel can not be edited.
    I've also had delays when
    I type equations like this:
    T= 13.75-1.026*10^5/(X-1)+2.767*10^8/(X-1)^2-3.408*10^11/(X-1)^3+1.929*10^14/(X-1)^4-2.894*10^16/(X-1)^5;
    X is a vector of 1x400.
    The processing capacity is limited node function?,
    as I can give more processing power.

    I'm not quite sure what you are asking, but you could try this if X is a vector:
    Is this what you were looking for?
    This will step through your array (vector) one element at a time, so it doesn't really matter how large the array is, assuming you are careful in other parts of your application.
    Cory K

  • Labview eval formula node with VI

    The VI has been attached this time
    I really have no idea why it doens't work
    please help
    thanks
    ====================
    =Labview 7.0 & 8.0 & 8.5=
    =====================
    Attachments:
    Untitled.vi ‏37 KB

    It seems to work fine. Make sure that all inputs are defined. I have attached your example showing some simple inputs set as default values, just run it and see.
    (E.g. remember that "variables output" is actually an input that needs to be defined!)
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Formula.vi ‏29 KB

  • "Eval Parsed Formula Node VI" does not return outputs in predefined order

    I make a data analysis program, where the data consists of some million events and each event has e.g. 4 channels and 1-5 hits on each channel. 
    I would like the user to select different expressions of these channels to give coordinates to plot in a 2D histogram (increment a bin in Intensity Graph), e.g. for some experiment you want to show x=ch1-ch2; y=ch1+ch2+ch3+ch4; while in another experiment you want x=ch1-123; y=123-ch2;
    There are other VIs that use static LabView-code for the normal things, but now after a few years of adding to this program I find that it would be quite good with a general plotter and let the user specify simple expressions like this. Also with the "normal" static plots, there is a need to filter out bad data and then it would be much simpler both to program and use if you could write text expressions with boolean logic to combine multiple filters. Making a LabView code and GUI that allows AND/OR/parenthesis combinations of expressions will be quite an effort and not very reusable.
    So, with the above motivation, I hope you see that it would make sense to have a useable string formula evaluator in LabView. I find some info about MathScript's user-defineable functions, but haven't managed to get MathScript working in LV2010 yet (maybe some licensing or installation issues, I think I had it in 8.6). But I think it would be possible to do most of what I want for the display-part (not the filtering) with the simpler Eval/Parse Formula Node VIs and suitable use of the limited variable name space. So I started testing, and found a quite annoying issue with how the evaulator works.
    To the parser, you are expected to send an array of output variable names. But then it ignores this array, and returns one output per assignment/semicolon in the formula, in the order of the formula text. Since the static parts of my program need to know what the output values mean (which of them is x and which is y), I would have to rely on the user not using any intermediate variable and defining x before y. The attached screenshot demonstrates the problem, and also that it has been solved by NI statff in the "Eval Formula Node VI" which does the appropriate array-searching to extract only the pre-defined outputs, in their expected order. But using that VI is about 100 times as slow, I need to pre-compile the formula and then only use the evaulator in the loop that runs over a million events.
    I don't know if I'll take the time to make my own tweks to the parsing stage (e.g. preparation of array-mapping to not have to repeat the search or maybe hacking the output list generated by the parser) or if I'll have to make it in a static Formula Node in the block-diagram (which supports more functions), so that the user has to run with development environment and stop the program to change the plotting function. But I wanted to share this trouble with you, in hope of improvments in future LabView versions or ideas from other people on how I could accomplish my aim. I have MATLAB-formula node possibility too, but is far as I have seen the only place the user could update the formula would then be in a separate .m file, which is re-read only when typing "clear functions" in the Matlab console window. (Having this window is also an annoyance, and perhaps the performance of calling Matlab in every iteration is not great.) 
    Besides this issue, it also seems very strange there is virtually no support for conditional expressions or operators in Formula Node evaulated formulas (called Mathematics VIs in the documentation). Maybe using (1+sign(a-b))/2 you can build something that is 0 when a<b and 1 when a>b, but it is not user friendly! Would it really be diffcult to add a function like iif(condition, return_value_if_true, return_value_if_false) to replace the unsupported "condition ? if_true : if_false" operator? Would it really be difficult to add support for the < <= >= > == || && operators? Although compiled to an assemply language, this can't exactly be difficult for a CPU.
    Attachments:
    LV script test.png ‏62 KB
    LV script test.vi ‏18 KB

    (1) You can put any kind of code inside an event structure with the limitation that it should be able to complete quickly and without user interaction.  For example a while loop for a newton-raphson method is fine, but an interactive while loop where the stop condition depends on user iteraction is not recommended. By default, event structures lock the front panel until the event completes, so you would not even be able to stop it.
    (2) Yes, you can do all that. LabVIEW has no limitation as a programming language. Use shift registers to hold data and state information, the manipulate the contents as needed.
    (3) I would recommend to use plain LabVIEW primitives instead of formula nodes. Show us your code so we can better see what it's all about. Obviously you have a mismatch betweeen scalars and arrays. It is impossible from the given information where the problem is.
    (4) Yes, look inside the nonlinear curve fit VI (you can open it an inspect the code!). One of the subVIs does exactly that. Just supply your model VI.
    LabVIEW Champion . Do more with less code and in less time .

  • How to change content in the formula node of the current vi

    Actually I want to give formula with array index. 
    My formula p=a[0]-30; But i couldnot give array index in the formula expression..
    Please help me in this issue.

    Muthu92 wrote:
    Thank you for your reply. It is very useful for me.  But i can't give conditional operator in that operator. It is showing error.
    My Test cases
    A[0]+A[1]>150
    A[31]-50 <100.
    If those are your exact statements, then they don't make sense in a formula node.  You have to use them in an if-statement or some other type of control logic.  This mimics text-based programming languages such as C... See here for instructions on formula node syntax: http://zone.ni.com/reference/en-XX/help/371361G-01​/lvhowto/formula_node_syntax/
    For instance, you COULD say something like:
    **In this example, let A[0] == x, A[1] == y, A[31] == z**
    if(x+y>150)
    /* do something if this is true */
    else if(z-50 < 100)
    /* do something else */
    EDIT: 
    It should also be noted that Variable Names MUST be lowercase!! I just discovered this
    EDIT2:
    I stand corrected.  After trying to create an example and digging through the LabVIEW Help, I stumbled across this:
    Differences between the Parser in the Mathematics VIs and the Formula Node
    The parser in the Mathematics VIs supports all elements that Formula Nodes support with the following exceptions:
    Variables—Only a, a0, ..., a9, ... z, z0, ..., z9, are valid.
    Logical, conditional, inequality, equality—?:,, &&, !=, ==, <, >, <=, and >= are not valid.
    Functions—atan2, max, min, mod, pow, rem, and sizeOfDim are not valid. You can use these functions in a Formula Node or use their corresponding LabVIEW functions.
    So it DOES NOT seem like Eval Formula Node can do conditionals like you want.  I would just implement them using a LabVIEW based algorithm after all.  Trying to out smart the formula nodes to avoid simple LabVIEW code is just too much of a hassle
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    If someone helped you out, please select their post as the solution and/or give them Kudos!

  • Programmat​ically altering strings to be evaluated in a Formula Node?

    Hello,
    I want the user of my program to enter an expression in a string control
    that is a function of two variables. I want to be able to evaluate this
    string as if it were in a formula node.
    Is there a way of programmatically altering strings to be evaluated in a
    Formula Node?
    Thanks,
    Peter

    I found 'Eval Formula Node.vi'. That does just what I was looking for.
    Thanks
    Peter
    "Peter T" wrote in message news:3d810eba@newsgroups....
    > Hello,
    >
    > I want the user of my program to enter an expression in a string control
    > that is a function of two variables. I want to be able to evaluate this
    > string as if it were in a formula node.
    >
    > Is there a way of programmatically altering strings to be evaluated in a
    > Formula Node?
    >
    > Thanks,
    >
    > Peter
    >
    >

  • "Square" function in formula node

    The square(x) function in the formula node does not seem to work, can someone confirm, or give me some example syntax?
    LabVIEW 6.1, Win2K
    Certified LabVIEW Architect

    Hi Nadav, Sacha and Martin
    1. The Square Function is not Avilable in Base Package.
    2. The Square Function will not work in the Formula node. There are differences in using the Formula Node and Mathematics Parser. Please Look at attached file in .rtf format. This is Just a Copy of LV6.1 Help
    3. To Implement A Square(x) function Use "Eval Formula Node.vi" or Square(x) function as defined above.
    Please find Attached two implementations of Square(x) and differences as promised.
    Good Luck!!
    Mache
    Good Luck!
    Mache
    Attachments:
    Square_Function.vi ‏16 KB
    Square_Fucntion_2.vi ‏26 KB
    Differences_Between_the_Parser_in_the_Mathematics_VIs_and_the_Formula_Node.rtf ‏16 KB

Maybe you are looking for