|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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? |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
||||
|
||||
|
Re: Difference between Shift Register and Feedback Node
i hope you aren't using shift registers under teleop
![]() |
|
#4
|
||||
|
||||
|
Re: Difference between Shift Register and Feedback Node
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.
|
|
#5
|
||||
|
||||
|
Re: Difference between Shift Register and Feedback Node
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. |
|
#6
|
|||
|
|||
|
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 Last edited by zaphodp.jensen : 01-02-2012 at 09:00. Reason: Added more information. |
|
#7
|
||||
|
||||
|
Re: Difference between Shift Register and Feedback Node
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.
|
|
#8
|
||||
|
||||
|
Re: Difference between Shift Register and Feedback Node
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.
|
|
#9
|
||||||
|
||||||
|
Re: Difference between Shift Register and Feedback Node
Quote:
|
|
#10
|
||||
|
||||
|
Re: Difference between Shift Register and Feedback Node
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.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|