LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

functional global mishap/oddity

Solved!
Go to solution

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!

David A. Taylor
0 Kudos
Message 1 of 7
(2,998 Views)

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

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(2,988 Views)

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.


___________________
Try to take over the world!
0 Kudos
Message 3 of 7
(2,986 Views)

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 

David A. Taylor
Download All
0 Kudos
Message 4 of 7
(2,977 Views)

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.

David A. Taylor
0 Kudos
Message 5 of 7
(2,974 Views)
Solution
Accepted by topic author Mariahnova

Hi David,

 

you have to at least a little bit creative Smiley Wink 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...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 7
(2,969 Views)

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.

David A. Taylor
0 Kudos
Message 7 of 7
(2,956 Views)