Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Difference between Shift Register and Feedback Node (http://www.chiefdelphi.com/forums/showthread.php?t=101620)

MotorHead 31-01-2012 12:53

Difference between Shift Register and Feedback Node
 
This is a general question about LV programming, but would love to hear some opinions on this...What is the difference between using Shift Registers and Feedback Nodes? They appear to be functionally the same, just drawn differently in the Do Loop. Is there performance differences between the two?

I did some poking around NI website with this question and found some great debates about their use, but most of the discussion were referencing a few rev's back of LV. Is there a definitive answer on when to use one over the other for the latest revisions of LV?

Omar 31-01-2012 13:17

Re: Difference between Shift Register and Feedback Node
 
They are pretty much the same. I used them at different times more from a personal preference. I use shift reg more just because I have been programming with LabVIEW from the early 90's and grew up with shift reg.

I use shift reg 3/4 of the time.

I use feedback nodes to save space on the block diagram and to keep from running wire all cross my block diagram. I most only use the feed back nodes pointing to the right. I do not like to have any wires going from right to left. So in those cases I use shift reg. These are all personal preferences and not the same for everyone.

I have never seen any real speed differences that really matters.

The feedback mode dose have some built in functions that to do the same with shift reg you would have to add a little code. But anything you can do with a feed node you can do with a shift reg and a little extra code.

There are some extra initialization setting (configuring) that the shift reg does not have, but I never had a need for them.

Which one you use is up to YOU.

tilky 31-01-2012 16:00

Re: Difference between Shift Register and Feedback Node
 
i hope you aren't using shift registers under teleop:yikes:

SuperS_5 01-02-2012 00:31

Re: Difference between Shift Register and Feedback Node
 
Quote:

Originally Posted by tilky (Post 1117211)
i hope you aren't using shift registers under teleop:yikes:

Single run loops are a common design when using uninitialized shift registers. I have personally stated to move away from this, towards feedback nodes. This is mostly due to some misunderstandings with junior programmers. I find that feedback nodes offer more information at first glance. This is particularly important for code review. This however, comes with the risk of sloppy looking code. I believe uninitialized shift registers, used in single run loops have some overhead due to the loop. I am unsure of how the compiler optimizations affect this. I often will use them interchangably.

Omar 01-02-2012 08:50

Re: Difference between Shift Register and Feedback Node
 
Quote:

Originally Posted by tilky (Post 1117211)
i hope you aren't using shift registers under teleop:yikes:

We use shift reg all the time in teleop.
The number one way I use shift reg is in single loop while loop just to store a value for later use.

zaphodp.jensen 01-02-2012 08:51

Re: Difference between Shift Register and Feedback Node
 
Simply, shift registers are just a way to pass a value from one iteration of a loop to the next iteration of the loop. They require a "host loop" that they connect within.

Loop iterations (0 is the initial value passed into the shift register)
0 1 2 3 4 5 6 7
Output (This looks weird, but due to the design of the shift register, the output comes before the input, left to right)
0 0 0 1 2 2 3 0
Input
0 1 2 2 3 0 7
Final output 7

A feedback node is basically a shift register without the loop. The shift register takes and delays the incoming signal one iteration of the vi. This would be used in Teleop, where you can't have loops.

VI iterations
0 1 2 3 4 5 6 7
Input
0 0 1 2 2 3 0
Output
0 0 0 1 2 2 3 0

MotorHead 01-02-2012 16:33

Re: Difference between Shift Register and Feedback Node
 
Quote:

Originally Posted by Omar (Post 1117724)
We use shift reg all the time in teleop.
The number one way I use shift reg is in single loop while loop just to store a value for later use.

Could you explain more about this? Post a code example perhaps. I was under the impression as well that you could not do this since the shift register involved a loop and you didn't want the loop tying up telop. In the past, I have written information to a Global Variable and let a loop inside of Periodic Task access the value.

Thad House 01-02-2012 16:50

Re: Difference between Shift Register and Feedback Node
 
1 Attachment(s)
Our team uses while loops with shift registers to run all of our inputs and outputs. Inside each loop is a case structure with an enum for 3 modes, which are init, run and end. All the code that would normally be placed in the begin VI is placed in the init case, and then that case is run in begin. In run is all of our code that is used at runtime. In end it the code that is normally located in finish. This shift registers are used to transfer the references between the 3 states. This means that we do not need to use refnums which saves some resources.

Joe Ross 01-02-2012 17:48

Re: Difference between Shift Register and Feedback Node
 
Quote:

Originally Posted by MotorHead (Post 1117989)
Could you explain more about this? Post a code example perhaps. I was under the impression as well that you could not do this since the shift register involved a loop and you didn't want the loop tying up telop. In the past, I have written information to a Global Variable and let a loop inside of Periodic Task access the value.

The trick is that the stop of the while loop is wired to a true constant, so that the loop only runs once.

SuperS_5 02-02-2012 00:25

Re: Difference between Shift Register and Feedback Node
 
Quote:

Originally Posted by sst.thad (Post 1118004)
Inside each loop is a case structure with an enum for 3 modes, which are init, run and end.

Just be careful with Enums like this. This is very common practice BTW, and one method to keep your code isolated. Your action Enum, (Init|work|end) should always be a TypeDefd control. This also presents the possibility of the constant value automatically changing if the typedef is updated. I typically will write the desired value as a BD note, next to the Enum constant.


All times are GMT -5. The time now is 11:44.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi