LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Indicator Value Updated After 2nd Run

Solved!
Go to solution

Hello,

 

I've this statistics vi that calculates various things. One of the indicators updates its value only on the second run and not on the first run, I'm confused as to why it happens. I've tried using flat sequence, but it still does the same thing.

Any ideas?

 

Thank you,

Download All
0 Kudos
Message 1 of 6
(3,320 Views)

Where is the code shown in indicator.png located?  It looks like the subVI is probably your subarray_post.vi, but I don't see where anything comes into play in your stat_done.vi.

 

What do you mean by first run vs. second run?  Which indicator?

0 Kudos
Message 2 of 6
(3,307 Views)

Hi Ravens Fan,

 

The .png file shows which indicator it is. When I run stats_done with a .txt file, subarray.vi suppose to count jumps(doesn't matter though) and then pass the value to "# of times exceeded," which in turn writes it to the array in the front panel and the .txt file. BUT, "# of times exceeded" shows a value only when I run stats_done twice instead of once. Here is a .txt file that you can run with stats_done.vi, if you want; I believe it'll explain better than me (look at # of jumps value in the front panel). It's a really weird issue....

 

Thank you,

0 Kudos
Message 3 of 6
(3,302 Views)

Race condition because you are using a local variable.

 

# of times Z exceeded threshold

 

The local variable gets read, and is 0 the first time you run the program.  The value doesn't get set until later when data is finally written to the terminal.

 

Any reason you are using a local variable there instead of using a wire?

 

I'd also recommend you use block diagram cleanup so you don't have so many wires hidden behind other wires and structures.

0 Kudos
Message 4 of 6
(3,291 Views)

Hi,

 

I'm using local variable just to avoid passing wires all over the block diagram. I'll clean up the block diagram.

If that's the issue, how come flat sequence didn't work when I tried it (just out of curiosity)?

 

Thank you,

 

 

0 Kudos
Message 5 of 6
(3,267 Views)
Solution
Accepted by topic author simply_me

@simply_me wrote:

Hi,

 

I'm using local variable just to avoid passing wires all over the block diagram. I'll clean up the block diagram.

 

BAD IDEA!  Use wires.  Read this thread.

 

  

If that's the issue, how come flat sequence didn't work when I tried it (just out of curiosity)?

 

I'd have to see your code with the flat sequence structure in place to know.  My guess, you didn't have the sequence structure positioned in the way you thought you did.

 

Thank you,

 

 


 

Message 6 of 6
(3,248 Views)