Formula Node result of NaN

Hello to all,
I have done a Formula Node with the next formula:B=(2*16/3.14159*(asin(sqrt(V/Ab))-3.14159/4))-(2*16/3.14159*(asin(sqrt(Uoffset/Ab))-3.14159/4));
Ab=3.269.
V is the data entry to the formula node.
Uoffset is the mean of the 100 first values of the data that I obtain it previosly.
I know that I can not do the square of the negative number and the asin I can not do it for values greater than 1 for that reason I don´t put values greater than 3.269 into the V value never and negative values either.
I take this precautions but I obtain several times the output value of NaN I use the entry V for example:0.00061035 could be that the format of the entry it is very extends.
Also when I introduce the same data to this formula, one times I obtain some values in the out and when I execute the subVI with the same data I obtain other values in the out.  Said it diferently I obtain different out for the same data in. How it is possible????
The other hand I need to do the integral and the derivate of one array, how can I do it??? And the more important how I can or what I use for the parameter dt of the derivate???
Thanks a lot
Gonzalo De Francisco Ortiz

Hi Gonzalo,
after having a first look: You have a race condition in your code: why do you use a local for the mean value instead of simple wiring?
I think that's the reason for your unexpected results!
Other small items:
- when you use auto-indexing you don't need to provide 'num of iterations' to the for-loop.
- the only difference between the 2 cases is the 'abs'-function used for negative inputs. Just do the 'abs'-function everytime and you don't need the case-structure...
- when testing numbers against zero you can use specialized functions from the comparision palette
Editing:
I attached a changed example in LV8.0
Message Edited by GerdW on 02-01-2007 01:22 PM
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome
Attachments:
FormulaNode.vi ‏20 KB

