FRC LabVIEW Mentor Training Hands-On Seminar

107

description

FRC LabVIEW Mentor Training Hands-On Seminar. National Instruments. Objective. To help recruit, train, and prepare mentors for the software development aspect of the FRC Mentors work with FRC pre-built mini robots and laptops to learn about Software development fundamentals - PowerPoint PPT Presentation

Transcript of FRC LabVIEW Mentor Training Hands-On Seminar

Page 1: FRC LabVIEW Mentor Training Hands-On Seminar
Page 2: FRC LabVIEW Mentor Training Hands-On Seminar

FRC LabVIEW Mentor TrainingHands-On Seminar

National Instruments

Page 3: FRC LabVIEW Mentor Training Hands-On Seminar

Objective

• To help recruit, train, and prepare mentors for the software development aspect of the FRC

• Mentors work with FRC pre-built mini robots and laptops to learn about– Software development fundamentals– LabVIEW basics– LabVIEW FRC program template and components

• Have fun!

Page 4: FRC LabVIEW Mentor Training Hands-On Seminar

 

Half-Day Schedule 

 30 min Overview of FIRST, FRC, and the FRC Control System

 

 

45 minSoftware Development Fundamentals: Coaching students to implement flowcharts or state transition diagrams to meet control application challenges

 

 

1.5 hrsIntroduction to NI LabVIEW: Overview of the LabVIEW environment, dataflow programming, and common programming structures used in the FRC code template

 

 1.5 hrs LabVIEW VIs for FRC: Explore and program the robots using the 

FRC functions  

 5 min Additional Resources and Next Steps

 

       

Agenda

Page 5: FRC LabVIEW Mentor Training Hands-On Seminar

Overview FIRST, FRC, and FRC Control System

Page 6: FRC LabVIEW Mentor Training Hands-On Seminar

I. Vision & Mission Vision“To transform our culture by creating a world where science and technology are celebrated and where young people dream of becoming science and technology heroes.” Dean Kamen, Founder

MissionTo inspire young people to be science and technology leaders by engaging them in exciting mentor-based programs that build science, engineering, and technology skills; that inspire innovation; and that foster well-rounded life capabilities including self-confidence, communication, and leadership.

Page 7: FRC LabVIEW Mentor Training Hands-On Seminar

II. Organization & Programs

K 1 2 3 4 5 6 7 8 9 10 11 12

Grade Level

FIRST LEGO League FIRST Tech Challenge

FIRST Robotics Competition

Junior FIRST LEGO® League

FIRST Programs

Page 8: FRC LabVIEW Mentor Training Hands-On Seminar

• BUT look at what is involved:– Math (algebra, geometry, trig, calculus)– Science (physics, chemistry, experimentation)– Language arts (writing, public speaking)– Business (marketing, PR, fundraising)– Finance (accounting)– Computer science (programming,

3D animation)– Fabrication (woodworking, metalworking)– Mentorship (working side-by-side with

professionals)– Teamwork

Mission is to INSPIRE, not EDUCATE

Page 9: FRC LabVIEW Mentor Training Hands-On Seminar

II. Organization & ProgramsFIRST Robotics Competition (FRC)

• How it works:– Combines the excitement of sport with

science and technology – Creates a unique varsity sport for the

mind– Grades 9–12 students (ages 14–18)

discover the value of education and careers in science, technology, and engineering

– New game each year– Common kit of parts– 6-week build period

Page 10: FRC LabVIEW Mentor Training Hands-On Seminar

II. Organization & ProgramsFIRST Robotics Competition Team Growth

• FRC 2010 Season– 1,809 teams

– 45,000+ high-school-age students

– Average 25 students per team

– 44 regional/state championships

– 7 district competitions– 340 teams advance to FIRST

championship28

151199

271372

515

642

787

927991

1,133

1,307

1,501

1,683

1809

0100

200300

400

500600

700800

9001000

11001200

