|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: Difference between Shift Register and Feedback Node
i hope you aren't using shift registers under teleop
![]() |
|
#2
|
||||
|
||||
|
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.
|
|
#3
|
|||
|
|||
|
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. |
|
#4
|
||||
|
||||
|
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. |
|
#5
|
||||
|
||||
|
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.
|
|
#6
|
||||
|
||||
|
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.
|
|
#7
|
||||
|
||||
|
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.
|
|
#8
|
||||||
|
||||||
|
Re: Difference between Shift Register and Feedback Node
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|