Presentation is loading. Please wait.

Presentation is loading. Please wait.

Note: before starting launch LabVIEW and the Example Finder, and do a palette search to have everything loaded and ready to go. IMPORTANT: Students will.

Similar presentations


Presentation on theme: "Note: before starting launch LabVIEW and the Example Finder, and do a palette search to have everything loaded and ready to go. IMPORTANT: Students will."— Presentation transcript:

1 Note: before starting launch LabVIEW and the Example Finder, and do a palette search to have everything loaded and ready to go. IMPORTANT: Students will need one Logitech Attack3 Joystick to complete the Exercises in this tutorial.

2 FRC LabVIEW Basic Training

3 FRC Robot Simulator Demonstration
Demonstration: 10 minutes HW Requirements: Logitech Attack3 Joystick Demonstrate the Robot Simulator to students. The Robot Simulator is introduced for the first time in FRC 2013 which allows students to program a predefined robot without having an RT CompactRIO Target.  Programming is the same except only the specific I/O of the predefined robot is supported.  Robot code that works in simulation mode can be moved to the RT Target and run on a real robot. (Instructions found in LabVIEW Project Explorer 2013 Robot Project >> My Computer >> Robot Simulation Readme.html) Start the Driver Station - it is needed for real and simulated robots. 2. Open Robot Main (under the cRIO context) 3. Right-click in the lower left corner of Robot Main.vi and choose 2013 Robot Project.lvproj/My Computer 4. Wait a moment while some subVIs reload 5. Run Robot Main.vi and notice that the FRC Simulation Viewer opens 6. The Driver Station should show you are in Simulated Mode, and you will need to Enable Teleop mode in order to drive the simulated robot. 7. To run Robot Main.vi on the cRIO, right-click in the lower left corner of Robot Main.vi and choose 2013 Robot Project.lvproj/RT CompactRIO Target

4 Objective Efficiently navigate the LabVIEW environment
Develop, debug, and test LabVIEW 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

5 Agenda Half-Day Schedule 30 min Introduction to NI LabVIEW Environment
Half-Day Schedule 30 min Introduction to NI LabVIEW Environment Working with the NI LabVIEW Virtual Instrument (VI) 1.5 hrs Programming Fundamentals: Dataflow programming, common programming structures used in the FRC code template LabVIEW for FRC: Explore and program using the FRC Robot Project template with the Robot Simulator LabVIEW for FRC: Deploy to a real FRC Robot 5 min Additional Resources and Next Steps

6 Introduction to NI LabVIEW Environment
This section will go over the components which make up LabVIEW such as the Project Explorer, VIs, and the FRC start splash screen for FRC beginners.

7 What Is LabVIEW? A graphical programming environment used to develop sophisticated measurement, test, and control systems. LabVIEW: Interfaces with wide variety of hardware Scales across different targets and OSs Provides built-in analysis libraries LabVIEW is a graphical programming language quite different from traditional programming languages like C++ and Visual Basic. As we’ll learn, one of the greatest strengths of LabVIEW is how intuitive it is to program. We’ll see how the Virtual Instrument approach to programming, employed by LabVIEW, makes it possible to create sophisticated and powerful programs with elegant, graphical user interfaces. LabVIEW interfaces with wide variety of hardware devices.

8 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 In this course we will use the LabVIEW project for accessing and organizing project files. You view project files in the Project Explorer window. Project files can include LabVIEW and non-LabVIEW files.

9 LabVIEW Files Common LabVIEW file extensions: LabVIEW project —.lvproj
Virtual instrument (VI) — .vi Custom control — .ctl LabVIEW uses many different types of files. In this class you will learn about three different LabVIEW files – LabVIEW projects, VIs, and custom controls. Historically, LabVIEW programs are called virtual instruments, or VIs, because their appearance and operation imitate physical instruments, such as oscilloscopes and multimeters. Today LabVIEW VIs can be extremely powerful and sophisticated programs with elegant graphical user interfaces. Later in this course you learn how custom controls can improve maintainability of your LabVIEW application. LabVIEW projects can also include non-LabVIEW file types. For example, you can include documentation files. Note: If students need to work with legacy code, you might briefly cover .llb files.

