×

Our Future . . .

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

  1. To document the tips, tricks, and other higher level development practices that make programming for FRC in LabVIEW easier.
  2. 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:

  1. 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.
  2. 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).

 

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

FRC LabVIEW Tutorials - Arduino on the Driver Station

Table of Contents

Background

Many of the years that the authors have been involved with FRC, we wanted to collect I/O on the Driver Station. Sometimes it was an abort button, other times a potentiometer to select an auto program, and still others we wanted to put LED's on the Driver Station that would light up to alert the drivers/coach to something (game piece acquired, aligned for shot, etc.)

The TI Launchpad allows for the input to the driverstation by acting as an extra Joystick but requires a bit of setup and is only an input.

Below is presented a setup that allows for an Arduino to be used for generic I/O on the Driver Station through the LabVIEW Interface for Arduino (now, LINX).


For this tutorial, we will implement reading a potentiometer and displaying it on the Dashboard. The setup presented below can be used to read or write to/from any of the pins on the Arduino (including writing PWM out).

Setup

First, we wire a potentiometer so that it can act as an Analog Input to the Arduino.

We wire 5V and Ground from the Arduino to the two outer pins of the potentiometer and connect the wiper pin to A0.

Wire the potentiometer to A0

The library we will use to interact with the Arduino from LabVIEW is called the LabVIEW Interface for Arduino (now, LINX) which we need to download and install to LabVIEW.

On labviewmakerhub.com select download now

If prompted, select to open in Package Manager.

open in VI Package Manager

Select Install

Select install

Follow prompts

Follow prompts

To see where the installed library is in the palette, select 'Show in Palettes'

Show in palettes

Connect the Arduino to the computer and open LabVIEW (Note: The Arduino driver is needed for this step - you can download and install it with the default IDE at Arduino.cc)

From the launch screen (or any screen actually) select Tools -> MakerHub -> LINX -> LINX Firmware Wizard...

Open Firmware wizard

Select the correct type of Arduino firmware to use and click next.

Select the correct type of Arduino

Select the port that the Arduino is connected to (See Arduino getting started info for help) and click next to download firmware.

This firmware implements a communication interface that allows for the VIs we installed earlier to control the I/O on the Arduino.

Select Port

Click next to download the default firmware image

click next

Create custom dashboard

Once the download finishes, press "Finish" to return to the LabVIEW welcome screen.

Select a New -> FRC Dashboard Project.

In the configuration dialogue choose what you would like to name the project and where to save it and click next.

Select the correct type of Arduino

In the Project Explorer window, select and open "Dashboard Main.vi"

This is a source code version of the default dashboard. Go to the block diagram (press CTRL + e or select Window -> Show Block Diagram).

Scroll to the top (the region that is expected to be edited), and add a While Loop.

View the block diagram

Open the palette (right click if it is not already open) and select MakerHub -> LINX -> Open

This VI creates the communication link to the Arduino for us.

Place it to the left of the new While Loop

Get the LINX Open vi

Right click on the top left terminal of the Open.vi and select Create -> Constant

Select the port the Arduino is connected to.

Create port constant

Wire the top right terminal (LINX Resource) to the While Loop and set it to a Shift Register

Wire resource to loop

Wire the error out from the Open to the While Loop.

Get a Close.vi from the LINX palette and place it to the right of the while Loop - this VI will unreserve the port.

Wire the error from the left of the While Loop to the close vi

Wire LINX close VI

Branch the error wire and connect it to the stop terminal for the loop.

From the MakerHub -> LINX -> Peripherals -> Analog palette Select the Analog Read.vi

Get Analog Read vi

And set the Analog channel and pass the reference and the error through the read vi

Set the analog channel to read

Unfortunately, if we abort the VI, the port to the Arduino is not properly closed.

The port will remain reserved (but unavailable to the Open.vi) until the owning process (right now, LabVIEW) is completely shut down.

This does not create an issue for the built version of the dashboard as that is an executable of its own and releases the port when it is closed.

To make this easier to deal with while in development in LabVIEW, we will create a stop button in a new VI. Create a new VI.

Place a stop button and an round LED (or some other form of both a Boolean control and indicator) on the front panel.

Stop vi front panel

Connect the output to a terminal on the VI by clicking on the terminal first, then the indicator

Connect the output to the terminal

On the block diagram, simply connect the control to the indicator.

This will allow you to press the button to send a True out to the calling VI.

Save this vi as stop_button.vi

connect the control to the indicator.

Drag the VI just created (by the icon) to the block diagram of the Dashboard Main.vi

Drag the Stop VI in

Insert an OR on the Error wire going to the stop terminal and connect the output of the Stop VI to the OR

Connect the Stop VI to the or

The finished product

The finished Arduino Loop

Test

For the sake of testing it, we will replace the numeric indicator with a Horizontal Progress bar.

replace the numeric indicator with a Horizontal Progress bar

Open Properties on the bar.

Open the properties

On the scale tab set the Maximum to 5 (the Arduino will read an AI from 0V to 5V).

Set the max to 5

Run the Dashboard VI. After a few seconds, the connection with the Arduino will be established and the progress bar will update as you move the potentiometer.

Watch the bar update

To stop running, first open stop_button.vi and press the stop button the front panel

This will cause the Arduino loop to stop executing allowing the Close.vi to close the port to it.

Press the Stop Button

(How can I know if it worked?, the stop_button vi will stop executing because it is no longer getting called).


You can then abort the dashboard VI from the block diagram.


See our tutorial on Connecting a Gyro to the dashboard for more information on using this custom dashboard with the Driver Station and running it.

Sending data to the robot

To send this value to the robot, use the Dashboard Write vi and name the variable.

Send to robot

Reading data from the robot

The Dashboard VI's can be used to write data on the robot and read it on the dashboard, or vice versa.

Use the write vi to send the data and the read vi to receive it. Make sure to use the same data type on each end and the same (case-sensitive) name.

Read and write vi's

You can use the data sent from the robot to control the Arduino as well.

Read data from the robot

To use the dashboard you just created

Easiest way, build it, open it, then open the Driver Station. The DS should recognize that a dashboard is already open and just work with it.

Some possible improvements

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

Google Form to request details