08-20-2011 11:39 PM
Dear all.
I have problem with using feedback node and I often experience problem like this.
When I have to make an array with appropriate elements(satisfying certain condition), I usually make a loop and find proper element in each cycle and then accumulate this element to make an full array.
To do this, I use 'insert into array' and 'feedback node'.
It works well when I run this VI only. But problems appear when I make this VI as a sub VI. In this case, when I run this sub VI twice or more the buffer for feedback node is not initialized. First fun of sub VI works well but when it is run second time, it remembers element in the first run(which is undesirable). I think the sub VI is not clearly finished until main VI is finished.
How can I solve this problem?
ps. making auto indexed turnnel in a loop can be a solution becaues it doesn't need feedback node. But i cannot used this for certain reason.
08-21-2011 08:06 AM
Is it possible for you to post your code? I think there is a more elegant solution to the problem that you are having but would be able to guide once I visualize the issue.
08-21-2011 09:26 AM - edited 08-21-2011 09:29 AM
A FBN will act like a USR, unless you wire something to the initializer With this configuration:
The FBN configuration shows as
With this change:
You must globally initialize (either on Compile or First call) which means that the data in the FBN is stored as long as the vi is in memory and the FBN does not re-initialize between calls CAVEAT: you could force the sub-vi to reload on each call to get the behavior you want but that is silly since it would add unnecessary overhead but, this is possible
And yes- for this simple example the code would not really run at all- the optomizer would replace it with a constant in the compiled code but, that's another story
09-03-2011 08:05 AM
09-03-2011 11:12 AM
It is hard to give an answer without seeing your VI.
But it sounds like you have a subVI in a For Loop, and you want to initialize the feedback node in the subVI with a different value on each iteration of the For Loop.
That is where autoindexing comes in. Create an array of the different values. Feed the array into the For Loop with autoindexing turned on for the tunnel. Now each iteration of the For loop will use the next element of the array in turn. That is the value that can be fed to your subVI and thus your intializer terminal.
09-03-2011 11:55 AM
@dlacres wrote:
The problem is that the feedback node is not unique for each instance of the sub vi.
If each instance of the subVI should have its own memory space for the feedback node, you need to make the subVI reentrant. Open the subVI and go to "VI properties ... execution" to configure.
05-23-2012 03:01 PM - edited 05-23-2012 03:01 PM
"...you need to make the subVI reentrant."
Bless you! This has been driving me nuts: Feedback Nodes working in outer loops, then not initializing "correctly" (meaning the way I think they should ) when converted to a subvi. This has bit me twice now, but your answer took care of it. I don't think I can give you a kudo since the original post isn't mine, but the next time you're in Tucson look me up and I'll buy the beer.
05-23-2012 03:10 PM
You can give kudos to any post you want as long as you are logged in.
(Only the thread author can mark a post as solution, but that something else.)
05-23-2012 04:23 PM
Done, but I'll still spring for the brews..........