Note: As of the end of December 2018, our site has changed hosts and some architecture. As a result, all tutorials are now have a /tutorials in their paths. You will need to update bookmarks.

×

Our Future . . .

When I initially created this site in 2014, it was to serve two primary purposes.

To document the tips, tricks, and other higher level development practices that make programming for FRC in LabVIEW easier.

Provide a common place for LabVIEW teams to find resources.

At first, this meant documenting the architectural and similar tools that I had learned on my way to becoming a Certified LabVIEW Developer, that had been put to use by the team I was currently mentoring (#3937, Breakaway). (This had the added bonus of helping the senior programmer that had been soaking all this up document it for his successor.)

Since then, this site has had a few additions and updates (mostly by me).

While I have often invited other teams (I am no longer in the AR area and have pretty much lost contact with Breakaway) on CD and at the regionals I've been at to write tutorials for specific topics that they had solved, I was rarely met with a response (specifically once - shout out to the Huskie Robotics 3061 for actually following through, but they were the only ones).

In recent years, I have found myself going through some family changes and needing to dial back my commitment to other activities.

This leaves this site both:

Looking for a new champion/curator, that is willing to:

maintain the back end,

make sure material that becomes obsolete is either updated, or moved to the archives section of the menu,

and either write content or get other teams to write content to help this site remain relevant.

Looking for a new source of funding/hosting. (I have been personall providing the $36/yr that it costs to maintain it using Google Domains for the domain name - and email - and Hosting24 for the hosting; I have thought about using some sort of a Donate button, but have not been able to find a platform that allows for *only* raising the target amount). (With moving to Github's gh-pages for hosting, the cost has been reduced to $12/yr, mitigating this need).

If you have any interest in seeing the continuation of this site, please let me know.

FRC LabVIEW Tutorials - FGV

What is a Functional Global Variable(FGV)?

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.

FGV vs. Global Variable

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

Race Conditions
This one is the trump card, if one loop (for example, Teleop) needs to increment whatever is currently in the variable, and another occasionally needs to decrement it, use an fgv

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.

Race Conditions
This one is the trump card, if one loop (for example, Teleop) needs to increment whatever is currently in the variable, and another occasionally needs to decrement it, use an fgv

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.

Always consider which is the better data structure for the particular scenario.

How to make an FGV

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

Create a new VI

This vi will be the FGV, so it needs a couple of controls.

An Enum - use an enum to determine if initializing, setting, or reading the data

Motor In - use a numeric input to allow for the data to be set

Motor Out - use a numeric indicator for passing the data out to the calling code

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.

Block Diagram

The basis of the FGV is a while loop that has two things:

A constant so it only runs once

An uninitialized shift register to hold the data

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:

Move it to the output of the shift register so it is always updated

Configure the output to be the default for a number (which is zero) if the selected Mode is not Read.
This example implements a default.

If this tutorial inadvertently leaves some details out, please tell us about it and we will update it.

May we use Google Analytics to collect anonymized data on your use of the site?May we use Google Analytics to collect anonymized data on your use of this site such as browser type and size, what site referred you, and country of use?

We use this to help us understand how we are doing on getting the word out, and what browsers we should be testing against to make sure the site works for all our readers.