ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array not updated

Solved!
Go to solution

Hello,

 

I'm quite new to labview. I've created a simple program that takes some inputs (start_value, stop_value and step), and creates an array with the corresponding values.

This is what I've done so far:

The problem is that the displayed array, does not show the actual values from the last run, but the ones from the previous. So I must run it twice to get the good values in the array.

 

Why is it happening? What am I doing wrong ?

 

Thanks in advance.

 

Vi_array.PNG

0 Kudos
Message 1 of 5
(3,062 Views)
Solution
Accepted by angel6700

Race Condition Alarm!

 

Replace the local variable by a wire to get your VI working correctly!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(3,057 Views)

Thank you very much !!

 

Now, it seems it's time to learn the basics of those race conditions !

 

Best regards !

Angel.

0 Kudos
Message 3 of 5
(3,041 Views)

@angel6700 wrote:

Now, it seems it's time to learn the basics of those race conditions !


General rule of thumb: use a wire if you can.  LabVIEW can be a very highly parallel language.  You have to use wires to force data flow to set the order of operations.

 

Then when you get a little farther down the experience trail: A Look At Race Conditions



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 5
(3,033 Views)

OK, so you learned about race conditions. Good! 😄

 

So, while you are "ramping" (sic) up your learning curve, here are some alternatives that will typically give you the same result (your code is the top loop).

 

altenbach_0-1586963477165.png

 

Notes: There is a "+1" primitive. Avoid right-to-left wires. Learn about coercion dots.Look inside "ramp by delta" to see how to deal with potentially bad inputs (inf, zero, Nan, etc.). For example, a step of zero will probably run out of memory unless you protect the downstream code from it, etc.

 

0 Kudos
Message 5 of 5
(3,001 Views)