10 Parts of a VI VIs have 3 main components: Icon/Connector pane
Block diagram Front panel

11 Parts of a VI – Front Panel
Front Panel – User interface for the VI You build the front panel with controls (inputs) and indicators (outputs). Discuss how a front panel is the user interface of the VI and contains controls and indicators. A section following this slide concentrates on the front panel in more depth.

12 Parts of a VI – Block Diagram
Block Diagram – Contains the graphical source code Front panel objects appear as terminals on the block diagram.

13 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 subVI. A subVI is a VI that appears on the block diagram of another VI. A subVI is similar to a subroutine or function in a text-based programming language.

14 How to Get Started? Getting Started Window Projects Tutorials
Templates Tutorials HW/SW online help references Utilities Support Show each tab of the Getting Started Window and explain. Projects – where they will create their robot project. Tutorials – everything from setting up hardware to developing their robot program. Utilities – image cRIO, setup Axis camera, etc. You can add your own utilities. Support – Example Finder and help links

15 How to Get Started? – Find Examples
Find FRC templates in the Supprt Tab Find FRC Examples… Example located in NI Example Finder >> FRC Robotics Explain verbally how to find FRC Examples in Support >> Find FRC Examples.. This shortcut will open NI Example Finder and take you to the FRC section.

16 Create FRC Robot Project
Demonstration: Start up LabVIEW In the FRC splash screen select New >> FRC cRIO Robot Project You can leave the IP address as is (10.xx.yy.2) and choose Arcade Robot with Arm – hardware or simulation Briefly explain My Computer, RT CompactRIO Target, and Team Code Folder (where teams will incorporate their code).

17 Return to Getting Started Screen
In the LabVIEW Project Explorer or a VI, select View >> Getting Started Window… You can always go back to the Getting Started window to begin a new cRIO Robot Project or find additional examples by navigating to View >> Getting Started Window…

18 Exercise 1 - Configure an FRC Robot Project template
Open up LabVIEW Create a new FRC Robotics Project Create and save a new blank VI Exercise 1 – 15 Minutes Students will now configure their own 2013 FRC cRIO Robot Project Start up LabVIEW. Navigate to Start >> All Programs >> National Instruments >> LabVIEW 2012 (32-bit) >> select LabVIEW 2012 (32-bit) In the FRC splash screen, under the New category, select FRC cRIO Robot Project Configure the FRC cRIO template (IP address is going to be 10.xx.yy.2 where xx.yy is their team number). For example, team 1234’s IP address will be or teams 0005 will be ) Choose the Arcade Robot with Arm – hardware or simulation for simulation. Create a Blank VI in the Project Explorer right-clicking on My Computer >> New >> VI Students will modify the Blank VI in Exercise 2

19 Working with the NI LabVIEW Virtual Instrument (VI)
This section will cover the environment of a VI: Front Panel & Block Diagram Status Bars Context Help Example Finder Searching palettes (controls/indicators and functions) Quick Drop

20 Front Panel Briefly mention the functionality of the items on the toolbar: Run, Run Continuously, Abort Execution, Pause, Text Settings, Align Objects, Distribute Objects, Resize Objects, Reorder, Search, Help Click the Run button to run the VI. LabVIEW compiles the VI, if necessary. You can run a VI if the Run button appears as a solid white arrow. Note that the Run button appears broken when the VI contains edit-time errors. Students will learn about fixing edit-time errors in the next lesson.

21 Controls and Indicators
Output devices Graphs, LEDs Display data the block diagram acquires or generates Controls Input devices Knobs, buttons, slides Supply data to the block diagram Engage the students in identifying controls and indicators on this front panel. In the next few slides, you discuss basic data types: numerics, strings and Booleans. Discuss only front panel information here, such as appearance and what type of data you put in the control or indicator. You discuss representation, mechanical action, and string display types in the next lesson.