1300

14001500

16001700

1800

1900

'92 '97 '98 '99 '00 '01 '02 '03 '04 '05 '06 '07 '08 '09 10

Page 11: FRC LabVIEW Mentor Training Hands-On Seminar

“I love working with these kids! I’m amazed and inspired by what they can accomplish, and their enthusiasm and energy is contagious.”Kristen Kelso, FLL Coach and Judge, Former FIRST Robotics Competition Participant

VI. Get Involved

Mentors• Become a mentor

– Empower children with a sense of accomplishment

– Provide valuable one-on-one interaction

– Be respected and admired by team members

– Be inspired and energized through your participation

Page 12: FRC LabVIEW Mentor Training Hands-On Seminar

FRC Control System: LabVIEW and CompactRIO

• FIRST Robotics Competition: FIRST standardizes on NI CompactRIO hardware powered by NI LabVIEW software

• FIRST Technical Challenge: Adoption of the LEGO® MINDSTORMS® NXT platform, programmable with NI LabVIEW

Adoption of a Progressive Programming Platform

Page 13: FRC LabVIEW Mentor Training Hands-On Seminar

• Students begin to program at age 6 with intuitive, graphical software• Progressive programming platform—Technology that meets the needs

of students of all ages• Strong industry usage—Strong adoption of LabVIEW and CompactRIO

in industry means students develop skills they can use in college and their careers

Page 14: FRC LabVIEW Mentor Training Hands-On Seminar

Power Distribution CompactRIO Controller

WirelessAccess Pt

Digital Sidecar

Page 15: FRC LabVIEW Mentor Training Hands-On Seminar

Role of the Controller

• Autonomous– Motor/actuator control– Motion control– Path control– Object avoidance

• Teleoperated– Driver station input processing– Telemetry back to console– “Action” control– Motion smoothing

Page 16: FRC LabVIEW Mentor Training Hands-On Seminar

Superior PerformanceEnhanced Processing• 400 MHz PowerPC industrial

real-time processor• 128 MB DRAM memory, 256 MB flash

storage• Embedded for reliable, autonomous

operation

802.11 Wireless Ethernet• 0/100 Mbit/s Ethernet port• Programmatic communication over

wireless network

Rugged• 50 g shock rating• 20 to 55 °C

Page 17: FRC LabVIEW Mentor Training Hands-On Seminar

NI 9201—Analog Input (x2) NI 9403—Digital I/O (x2)

NI 9472—Digital I/O

• 8 analog inputs• ±10 V input rangeSensors (accelerometers, gyros, and so on)

• 32-channel digital I/O• 5 V/TTL, sinking/sourcing

digital I/OPWM motor control, encoders

• 8-channel digital I/O• 6 to 36 V output rangePneumatics (relays and solenoids)

Flexible Inputs and Outputs

Page 18: FRC LabVIEW Mentor Training Hands-On Seminar

Easy to Program• Programmable in C, Java, and LabVIEW• Wireless debugging• Laptop dashboard

Page 19: FRC LabVIEW Mentor Training Hands-On Seminar

Stage 1 Stage 2 Stage 3develop download deploy

Program Your Robot

Page 20: FRC LabVIEW Mentor Training Hands-On Seminar

Software Development Fundamentals

Page 21: FRC LabVIEW Mentor Training Hands-On Seminar

Software Development Method

1. Define the problem (scenario)2. Design an algorithm and/or flowchart3. Implement the design4. Test and verify the implementation5. Maintain and update the implementation

Page 22: FRC LabVIEW Mentor Training Hands-On Seminar

Define the Problem

Furnace Example

You need to design a furnace system to keep a building within a comfortable temperature range. For simplicity, the building has only a furnace and no air conditioning.

Page 23: FRC LabVIEW Mentor Training Hands-On Seminar

Design a Flowchart and/or Algorithm

Page 24: FRC LabVIEW Mentor Training Hands-On Seminar

