In a multi-conditional formula node it keeps returning same thing

I am trying to execute a multi-conditional if else loop. From this website it says version 6.0 (which I have) can use C language so it should be something like:
if (x=0) y= 1000;
else if (x=1) y= 60000;
else if (x=2) y= 90000;
else y=0;
etc
what I am trying to do is take a value from a ring (0,1,2,3) and multiply it by a certain constant depending on what the value is. However, no matter what I do the loop is returning only the first value of the if statement no matter what the input value is. How can I get this loop to return 60000 if x=1 etc?

Jem,
I noticed that your code only uses one equal sign for the comparison, when you should be using two? Is this the issue? When I tried your code in LabVIEW 6.0.2 with "==" instead of "=" in the comparison of the if statements. It functioned properly.
Randy Hoskin
Applications Engineer
National Instruments
http://www.ni.com/ask

Similar Messages

  • Copy Multi-Layered Drawing-Object and keep the same Layers

    Good evening
    We often have to clone a Drawing-Object and the clone should use the same Layers. We expected that we can just select the Objects on the related Layers, Drag and keep a key (e.g. Ctrl) and Drop the copy
    An example:
    The original Object has an rectangle and a text on two layers:
    Layer 1: Rectangle (Original)
    Layer 2: Text (Original)
    After cloning, we should have:
    Layer 1: Rectangle (Original) Rectangle (Copy)
    Layer 2: Text (Original) Text (Copy)
    Thanks a lot for all ideas in advance,
    kind regards,
    Thomas

    Thank you for your fast answer!, unfortunately it does not work as expected: after the Copy-Operation I always have more Layers than before. To use my example again:
    The original Object has an rectangle and a text on two layers:
    Layer 1: Rectangle (Original)
    Layer 2: Text (Original)
    Then I select the Rectangle and the Text an copy these Objects.
    I always get:
    Layer 1: Rectangle (Original)
    Layer 2: Text (Original)
    Layer 3: Rectangle (Copy)
    Layer 4: Text (Copy)
    What I expect after copy is:
    Layer 1: Rectangle (Original) Rectangle (Copy)
    Layer 2: Text (Original) Text (Copy)
    Kind regards,
    Thomas

  • I can't update my garmin, keep getting same thing - pluginNotInstalledException.  Any solutions?

    I'm trying to update maps on Garmin 255w.  Keep getting the same screen - pluginnotinstalledexception.  don't know what this means.  I've dwonloaded WebUpdater from Garmin, following all the directions and still stuck! any thoughts?

    Hi bill9198,
    Thanks for visiting Apple Support Communities.
    You may find the steps in this article helpful for troubleshooting the iTunes Store:
    Can't connect to the iTunes Store
    http://support.apple.com/kb/ts1368
    Cheers,
    Jeremy

  • 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

  • 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

  • Formula node, keep getting errors

    I am trying to integrate a formula node into an array, I keep getting errors and don't know why. Any ideas?
    Thanks!
    Solved!
    Go to Solution.
    Attachments:
    trial7.vi ‏42 KB

    That is a better attempt.
    The problem is that you only defined your output y array to be a 1-D array.  And your math on the input array is also acting like it is a 1-D array.
    See the attached modification.
    But your formula is simple enough that doing it in real LabVIEW code is easier and you don't have to deal with syntax problems of the formula node.
    (Note, since I don't have your data, I couldn't run this, so it is possible there are errors.)
    Attachments:
    trial7MOD.vi ‏57 KB

  • Formula node, condition

    I want to use conditional expressions such as
    if () then
    statement
    else
    end if
    in the formula node, but there were error messages "unassigned output".
    I followed Ankita's suggestion to use
    if (x<5)
    y=4;
    z=8;
    else
    y=8;
    z=4;
    but there were same error messages(I tried "end if;" also.).
    Thanks.

    Which version of LabVIEW are you using? Any chance it is earlier than 6.0?
    If so, then Ankita's suggestions probably won't work, because there were major changes in Formula Node behavior. I recall that every variable introduced in pre-6.0 formula nodes had to be explicitly added as either an input terminal or an output terminal on the formula node. Furthermore, those older formula nodes used a different style for conditional syntax. It's all documented in the manuals or help documentation that shipped with your LabVIEW version, whatever that may be.
    More to the point, I suggest that you abandon the formula node for simple conditionals like this and just use a case statement. You can wire your x variable into a less-than node, then wire the output of that into a case statement selector. You can very often avoid formula nodes by using case statements or even the "Select" node on the Comparison palette.
    My two cents,
    John

  • Formula node conditional

    Hi Guys
    I wrote a simple conditional code in formula node and there is no error but it doesn't calculate. It works wrong and when I check the code I can't find any mistake.Please read my code and Let me know what is wrong with my code.
    Thanks so much
    Solved!
    Go to Solution.
    Attachments:
    watt.vi ‏7 KB

    It's fairly clear you are a text-based programmer. You should learn to do things the LabVIEW way. Here is your formula node code written in LabVIEW:
    Note that you should NOT perform a direct comparison to zero with floating point numbers. This issue has been discussed MANY times in this forum (example search) and has nothing to do with LabVIEW, as it is an issue with the way numbers are stored with computers.
    Attachments:
    the LabVIEW way.png ‏21 KB

  • If-then statement in formula node

    **Note - The attached file shows the current block diagram.
    I have a formula node inside a for loop. Inside the formula node I am trying to program the if-then statement:
    If T1<2.0E-5 OR T1>5.5E-4 THEN GOTO 3
    U7=U7+V
    I have 4 items I need help with:
    (1) Is 'II' the correct operator for 'OR'?
    (2) Is 'goto' an acceptable operator within LabVIEW?
    (3) 'U7' is building a 1D array. How do I need to define it? Is it simply 'int U7'? Also, I will add an output value named 'U7' on the formula node wall with an indicator wired to it from outside the for loop.
    (4) Is my use of the equal sign appropriate or do I need to use '=='?
    Thanks for the help.
    Philip
    Attachments:
    if-then_in_FN.jpg ‏18 KB

    Thanks for the help. I went ahead and rewrote the program so I could omit the 'goto's. Another problem that I am having is that I want 2 statements for 1 assignment:
    if (T1>=.002004 && T1<=.002584)
    B1=U
    A1=V;
    I want to assign both B1 and A1 values when the above condition is true. I tried a comma between the U and A1 but it doesn't work as well. Should I define A1 and B1 separately? Or would this create problems?
    if (T1>=.002004 && T1<=.002584)
    B1=U;
    if (T1>=.002004 && T1<=.002584)
    A1=V;
    Thanks,
    Philip

  • "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!

  • In formula node how to use array outputs

    someone has talked about this. but it is still a problem to me.
    no matter how i declare the variable, the output terminal keeps a scalar.

    You should be able to declare it using:
    int32 VarName[x][y];
    That should make an array of 32bit integers.
    See one of my earlier posts here: http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=506500000008000000EE2C0000&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0&USEARCHCONTEXT_TIER_0=0&USEARCHCONTEXT_TIER_S=0&USEARCHCONTEXT_QUESTION_0=array+formula+node&USEARCHCONTEXT_QUESTION_S=0
    Try copying the code that I posted into your formula node and see if you get an array out. Or try the example I attached with the same code in it.
    Let us know if you are still having trouble.
    Brian
    Attachments:
    ArrayFormulaNode.vi ‏23 KB

  • Shift Register while Indexing Arrays in Formula Node

    Hello, 
    I am having trouble using the formula node while indexing my two arrays.  I keep getting "NaN" for my output array. I believe the problem lies within my shift register.  My guess is that for the first calculation there is not a PreviousAngle so that is why it is giving me "NaN."  For the first index I would like the value of the PreviousAngle to be 0. I am new to LabView and unsure what to do.
    Thanks!
    Christian Seymour
    Solved!
    Go to Solution.
    Attachments:
    Complementary Filter.vi ‏21 KB

    The shift register should contain 0 by default since you are using a double [if uninitalized, the shfit register takes the default value of the data type.  In this case, the default Double is 0], but you should explicitly initalize the shift register to a default value in most cases.
    To do so, right click on the "previous angle" shift register and select "Create constant".  This will create a Double value of 0 to fill in the register for the first calculation.
    If you need a number other than 0 to start, you can just change this constant.
    **Note:  This is a good habit to have.  Shift registers retain value as long as the VI is in memory.  So if you run this more than once, it will have the value from the last execution automatically!  This is usually unintended behavior for new LabVIEW users -- however you can sometimes take advantage of this feature in some applications and make it intended behavior
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    If someone helped you out, please select their post as the solution and/or give them Kudos!

  • Array data in formula node

    I want to take the Y value (being the amplitute) from the input signal and put it into a formula node. I keep getting the error signal as in the attached VI. Is there a way of seperating the value in labview?
    Attachments:
    Formula signal.vi ‏32 KB

    Hi Cork,
    yes, it's possible! And WTH: you can do it without a formula node with ready-to-use functions!
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Dead loop in formula node

    Hi,
    I have encountered the following problem in a formula node. Everything seems simple and right. But there is no output and the loop goes on forever. The sizes of both input arrays are the same. Need your advice. Thanks.
    Rut
    Attachments:
    Algorithm.vi ‏11 KB

    Look, I am far out on a limb here, because I am not a C programmer. Whatever you're doing would make more sense from a FORTRAN point of view.
    The LabVIEW formula node uses BNF notation (check the help), which is in many ways C like. So the syntax for a FOR loop is:
    for ( InitExpression ; CondExpression ; LoopExpression ) Statement
    This means the loop iterates until "CondExpression" is true.
    Do a google search on "C For loop" and you might find for example pages like:
    http://www.hitmill.com/programming/cpp/forLoop.htm
    http://www.geocities.com/learnprogramming123/Clesson8Beginner.htm
    Your condExpression is "n1-1", which, during the execution of the node is a constant. For example if you array size is 50, n1-1=49, FOREVER! The condition is never true so the loop will never stop.
    I hope somebody more knowledgable will chip in at one point.
    LabVIEW Champion . Do more with less code and in less time .

Maybe you are looking for

  • What is a Data Socket? What is its use?

    What is a Data Socket? What is it used for? Regards, cooldude  Solved! Go to Solution.

  • 'dd-mm-yyyy hh24:mi:ss ' convertion

    '20061106024500' i want to convert it into 'dd-mm-yyyy hh24:mi:ss format how will i do this.

  • EREC : Recruiter Dash Board- My applications.

    Hi, We are on E-Rec EHP4. While an external Candidate applies to a requisition via Reference code and as a recruiter when we check on My Applications in Dashboard. It shows most of the information except "CV" with an error message "Not all informatio

  • Historical Reporting Client Login Failure - UCCX 7.0(1)

    We're experiencing intermittent login failures with the Historical Reporting Client, extract from the log file below: 1: 28/04/2010 11:58:25 %CHC-LOG_SUBFAC-3-UNK: Error # 35761 ,Description= Request timed out ,LastDllError= 0 2: 28/04/2010 11:58:25

  • Document Check In Fails  Communication Error.

    While locally editing a document, I save it locally and the hit the check in button.  It looks like the file is uploading but, then the directory screen comes back with a red exclamation point stating "a communications error has occurred, document co