LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problem with feedback node usage

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. 

0 Kudos
Message 1 of 9
(5,313 Views)

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.

Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 2 of 9
(5,295 Views)

 

A FBN will act like a USR, unless you wire something to the initializer With this configuration:

!bam.png

The FBN configuration shows as

Ahhh.png

With this change:

!bam2.png

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

Ahhh2.png

 

 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


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 9
(5,288 Views)
I also have this same problem. I am not sure what global initialize means. I am a volunteer helping with FTC robotics. I have created a simple control law for the robot. In my top level VI I use a timed loop to call all of the sub VIs at 50 hz. I created a sub vi called integrator that uses a feedback node to accumulate (integrate) the signal. I want to use this sub vi all over my model. The problem is that the feedback node is not unique for each instance of the sub vi. With the previous answer you said to provide a global initialize to the feedback node. It looked like you wired the initial value outside the loop. In my scenario, does this mean that I have to wire a signal up to the top timed loop for each sub vi integrator to give it it's own initial value and thus its own space in memory? Is there any shortcut I can use? This will take forever to do and will be a maintenance nightmare. Thanks in advance for any suggestions.
0 Kudos
Message 4 of 9
(5,245 Views)

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.

0 Kudos
Message 5 of 9
(5,235 Views)

@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.

Message 6 of 9
(5,230 Views)

"...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 Smiley Wink ) 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.

John

"Praise the Lord and pass the ammunition."- Lt. (j.g.) Howell Forgy, Sky Pilot, USS New Orleans, 12/7/41
0 Kudos
Message 7 of 9
(5,135 Views)

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.)

0 Kudos
Message 8 of 9
(5,128 Views)

Done, but I'll still spring for the brews..........

John

"Praise the Lord and pass the ammunition."- Lt. (j.g.) Howell Forgy, Sky Pilot, USS New Orleans, 12/7/41
0 Kudos
Message 9 of 9
(5,116 Views)