LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug? What's wrong with this?

Solved!
Go to solution

can someone please take a look at this vi file.. why is the "if" block in the formula node executed incorrectly?

Thanks..

0 Kudos
Message 1 of 8
(3,163 Views)

What is not working as expected? It seems you're assuming the variables in a Formula Node keep their value from a previous run. This is not the case. If you need to retain the variables from a previous run you need to use a shift register and feed the previous value into the Formula Node.

 

0 Kudos
Message 2 of 8
(3,159 Views)
Solution
Accepted by topic author splee

@dan_u wrote:

What is not working as expected? It seems you're assuming the variables in a Formula Node keep their value from a previous run. This is not the case. If you need to retain the variables from a previous run you need to use a shift register and feed the previous value into the Formula Node.

 


Something like that:

 

Snippet.png

Message 3 of 8
(3,153 Views)

@dan_u wrote:

What is not working as expected? It seems you're assuming the variables in a Formula Node keep their value from a previous run. This is not the case. If you need to retain the variables from a previous run you need to use a shift register and feed the previous value into the Formula Node.

 


exactly "diff = now + previous" does not execute as expected. So the value of "previous" is not retained?

0 Kudos
Message 4 of 8
(3,148 Views)

Yes, it is initialized to 0 in each run. If you want to keep the value you need to use a shift register and feed the value to the formula node.

 

 

Message 5 of 8
(3,145 Views)

@Andrey Dmitriev wrote:

@dan_u wrote:

What is not working as expected? It seems you're assuming the variables in a Formula Node keep their value from a previous run. This is not the case. If you need to retain the variables from a previous run you need to use a shift register and feed the previous value into the Formula Node.

 


Something like that:

 

Snippet.png


Dmitriev,

The "previous" with a downward-pointing arrow is an input or output?

0 Kudos
Message 6 of 8
(3,144 Views)

@splee wrote:
Dmitriev,

The "previous" with a downward-pointing arrow is an input or output?



It's a shift register, the arrows can be looked at as a "loop around". The downward arrow can also be an input (if something connects from the left) but the point is to send the "/\" back to "\/" the next loop.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 8
(3,126 Views)

@splee wrote:

Dmitriev,

The "previous" with a downward-pointing arrow is an input or output?


Sounds to me like somebody needs to spend some time with the LabVIEW Help and tutorials....  To learn more about LabVIEW it is recommended that you go through the introduction material, tutorial(s), and other material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. There are also several Technical Resources. You can also take the online courses for free.

0 Kudos
Message 8 of 8
(3,107 Views)