LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

moving elements from array to array

I have initialized an array and add elements to it by pressing a button, then im using the delete from array function to remove an element from this array and move it into an another array using initialize again. But how can i make it so that this new array holds only 2 elements at once, and whenever an element enters this new array, this element is then removed and passed on after 5 seconds.

0 Kudos
Message 1 of 84
(2,174 Views)

"Passed on" to where?

Can the other array hold less than two elements?

What should happen if new elements arrive in the second array before 5 seconds have elapsed?

 

Your question is very ambiguous. Please attach your vi attempt to clarify.

 

What's the purpose of the program? It is better to describe what you want to do instead of how you want to do it.

0 Kudos
Message 2 of 84
(2,153 Views)

Im sorry Im really new to LabView and this is my first time asking.

 

So when I said passed on, I just meant that after the new array has been created and the element spends 5 seconds in this array, Ill just continue with my code which is again placing this element into a third array (but this is not the part I need help with). 

 

And yes this array can hold less than 2 elements, but the max it can hold at any one time is 2 only. And whenever an element is added to this array I want this element to be removed and passed on to a third array (which again I can do) after 5 seconds. And what im struggling with the most is how can I count 5 seconds for each element alone. so if an element is added to this array then after 2 seconds another element is added. The first element goes out after 3 seconds but the second element goes out after 5, so each element should last for 5 seconds in this array. (this represents people entering an array then leaving after 5 seconds).

0 Kudos
Message 3 of 84
(2,140 Views)

You really need to show us your VI!

 

The vlsual cortex is extremely good at recognizing patterns and any experienced LabVIEW programmer can tell within milliseconds what needs to be done.

 

Reading paragraphs of chatter talking about 3 different arrays ("this array", "new array", "third array", etc.) and convoluted requirements is way too fuzzy! There are millions of possible code architectures that can be described that same way.

0 Kudos
Message 4 of 84
(2,137 Views)

Overall, your code sounds like a nightmare and you really need to start over telling us about the exact requirements.

 

  1. Where do the new values come from (user, instrument, etc.)
  2. How often do new values arrive?
  3. How much history do you want to keep (ultimately you'll run out of memory).
  4. What's the purpose of the second array? Is there an indicator for it?
  5. What's the purpose of the third array?
  6. How does the user interact with the VI?
  7. What should the user see on the front panel?
  8. What is the purpose of all this???

 

In general constantly growing and shrinking arrays is called memory thrashing because arrays always need to contiguous in memory, so if allocated space runs out, the entire array needs to be moved to a larger free space. (probably no issue with small arrays). I am sure you probably could do a solution that is more "in place". we can help with that.

 

 

0 Kudos
Message 5 of 84
(2,127 Views)

As you can see I set up the first array how I wanted, but now for the second array, I can't figure out how to make it able to hold only 2 elements at once, then each of these elements are held for only 5 seconds. (so if there are 2 elements in the second array, the elements in the first array will stay there until there's a free spot)

0 Kudos
Message 6 of 84
(2,119 Views)

I posted the code that I need help with in the previous question, but to answer this, firstly the input arrives from a physical button, once this button is pressed a person will be added to a waiting area (first array) then this person must be moved to the second waiting area (second array) but only 2 people at once can go this second waiting area and they spend only 5 seconds there, then this person will be moved to a 3rd waiting area (third array). This VI is a simulation and will run for 4 mins and during these 4 mins the button will be pressed multiple times

0 Kudos
Message 7 of 84
(2,117 Views)

Also the data type of these array is a cluster, so each button press adds a cluster with a bit of information about the person. ( I have no problem with this bit of code im just mentioning that the data type is a cluster

0 Kudos
Message 8 of 84
(2,105 Views)

Sorry, I am currently on the road. Will look at it later.

0 Kudos
Message 9 of 84
(2,097 Views)

Hi dan³,

 


@dannn2020 wrote:

I posted the code that I need help with in the previous question,


No, you did not post any code!

All we got is an image of some small part of your VI's block diagram!

 

Would you also bring a photograph of your car to the garage when it needs to be repaired?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 84
(2,094 Views)