Steps to Design a Flowchart

1. List all your inputs, outputs, and additional requirements

2. Define the possible states (nodes) and actions in each state

3. Define your state (node) transitions4. Draw a flowchart linking the states (nodes)

Page 25: FRC LabVIEW Mentor Training Hands-On Seminar

Design a Flowchart—Furnace

This application has the following requirements:• The interior temperature must remain within a set range:

70 –75 °F• The heater turns on when the temperature is less than

70 °F and heat the room up until the temperature is 75 °F• There is no AC to control

Page 26: FRC LabVIEW Mentor Training Hands-On Seminar

Example—Furnace

Transition/Decision

State and Action Related to State

Page 27: FRC LabVIEW Mentor Training Hands-On Seminar

Example (Advanced)—Coke Machine

This application has the following requirements:• All Coke products are sold for 50 cents• The machine accepts only nickels, dimes, and quarters• Exact change is not needed• Change can be returned at any time during the process of

entering coins• Only Coke is sold in machine (no buttons to select other

beverage)

Page 28: FRC LabVIEW Mentor Training Hands-On Seminar
Page 29: FRC LabVIEW Mentor Training Hands-On Seminar

Example (Advanced)—Coke MachineAction Related to State

Transition

State

Page 30: FRC LabVIEW Mentor Training Hands-On Seminar

Example—Robot: Remote Control

This application has the following requirements: • Robot must navigate a field with obstacles and other robots and

press a button that can be reached only by an extendable arm• There is a line on the course that marks a clear path from the

robot’s starting position to the button’s location• Manual/Teleoperated mode only

Page 31: FRC LabVIEW Mentor Training Hands-On Seminar

Example—Robot: Remote Control

Page 32: FRC LabVIEW Mentor Training Hands-On Seminar

Example—Robot: Autonomous

This application has the following requirements: • Robot must navigate a field with obstacles and other robots and

press a button that can be reached only by an extendable arm• There is a line on the course that marks a clear path from the

robot’s starting position to the button’s location• Autonomous mode only

Page 33: FRC LabVIEW Mentor Training Hands-On Seminar
Page 34: FRC LabVIEW Mentor Training Hands-On Seminar

Software Development Method

1. Define the problem (scenario)2. Design an algorithm and/or flowchart3. Implement the design4. Test and verify the implementation5. Maintain and update the implementation

Addressed in Section 4: FRC Steps to Robot Success

Page 35: FRC LabVIEW Mentor Training Hands-On Seminar

Introduction to NI LabVIEW

Page 36: FRC LabVIEW Mentor Training Hands-On Seminar

What is LabVIEW?

• Speak G– Graphical programming

language• Go with the flow

– Dataflow programming• Easy writing

– Easy to learn– Powerful debugging tools

Page 37: FRC LabVIEW Mentor Training Hands-On Seminar

Each VI has 2 windows

Front panel• User interface (UI)

– Controls = inputs– Indicators = outputs

Block diagram• Graphical code

– Data travels on wires from controls through functions to indicators

– Blocks execute by data flow

LabVIEW Programs Are Called Virtual Instruments (VIs)

Page 38: FRC LabVIEW Mentor Training Hands-On Seminar

Controls Palette (Controls and Indicators)

Indicator:Numeric Slide

Control:Numeric

Customize Palette View

Page 39: FRC LabVIEW Mentor Training Hands-On Seminar

Functions (and Structures) Palette

(Place items on the Block Diagram Window)

Structure:While Loop

Page 40: FRC LabVIEW Mentor Training Hands-On Seminar

Types of Functions (from the Functions Palette)Express VIs: Interactive VIs with configurable dialog page (blue border)

Standard VIs: Modularized VIs customized by wiring (customizable)

Functions: Fundamental operating elements of LabVIEW; no front panel or block diagram (yellow)

Page 41: FRC LabVIEW Mentor Training Hands-On Seminar

