1 FRC Lab VIEW Basic Training 2 FRC
1
FRC Lab. VIEW Basic Training 2
FRC Robot Simulator Demonstration 3
Objective • Efficiently navigate the Lab. VIEW environment • Develop, debug, and test Lab. VIEW VIs • Select, configure, and deploy the FRC Robot Project template to the Robot Simulator • Add functionality to the FRC Robot Project template in Simulation • Deploy FRC Robot Project to real FRC Robot 4
Agenda Half-Day Schedule 30 min Introduction to NI Lab. VIEW Environment 30 min Working with the NI Lab. VIEW Virtual Instrument (VI) 1. 5 hrs Programming Fundamentals: Dataflow programming, common programming structures used in the FRC code template Lab. VIEW for FRC: Explore and program using the FRC Robot Project template with the Robot Simulator 30 min Lab. VIEW for FRC: Deploy to a real FRC Robot 1. 5 hrs 5 min Additional Resources and Next Steps 5
Introduction to NI Lab. VIEW Environment 6
What Is Lab. VIEW? A graphical programming environment used to develop sophisticated measurement, test, and control systems. Lab. VIEW: • Interfaces with wide variety of hardware • Scales across different targets and OSs • Provides built-in analysis libraries — 7
Project Explorer Find, access, and organize project files § Prevent, detect, and resolve incorrect links § Deploy or download files to targets § Manage code for build options § • Executables, installers, and zip files § Integrate with source code control providers 8
Lab. VIEW Files • Common Lab. VIEW file extensions: Lab. VIEW project —. lvproj Virtual instrument (VI) —. vi Custom control —. ctl 9
Parts of a VI VIs have 3 main components: Icon/Connector pane Block diagram Front panel 10
Parts of a VI – Front Panel – User interface for the VI You build the front panel with controls (inputs) and indicators (outputs). 11
Parts of a VI – Block Diagram – Contains the graphical source code Front panel objects appear as terminals on the block diagram. 12
Parts of a VI – Icon/Connector Pane Icon – Graphical representation of a VI Connector Pane – Map of the inputs and outputs of a VI Icons and connector panes are necessary to use a VI as a sub. VI. • A sub. VI is a VI that appears on the block diagram of another VI. • A sub. VI is similar to a subroutine or function in a text -based programming language. 13
How to Get Started? • Getting Started Window § Projects • Templates § Tutorials • HW/SW online help references Utilities § Support § 14
How to Get Started? – Find Examples • Find FRC templates in the Supprt Tab • Find FRC Examples… • Example located in NI Example Finder >> FRC Robotics 15
Create FRC Robot Project 16
Return to Getting Started Screen • In the Lab. VIEW Project Explorer or a VI, select View >> Getting Started Window… 17
Exercise 1 - Configure an FRC Robot Project template • Open up Lab. VIEW • Create a new FRC Robotics Project • Create and save a new blank VI 18
Working with the NI Lab. VIEW Virtual Instrument (VI) 19
Front Panel 20
Controls and Indicators Controls • Input devices • Knobs, buttons, slides • Supply data to the block diagram Indicators • Output devices • Graphs, LEDs • Display data the block diagram acquires or generates 21
Block Diagram 22
Block Diagram • Block diagram items: Terminals § Constants § Nodes § • Functions • Sub. VIs • Structures Wires § Free labels § 23
Context Help Displays basic information about wires and nodes when you move the cursor over an object. § Can be shown or hidden in the following ways. § • Select Help» Show Context Help from the Lab. VIEW menu. • Press <Ctrl-H>. • Click the following button on the toolbar: 24
Lab. VIEW Help Contains detailed descriptions and instructions for most palettes, menus, tools, VIs, and functions. • Can be accessed by: § − Selecting Help» Lab. VIEW Help from the menu. − Clicking the Detailed help link in the Context Help window. − Right-clicking an object and selecting Help from the shortcut menu. 25
Examples Lab. VIEW includes hundreds of example VIs. § Use NI Example Finder to browse and search installed examples. § • Select Help» Find Examples in the menu. Click the example buttons in Lab. VIEW Help topics. 26
Searching for Controls, VIs, and Functions Ways to find controls, VIs, and functions: § Search or navigate the palettes. • Controls palette • Functions palette § Search by name of object. • Quick Drop dialog box § Search palettes, Lab. VIEW Help, and ni. com. • Search text box in toolbar 27
Controls Palette Contains the controls and indicators you use to create the front panel. § Navigate the subpalettes or use the Search button to search the Controls palette. § 28
Functions Palette Contains the VIs, functions, and constants you use to create the block diagram. § Navigate the subpalettes or use the Search button to search the Functions palette. § 29
Exercise 2 – Programming Your First VI • In your blank VI from Exercise 1 find and drop a Greater? node • Add controls and indicators to the front panel which will serve as inputs/outputs to the node. • From the Getting Started Window browse to and open an FRC Robotics Example 30
NI Lab. VIEW Programming Fundamentals 31
Dataflow Lab. VIEW follows a dataflow model for running VIs. § A node executes only when data are available at all of its required input terminals. § A node supplies data to the output terminals only when the node finishes execution. 32
Dataflow – Quiz Which node executes first? a) Add b) Subtract c) Random Number d) Divide e) Sine 33
Dataflow – Quiz Answers No single correct answer. Which node executes first? a) Add – Possibly b) Subtract – Definitely not c) Random Number – Possibly d) Divide – Possibly e) Sine – Definitely not 34
Correcting Broken VIs Broken Run arrow VI cannot be compiled VI cannot be executed 35
Common Causes of Broken VIs § Broken wires exist on the block diagram. • You wired a Boolean control to a String indicator. • You wired a numeric control to a numeric control. A required block diagram terminal is unwired. § A sub. VI is broken. § 36
Debugging Techniques What to look for if a VI produces unexpected data or behavior: § § § Are there any unwired or hidden sub. VIs? Is the default data correct? Does the VI pass undefined data? Are numeric representations correct? Are node executed in the correct order? 37
Debugging Techniques § Finding Errors Click on broken Run button. Window showing error appears. § § Execution Highlighting Probes 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. 38
Loops While Loop Run until stop condition met For Loop Run N times • Allow same piece of code to run multiple times • Exit conditions different for each 39
Drawing a Loop 1. Select the structure 2. Enclose code to be repeated 3. Drop or drag additional nodes and then wire 40
Shift Register—Access Previous Loop • Available Data 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 Initial Value Before Loop Begins Value 3 First Iteration Second Iteration Last Iteration 41
How Do I Make Decisions in Lab. VIEW? 1. Case Structures 2. Select (a) (b) (c) 42
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 43
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) 44
Building Arrays With Loops (Auto. Indexing) Auto-Indexing Enabled • 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 autoindexing Wire becomes thicker 1 D Array 0 1 2 5 3 4 Auto-Indexing Disabled Wire remains the same size 5 45 Only one value (last iteration) is passed out of the loop
Exercise 3 – Noise Generator • Create a VI which plots a random number when a toggle switch is on. • When the switch is off, plot 0. • The VI must run continuously. • Use a Waveform Chart for the plot 46
Summary—Quiz 1. Which structure must run at least one time? While Loop b) For Loop a) 47
Summary—Quiz Answer 1. Which structure must run at least one time? While Loop b) For Loop a) 48
Summary—Quiz 2. Which is only available on the block diagram? Control b) Constant c) Indicator d) Connector Pane a) 49
Summary—Quiz Answer 2. Which is only available on the block diagram? Control b) Constant c) Indicator d) Connector Pane a) 50
Lab. VIEW for FRC: Working with the FRC c. RIO Robot Project template and Robot Simulator 51
Understanding Robot Main. vi 52
Understand Joystick and Motor Code Begin. vi Finish. vi Teleop. vi 53
FIRST WPI Palette • WPI Palette contains many FIRST specific functions which let the user interact with things like sensors, motors, and cameras. 54
The Robotics Simulator • The simulator lets you test your code in simulation before deploying to your actual robot 55
Deploy Code to Simulator • Start the Driver Station - it is needed for real and simulated robots. • Right-click in the lower left corner of Robot Main. vi and choose 2013 Robot Project. lvproj/My Computer • Run Robot Main. vi and notice that the FRC Simulation Viewer opens • Enable Teleop mode in order to drive the simulated robot or enable Autonomous for independent control. 56
Exercise 4: Deploy FRC c. RIO Robot Project • Deploy the default robot project to the simulator § The Driver Station must be running 57
Exercise 5: Add Joystick Controls Modify code in Teleop. vi • Add joystick button to momentarily stop motors • Implement decision making with case structure • Extract value from cluster read from joystick • 58
Exercise 6: Actuators - Camera Servo • • • Move the Camera angle of the robot using a servo. Modify code in Begin. vi, Teleop. vi, and Finish. vi Initialize Camera Servo Reference Calculate Servo Angle based on throttlelever position Close out servo reference 59
Exercise 7: Sensors - Right Motor Encoder Read encoder data from the Right Motor • Distance • Rate • 60
Lab. VIEW for FRC: Deploy to a real FRC Robot 61
Run the FRC Robot Code • For Development § Open Robot Main. vi and press the Run button • For Competition In the project, right-click the build spec and choose Build § Right-click again and choose Run as Startup § 62
Exercise 8: Deploying to real FRC Robot Start a new FRC Lab. VIEW robot project • Get familiar with the FRC Compact. RIO robot program structure • Deploy code to a Compact. RIO target • Get familiar with the FRC Driver Station • Run Arcade Mode and Drive • 63
Additional Resources and Next Steps 64
2012 - 2013 National Instruments FIRST Robotics Grant Application National Instruments will provide Applicants are eligible to apply for grants to assist teams participating grants in the following amounts: in the 2012 -2013 FIRST LEGO • FLL - up to $500 League, FIRST Tech Challenge or • FTC - up to $1, 500 FIRST Robotics Competition. Any • FRC - up to $4, 000 financial assistance provided by National Instruments should be applied to registration fees, travel For more details and application, expenses, and/or general robot visit: expenses. Applications should be submitted by January 6, 2013. NI FIRST Grant Application Selected teams will be notified http: //t. co/u. Xd. IDf 58 by Feb. 20, 2013. 65
Ensuring Success Join the NI FIRST Community • online ni. com/frc • Ask support questions — monitored by applications engineers • Access training materials and tech documentation • Interact with other teams and mentors 66
Additional Resources • NI Academic Web and Student Corner – ni. com/academic • Connexions: Full Lab. VIEW Training Course cnx. rice. edu – Or search for “Lab. VIEW basics” – • Lab. VIEW Certification Lab. VIEW Fundamentals Exam (free on ni. com/academic) – Certified Lab. VIEW Associate Developer Exam (industry-recognized certification) – • Get your own copy of the Lab. VIEW Student Edition – ni. com/academic • National Instruments FIRST Website – ni. com/first By Robert H. Bishop Published by Prentice Ha 67
Your Next Step… Take the Free Lab. VIEW 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 68
- Slides: 68