LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to reset values when stoping a VI

Greetings. I would like to reset an indicator value whenever I restart the VI. Each Time I start my VI it retains the values of the last time it started. Example output:
 
increment...
1,2,3,4 (in the first run, then stop)
 
5,6,7,8(in the second run)
 
How to make the second run be 1,2,3,4 ??
 
Thanks in advance.
 
Nuno.
0 Kudos
Message 1 of 6
(4,052 Views)
An Indicator receives it's value from the code, so you need to change your program logic. Where does the wire to this indicator come from? What determines its value? Maybe you simply need to initialize a shift register? There are also tools such as "first Call?" from the syncronization palette. Can you attach your program?
 
(Usually, your problem occurs with controls. Here you have several options, e.g.: (1) Write zero to a local variable of the indicator, or (2) reset all to defaults via an invoke node.)
Message 2 of 6
(4,045 Views)
Hi altenbach,
I think that  Nunosantos is using too much local variables...
Of course there is a possibility to set default values of the terminals by programming by I don't think that this is the right solution for you . Please attach your VI Smiley Wink
Regards,
Manuel R
AE dans une autre vie
0 Kudos
Message 3 of 6
(4,017 Views)


@ManuelR wrote:
Hi altenbach,
I think that  Nunosantos is using too much local variables...

He wants to change the value displayed by an indicator (not a control!) during the run of the program, thus he must change the code logic that produces the value and that's what I suggested. Most likely the problem is caused by an uninitialized shift register (or an equivalent construct using locals). There is little else in a single VI that can remember state. 🙂

(The second comment was an expansion just in case he confused controls with indicators. There is nothing wrong with writing to a local variable once in an initialization section.)

I agree that we need to see the code to make final suggestions.

0 Kudos
Message 4 of 6
(4,009 Views)
There is also the handy "Clear Indicators When Called" option in the Execution section of VI Properties.
0 Kudos
Message 5 of 6
(4,008 Views)


@kehander wrote:
There is also the handy "Clear Indicators When Called" option in the Execution section of VI Properties.

And it will only work here if the indicator is abused as a control via locals. Unfortunately we cannot see the code. 😉

Starting to count 1,2,3,4 everytime the VI starts over would be as easy as connecting the indicator to "[ i ]+1" of a N=4 FOR loop. The fact that he gets 5,6,7,8 in the second run tells me that the code is much more complex than needed and we should focus on fixing the code. 😉

Nuno Santos, have you solved the problem yet?


 

0 Kudos
Message 6 of 6
(4,002 Views)