Yes, I am using continuous run. The default value of a boolean feedback node is FALSE, and that just happens to be what I need to to initialize to.
Quote:
Originally Posted by Greg McKaskle
The continuous run is simply running your entire diagram again and again including the init code. If you want better control over initialization, which you do, place your own loop around this with a button to exit the loop. You can then init on entering the loop and have state data inside the loop.
|
Huh. I just tried it, and I must have done it wrong, because it didn't work. One of the most basic VIs I'm working on to make my programming easier is the latching relay (the VI I uploaded). The output should
only be on if the trigger has been pressed, and should
only turn off if reset has been pressed. (in other words, there's one input to turn the signal on, and one to turn it off)
I suppose I could just wire every reset of every subVI I use to the "firstcall" indicator (which I should be doing anyways), but it makes it quite a pain for testing my code.
Quote:
Originally Posted by Greg McKaskle
Personally, I then prefer to switch over to the loop shift registers. They aren't necessarily better, but they are what I learned, and to me are simpler to explain things like initialization.
When you are ready to use the code you are writing as a subVI called from other locations, if the loop doesn't belong inside the subVI, but the state data does, then set the loop to a constant to run only once.
|
I'm not really sure how I can get a feedback node to initialize only once, when it seems to go through initialization every time it is called.
Apparently feedback nodes have a default initialization value. Shouldn't this mean that it resets to its default value when it is called for the first time, before it has a chance to collect data? (or perhaps even when "abort execution is pressed"*)
* I made a mistake in confusing "abort execution" with "stop" in my previous post.