09-21-2010 11:02 PM
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,
Solved! Go to Solution.
09-22-2010 12:21 AM
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?
09-22-2010 12:32 AM
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,
09-22-2010 12:52 AM
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.
09-22-2010 02:19 AM
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,
09-22-2010 08:52 AM
@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,