08-26-2010 01:15 AM
While mangling a functional global implementation I mistakenly put the read indicator inside the while loop in the read case. I quickly discovered that during any write operation, the indicator was always reset to some default value. The default is traceable from a previous mangling and the value is understandable. What I don't get is why the indicator inside the loop gets reset?
See the attached super-simple vi. This thing seems counterintuitive and I am sure missing something basic here.
Thanks!
Solved! Go to Solution.
08-26-2010 02:12 AM
Hi David,
I guess, the "Duration inside" gets reset to it's default value because you actually do a read operation of that indicator as it's wired to the connector pane. So the VI has to output a value - and it takes the default value...
For memory allocation optimization you should put all indicators/controls outside of the while loop. Read the LV Style Guide...
08-26-2010 02:16 AM
I can't look at the VI, but I'm assuming the indicator is also used as an output in the connector pane? Outputs on the connector pane are reset to their default when the VI runs if they have no value wired to them.
I have no idea what the logic for this is and never bothered finding out. If I'm using an indicator as an output, I always put it at the outermost level, so it will have an explicit value written to it every time the VI runs.
08-26-2010 02:36 AM
As a continuation to my previous posting, I just discovered that a functional global with multiple inputs also shows an equivalent quirk on the write operation. Say that I have a FG with two inputs on seperate terminals (as opposed to a cluster). Any time I call the FG in write mode and leave any input open it resets the open inputs to their defaults. I thought that the shift register was supposed to retain the previous value as long as it didn't leave memory?
If this does not run the same way on your computer, please let me know so that I can pitch mine out the window.
Tack,
Crazy in Sweden
08-26-2010 02:41 AM
Hi,
If I put all the controls outside of the while loop, they have to be attached to something, namely the shift registers. If I do that I reinitialize the shift registers every time. I can't see that as being an implementation of a functional global at all.
08-26-2010 02:44 AM
Hi David,
you have to at least a little bit creative See attachment.
When you want to write only one of the inputs to the FGV, you have to provide more OpModes (Read/Write)! You have to introduce OpModes like "Write Bob" and "Write Mary", where you only wire one of the inputs to the shift register...
08-26-2010 03:39 AM
The light has dawned! Oddly enough in another FG I built, I used a cluster and the read/writes were selected by the cluster item, which is exactly the implementation that you suggest. The remaining items in cluster were always read/written so their values were retained.
I just wasn't smart enough to realize that I got it right that time purely by accident.
Thank for the education and your help.