LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI of the Day (9/25/2009) - Feedback Node

Today another one of the many "new and improved" items (since LV 8.2), the "Feedback Node".  I was originally going to talk about something different, but a funny thing happened to me today.  Given my clunky mouse and laziness in regards to changing options, I once again wired an output to input and wound up with a feedback node.  It happened to be in a while loop, but when I moved it outside (my usual "shortcut" to deleting the thing in LV8.2) it survived, and LV seemed perfectly happy.  It seems I can kiss many while loops with hard-wired stops goodbye.  Given my penchant for those old-school functional globals, could be interesting.  Combined with recursion, I can now eliminate most loops if I was so inclined (which I am certainly not).

 

My example is an old LV8.2 variety, the classic calculation of the Fibonacci numbers.  I show two flavors, shift register and feedback node.  If there is a difference in LV8.2 between the two, I don't know what it is.  In LV8.6 and beyond, there are useful additions like Globabl initialization, and the fish out of water behavior.  In LV2009 you can increase the delay, haven't thought of a real use for that yet.  Could be useful, but with the delay hard-wired, it is hard for me to think of too many.  It is there for a reason, so perhaps somebody has been longing for that feature.

 

Fibonacci.png

 

As you can see, little to be gained (in LV8.2) in terms of readability or compactness.  This is why, until now, they were mostly a curiosity to me.

 

VIOTD groundrules here.

 

Note:  I will be Gone Fishin' next week (literally). 

Message Edited by Darin.K on 09-25-2009 12:56 PM
Message 1 of 7
(4,949 Views)
I remember when I use to use the feedback node then I found the shift register and never looked back lol
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 2 of 7
(4,944 Views)
I'm yet to use a single feedback node in my 1+ year of LabVIEWing.  It seems less intuitive to me than a SR.
--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 3 of 7
(4,940 Views)

Darin.K wrote:
If there is a difference in LV8.2 between the two, I don't know what it is.

 

Message Edited by Darin.K on 09-25-2009 12:56 PM


 

Speed.  Here is a thread where we benchmarked them:

 

http://forums.ni.com/ni/board/message?board.id=170&view=by_date_ascending&message.id=375969#M375969

 

In another thread, I added the speeds for 8.6.1f1:

 

http://forums.ni.com/ni/board/message?board.id=170&view=by_date_ascending&message.id=431700#M431700

 

I still haven't gotten around to installing LV2009, so cannot benchmark them yet.  They seemed to get the speed close in 8.5.1, but have diverged again.

 

There are places where feedback nodes can be very useful, especially in lower speed instances.  But it is important to not get "lazy" because it is there, especially when you can be looking at a 30% hit on execution speeds.

 

 

Message 4 of 7
(4,915 Views)

I have just started to use feedback nodes for real just recently.  I had always preferred the shift register as the flow of that was more logical.  However, the changes made to the feedback node a few versions ago where you can use it without having to attach it to a loop structure have made it useful.  Now if I want to feedback a value within a subVI that has no loop, or the place where I want to see the previous value is right near where I am generating the new value, such as adding a numeric, or comparing a boolean to its previous value, the feed back node gives me the ability to do that right there rather than having to stretch wires across the screen to shift registers, or wire it through all cases when in reality, the source and sink of that particular value are only located in a single case of a case structure.

 

If I need a value in multiple cases, or the source and sink of the data has a lot of code in between, them I will lean towards using the shift register.

 

One thing I definitely did was turn off the autowiring of the feedback node.  Any time you use a feedback node, it should be because that is what you are intending to do.  I don't want one being generated because I made a mistake in wiring or am just trying to rewire a section of code.  In those cases, I would prefer the wire to just remain broken until I fix it, rather than having unbroken code with a feedback node that doesn't do what I intended.

Message 5 of 7
(4,891 Views)

Due to better performance, I usually stick to SR's over Feedback Nodes.

However, I do use Feedback Nodes sometimes to save real estate.

 

Instead of running a wire all the way across a loop, if it is a large loop,

I will just place a feedback node so it takes up less space.

Cory K
0 Kudos
Message 6 of 7
(4,874 Views)

One of the threads linked to includes the link to this post in Darren's blog where we also discussed this. In 8.x it has two improvements I like a lot:

 

1. The ability to change its direction (see top image). When it's pointing to the right, code which uses it usually becomes much more readable (although less in this example. It's much more evident when you have the wires contained to a small area and don't have to go left at all).

 

 


2. The ability to place it inside a structure and initialize it from several layers out. This is essentially a buffer which is held inside a single case of a case structure.


___________________
Try to take over the world!
Message 7 of 7
(4,841 Views)