• Recommended: Automatic Selection Tool• Tools to operate and modify both front panel and block

diagram objects

Operating Tool

Positioning/Resizing Tool

Labeling Tool

Wiring Tool

Automatic Selection Tool

Automatically chooses among the following tools:

Tools Palette

Page 42: FRC LabVIEW Mentor Training Hands-On Seminar

Run Button

Continuous Run Button

Abort Execution

Execution Highlighting Button

Additional Buttons on the Diagram Toolbar

Retain Wire Values Button

Step Function Buttons

Status Toolbar

Page 43: FRC LabVIEW Mentor Training Hands-On Seminar

Debugging Techniques• Finding Errors

• Execution Highlighting

• Probes

Click on broken Run button.Window showing error appears.

Click on Execution Highlighting button; data flow is animated using bubbles. Values are displayed on wires.

Right-click on wire to display probe; it shows data as it flows through wire segment.

You can also select the Probe tool from the Tools palette and click on the wire.

Page 44: FRC LabVIEW Mentor Training Hands-On Seminar

Context Help Window• Help»Show Context Help or press <Ctrl-H>• Hover cursor over object to update window

Additional Help–Right-click on the VI icon

and choose Help, or–Choose “Detailed Help.” on

the context help window

Page 45: FRC LabVIEW Mentor Training Hands-On Seminar

• Block diagram execution– Dependent on the flow of data– Block diagram does NOT execute

left to right• Node executes when data is

available to ALL input terminals• Nodes supply data to all output

terminals when done

Dataflow Programming

Page 46: FRC LabVIEW Mentor Training Hands-On Seminar

Dataflow Programming

Page 47: FRC LabVIEW Mentor Training Hands-On Seminar

Data Types Found in LabVIEW

Page 48: FRC LabVIEW Mentor Training Hands-On Seminar

LabVIEW Shortcuts and Tools• <Ctrl-R>: Run the VI• <Ctrl-E>: Swap between front panel and block diagram• <Ctrl-H>: Turn on context help• <Ctrl-B>: Remove broken wires• <Ctrl-Z>: Undo

• View»Navigation Window or Ctrl-Shift-N• Tools»CompactRIO Imaging Tool…• Tools»Setup Axis Camera• Tools»Options

Page 49: FRC LabVIEW Mentor Training Hands-On Seminar

LabVIEW Exercise 1: Create a Simple LabVIEW VI

You will learn– How to work in the LabVIEW

environment

Create an application that– Simulates data collection

– Turns on a front panel indicator when threshold is reached

Page 50: FRC LabVIEW Mentor Training Hands-On Seminar

Key LabVIEW Structures for FIRST• Project Explorer• Clusters• Loops• Case Structure• Shift Registers• Enums• State Machines

Page 51: FRC LabVIEW Mentor Training Hands-On Seminar

• Group and organize VIs• Manage hardware and I/O• Manage large LabVIEW

applications• Manage VIs for multiple targets

Determine which code is running on laptop versus which code is running on CompactRIO hardware

(LabVIEW»Project»New)

LabVIEW Project

Robot Main.vi runs on the CompactRIO target since the VI falls under RT CompactRIO Target. Code under “My Computer” runs on the laptop.

You also can verify the program target by looking at the bottom left of the VI’s front panel .

Page 52: FRC LabVIEW Mentor Training Hands-On Seminar

Introduction to Clusters• Data structure that groups data together• Data may be of different types• Elements must be either all controls or all indicators• Thought of as wires bundled into a cable

Easier to bundle wires together and pass around as a group rather than wire each individually

• Order is important

Page 53: FRC LabVIEW Mentor Training Hands-On Seminar

Cluster Functions• In the Cluster & Variant subpalette of the Programming functions palette• Can also be accessed by right-clicking the cluster terminal

(Terminal labels reflect data type)

Page 54: FRC LabVIEW Mentor Training Hands-On Seminar

