LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Initialize array and then using a feedback node to replace elements

Solved!
Go to solution

Hello Friends,

 

I have a typical problem. I need to store values in a 1-d array with 7 elements. I want to start with a all zero element array. I then start sending values and indices one by one so that the value is inserted into array and is stored. My problem is, when I start with an all zero array ,what happens is whenever i send a value it replaces a zero at the correct index  but it doesnt store that value for the next iteration as the zero array sets the array to zero again. So only one element changes in the array all the time. I dont want it like that. Once started i want all my values stored in the corresponding index unless until a value with the same index replaces that. here is my attempt in jpg format.I tried to insert a zero array which runs only once in a while loop and then connect the replace array in feedback mode so that the insertion of zero elements happens only once.But i am not able to do that. pls help me inthis regard

 

replace array.JPG

Message Edited by Srik on 10-15-2009 09:47 AM
0 Kudos
Message 1 of 7
(6,590 Views)

Hi Srik,

 

Is it essential that you have the 7 element array at start up?

 

I have attached a vi that will fill an array up to 7 elements (or however many you tell it) and then replaces the elements one by one starting from the top, it also calculates the rolling average but that can easily be removed...!

 

Hope this helps point you in the right direction.

 

Easy,

 

Darren.

Message 2 of 7
(6,583 Views)
Solution
Accepted by topic author Srik

Your image shows that you can't possibly have a 'next iteration' because there is no while loop around the Replace Array Element code and the while loop around the Initialize Array is useless. You're not clicking on the 'Run continuous' button are you? Don't!

 

Below is a basic example. You can learn some LabVIEW basics by taking some of the tutorials.

 

Message Edited by Dennis Knutson on 10-15-2009 09:07 AM
0 Kudos
Message 3 of 7
(6,580 Views)
Thanks Wortel.. i got an idea how to do it seeing yours...thanks a ton
0 Kudos
Message 4 of 7
(6,579 Views)
No worries, don't forget to click "Solved" if you have found the solution... Also "Kudos" if you think it's deserved! Smiley Wink
Message 5 of 7
(6,574 Views)

Hello,

   I, too, am trying to initialize an array and then use a feedback node.  I am also brand new to Labview.  I think that I can't use a while loop in a sub VI because it will cause the main VI to freeze as the subvi keeps executing.  Any thoughts?

0 Kudos
Message 6 of 7
(5,797 Views)

You can use a while loop in a subVI.  You can have it execute just once by wiring a True constant to the stop terminal.  With uninitialized shift registers on the while loop, you have a function global variable or action engine.

 

Action Engine Nugget

0 Kudos
Message 7 of 7
(5,790 Views)