03-16-2011 01:30 PM
Touche !
Ben
03-16-2011 02:47 PM
Hi all,
Some of my VI use the uninitialized shift register as a function global, but it assumes that when I restart the program, the value of the shift register is zero. Is that a bad programming practice? I don't want to initialize the shift register, becasue I want the shift register to save the value from the previous time when the vi is called. I only want the shift register to be zero when I call it for the first time.
03-16-2011 03:02 PM
At the risk of getting beaten up by Ben, I think that is a perfectly legitimate use of the USR, and what I assumed you were doing when I offered my tip. I tend to use globally initialized feedback nodes these days, you need the First Call? primitive or an explicit call to initialize your FGV with shift registers. Not to mention that "extra" loop.
Perhaps others had the impression that you were going to start Ctrl-running all of your VIs instead of initializing the SRs.
Before I post any code to the forums I try to remember to do this sequence:
Ctrl-Run,Run,Run,Ctrl-Run,Run to catch those unintended USRs and see that any USRs are behaving.
And to be explicit: Ctrl-Run is a debugging tool, like the run continuously button. Although the combination of USR and run continuously could do some interesting things...
03-16-2011 03:14 PM
@Darin.K wrote:
At the risk of getting beaten up by Ben, I think that is a perfectly legitimate use of the USR, ..
Ctrl-Run,Run,Run,Ctrl-Run,Run to catch those unintended USRs and see that any USRs are behaving.
And to be explicit: Ctrl-Run is a debugging tool, like the run continuously button. Although the combination of USR and run continuously could do some interesting things...
Fair enough. What a difference a few more words make. I did a quick attempt to devote that tid-bit to memory but now i have the Beach Boys song in my head
Crtl-run run run ctrl run run...
Ben
03-17-2011 01:07 AM
@Darin.K wrote:
I tend to use globally initialized feedback nodes these days...
Yes, that's what I do. A globally initialized feeback node is probably the best solution. The feeedback node will correctly initialize at the start of the program and will not initialize again for the duration of the program run.
03-17-2011 01:58 PM
Hi alten,
Globally initialized feedback node ist just the feedback now with it inital value wired to a value, right?
03-17-2011 02:07 PM
No,
03-17-2011 05:19 PM
Hi Altan,
I meant what is the different between
Globally initialized feedback node
and
Feedback node
If there is a difference, what is the difference? If they are the same, what did we add globally initialized before feedback node?
03-17-2011 07:00 PM
A feedback node can be globally initialized or locally initialized.
03-18-2011 09:21 AM
Hi Alten,
Thanks for teaching me so much about feedback node? I haven't used feedback node that much, and I thought that feedback node is just like a shift register. From what you pointed out, I realized that a I can configure the feedback node, so that I can initialize it at different loop location in a nested loop situation, I can configure it to initialize on first call or on compile. Now, I am already see myself abusing the feedback node a lot. 🙂
Yik