LoopsWhile Loop For Loop

Run until stop condition met Run N times

• Allow same piece of code to run multiple times• Exit conditions different for each

Page 55: FRC LabVIEW Mentor Training Hands-On Seminar

1. Select the structure

2. Enclose code to be repeated

3. Drop or drag additional nodes and then wire

Drawing a Loop

Page 56: FRC LabVIEW Mentor Training Hands-On Seminar

1. Case Structures

2. Select(a) (b)

(c)

How Do I Make Decisions in LabVIEW?

Page 57: FRC LabVIEW Mentor Training Hands-On Seminar

Shift Register—Access Previous Loop Data• Available at left or right border of loop structures• Right-click the border and select Add Shift Register • Right terminal stores data on completion of iteration• Left terminal provides stored data at beginning of next iteration

Before LoopBegins

First Iteration

SecondIteration

LastIteration

Value 3InitialValue

Page 58: FRC LabVIEW Mentor Training Hands-On Seminar

Enum• An enum

represents a pair of values, a string, and a numeric, where the enum can be one of a defined list of values

Page 59: FRC LabVIEW Mentor Training Hands-On Seminar

Enum• Enum: enumerated

control, constant, or indicator

• Enums are useful because it is easier to manipulate numbers than strings on the block diagram

Page 60: FRC LabVIEW Mentor Training Hands-On Seminar

A state machine consists of a set of states and a transition function that maps to the next state

LabVIEW State Machine

While Loop

Case StructureShift Register

Page 61: FRC LabVIEW Mentor Training Hands-On Seminar

A state machine consists of a set of states and a transition function that maps to the next state

LabVIEW State Machine

While Loop

Case Structure “Heater On” state shown.

Shift Register

Page 62: FRC LabVIEW Mentor Training Hands-On Seminar

LabVIEW Exercise 2: Controlling Program Execution

You will learn– How to incorporate logic into your LabVIEW

application

Create an application that– Charts a sine or triangle wave depending on

the toggle switch position

Page 63: FRC LabVIEW Mentor Training Hands-On Seminar

Advanced

For reference but not covered in hands-on session.

Page 64: FRC LabVIEW Mentor Training Hands-On Seminar

Create SubVI• Enclose area to be converted into a subVI• Select Edit»Create SubVI from the Edit menu

Page 65: FRC LabVIEW Mentor Training Hands-On Seminar

Connector Pane and Icon Viewer

• Use this connector pane layout as a standard

• Top terminals are usually reserved for file paths and references, such as a file reference

• Bottom terminals are usually reserved for error clusters

Page 66: FRC LabVIEW Mentor Training Hands-On Seminar

Icon Viewer—Create an Icon• Create custom icons by right-clicking the icon in the upper-right

corner of the front panel or block diagram and selecting Edit Icon or by double-clicking the icon

• You also can drag a graphic from anywhere in your file system and drop it on the icon

• Refer to the Icon Art Glossary at ni.com for standard graphics to use in a VI icon

Page 67: FRC LabVIEW Mentor Training Hands-On Seminar

How Do I Time a Loop?1. Loop Time Delay

• Configure the Time Delay Express VI for a number of seconds to wait each iteration of the loop (works on For and While loops)

2. Timed Loops• Configure special-timed While Loop for desired dt

Timed LoopTime Delay

Page 68: FRC LabVIEW Mentor Training Hands-On Seminar

Charts—Add 1 Data Point at a Time With HistoryWaveform chart—Special numeric indicator that can display a history of values

• Chart updates with each point it receives

Controls»Express»Graph Indicators»Chart

Page 69: FRC LabVIEW Mentor Training Hands-On Seminar

Graphs—Display Many Data Points at OnceWaveform graph—Special numeric indicator that displays an array of data • Graph updates after all points have been collected• May be used in a loop if the VI collects buffers of data

Controls»Express»Graph Indicators»Graph

