LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Shift register initial value

Solved!
Go to solution

Smiley Very Happy

 

 

Touche !

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 11 of 22
(2,597 Views)

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. 

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 12 of 22
(2,588 Views)
Solution
Accepted by topic author jyang72211

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... Smiley Tongue

Message 13 of 22
(2,587 Views)

@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... Smiley Tongue


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

 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 14 of 22
(2,578 Views)

 


@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.

 

Message 15 of 22
(2,556 Views)

Hi alten,

 

Globally initialized feedback node ist just the feedback now with it inital value wired to a value, right?

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 16 of 22
(2,514 Views)

No,

 

 

  • A subVI with an initialized shift register will initialize it every time the subVI is called.
  • A subVI with a globally initialized feedback node will only intialize the first time the subVI is called.
Big difference!

 

Message 17 of 22
(2,509 Views)

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?

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 18 of 22
(2,492 Views)

A feedback node can be globally initialized or locally initialized.

 

 

  • If it is inside loops and not globally intialized, you can move the initializer terminal to any loop boundary and either leave it unwired or initialize it.
  • If it is globally initialized and you don't wire the initializer terminal, it acts like an uninitialized shift register, remembering the value between runs.
  • If it is globally initialized and you wire the initializer terminal, it will initialize on "first run" and then never again on further calls, as long as the program keeps running. ("continuous run" does not count).

 

Message 19 of 22
(2,482 Views)

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

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 20 of 22
(2,448 Views)