Similar Messages

  • NaN & Inf in Formula node

    Are there no NaN, Inf, -Inf constants in formula nodes? Typing for example "x = NaN;" doesn't work.
    I can generate them with 0/0, 1/0, -1/0 but it's not very elegant...

    If you want to put Inf or Nan in X and use it in another formula, you can do this.
    If you just want to put constants in X indicator or array, just wire them.
    Or maybe am I missing something ? what do you want to do ?
    hope this helps
    Message Edité par JDlabview le 06-17-2010 10:41 AM
    J.D.
    French Labview beginner
    N'oubliez pas de complimenter les bonnes réponses - Don't forget Kudos for good answers

  • Formula Node Floor(x) Produces Different Result

    Hi, A search didn't find anything about the Floor(x) function, so... I'm using LabVIEW 6.0.2, and the Floor(x)function in a Formula Node seems to be producing different results depending on previous calculations. I've got the following 2 lines in a Formula Node:
    MSS = Ref / RefDiv;
    MDN = floor(RF / MSS);
    Ref is always 20.0M, RefDiv always 500.0, and for this calcualtion RF is always 1539.4, all numbers Double with 6 digits of precision. I generate an array of frequencies given a start, step, and frequency count. These frequencies then go to a subVI with a Formula Node that calculates the byte values to send to a couple PLLs.
    If Start = 70.1, Step = .025, and Count = 20, at frequency 70.2 the Floor function gives 38.485.
    If Start = 70.0, Step = .025, and Count = 20, at frequency 70.2 the Floor function gives 38.484.
    I've omitted some calc steps here, but I've verified the starting values in the subVI are the same in both cases. Why the result changes I'm hoping someone can tell me...
    Thanks,
    Steve

    I want to thank those involved again for their help. With ideas and hints from others I found a solution without scaling.
    In recap, what had bothered me was it *appeared* like the same subVI was giving correct results one time and incorrect results only randomly. While I understand binary fractional imprecision, I wasn't doing any looped calculations 100+ times or anything.
    I did some more checking though. The problem was indeed introduced by cumulative fractional addition. In this case 10 additions were enought to cause the error. Apparently, floor(71.199_94) produces 72.0. However, using a shift register and constant fraction to add an offset to produce an array introduces enough error in under 10 iterations to be a problem. By the time the loop got to what was supposed to be 72.0, it was actually 71.199_84 or something, enough to throw the floor function. Now I understand why the error occurred, and why it wasn't a problem before.
    I fixed this problem by changing the real frequency number to a I32 before introduction to the formula node. This corrected the error introduced by the fractional addition by forcing 71.199_84 to 72, instead of letting it propagate through the rest of the calculations. And it was a whole lot easier than changing all the VIs to allow scaling! Also, I prefer to know where and why the problem happened, instead of just scaling all my calcualtions. Maybe I can recoginse potential problems in the future.
    My boss wants to go back and look at his program to see if HPVee somehow bypassed the problem or if he did the calculations differently.
    Thanks again for the insight and help,
    Steve

  • Formula node windows xp

    Hello All
    I use labview 5.0. 4 years ago, we develop a vi with a formula node inside. We never had problem using it with Windows NT, Windows 98. Now, I have a minor change to make in the formula inside. I made this modification and the only result i get is NaN (not a number). I put the formula as it was before and still have the same result : NaN.
    I'll put here my formula (it ain't a big one) so someone can help me.
    Tth = -R * C * (ln(1 - 0.8) - ln(1 - 0.4));
    Tmax = Tth + (40/100 * Tth);
    Tmin = Tth - (10/100 * Tth);
    Thanks
    Caroline
    Caroline Paulin
    R&D technician
    Astroflex inc
    Canada

    it's l as "lima" because I'm actually using natural logarithmic function to calculate the theorical charging time of a capacitor.
    I should have guessed it was the natural logarithmic function instead of an input parameter. Sometimes I type faster than I think.
    I've made a quick example VI with your formula that generates random numbers for "R" and "C" and I added a parameter for the '40' in the second line so it will divide every value from 1 to 100. I can't get it to come up with any NaN values. The example is attached. Try running it and see what happens. The Iteration count will stop on '100' if no NaNs are produced, and will stop at any value that does produce an NAN.
    Ed
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
    Attachments:
    Example.llb ‏35 KB

  • Formula node uInt32 overflow

    I'm having a weird behaviour in formula node. The overflow of unsigned integer operations simply doesn't match the results of standard LabVIEW blocks as shown in the attached picture.
    How can I deal with this problem? I need the behaviour of the block diagram. I could not do a right logical shift in unsigned integers in block diagram, so I'm using formula node (I could not figure out how to do it because I can't negate a unsigned value).
    I'm using LV2012SP1. Were there any changes in this behaviour in newer versions?
    Thank you.

    I found a problem in hexadecimal and octal numeric representations of the formula node. The picture illustrates the issue. Three variables are assigned with the same value but outputs different results.
    The hex and octal representations only work for half range of the 32 bits unsigned integer. When the value assigned gets beyond this limit the variable receives zero. This doesn't happen with a decimal value neither with 8 bits variables. Seems the problem doesn't only happen with overflow operations.

  • HELP: Run-time array dimension in LabVIEW formula node

    I need to dimension an array at run time within a formula node as follows:
    int32 i,N;
    N = sizeOfDim(inputArray,0);
    float64 outputArray[N];
    for (i = 0; i outputArray[i] = myfunction(inputArray[i]);
    However, LabVIEW complains "Formula Node: index list expected". On the
    other hand, if I say
    float64 outputArray[1000];
    LabVIEW is perfectly happy. But that's not what I need to do! Is there
    an alternative
    way of accomplishing my goal?
    BTW, I've tried calculating N outside the formula node and then
    presenting it as
    an input with the same results. I've got a bad feeling that run time
    array dimensioning
    just isn't allowed.
    TIA,
    Hugh

    Can't you just use the Initialize Array function outside the formula node and pass that instead?

  • Serious bug in LabView 8.5 Formula Node

    Hello,
    Thought I would warn my fellow LabView programmers about a serious error in the Formula Node:
    The problem may be encountered by anyone running a non-us LabView installation:
    I am located in Norway, and over here we use the comma (,) as the separator in floating point numbers: So, the use 3.14 is written like 3,14.
    The problem is that the Formula Node accepts both formats, but only the US Notation is interpreted correctly !
    Example:
    float64 x1, x2;
    x1 = 3.14;    // Interpreted Correctly !
    x2 = 3,14;     // Interpreted as 3: One might say this leads to problems.......
    Message Edited by geirove on 06-13-2008 06:23 AM
    Geir Ove

    geirove wrote:
    JoeLabView wrote:
    Hi Geir,
    It is not a bug.  ............
     The node does not recognize localized decimal separators."
    Of course it is a Bug:  **Any** code that **any** compiler does not recognize, should be flagged with an error message ! I have written my share of compilers myself, and they all flag down code that is not accepted as an error.
    Failing to do so may cause serious, expensive and very hard to trace errors.
    Sorry, but I would expect that the NI team in their 20. year of LabView development is capable of better than this.
    Sorry to disappoint you! It's not a bug since that statement is absolutely valid albeit useless in that context.
    The Formula Node since LabVIEW 7 supports C syntax except some advanced features such as pointers. In C the comma in expressions is the sequence operator meaning it separates expressions that will be executed from left to right and the last one will actually be the result of the entire sequence expression. This is often used for the initilizer expression inside the for statement, to initilize several variables to a start value.
    And the NI team really is a lot better than you think. The online help may be a bit short about the reasons why the comma is not supported as decimal point but there have been many people thinking about this before it was made like that. It was either C syntax support without localized decimal point or some homegrown syntax with localized decimal point and they went for the first.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

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

  • Bug using array in formula node, LV6.0

    Pass a 3-element integer array, containing values 5, 6, 7 into a formula node as input variable x. Pass variable y out. The formula node contains:
    int32 y;
    y = (x[2]-x[1]);
    My result is 6. If the parentheses are removed, the answer is 1. Apparently adding the parentheses causes the expression to be evaluated as y = x[2-1];.
    Has this been found/fixed? I have mailed NI separately.

    In 6.0.2 it returns 1 in both cases.
    "Adam Russell" wrote in message
    news:ajcc8d$1a266r$[email protected]..
    >
    > "Bill Atkins" wrote in message
    > news:[email protected]..
    > > Pass a 3-element integer array, containing values 5, 6, 7 into a
    > > formula node as input variable x. Pass variable y out. The formula
    > > node contains:
    > > int32 y;
    > > y = (x[2]-x[1]);
    > > My result is 6. If the parentheses are removed, the answer is 1.
    > > Apparently adding the parentheses causes the expression to be
    > > evaluated as y = x[2-1];.
    > > Has this been found/fixed? I have mailed NI separately.
    >
    > It works correctly in 6.1. I'm at home so I can't t
    ry it in 6.02.
    >
    >

  • Array in formula node

    Hello everyone,
    I am new in labview. I would like to display the coherence function with the correct frequency scale. For instance, I want it to be as follow: FreqAxis = 0:Fs/2/(N+1):Fs/2. where Fs is the sampling frequency and N the number of sample. I am trying to write using Formula node, but it is not working.
    Thanks for your time and your help.
    Axel

    Thanks again for your comments and your time .
    I have attached the .vi file and a screen-shot of the expected result (cohere2.png).
    Cheers
    Axel
    Attachments:
    Code_frequency.vi ‏531 KB
    cohere2.PNG ‏17 KB

  • Formula Node error: left brace required ???

    Hi,
    I'm trying to use a formula node to do a simple line calculation. However I'm receiving this error and I'm not sure why.
    Formula Node: left brace required
    Error on line 1 is marked by a '#' character: "y = 0.0183*x -# 0.2982;"
    I've tried replacing the y-intercept with a variable, but the same error results.
    Anyone know what to do?
    Thanks in advance.

    What version of LV are you using? The formula:
    y = 0.0183*x-0.2982;
    works perfectly fine in V6.0.2...
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Formula Node on PDA

    I'm using a formula node on Labview PDA and i have problem regarding multiplying double variable. If I multiply integer number (as double) everithing is OK.
    example 45*2 the results is 90.0
    If I multiply 2 fractional number the solution is wrong:
    example 45*2.5 the results is 112.0705032 and there is some strange features inserting the values inside the number control.
    I Attach the source code and the PDA executable (to convert Lat, Long coord. to UTM) in order to undestand the problem. I you remember that the same code work perfectly if the execution target is Labview for Windows.
    Best Regards
    Sergio Zanoli
    Attachments:
    Geo2UTM_standalone.vi ‏47 KB

    I checked the feature using a simple application on the PDA emulator and I could not replicate the error.
    I have attached the VI i worked with ..check if this helps.
    Attachments:
    Untitled.exe ‏332 KB

  • Formula node error

    Error using formula node with non-linear fitting VI.
    I am using LV 2011 on windows XP.
    Using Nonllinear Curve Fit.vi.  I have used this before successfully.I am using the "formula string" instance of this polymorphic VI.  When I run my program using the formula string "b0+b1*x", it runs fine and give sensible results.  When I use the formula string "b0+b1*x+A1*x^2" I get the error message "Error -23083 has occurred at an unknown location. Analysis: Bracket problem at the end."
    Attached screenshots show part of the block diagram that wrorks (lv0.bmp) and ppart of the block diagram that does not work (lv1.bmp).
    Thank you.
    Attachments:
    lv0.jpg ‏23 KB
    lv1.jpg ‏39 KB

    Thank you Dennis. It turns out the "caret" ("^") operator is OK here, and is raising a number to a power, as desired.  The problem was that I used an uppercase letter in a variable name.  Not allowed!  Nor can variable names have have two letters, although that wasn't the problem in my example. (It was a problem in some of my other attempts.)

  • Formula node bitwise OR has a bug?

    Hello everyone,
    I am trying to do a bitwise OR with 32 bits in an formula node. It seems that the OR operation produces unexpected results if the most significant bit is set. For example if I do:
    0x00000000 OR 0xffffffff I would expect 0xffffffff. Instead I get 0x80000000. In binary this looks like:
    00000000000000000000000000000000  OR
    11111111111111111111111111111111  EQUALS
    10000000000000000000000000000000
    Please see the attached minimal example for comparison of some example values. The output with using blocks is exactly the one I would expect and is also included in the example.
    I am using Labview Version 14.0f1 on Windows 7 Professional.
    This might also be in connection with the following currently unresolved bug:
    48016
    3P7CBB4Q
    http://www.ni.com/product-documentation/52150/en/#48016_by_Category
    However that that bug is for unsigned int32 and the suggested workaround is to use signed 32 bit integer, which nevertheless fails in the provided example code.
    If someone could have a look and tell me if this is a bug or if I am misunderstanding somtheing that would be great. I am already starting to go crazy.
    Best regards and thanks in advance
    Saali
    Attachments:
    Minimal_Bug_example.vi ‏10 KB

    No, actually this bug is different from what is documented.The documented bug happens with uInt32 and the documentation specifically suggests to use Int32 as a workaround for the known bug:
    "2. Use signed 32-bit integers instead of unsigned 32-bit integers in the formula node."
    However this is exactly what fails in my case when I use OR. I thought this might be some valuable information for the people trying to fix that bug. (Which seems to be hard to find, as it has been around so long and screws up very basic operations.)
    It might also be that NI does not really care for that bug because most people don't use the formula node for basic bit arithmetic. Anyway, I just wanted to put the information out somewhere for the next person who has that problem to find. I  guess the lesson I learned from this conversation is don't trust the formual node to much for doing low-level bit stuff...
    Best regards
    Saali

  • Formula Node - Embedded If statements

    Greetings,
    I would like to "embed" an if statement within an if statement using a formula node. The structure is as follows:
    if(x == y/2)
     y = 0;
     if(a < c && a > d)
      a = a - 1;
    For some reason when I run my code and both of the criteria for my if statments are true the formula node does not execute the a = a - 1.
    For example:
    a = -0.5
    c = 0
    d = -1
    Then 'a' should decrement to -1.5. However, when I run my code 'y' will reset to zero but 'a' will not decrement.
    Am I allowed to embed if statements within if statement using a formula node.
    Also, I am aware that I can accomplish this using other means but I would really prefer to use the formula node.
    Any help is greatly appreciated.
    Thanks.

    Threre is no problem with the formula as posted, you get -1.5 at the "a output" as expected.
    Of course if you want the original "a input" control to be modified with the new value, you would need to write the "a output" to it via a local variable.
    Still, I agree with GerdW that you are opening a can of worms here comparing DBLs for equality. This can very easily lead to unexpected results!
    Message Edited by altenbach on 03-16-2008 05:03 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    embeddedIF.vi ‏11 KB
    embeddedIF.png ‏11 KB

Maybe you are looking for

  • HT1420 How do I authorise my account on a Mac?

    I don't have any store options.

  • Problem Following SMP tutorial with SDK 8.1

    I'm attempting to follow the SMP development tutorial but I'm starting with Win SDK 8.1.  Attempting to use convert-moftoprovider fails with missing mofs that are referenced in storagewmi_provider.mof (like msft_filestoragetier.mof).  I don't see the

  • Embedded BI - Reporting Functionalities and Performances

    Hi, there are Reporting functionalities that are available only for Embedded BI/external BI or they are the same? IMPORTANT: there are differencies in Reporting on ERP Tables with Virtual Infocube use if BI is embedded/not embedded?  There are differ

  • Bill of Material (BOM) for any Material

    Dear all, I want to fetch the BOM Components for any material. can any body tell me the Flow of tables with link between them for finding the bom. Thans in advance Regards, Anshuman

  • You cannot open row in the document AP invoice

    Hi Experts, We're getting "You cannot open row in the document AP invoice" when adding an 3 AP Invoice from draft, it used to work before with our AP Invoices. We're using Service Type. 2005A PL46 What might be the problem? Any information will be gr