LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can anyone tell me if there is reason for this array to reinitialize to another location in memory?

What makes you post this question? An array of 40 values is hardly noticable.

 

 



I use other arrays in the same app for other things.  The arrays are much larger, containing hundreds of elements.  I want to be consistent in how I use the arrays.

0 Kudos
Message 11 of 45
(995 Views)

Please clarify the phrase " reason for this array to reinitialize " made in the subject line.

 

If your concern is due to you observing the array always as it was initialized and you never see the new value show-up, it is becuase you are not keeping the array after the sub-VI completes.

 

Still trying to help but confused what you really need help with,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 12 of 45
(994 Views)

Your question does not provide enough detail. If this is a subVI and if the front panel if the subVI is open, there will also be a copy for the array control on the left. What are the execution settings of the subVI? Is debugging enabled?

 

Please attach the actual calling VI and the subVI to further clarify what you mean.

 

An array of 40 I32 is so neglibly small, that even 50 copies in memory would not make a noticeable difference.

0 Kudos
Message 13 of 45
(993 Views)

The calling code is quite complex, so I've created a very stripped down version which I've attached.  You can see that the 40 member array is only used by the vi in question and nowhere else.  I'm running an encoder in my hardware, and the counts from the chip that keeps track of the encoder is being sent to the PC over and over.  That's what the while loop does.  The state machine is used to perform many other duties.  In the state shown, the NewAngleIn variable comes from another vi in the same for loop, and the value from that is correct.  That is, it is correctly measuring/keeping track of angle.  The for loop is used to access the many consecutive instances of angle, amoung other things, that are part of the main data array... who's size is related to DataBufferSize.

0 Kudos
Message 14 of 45
(988 Views)

BTW, I'm not worried about many copies in memory.  I'm worried about the time it takes to create them and fill them.

0 Kudos
Message 15 of 45
(986 Views)

I don't understand the way you are using your subVI.  Is there more code than what  you showed in the .jpg in your first post?

 

Your main VI initializes an array and passes it to the subVI.  The subVI replaces a particular element based on the index and then does some math with the adjacent element.  But next time your loop iterates again, you are starting off with a zeroed out array again.  Nothing in your code right now shows that you are maintaining the values in the array from one loop iteration to the next.

0 Kudos
Message 16 of 45
(981 Views)

For what I can see from the code you are showing, the array will always be all zero except for a single element that is changed. So what's the point?

Why isn't "reate index" in a shift regsiter? Where is it actually coming from and where is it going?

0 Kudos
Message 17 of 45
(980 Views)

After seeing the calling vi I must repeat.


@Ben wrote:

Please clarify the phrase " reason for this array to reinitialize " made in the subject line.

 

If your concern is due to you observing the array always as it was initialized and you never see the new value show-up, it is becuase you are not keeping the array after the sub-VI completes.

 

Still trying to help but confused what you really need help with,

 

Ben


 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 18 of 45
(977 Views)

If the array is located in memory, for example, at locations 0 to 39, when the program first starts and the array initializes, all 40 values will be 0.  The first time the loop iterates, the value in location 0 is replaced by NewAngleIn.  As long as the array stays put in memory, the value will stick.  Next time the loop iterates, NewAngleIn will go into location 1, and so on.  I am subtracting to find the difference between the latest NewAngleIn and the NewAngleIn that was stored 40 iterations ago.  Again, if the array stays put, accessing the array in this manner works.  I don't need to save a copy of it.  I just want to know if there is a way to know if the array is staying put in memory.

0 Kudos
Message 19 of 45
(971 Views)

@rickford66 wrote:

As long as the array stays put in memory, the value will stick


With each iteration, you are starting with a new, blank array from the input tunnel and nothing will "stick".

0 Kudos
Message 20 of 45
(969 Views)