LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Issues updating values of an array within a while loop.

I am wiring an array into a while loop and changing values within the array as the loop continues, but periodicaly the array within the loop will semingly reload the initial array. This is throughing a lot of my programing off because the end of the while loop is triggered by all of the values within the array I am altering equaling zero. Does any one have ideas on how I can prevent the code from sending the array into the while loop after the first time it is loaded?

 

I have uploaded som pictures that I hope will make it a little more clear what I am talking about. It currently works using a shift register to wire two values back to the array that was initialy imported in, the two values are then used to replace a value currently in the array.

 

Thanks for the help!

Download All
0 Kudos
Message 1 of 8
(3,630 Views)

You need the array itself to have a shift register.

0 Kudos
Message 2 of 8
(3,607 Views)

That makes a lot of sense, Thanks! Can I just shift register it to itself?

0 Kudos
Message 3 of 8
(3,596 Views)

Hi mine,

 

Can I just shift register it to itself?

Well, you store this array in a shift register.

If that is your question: yes.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 8
(3,584 Views)

@meismine wrote:

 but periodicaly the array within the loop will semingly reload the initial array.


There i no "seemingly" any changes to the array within the loop are lost when the next iteration starts. So yes, the array belings inside a shift register.

 

OTOH, the other two shift registers seem a bit unusual, don't you want to modify the array once you have current values, i.e. as the last operation inside the loop. Now you don't even need these two shift register.

 

Sorry, attaching puzzle pictures of code is not very useful to us and we might miss some subtleties. Next time just attach the actual VI! Thanks.

0 Kudos
Message 5 of 8
(3,548 Views)

Absolutly, I wasnt entirely sure what the protocol on this sort of thing was. If you would like to see it here is the updated vi and its sub vi.

 

I made the changes that you recomended but I think that the replace array function will still be nessesary. Would removing the shift register for bringing the two values around have any benefit aside from cleaning the code up?

Download All
0 Kudos
Message 6 of 8
(3,536 Views)
(Sorry, posting by phone, cannot see the code.)

If you use shift registers for the scalars, then the array update will be one iteration behind (the first iteration will have 0,0 or whatever the sr contained fom the previous run and the values from the last iteration will be discarded)
0 Kudos
Message 7 of 8
(3,519 Views)

Koolio, I will make the change. Thanks for your advice!

 

0 Kudos
Message 8 of 8
(3,507 Views)