LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reentrant execution for loop

Solved!
Go to solution

Do you have any example, just a start up...

0 Kudos
Message 11 of 21
(1,183 Views)

look up "clones" in the example finder or even here on the forum and on LAVA forum as well. See this one.


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 12 of 21
(1,180 Views)
Solution
Accepted by topic author ThijsBoeree

Just a quick one to get you started:

 

ViTemplateInLoop.png

 

Also, check http://digital.ni.com/public.nsf/allkb/49334E1013800E4886257A6800782495

 

/Martin



CLA
www.dvel.se
0 Kudos
Message 13 of 21
(1,176 Views)

I still have to less knowledge on this subject, so i think i have to go with the more static solution, but i can have up to 107 different channels... oh boy!

0 Kudos
Message 14 of 21
(1,165 Views)

No, take this opportunity to learn something and write better code!

 

To start with, I'm not sure I fully understood the problem. Do you want all you filters to be independent of each other? In that case you should set the "init/cont" to false, forcing it to reinitialise every time as opposed to continuing from the state it had the last time it ran.

 

If you really need the separate instances, just write a sub-vi that contains the filter you want to use with and wire the needed inputs to controls and the connector pane on the icon.  Then got to File -> Save As and at the bottom choose Template VIs. Now you will get yout template vi (named something.vit).

 

In the snippet code i posted, right click the static vi reference and browse to something.vit. Now you can call your created vit with the Call By Reference node just the same way as you called your filter, but each time in the loop a new vi will be dynamically created from your template and in the end you'll have 107 of your own filter vi:s. Make sure you use Close vi reference afterwards on these.



CLA
www.dvel.se
Message 15 of 21
(1,156 Views)

M_Peeker is totally right, take the opportunity!


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 16 of 21
(1,154 Views)

Okay,

 

then i almost was there, one question though, the output of the static reference isn't connectable to the open VI reference, but i do can connect it straight to the "call by reference VI" but how should i suppose to close it?

 

Regards,

Thijs

0 Kudos
Message 17 of 21
(1,149 Views)

Great, then you're on track.

 

To close the reference, use "Close Reference" under the Application Control palette and wire the "reference out" from the "Call by reference" to it.



CLA
www.dvel.se
0 Kudos
Message 18 of 21
(1,142 Views)
I solved it!! In a total different way!! I used the filter state and the final filter state, i will attach a vi next monday! The thing is with filters that it remembers only one signal's filterstate, so i've put the filterstates in a 2D array and use a shift register to remember each channel's filter state and then in my for loop i collect each filter state again. Easy! And it works great!!

Regards,
Thijs
Message 19 of 21
(1,119 Views)

Here is my solution!

 

remeber the filter state

 

 

0 Kudos
Message 20 of 21
(1,102 Views)