LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

remember iteration

How can I remember the iteration number of a while loop to access it in the unknown future. Shift registers are good for a few iterations backward, but what about 200 iterations back, or a variable number of iterations back?

Thanks.
0 Kudos
Message 1 of 5
(3,146 Views)
You can capture specific iteration into a numeric control or an array control depending on number of iteration you are interested in. Also you will need a case structure to capture the iterations. This holds if your interpretation of "unknown future" is within a vi life-time, a different method will be required it you want to access same information at the end of a vi run.
0 Kudos
Message 2 of 5
(3,146 Views)
> You can capture specific iteration into a numeric control or an array control depending on number of iteration you are interested in.

How?
0 Kudos
Message 3 of 5
(3,146 Views)
Here is an example.
0 Kudos
Message 4 of 5
(3,146 Views)
In article <50650000000800000033720000-1042324653000@exchange.ni.com>,
"Craig Leidholm" wrote:

> How can I remember the iteration number of a while loop to access it in
> the unknown future. Shift registers are good for a few iterations
> backward, but what about 200 iterations back, or a variable number of
> iterations back?
>
> Thanks.

Hi Craig,

"unknown future" makes me nervous. That just screams memory leak so you
have to be careful what and how much you log or track. I think your best
bet is to use Queues. I guess that you're gathering and then monitoring
some data with each iteration. You can add questionable data and the
iteration it was collected into a queue object and dump it after the loop
is completed. The other option is to fill
the queue with n samples
(dependent upon memory limitations) and then when it reaches the limit
your app can analyze the contents to determine whether you should continue
or not. Either way, with queues you can set a cap on its size when you
initialize it. When it reaches the cap your loop will have to stop as it
tries to add data to the queue because it's full. This prevents your
memory from getting used up and crashing or freezing your app. You can
do a similar thing with an arrayed cluster but the memory cap will have
to be mainained by your app.

You may want to use a combination of synchronization techniques. Hope
this helps.

- Kevin
0 Kudos
Message 5 of 5
(3,146 Views)