LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

formula node with global variable

Solved!
Go to solution

Hi,

 

I am tring to use formula node with global variables as an input and output,

but this is where I see the SW hangs forever.

By the way I am a novice to the labview.

Can some give me hint why this is happening?

 

Thank you in advance,

 

Do

 

0 Kudos
Message 1 of 9
(3,911 Views)

Oh my... Have a little text-based programming in your background, do we? Smiley Wink

 

Definitely not the way to code LabVIEW. What are all those global variables for?

0 Kudos
Message 2 of 9
(3,910 Views)

As you may have guessed from the formula node program, some of the variables are

the reference to arrays and I was trying to imitate the header file in C, so that

I can reference these informations from other subVI.

By the way this is not a optimum way to implement in the Labview.

 

Any idea why it is hanging?

Using the "highlight execution" option I can trace the input as they come in, but I do

not see any activities on output side?

 

What is going on?

 

Thanks,

 

Do

0 Kudos
Message 3 of 9
(3,905 Views)

WTF? I think you have try to learn LabVIEW 😄

You can beginn with a hello-world-tutorial...

 

Sorry for my expressive behaviour.

0 Kudos
Message 4 of 9
(3,897 Views)
Well, you don't have any while loops, so it's not an infinite loop situation. How big are your arrays, and how many iterations are being performed by each loop? My guess is that it's not hanging, but simply taking a really long time. This is not unexpected since this kind of operation in a formula node will be slower than doing it in native LabVIEW code. My suggestion is to rewrite it using LabVIEW code.
0 Kudos
Message 5 of 9
(3,890 Views)

Thank you for your reply.

 

Here is a For loop structure in my formula node.

By the way I did not think the formula node had this much of slowness.

Thanks for your information.

 

So if I were to use the Labview structure, should I directly translate

this structure to "For" and "case" structure?

Is there any way I can perform this with less complicated way?

 

Thank you in advance,

 

Do

 

for(i=0; i<6;i++)

{

   for(j=0; j<9; j++)

   {

      ....

    }

}

....

 

for(i=0; i<6;i++)

{

   for(j=0; j<9; j++)

   {

      ....

    }

 

    for(j=0; j<128; j++)

   {

      ....

    }

 

}

 

0 Kudos
Message 6 of 9
(3,876 Views)

Well, the first case of the two loops has a direct LabVIEW translation like this:

Example_VI_BD.png

 

However, just because that's the direct translation doesn't mean that's what you should be doing. In the formula node it seems as if you were copying elements from one array to another. Element-wise operation on arrays via loops can be quite inefficient in LabVIEW. Often one can operate in place with arrays, and an operation that would require two loops in a language like C would actually require no loops in LabVIEW. In fact, with the above example, even if you were to use loops, arrays can auto-index for-loops so you don't even need to wire the constants to the N terminals to tell the loop(s) how many times to run.

 

Can you describe what you're trying to accomplish? There's likely to be a more natural way to do it in LabVIEW that would require no loops. Have you gone through the tutorials? You can also look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.

0 Kudos
Message 7 of 9
(3,856 Views)

Hi,

 

Thank you very much for your information.

I figured out way it was hanging in my formula node.

One of the inner loop count was going from 0 to 128 and it was declared as "int8" which

was one bit short than "int8" declaration can handle, and that was why it was going

into infinite loop. Once I changed to "int16", it worked fine for me.

 

By the way I took the basic online training course, hopefully near future I can

take more advance courses to handle my C background instead of formula node. Smiley Tongue

Intention of this formula node was to reduce the complication of my LabView. As you indicated and

also read from the web there are some disadvantages relate to performance and memory usage,

but for now I am willing to take it.

That's for now.

 

I really appreciate your help.

 

Do

0 Kudos
Message 8 of 9
(3,829 Views)
Solution
Accepted by topic author horanyee

As smercurio was mentioning, if you had described what you wanted to do, we could show you tricks that can be done using LabVIEW.

 

For instance, the For Loops may not be necessary if you are trying to extract or manipulate data within arrays.

 

It's good that you have it working, but it would be better to learn the power behind LabVIEW.  Who knows, you may actually walk away from C-code..  😉

0 Kudos
Message 9 of 9
(3,824 Views)