22 Block Diagram Briefly mention the functionality of the items on the toolbar: Run, Run Continuously, Abort Execution, Pause, Highlight Execution, Retain Wire Values, Step Into, Step over, Step Out, Text Settings, Align Objects, Distribute Objects, Reorder, Clean Up Diagram Students learn about debugging tools in the next lesson. Use next slide to discuss different objects on block diagram. Click the Run button to run the VI. LabVIEW compiles the VI, if necessary. You can run a VI if the Run button appears as a solid white arrow. If the Run button appears broken, the VI contains edit-time errors. Students learn about fixing edit-time errors in the next lesson.

23 Block Diagram Block diagram items: Terminals Constants Nodes Wires
Functions SubVIs Structures Wires Free labels Objects on the block diagram include terminals and nodes. You build block diagrams by connecting the objects with wires. The color and symbol of each terminal indicate the data type of the corresponding control or indicator. Constants are terminals on the block diagram that supply fixed data values to the block diagram. Nodes are objects on the block diagram that have inputs and/or outputs and perform operations when a VI runs.

24 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 LabVIEW menu. Press <Ctrl-H>. Click the following button on the toolbar:

25 LabVIEW Help Contains detailed descriptions and instructions for most palettes, menus, tools, VIs, and functions. Can be accessed by: Selecting Help» LabVIEW 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.

26 Click the example buttons in LabVIEW Help topics.
Examples LabVIEW includes hundreds of example VIs. Use NI Example Finder to browse and search installed examples. Select Help»Find Examples in the menu. Use the NI Example Finder to search all installed examples and examples located in the NI Developer Zone on the web. Modify any example VI to fit an application, or copy and paste from an example into a VI that you create. Methods of accessing the NI Example Finder: Select Help»Find Examples for FRC examples. Click the Find Examples link in the Support tab of the Getting Started window Click the example buttons in LabVIEW Help topics.

27 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, LabVIEW Help, and ni.com. Search text box in toolbar

28 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. Indicate that the Controls palette is available only when the front panel window is the active window.

29 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.

30 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 Exercise 2 – 15 Minutes The students will get familiarized to searching for VIs, placing controls/indicators, wiring, and running the VI. Find the Greater? node by right-clicking on the Block Diagram bringing up the Functions Palette >> Programming >> Comparison >> select Greater? Add two controls by right-clicking on the Front Panel to bring up the Controls Palette >> Modern >> Numeric >> select Numeric Control for the first input. Repeat for the second input. On the Block Diagram, wire the control terminals to the Greater? node inputs. Add one indicator by right-clicking on the Front Panel to bring up the Controls Palette >> Modern >> Boolean >> select Round LED. On the Block Diagram, wire the output of the Greater? node to the Round LED terminal. Run the VI by clicking on the Run Arrow. Verify correct behavior of application Open an example through the NI Example Finder by clicking on Help >> Find Examples… >> FRC Robotics >> Joystick >> Arcade Drive Example.lvproj Explore the new project and the new template VI. Don’t go into details since a more in-depth exercise will come in the second half of the training. Transition: Now that we know how to navigate the LabVIEW environment, we will now being studying LabVIEW programming Fundementals in the next section.

31 NI LabVIEW Programming Fundamentals
This section will discuss the following topics: Dataflow Debugging Tools While and For Loops Case Structures Shift Registers Arrays Clusters

32 Dataflow LabVIEW 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. When a node executes, it produces output data and passes the data to the next node in the dataflow path. The movement of data through the nodes determines the execution order of the VIs and functions on the block diagram. LabVIEW does NOT use a control flow program execution model like Visual Basic, C++, JAVA, and most other text-based programming languages. In a control flow model, the sequential order of program elements determines the execution order of a program.

33 Dataflow – Quiz Which node executes first? Add Subtract Random Number
Divide Sine This quiz is intended to encourage students to think about dataflow and its implications. The answers are on the next slide.

