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

Similar Messages

  • 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

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

  • Formula Node label bug?

    A last one for this week (hopefully)...
    Drop a formula node on the BD and show its label:
    Now resize the Formula Node from the top:
    Oops! The formula node got stuck in its original position. I do not know of other objects label behaving like that.
    Tested in LV 2011.
    Solved!
    Go to Solution.

    Ravens Fan wrote:
    I guess no one has ever felt the need to label a formula node AND resize it after doing so.
    ... and most people would probably resize from the bottom right anyway...
    LabVIEW Champion . Do more with less code and in less time .

  • BUG: Arithmatic shift right in expression and formula node

    Don't believe this isn't a known bug, but I couldn't find it... Tested in
    LV7.1 and LV8.5.
    In an expression node, if you use the << operator, the function produces
    wrong results if the input isn't an I32. For instance, x<<1 in an expression
    node, with an U8 as input:
    1 result 2
    128 result 255 WRONG, should be 0!
    130 result 255 WRONG, should be 4!
    The normal shift function is correct (I used it to compare the results,
    after I noticed that C results where different). Also, the function works
    correct when used for U32's (e.g F0000002 results in 4) or I32's. When an I8
    is used, results are limitted to 128. U16's and I16;s fail as well.
    As a work around: convert the input to U32, and afterwards to U8.
    In a formula node, create an aditional input that is an u32: "T32=T8; var=
    T32<<1;" might work in a lot of cases...
    Regards,
    Wiebe.

    LabVIEW 8.6.1 and bug still here:
    Compared with CVI C compiler and Intel C++ Compiler - both return zero. But formula node returned 255.
    I've lost more than hour for looking trobles in my code, but it was behaviour of shift!
    Andrey.

  • Report of an apparent formula node casting bug

    The attached LLB contains a vi (casting vi.vi) that causes LabVIEW to crash on my installation (6.02, Windows 2000). The crash is apparently related to a problem with automatic type-casting after a formula node, and inside a VI. The attached VIs were constructed from scratch to duplicate the crash, so it's not a corrupted file problem. Having isolated the problem this far, I can easily work around it; but I thought I should also report the issue, since I don't find it on your web site after a trying couple of different search strategies.
    Attachments:
    cast_failure.llb ‏23 KB

    It seems the problem has been fixed: It does not crash under LabVIEW 6.1 or LabVIEW 7. (I can reproduce the crash under LabVIEW 6).
    LabVIEW Champion . Do more with less code and in less time .

  • Problems with bit shift left in Formula Node

    Hi,
    Sorry but my English is not good.
    I'm trying to execute a bit shift left in the Formula Node, but the shift left is not working as I expected.
    uInt32 parametro[5];
    float32 valorAmostra;
    int16 indiceAmostra;
    uInt8 indiceResposta;
    int16 controle;
    int32 valor;
    int8 i;
    for(i=0; i<5; i++)
    parametro[i]=param[i];
    valor = parametro[5]<<16 | parametro[4]<<8 | parametro[3];
    controle = parametro[1]<<8 | parametro[0];
    indiceAmostra = (controle & 0x3FF);
    indiceResposta = (controle >> 10);
    valorAmostra = valor & 0x7FFFFF;
    valorAmostra = valorAmostra*(2.4/8388607);
    if((valor & 0x800000) == 0x800000)
    valorAmostra = valorAmostra*(-1);
    the input param array is of the type uInt8, as I saw in other topics that does not shift with uInt8,
    I copy the values of param array to parametro which is of type  uInt32, but still did not work.
    Testing the input param with the following values:
    param[] = {10,14,10,0,16}
    the valorAmostra returned is 0,00117188 when he should be 0,300003.
    Can someone help me please?
    Solved!
    Go to Solution.

    Portuguese:
    Olá,
    Existe um bug no LabVIEW para esta operação. Este bug deverá ser corrigido em versões futuras. Uma solução para esta situação é utilizar um int32 ao invés de um ulnt32.
    Qualquer dúvida por favor entre em contato.
    Obrigado.
    English:
    I investigated the problem you are having, and it turns out that it is a bug that has already been reported and documented. The work around for it is to use int32 rather than uInt32.
    Thanks.
    Luciano Borges
    R&D Engineer
    Pirelli Brazil

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

  • Formula node

    Hi everyone.
    I have a problem with the formula node.
    I want to calculate the following  function:
    Ux=xdot+Omegat*(y-y0)+thetax
    where xdot, Omegat, y, thetax are all 1D arrays ( honestly these are waveforms but I convert these in arrays) while y0 is a constant. Also the output Ux has to be a 1D array.
    When I implement the formula in the appropriate box I receive a message about
    "array indexing indices".
    For more information I link my .VI.
    Some idea how to solve this task?
    Second question:
    Using the formula node is faster than realize all these operations in a
    different way?
    I ask it because I will need to include this .VI into 5
    different "for loops"?
    Thanks
    matomato
    Attachments:
    formula node.vi ‏87 KB

    Hi matomato,
    fastest is usually to use LabView primitives! See attachment...
    Edited: made another small change to your vi: changed y0 to DBL to avoid unneccessary datatype conversions!
    Message Edited by GerdW on 02-27-2008 05:11 PM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    formula node1.vi ‏87 KB

  • 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

  • Want to learn more about shift registers and formula nodes

    I am new to Labview and have looked at the example files and help files regarding shift registers and formula nodes. I was hoping that someone has a simple and detailed VI expaining how each of them(shift registers and formula nodes) works.

    Formula nodes are not one of the first things you will need to be looking at. look at the help files (press ctrl-H) for some syntax examples. Shift registers are easy: they carry the value from the end of the loop back into the start of the loop. The great power of shift registers is to use them without initializing. In that case they will retain their last value as long as the vi is in memory. This is a little more advanced topic, though.
    I included a simple example that illustrates what a shift register does. Requires Labview 7.1
    Good luck,
    aartjan
    Attachments:
    shift (LV7.1).vi ‏19 KB

  • 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

  • Empty array of unknown size in formula node

    I have to declare an empty array say, P of unknown size in formula node. How to do that?

    Hi sukhiray,
    an empty array has a known size...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Sine square function in formula node

    Hello
    I need to generate a function
    I = Iz * sin^2(B)
    where B = (pi/2)*(V/70)
    Iz = 0, 0.1, 0.2, 0.3 ... 1.0
    V = 1,2,3 ,4...135
    I tried to do thi sin formula node. but cud not get it.
    See attchment.
    Nghtcwrlr
    ********************Kudos are alwayzz Welcome !! ******************
    Attachments:
    Sine square in formulanode.vi ‏18 KB

    This will not work. B has 105 elements, and IZ has only 10. B and IZ must have the same numers of elements. And you should perhaps use a for loop not a formula node
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)

  • Array index problem in formula node

    dear friend
    I'm trying to use formula node to solve a problem because I make this program using c at the begining.
    It runs perfectly in turbo c, but somehow it doesn't work in the formula node.
    I try to debug my source code, and I find that the formula node seems can't read the true value in
    the array.
    Here is the code in the formula node.
    int32 i,j,k;
    for ( i = 0 ; i < sopa; i++ )
     j = 1;
     ep[i][0] = pa[i];
     ep[i][1] = np[ep[i][0]][0];
     while ( ep[i][j-1] != exit )
      for ( k = 0 ; k < sonp ; k++ )
        if ( np[ep[i][j-1]][k] != -1 && (pc[ep[i][j-1]][ep[i][j]] + pc[ep[i][j]][exit] >= pc[ep[i][j-1]][np[ep[i][j-1]][k]] + pc[np[ep[i][j-1]][k]][exit] ) && (pc[ep[i][j-1]][np[ep[i][j-1]][k]] == org[ep[i][j-1]][np[ep[i][j-1]][k]] ))
          ep[i][j] = np[ep[i][j-1]][k];
      j++;
    This is the part that I think the problem might be.
    if ( np[ep[i][j-1]][k] != -1 && (pc[ep[i][j-1]][ep[i][j]] + pc[ep[i][j]][exit] >= pc[ep[i][j-1]][np[ep[i][j-1]][k]] + pc[np[ep[i][j-1]][k]][exit] ) && (pc[ep[i][j-1]][np[ep[i][j-1]][k]] == org[ep[i][j-1]][np[ep[i][j-1]][k]] ))
     ep[i][j] = np[ep[i][j-1]][k];
    I state that "np[ep[i][j-1]][k] != -1" but I do get the value -1 in the array "ep".
    Could someone tell me why I get -1 in the array?
    I hope I can finally do it all by labview not using formula node,but array like "pc[ep[i][j-1]][np[ep[i][j-1]][k]] "
    seems very hard to wire in labview. Could someone give me some good advices of doing this?
    Thanks for your help

    altenbach 已寫:
    normanshi wrote:
     ep[i][0] = pa[i];                                          (A)
     ep[i][1] = np[ep[i][0]][0];                            (B)
    ...    if ( np[ep[i][j-1]][k] != -1 && ... )          (C)
          ep[i][j] = np[ep[i][j-1]][k];                       (D)
    I state that "np[ep[i][j-1]][k] != -1" but I do get the value -1 in the array "ep".
    Could someone tell me why I get -1 in the array?
    I hope I can finally do it all by labview not using formula node,but array like "pc[ep[i][j-1]][np[ep[i][j-1]][k]] "
    seems very hard to wire in labview. Could someone give me some good advices of doing this?
    There are many possible scenarios to get a -1 in the ep output. For example if the -1 gets already written in step (A) or (B) at a certain index, and that index does not get overwritten in step (D). You are indexing all over the place! Is there some bounds checking on the array contents? What are typical inputs and array sizes?
    I'm sure about that the -1 doesn't get already written in step (A) or (B) because ep[i][0] and ep[i][1] is fine. What really makes me confuse is that sometimes ep array has the value like this.
    That means it does overwritten some value in step (D). The -1 should never be written into it because I have already state that np[ep[i][j-1]][k] != -1. Somehow I still get -1,and this is really strange! I'm indexing all over the place becuase I can't figure out a better way to achieve my requirement.
    I think I should briefly tell you what I'm trying to do. In this program,I input some values which means the distance from one point to another. Then I use floyd's all pairs shortest-path algorithm to find all the shortest distance. Finally I want to find out the "shortest path". I mean like from point 4 to point 0,the shortest path might be like 4 -> 2 -> 1 -> 0, and what the formula node part do is trying to find out this "shortest path". Maybe you can give me some better advice of doing this, I have been thinking a better way to do it for about two months. I think I'm really not good at this.
    I try to do it all by labview ,but again I get a strange problem. This time the ep[i][j-1] doesn't get the correct value. In the first time i=0 j-1=0 ep[i][j-1] = 1,but the second time i = 0 j-1 = 1 ep[i][j-1] = 0. This makes the "ep[i][j-1]!=exit" get the incorrect boolean value. The ep[i][j-1] should be 2,not 0. I try to use highlight to find if I make any mistake, but I can't one.This is the input and I put the labview program in attached file (temp4.vi).
    Could you help me find out why this happened?
    Thanks for your help altenbach!
    由 normanshi 在 08-19-2006 10:06 PM 上編輯的訊息
    Attachments:
    temp4.vi ‏191 KB
    ep.jpg ‏10 KB
    input.jpg ‏9 KB

Maybe you are looking for

  • I have put my itune code on the wrong email address how can i transfer it to my new address please?

    I have put itune code on the wrong email address how can I transfer it to my current email address please?

  • Computer was stolen--how to transfer from iPod to new computer

    My computer was stolen and I want to transfer my iPod library to my new computer. I know how to transfer from one computer to another using an iPod but is there a way to do it when I don't have the computer that has my iTunes library?

  • What does the config.0.trc file indicate?

    In the manual installing hotfixes for Patch 4 ep 6 sp2, it tells you to check the configmerge in the file config.x.trc  (x being the latest version).  The file is located in the <j2eeinst>/cluster/server directory.  Can anyone tell me what this file

  • Queue_not_empty error while applying patch

    I am getting the following error message while applying SEM patch on IDES BW3.5/SEM 4.0  on Windows 2003 server and having Oracle 9i as database Error in phase : Check_Requirement Reason for error : Queue_Not_Empty Please resolve this issue as I requ

  • To print transfer order by range

    Hi, I had 20 transfer order created and I would like to kick off the printing by selection on screen from TO#1 to TO#20. Is it possible to do so in LT31? There is a program, RLVSDR40 but it does not have any TCODE linked to it. Is there a standard TC