Page 70: FRC LabVIEW Mentor Training Hands-On Seminar

• Loops can accumulate arrays at their boundaries with auto-indexing

• For Loops auto-index by default• While Loops output only the

final value by default• Right-click tunnel and

enable/disable auto-indexing

Building Arrays With Loops (Auto-Indexing)

Wire becomes thicker

Wire remains the same size

Auto-Indexing Disabled

Auto-Indexing Enabled

Only one value (last iteration) is passed out of the loop

1D Array0 1 2 3 4 5

5

Page 71: FRC LabVIEW Mentor Training Hands-On Seminar

Creating an Array (Step 1 of 2)From the Controls»Modern»Array, Matrix, and Cluster subpalette, select the Array icon.

Drop it on the front panel.

Page 72: FRC LabVIEW Mentor Training Hands-On Seminar

Create an Array (Step 2 of 2)1. Place an array shell.2. Insert data type into the shell (for example, numeric control).

Page 73: FRC LabVIEW Mentor Training Hands-On Seminar

Using Arrays and Clusters With GraphsThe waveform data type contains 3 pieces of data:• t0 = Start time• dt = Time between samples• Y = Array of Y magnitudes

You can create a waveform cluster in two ways:

Build Waveform (absolute time) Cluster (relative time)

Page 74: FRC LabVIEW Mentor Training Hands-On Seminar

Programming an FRC Robot

Page 75: FRC LabVIEW Mentor Training Hands-On Seminar

Understanding Robot Main.vi

Page 76: FRC LabVIEW Mentor Training Hands-On Seminar

Robot Main Block Diagram

SubVIs

Case Structure

While Loop

Sequence Structure

Global VariablesControls (FromFront Panel)

Page 77: FRC LabVIEW Mentor Training Hands-On Seminar

Robot Main—Flowchart View

Page 78: FRC LabVIEW Mentor Training Hands-On Seminar

Begin.vi

Its purpose is to initialize and define all of the motors, sensors, I/O, and other items connected to your robot.

Every time you use a device, you must initialize/open it in the Begin VI and give it a name. (Also in Finish.VI later)

Page 79: FRC LabVIEW Mentor Training Hands-On Seminar

• The green Booleans control the orientation of the motors.

• The two blue enums correspond to the PWM output ports on the robot.

Motor Configuration (Within Begin.vi)

Page 80: FRC LabVIEW Mentor Training Hands-On Seminar

Motor Reference Registry Set (Within Begin.VI)• The pink string refers to the refnum

name given to the device. Here “Left and Right Motors” will be called later in the program to access these Jaguar motor controllers.

• The Drive Reference Registry Set VI sets a reference into a registry so that other VIs can call the reference.

Page 81: FRC LabVIEW Mentor Training Hands-On Seminar

TeleOp.vi

• To view Teleop.vi in Robot Main, select Teleop Enabled in the case structure.

• It is called each time a teleop driver station packet is received and robot is enabled.

• Teleop is the subVI that contains the code that you can use to drive the robot with the joystick. You can program Teleop code in this subVI.

Page 82: FRC LabVIEW Mentor Training Hands-On Seminar

Autonomous Independent.vi

• The Autonomous Independent.vi is automatically started when the autonomous mode begins and automatically ended when the autonomous mode ends.

• This is where the code executed during autonomous mode is contained.

Page 83: FRC LabVIEW Mentor Training Hands-On Seminar

Autonomous Independent.vi

• In the default code, there are three While Loops. These loops turn the robot right, turn the robot left, and stop the robot, respectively.

• The data is wired sequentially from one loop to another. It is important to note that the code runs in the same sequence as it is wired. The second While Loop does not run until the first loop is finished.

Page 84: FRC LabVIEW Mentor Training Hands-On Seminar

Finish.vi

Finish SubVI is called before exiting, so you can save data, clean up I/O, and so on.

If a new device (for example, a joystick) was added to Begin VI, you must close this device in Finish VI.