34 Dataflow – Quiz Answers
No single correct answer. Which node executes first? Add – Possibly Subtract – Definitely not Random Number – Possibly Divide – Possibly Sine – Definitely not In LabVIEW, the flow of data rather than the sequential order of commands determines the execution order of block diagram elements. Therefore, you can create block diagrams that have simultaneous operations.

35 Correcting Broken VIs One of the most common debugging features used in LabVIEW is the compiler which is always on. While you are developing a program, the compiler continuously checks for errors and provides semantic and syntactic feedback on the application. When the Run button is not broken, the VI is compiled and can be executed. If an error exists, you cannot run the program. You see a broken Run button in the toolbar. The VI is not executable. You must resolve any errors noted in the Errors List window before you can run the VI. Instructors: This is a good opportunity to remind students that LabVIEW is a compiled language. Broken Run arrow  VI cannot be compiled  VI cannot be executed

36 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 subVI is broken.

37 Debugging Techniques What to look for if a VI produces unexpected data or behavior: Are there any unwired or hidden subVIs? Is the default data correct? Does the VI pass undefined data? Are numeric representations correct? Are node executed in the correct order? Stress that you use debugging techniques when a VI produces unexpected data or behavior, not when the VI has a broken Run button. The items on this slide are just some of the debugging techniques to use. Later, student learn other techniques.

38 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. When your VI is not executable, a broken arrow is displayed in the Run button in the palette. Finding Errors: To list errors, click on the broken arrow. To locate the bad object, click on the error message. Execution Highlighting: Animates the diagram and traces the flow of the data, allowing you to view intermediate values. Click on the light bulb on the toolbar. Probe: Used to view values in arrays and clusters. Click on wires with the Probe tool or right-click on the wire to set probes. Retain Wire Values: Used with probes to view the values from the last iteration of the program. Breakpoint: Set pauses at different locations on the diagram. Click on wires or objects with the Breakpoint tool to set breakpoints. 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.

39 Run until stop condition met
Loops While Loop For Loop Run until stop condition met Run N times Use While or For Loops to enable sections of your LabVIEW code to run repeatedly. A While Loop will continue to execute until a stop condition is specified. The stop condition can be a simple button press or a series of specific logical conditions. The For Loop will execute a predetermined number of times as specified by the number of iterations you wire to the N input. You may also connect an array wire to the edge of a For Loop and leave the N input unwired. The For Loop’s number of iterations will be determined by the array size that is wired at its edge. This is called auto-indexing. To find the While and For Loops, as well as other control structures, left-click on any empty space on the block diagram and navigate to Programming»Structures. Allow same piece of code to run multiple times Exit conditions different for each

40 Drawing a Loop 2. Enclose code to be repeated 1. Select the structure
3. Drop or drag additional nodes and then wire Place loops in your diagram by selecting them from the Functions palette: When selected, the mouse cursor becomes a special pointer that you use to enclose the section of code you want to include in the While Loop. Click the mouse button to define the top-left corner and then click the mouse button again at the bottom-right corner. The While Loop boundary appears around the selected code. Drag or drop additional nodes in the While Loop if needed.

41 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 Initial Value Value 3 Shift registers transfer data from one iteration to the next: Right-click on the left or right side of a For Loop or a While Loop and select Add Shift Register. The right terminal stores data at the end of an iteration. Data appears at the left terminal at the start of the next iteration. A shift register adapts to any data type wired into it. An input of 0 would result in an output of 5 on the first iteration, 10 on the second iteration, and 15 on the third iteration. Said another way, shift registers are used to retain values from one iteration to the next. They are valuable for many applications that have memory or feedback between states. See Help»Search the LabVIEW Help… for more information. Before Loop Begins First Iteration Second Iteration Last Iteration

