Building and Loading your First LabVIEW Program

This document covers how to build and load an FRC LabVIEW program onto a cRIO. Before beginning, make sure that you have installed LabVIEW for FRC and the NI FRC Update and that you have imaged your cRIO as described in the Getting Started with the 2014 Control System manual.

Creating a Project

Creating a Project

Launch LabVIEW and click the FRC cRIO Robot Project link in the Projects window to display the Create New FRC Robot Project dialog box.

Configuring Project

Configuring Project
  1. In the Project name text box, enter the name you want to use to identify the new FRC robot project.
  2. In the Project folder text box, enter the location on the host machine to which you want to save the project files and VIs or click the folder icon to browse to the desired location.
  3. Select a robot type, if unsure, use the default Arcade Drive Robot - hardware or simulation. Don't click Finish yet.

Configure cRIO IP

Configure cRIO IP

4. In the cRIO IP address text box, enter the IP address of the cRIO to which you want to deploy the project. The IP address of the cRIO must be in the form 10.xx.yy.2, where yy corresponds to the last two digits of the team number and xx corresponds to the remaining first or first two digits of the team number. Note that the team number entered here should not contain any leading zeroes. Then click Finish.

Running the Program

  1. In the Project Explorer window, double-click the Robot Main.vi item to open the Robot Main VI.
  2. Click the Run button (White Arrow on the top ribbon) of the Robot Main VI to deploy the VI to the cRIO. LabVIEW deploys the VI, all items required by the VI, and the target settings to memory on the cRIO. If you receive a conflict dialog, click Ok to unload the startup program and load the new code. The startup program will still load on the next cRIO boot.
  3. Using the Driver Station software, put the robot in Teleop Mode
  4. Click Enable.
  5. Move the joysticks and observe how the robot responds.
  6. Click the Abort button of the Robot Main VI. Notice that the VI stops. When you deploy a program with the Run button, the program runs on the cRIO, but you can manipulate the front panel objects of the program from the host computer.

Note that a program deployed in this manner will not remain on the cRIO after a power cycle. To deploy a program to run every time the cRIO starts follow the next step, Deploying the program.

Deploying the program

Deploying the program

To run in the competition, you will need to deploy a program to your cRIO. This allows the program to survive across reboots of the controller, but doesn't allow the same debugging features (front panel, probes, highlight execution) as running from the front panel. To deploy your program:

  1. In the Project Explorer, click the + next to Build Specifications to expand it.
  2. Right-click on FRC Robot Boot-up Deployment and select Build, then click OK on the dialog. Wait for the build to complete.
  3. Right-click again on FRC Robot Boot-Up Deployment and select Run as Startup. If you receive a conflict dialog, click OK. This dialog simply indicates that there is currently a program on the cRIO which will be terminated/replaced.
  4. Either check the box to close the deployment window on successful completion or click the close button when the deployment completes
  5. You will receive a prompt to reboot your cRIO, click OK.

Inverting Motors

Inverting Motors

Depending on the wiring and construction of your robot, it is possible that you will need to invert the direction of one or motors in your code in order to have all motors spinning the correct direction. If pushing the joystick directly away from you results in anything other than the robot driving forward, one or more motors needs to be inverted. If you have 2 motors in the Robot Drive, invert the side of the robot that moves in the wrong direction.

If you have 4 motors in your Robot Drive and one side drives the wrong way, invert both motors on that side. If you have 4 motors and one side of the drive appears to not move at all when commanded the motors may be fighting each other, try inverting one of the two motors and observing if that side of the drive now moves when commanded.

Motors are inverted using a boolean constant wired in to the appropriate terminal on the Robot Drive Open in Begin.VI. In the existing template their may be constants already wired up and labeled for you, simply click on the constant to change from True to False or False to True. If you need to create the constants, hover over the terminals of the icon to find the appropriate terminals then right-click and select Create->Constant from the menu.

Make sure to Save then re-run or deploy the program after making changes.

Troubleshooting

Troubleshooting

The majority of errors that appear during the Run or Deploy process are related to network communication with the cRIO. Errors such as: "Connection failed. The network address might be invalid or the target is not responding", "Lost Connection to Real-Time Target", and "Unable to Deploy Target Settings" can typically be traced to a networking issue. To troubleshoot these issues:

  1. Ensure that your cRIO has been imaged and set to LabVIEW per the Imaging your cRIO section.
  2. Make sure that the IP in the Project Explorer is correct per the "Configure cRIO IP" step above. If it is not, right click on that line and select properties, correct the address in the bottom box, then click OK.
  3. Make sure that the IP on your computer is set correctly. Note that the Driver Station software should set the computer IP automatically. See the section on Imaging your cRIO for details on checking or setting your IP.
  4. Ensure that you can ping the cRIO by opening a Command Prompt window and typing "ping 10.XX.YY.2" (replacing the XX and YY with your team number) then press enter.
  5. Check if the Windows Firewall or other Firewall are blocking the connection. Reference the Imaging your cRIO section for assistance.

An "Access Denied" or "Target in Use" message indicates that the cRIO is being used by another instance of LabVIEW or the previous program did not terminate properly (for example, the network connection was broken on a program deployed with the Run arrow). Rebooting the cRIO will resolve this type of error.