Page 85: FRC LabVIEW Mentor Training Hands-On Seminar

Close Motor Reference (Within Finish VI)

• To close a motor reference, use a Drive Reference Get VI and a Drive Reference Close VI.

• Follow a similar structure for other devices such as joysticks, cameras, and so on.

Page 86: FRC LabVIEW Mentor Training Hands-On Seminar

FRC Robot Exercise 1:Configure and Deploy ProjectTasks• Start a new FRC LabVIEW robot project• Get familiar with the FRC CompactRIO robot

program structure• Deploy code to a CompactRIO target• Get familiar with the FRC Driver Station• Run Arcade Mode and Drive

Page 87: FRC LabVIEW Mentor Training Hands-On Seminar

LabVIEW FRC Installation Shortcuts

When you install LabVIEW on your computer, you are going to find four different icons:• FRC LabVIEW Icon

– Opens the LabVIEW program• FRC cRIO Imaging Tool

– Opens the cRIO Imaging Tool, which sets the cRIO IP address and updates the firmware image

• FRC Driver Station Icon– Opens the Driver Station, which handles the communication between

the computer and the robot• Setup Axis Camera

– Opens the Setup Axis Camera tool, which is used for configuring the axis camera

Page 88: FRC LabVIEW Mentor Training Hands-On Seminar

Getting Started

• When you open the LabVIEW program, a Getting Started Window pops up.

• Getting started tutorials for FRC are provided on the right side of the Getting Started Window. The tutorials include plenty of useful information.

• To start a new FRC LabVIEW project, click FRC cRIO Robot Project on the left side of the window.

Page 89: FRC LabVIEW Mentor Training Hands-On Seminar

Create New FRC Robot Project

• Here, you can change– Project name– Project location– cRIO IP address

Page 90: FRC LabVIEW Mentor Training Hands-On Seminar

Project Explorer• The Project Explorer opens after

creating the new FRC robot project

• You can use the Project Explorer Window to create and edit LabVIEW projects

• All code included in the FRC robot project default template is listed under the Items tab

• To start modifying the robot code, expand RT CompactRIO Target and double-click Robot Main.vi

Page 91: FRC LabVIEW Mentor Training Hands-On Seminar

Robot Main.VI

Page 92: FRC LabVIEW Mentor Training Hands-On Seminar

Deploying Code to Robot• You can run the Arcade Drive with the

default FRC robot code provided• Always run the RobotMain.vi• To deploy the code to the CompactRIO

target, click Run in the top left corner.

Stage 1 Stage 2 Stage 3develop download deploy

Page 93: FRC LabVIEW Mentor Training Hands-On Seminar

FRC Driver Station• Before running the Arcade Drive using the default FRC robot code, you need to

open the FRC Driver Station.

• The FRC Driver Station handles the communication between the computer and the robot.

• When the lights of the Communications, Robot Code, and the Stop Button turn green, the robot is ready to run.

• Select Teleoperated and then click Enable to start the robot.

Page 94: FRC LabVIEW Mentor Training Hands-On Seminar

Adding Joystick Controls

• Done within Teleop SubVI

• The Drive Reference Get VI gets the reference and passes it to the Arcade Drive VI

• The Joystick Reference Get VI gets the reference and sends it to Joystick Get VI

• The Joystick Get VI gets the user input value of the joystick axes and sends out a cluster

• The cluster is unbundled using the Unbundle by Name function to get the values of the x and y axes; values are sent to the Arcade Drive VI

Page 95: FRC LabVIEW Mentor Training Hands-On Seminar

Adding Joystick Controls• The Joystick Get VI outputs the values of the buttons

as a Button cluster.

• To access data in a cluster, you need to insert an Unbundle by Name function.

• To do this, right-click on the block diagram and click the Cluster, Class & Variant palette. Then click Unbundle by Name and wire this up to the button output of the Joystick Get VI.