42 How Do I Make Decisions in LabVIEW?
Case Structures Select (a) (b) Case Structure The case structure has one or more subdiagrams, or cases, one of which executes when the structure executes. The value wired to the selector terminal determines which case to execute and can be Boolean, string, integer, or enumerated. Right-click the structure border to add or delete cases. Use the Labeling tool to enter value(s) in the case selector label and configure the value(s) handled by each case. It is found at Functions»Programming»Structures»Case Structure. Select Returns the value wired to the t input or f input, depending on the value of s. If s is TRUE, this function returns the value wired to t. If s is FALSE, this function returns the value wired to f. The connector pane displays the default data types for this polymorphic function. It is found at Functions»Programming»Comparison»Select. Example A: Boolean input. Simple if-then case. If the Boolean input is TRUE, the true case executes; otherwise the FALSE case executes. Example B: Numeric input. The input value determines which box to execute. If out of range of the cases, LabVIEW chooses the default case. Example C: When the Boolean passes a TRUE value to the Select VI, the value 5 is passed to the indicator. When the Boolean passes a FALSE value to the Select VI, 0 is passed to the indicator. (c)

43 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 Clusters group like or unlike components together. They are equivalent to a record in Pascal or a struct in ANSI C. Cluster components may be of different data types. Examples Error information—Grouping a Boolean error flag, a numeric error code, and an error source string to specify the exact error. User information—Grouping a string indicating a user’s name and an ID number specifying the user’s security code. All elements of a cluster must be either controls or indicators. You cannot have a string control and a Boolean indicator. Think of clusters as grouping individual wires (data objects) together into a cable (cluster).

44 Cluster Functions In the Cluster & Variant subpalette of the Programming functions palette Can also be accessed by right-clicking the cluster terminal The terms bundle and cluster are closely related in LabVIEW. Example: You use a bundle function to create a cluster. You use an unbundle function to extract the parts of a cluster. Bundle—Forms a cluster containing the given objects in the specified order. Bundle by Name—Updates specific cluster object values (the object must have an owned label). Unbundle—Splits a cluster into each of its individual elements by data type. Unbundle by Name—Returns the cluster elements whose names you specify. (Terminal labels reflect data type)

45 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 auto-indexing Wire becomes thicker 1D Array Auto-Indexing Disabled Wire remains the same size For Loops and While Loops can index and accumulate arrays at their boundaries. This is known as auto-indexing. The indexing point on the boundary is called a tunnel The For Loop is auto-indexing-enabled by default The While Loop is auto-indexing-disabled by default Examples Enable auto-indexing to collect values within the loop and build the array. All values are placed in the array upon exiting the loop. Disable auto-indexing if you are interested only in the final value. 5 Only one value (last iteration) is passed out of the loop

46 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 Exercise 3 – 15 minutes Solution available in ~\FRC Basic Training Solutions\Exercise 3 – Noise Generator\Noise Generator.vi Continue to use the Blank VI created under My Computer from previous Exercises. You can delete the previous code from Exercise 2. Use a While-loop with a Stop Button to run continuously. Insert a Waveform Chart for plot. Implement a Case Structure controlled by a Vertical Toggle Switch. For the TRUE case, use a Random Number Generator to plot to the Waveform Chart. For the FALSE case, plot a constant 0.

47 Summary—Quiz 1. Which structure must run at least one time? While Loop
For Loop Answer is a.

48 Summary—Quiz Answer 1. Which structure must run at least one time?
While Loop For Loop

49 Summary—Quiz Control Constant Indicator Connector Pane
2. Which is only available on the block diagram? Control Constant Indicator Connector Pane Answer is b.

50 Summary—Quiz Answer Control Constant Indicator Connector Pane
2. Which is only available on the block diagram? Control Constant Indicator Connector Pane Answer is b. Transition: Now that we have reviewed common LabVIEW programming structures, we will bring these together and develop on the FRC cRIO Robot Template.

51 LabVIEW for FRC: Working with the FRC cRIO Robot Project template and Robot Simulator

