An FGV is a standard LabVIEW data structure that implements data storage in a globally accessible way. Every time you call the FGV (which is a vi), the block diagram runs exactly once - either updating the data or reading it.
The FGV is a data structure designed to help prevent race conditions. However, if you are writing to your variable in one loop (for example, in Teleop), and reading from it in another (for example, periodic tasks), this will not cause a race condition.
There are three criteria that should be considered when choosing to implement an FGV or a simple Global
Custom Boundaries Here an FGV wins. If you want your shooter wheel speed (or whatever the data represents) to have certain boundaries on it (i.e. from 0 to 0.5), than an FGV can allow you to enforce this whenever setting the value. So an FGV wins in this case.
For this example, we will make an FGV that contains the speed for the a shooter motor, and will briefly discuss how to use it
This vi will be the FGV, so it needs a couple of controls.
These controls and the indicator need to be accessible via the connector pane.
To connect a control or indicator to the connector pane, select the desired terminal.
Then select the control or indicator to connect it to.
The basis of the FGV is a while loop that has two things:
Add a shift register to the while loop
Put a case structure inside the while loop and connect it the enum to the selector. Notice that not all of the enum values are setup as cases initially, so right click on the case structure and select “Add case for every value”.
For the initialize case, put a default value in.
In the set case, this is where we can enforce the valid range of values. We take the input and run it through a coerce block and store the coerced value in the shift register.
In the read case, we take the value from the shift register and report it to the indicator.
We are now faced with a decision of what to do in the other cases where the output is not needed.
Two options present themselves:
And we are Done. Click here to download the finished version