Page 96: FRC LabVIEW Mentor Training Hands-On Seminar

FRC Robot Exercise 2:Add Joystick ControlsTasks• Modify code in Teleop SubVI • Add joystick button to momentarily stop motors• Implement decision making with case structure• Extract value from cluster read from joystick

Page 97: FRC LabVIEW Mentor Training Hands-On Seminar

Adding Joystick Controls

• In the False Case (when Button 1 is not pressed), the motors should keep running.

• In the True Case (when Button 1 is pressed), the motors should stop. Therefore, the x- and y-axis values should be zero.

Page 98: FRC LabVIEW Mentor Training Hands-On Seminar

Adding a New Device

• Every time you add a device, you must initialize/open it in the Begin VI and give it a name.

• If a new device (for example, a motor or joystick) was added to Begin VI, you must also close this device in Finish VI.

• The device can then be communicated to in Teleop or Autonomous SubVIs. Note: In the last exercise, we didn’t need to initialize or finish the joystick device when adding a button since this was already done in the template provided.

Page 99: FRC LabVIEW Mentor Training Hands-On Seminar

FRC Robot Exercise 3:Add a Servo MotorTasks• Initialize the new servo motor by modifying Begin

SubVI• Modify the Teleop SubVI to use the joystick to

move the new servo motor• Modify the Finish SubVI to close the reference of

the new servo motor

Page 100: FRC LabVIEW Mentor Training Hands-On Seminar

Adding a Servo Motor

• The value of the y-axis ranges from –1 to 1, and the range of the servo angle is from 0 to 170 degrees.

• Hence the formula is (User Input + 1) * 85 = Servo Angle

Page 101: FRC LabVIEW Mentor Training Hands-On Seminar

FRC Robot Exercise 4:Add a Digital Input as Limit SwitchTasks• Initialize the new limit switch using digital input by

modifying Begin SubVI• Modify the Teleop SubVI to read the digital input to

monitor if the switch has been pressed• Modify the Finish SubVI to close the reference of

the digital line for the limit switchBONUS: Modify the code to use both the limit switch on the robot and the joystick button to stop the robot.

Page 102: FRC LabVIEW Mentor Training Hands-On Seminar

Adding a Digital Line for a Limit Switch

• Remember: Code is inverted on the limit switch. When it is pressed (or closed), the output value is False. When the limit switch is not pressed (open), the output value is True.

Page 103: FRC LabVIEW Mentor Training Hands-On Seminar

Adding a Digital Line for a Limit Switch

• BONUS: Use a Boolean OR to use either the joystick button or the limit switch.

Page 104: FRC LabVIEW Mentor Training Hands-On Seminar

Additional Resources and Next Steps

Page 105: FRC LabVIEW Mentor Training Hands-On Seminar

Ensuring Success

• ni.com/first• Ask support questions—

monitored by applications engineers

• Access training materials and tech documentation

• Interact with other teams and mentors

Join the NI FIRST Community online

Page 106: FRC LabVIEW Mentor Training Hands-On Seminar

Additional Resources• NI Academic Web and Student Corner

– ni.com/academic• Connexions: Full LabVIEW Training Course

– cnx.rice.edu– Or search for “LabVIEW basics”

• LabVIEW Certification– LabVIEW Fundamentals Exam (free on ni.com/academic)– Certified LabVIEW Associate Developer Exam (industry-recognized certification)

• Get your own copy of the LabVIEW Student Edition– ni.com/academic

• National Instruments FIRST Website– ni.com/first

By Robert H. Bishop

Published by Prentice Hall

Page 107: FRC LabVIEW Mentor Training Hands-On Seminar

Your Next Step…Take the Free LabVIEW Fundamentals Exam

at ni.com/academic

Visit NI’s FRC Website and Network with Other FIRST Participants

ni.com/first

Visit the FRC Website and Learn About Other Resources and Program Specifics

usfirst.org