52 Understanding Robot Main.vi
As you will see in the next exercise, when you configure a new project in LabVIEW FRC, a default code template will be available. By using this core template, you should be able to drive the robot in Arcade mode without making any code changes. In the coming slides, we will investigate the block diagram (code) of the Robot Main.vi to understand the key components and their functions.

53 Understand Joystick and Motor Code
Begin.vi This subVI is called once at the start of the Robot Main.vi. Its purpose is to initialize and define all of the motors, sensors, I/O, and other items connected to your robot. The default FRC robot code initializes the camera settings, two motors, and joystick. Turn on the Context Help by pressing <Ctrl-H>. Then hover over each function on the block diagram to see its name and description. Teleop.vi To see the block diagram of the Teleop SubVI, select Teleop Enable in the case structure and then double-click it in the Robot Main. The front panel of the Teleop SubVI will open. Switch to its block diagram. This is the code that reads the joystick and makes the robot move in Arcade Drive. Finish.vi To see the block diagram of Finish SubVI, select Finish in the case structure and then double-click it in Robot Main. The default FRC robot code closes the reference of the camera settings, two motors, and joystick. Whenever a device is added to Begin.vi, you should also close that device in Finish.vi. Begin.vi Teleop.vi Finish.vi

54 FIRST WPI Palette WPI Palette contains many FIRST specific functions which let the user interact with things like sensors, motors, and cameras.

55 The Robotics Simulator
The simulator lets you test your code in simulation before deploying to your actual robot Explain the Options available on the simulator. Simulate – Play/Pause the simulator without stopping code execution Time Factor – For slower computers, increasing the time factor can help in speeding up the responsiveness of the robot drive. View – Driver (view the stage as in competition), Side (view the stage as a spectator) Follow – Sets camera focus on robot (ZOOM) Color – Changes the background color of the simulator Driver Station IP – Use a static IP address for the simulated robot. For most applications you can leave it as Auto

56 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. 1. Start the Driver Station - it is needed for real and simulated robots. Open Robot Main (under the cRIO context) 2. Right-click in the lower left corner of Robot Main.vi and choose 2013 Robot Project.lvproj/My Computer 3. Wait a moment while some subVIs reload 4. Run Robot Main.vi and notice that the FRC Simulation Viewer opens The Driver Station should show you are in Simulated Mode, and you will need to Enable Teleop mode in order to drive the simulated robot. 5. To run Robot Main.vi on the cRIO, right-click in the lower left corner of Robot Main.vi and choose 2013 Robot Project.lvproj/RT CompactRIO Target To switch back to the cRIO, simply right-click in the lower left corner of Robot Main.vi again and choose 2013 Robot Project.lvproj/RT CompactRIO Target

57 Exercise 4: Deploy FRC cRIO Robot Project
Deploy the default robot project to the simulator The Driver Station must be running Exercise 4 – 15 Minutes 1. Start the Driver Station - it is needed for real and simulated robots. Open Robot Main (under the cRIO context) 2. Right-click in the lower left corner of Robot Main.vi and choose 2013 Robot Project.lvproj/My Computer 3. Wait a moment while some subVIs reload 4. Run Robot Main.vi and notice that the FRC Simulation Viewer opens The Driver Station should show you are in Simulated Mode, and you will need to Enable Teleop mode in order to drive the simulated robot.

58 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 Exercise 5 – 20 minutes Solution available in ~\FRC Basic Training Solutions\Exercise 5 – Add Joystick Controls Read Joystick trigger button from WPI_JoystickGet.vi using an Unbundle By Name. Implement a Case Structure to send X and Y axis value of 0 when trigger button is pressed. When trigger button is not pressed, let regular Joystick X and Y axis values through.

59 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 throttle-lever position Close out servo reference Exercise 6 – 20 minutes Solution ~/FRC Basic Training Solutions\Excercise 6 - Actuators - Camera Servo Create Servo Reference in Begin.vi. Make sure to use Digital Module 1 and PWM Channel 5. WPI_ServoOpen.vi WPI_ServoRefNum Registry Set.vi In Teleop.vi, get the servo reference from Begin.vi and set servo angle. WPI_ServoRefNum Registry Get.vi WPI_ServoSetAngle.vi Read the axis 3 (throttle) from the controller and calculate the servo angle using the formula: [(axis 3 throttle) + 1]*85 = servo angle In Finish.vi, close out the camera servo reference WPI_ServoRefNum Registry Get.vi WPI_ServoClose.vi

60 Exercise 7: Sensors - Right Motor Encoder
Read encoder data from the Right Motor Distance Rate Exercise 7 – 20 Minutes Solution ~\FRC Basic Training Solutions\Exercise 7 – Sensors – Right Motor Encoder In Begin.vi, set up the Right Motor Encoder by creating two WPI_DigitalInputOpen.vi and converting them to Digital Sources by using the WPI_CounterToDigitalSource.vi. Finally, use the WPI_EncoderOpen.vi to initialize the encoder. Make sure to start decoding by using the WPI_EncoderStart.vi 3. In TeleOp.vi, implement the WPI_EncoderGet.vi to view Distance, Rate, and Direction values from the encoder. 4. In Finish.vi, stop decoding by using WPI_EncoderStop.vi and close out the encoder reference.

61 LabVIEW for FRC: Deploy to a real FRC Robot
In this section, the students will deploy to a real FRC robot and run the FRC cRIO Robot Project template in TeleOp mode

62 Run the FRC Robot Code For Development For Competition
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 When developing robot code, it is easiest to test it by pressing the run button. For competition, it is required to run the code as an executable on the cRIO. The Build step creates the executable. The Run as Startup step sets up the executable on the cRIO such that when the cRIO is rebooted the executable will run.

63 Exercise 8: Deploying to real FRC Robot
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 Exercise 8 – 20 minutes Pre-requirements: The real robot’s cRIO must be flashed with the newest 2012 FRC image using the FRC 2013 cRIO Imaging Tool Start up FRC Driver Station and plug in Joystick to development computer. In the Setup tab, enter Team Number. Verify that Joystick and Communications LED indicators are green. If not, troubleshoot network. Open up a new FRC cRIO Robot Project from the splash screen Configure the cRIO Robot Project with the corresponding IP address depending on the team. Choose Arcade Drive Robot – hardware or simulation Right click on the RT CompactRIO Target in Project Explorer >> choose Connect Open Robot Main.vi and run it. This action will start deploying code to the cRIO Once the code is running, verify in Driver Station that Robot Code LED indicator is green. Select Teleoperated and Enable. Move the Joystick to control the robot.

64 Additional Resources and Next Steps

65 2012 - 2013 National Instruments FIRST Robotics Grant Application
National Instruments will provide grants to assist teams participating in the FIRST LEGO League, FIRST Tech Challenge or FIRST Robotics Competition. Any financial assistance provided by National Instruments should be applied to registration fees, travel expenses, and/or general robot expenses. Applications should be submitted by January 6, Selected teams will be notified by Feb. 20, 2013. Applicants are eligible to apply for grants in the following amounts: FLL - up to $500
 FTC - up to $1,500
 FRC - up to $4,000 For more details and application, visit: NI FIRST Grant Application FIRST in Texas announced that Dr. James Truchard, co-founder and president of National Instruments and a long-time supporter of FIRST, has given a personal donation in support of FIRST Robotics Competition (FRC) team training and growth. The donation is coupled with engineering mentorship and technical training from 40 National Instruments engineers, where activities include financial support for FRC teams and onsite training workshops at 35 locations across the United States coinciding with this week’s FRC regional kick off events.

66 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 The ni.com/first community is THE place to go for LabVIEW for FRC and cRIO-FRC support, specifications, training, and so on.

67 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 National Instruments FIRST Website ni.com/first By Robert H. Bishop Published by Prentice Hall

68 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


Download ppt "Note: before starting launch LabVIEW and the Example Finder, and do a palette search to have everything loaded and ready to go. IMPORTANT: Students will."

Similar presentations


Ads by Google