Home
FRC Robot Exercise 1 - Deer Creek High School
Contents
1. FRC LabVIEW Mentor Training Hands On Seminar 146 ni com 3 Select the ServoOpen VI and place it on the block diagram DIO Module Slot 4 a ServoDeviceRef PWM Channel Angular Range error in no error error out You also need the Servo Reference Registry Set VI to register the servo May be called WPI_ServoRefNum Registry Set vi 4 To insert it right click on the block diagram click WPI Robotics Library then click Actuators palette and then click Servo palette Vision and Motion gt gt d Mathematics d Signal Processing gt Data Communication gt Connectivity gt Control Design amp Simulation gt SignalExpress Express Addons Favorites En PS AE User Libraries Select a VI Real Time FPGA Interface FIRST Vision PID WPI Robotics Library v fe v ta 1 WPI Robotics Library Actuators ROBOT ROBOT ROBOT p Em gt 7 7 ST v gt i E gt 7 Actuators i ERR ROBOT P ROBOT p ROBOT SANN as tq 980 b ROBOT 5 Select the Servo Reference Registry Set VI and place it on the block diagram ServoDeviceRef ServoDeviceRef refnum name error in no error error out 6 Create a PWM constant that corresponds to the channel where the servo is connected To do this right click on the PWM Channel input on the ServoOpen VI click Create and then click Constant Select the desired channel PWM3 from the pull down menu of the PWM co
2. The waveform chart is a special numeric indicator that displays one or more plots It is located on the Controls Modern Graph palette Waveform charts can display single or multiple plots The following front panel shows an example of a multiplot waveform chart You can change the minimum and maximum values of either the x axis or y axis by double clicking on the value with the labeling tool and typing the new value Similarly you can change the label of the axis You can also right click the plot legend and change the style shape and color of the trace that is displayed on the chart National Instruments Corporation 103 FRC LabVIEW Mentor Training Hands On Seminar Graphs Display Many Data Points at Once Waveform 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 A Search gt Modern c xpress L Graph Indicators gt NET amp ActiveX XY Graph Controls Express Graph Indicators Graph ni com first nl il il i ii NATIONAL INSTRUMENTS ni com Graphs are very powerful indicators in LabVIEW You can use these highly customizable tools to concisely display a great deal of information With the properties page of the graph you can display settings for plot types scale and cursor options and many other features of the graph To open the properties page right click the gr
3. Tutorial 4 Developing a Robot Project Tutorial S Editing Team Code wIs F Tutorial 6 Creating a Custom Dashboard nila Tutorial 7 Integrating Examples into Robot Code What s New For FRE 2011 Troubleshooting the Robot Tutorials Online Technical Support Check for Updates LabyIEW Help Discussion Forum A Find FRc Examples 2 Create New FRC cRIO Robot Project Here you can change o Project name o Project location o cRIOIPaddress Note This setting tell LabVIEW the IP address of the cRIO control but does not set the IP address To set the IP address use the cRIO Imaging Tool National Instruments Corporation 123 FRC LabVIEW Mentor Training Hands On Seminar 3 Replace xx yy in the cRIO IP address with your four digit team number o Team 1234 gt 10 12 34 02 o Team 123 gt 10 01 23 02 4 Apreview of the project file is shown below r nA ee if Ro nat Pi OPEC Select project name folder and IP address m Project Robot Project lvproj m MN My Computer I HS RT CompactRIQ Target 10sx vw 2011 Robot Project a TypeDefs Eh Gi Team Code Begin vi Autonomous Independent Teleop wi vision Processing vi Disabled vi Periodic Tasks vi Robot Global Data vi Build DashBoard Data vi ie Finish vi H CJ ision Support Code a Robot Framework with Game Code a Cd Support Code k mm Robot Main vi jj La Dependencies Project name Project folder teu ce Us
4. WPI Robotics Robot Drive Sensors Actuators I O Driver Station Camera So Communications Utilities This ost a contains most of what you will use CEE to program your robot s NATIONAL ni com first INSTRUMENTS ni com From the LabVIEW block diagram within the Functions palette are a series of sub palettes related to FIRST The two primary palettes used are FIRST Vision and WPI Robotics FRC LabVIEW Mentor Training Hands On Seminar 72 ni com Customized Example Finder NI Example Finder Analyzing and Processing Signals C3 Building User Interfaces C3 Communicating with External Applications Distributing and Documenting Applications C3 Actuators 3 Analog Z Complete List C3 0MA 3 Digital L Driver Station Inputs re 3 Joystick C3 Pneumatics C3 Robot and Motor C3 SPI C Safety C3 Sensors C3 Vision 2 Favorites IJ Fundamentals T Include ni com examples O Hardware Input and Output A nicom query timeout SD Industry Applications C3 Most Recent Hardware C3 Networking Find hardware Z New Examoles for LabVIEW 8x z T Limit results to hardware Addto Favorites Setup Help Close 7 NATIONAL ni com first SP instrumenrs ni com Accessible from the Getting Started launch window of LabVIEW FRC is an option to Find FRC Examples Here you will find may different examples of LabVIEW code to interface with different components of the robot National Instruments Corpor
5. FRC Driver Station Team 9999 Volts Communications Robot Code Stop Button No Robot Communication Elapsed Time 0 00 0 Teleoperat d Autono ous Reanting UserLogin Pat PC Battery lt lt Team Station Red 1 14 Now you can drive the robot with the joystick END OF FRC EXERCISE 1 National Instruments Corporation 127 User Messages FRC LabVIEW Mentor Training Hands On Seminar LabVIEW FRC Installation Shortcuts When you install LabVIEW on your computer you are going to find of different icons i 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 gt NATIONAL ni com first INSTRUMENTS ni com Review of LabVIEW FRC Robot Exercise 1 FRC LabVIEW Mentor Training Hands On Seminar 128 ni com Getting Started When you open the LabVIEW program a Fe Operate ook Hik Getting Started Window pops up LabVIEW FRC Edition 2011 42 e Getting started tutorials for FRC are ms provided on the right side of the Getting Started Window The tutorials include plenty of useful information e To start a new FRC LabVIEW project click
6. Mum Ctrl Fointer Slide Fill Slide Fill Slide Pointer Slide 4 A 2 4 Dial Color Box e User Controls Select a Control T 10 Click the LEDs sub palette and place a Round LED on the front panel National Instruments Corporation 63 FRC LabVIEW Mentor Training Hands On Seminar Square LED Round LED Select a Control 11 Right click the Vertical Pointer Slide and select Properties The Properties Dialog Box appears Examine the different properties that you can modify Make the following changes on the Appearance tab and click OK to apply the changes Label Limit Slider 1 Check Show digital display s Caption E Visible Enabled State Enabled Disabled m Disabled amp grayed Colors Slider Pay Fill Show increrment decrement buttons Fill style Show value tip strip q Gars FRC LabVIEW Mentor Training Hands On Seminar 64 ni com 12 Right click the Round LED labeled Boolean and select Properties Examine the different properties that you can modify On the Appearance tab change the label from Boolean to Alarm Click OK to apply your change Move the objects on the front panel so it resembles the following 49 Generate and Display TutorialGenerateDisplay 1 vi Front Panel eet lhe File Edit View Project TETT Tools Window Help a 15pt Application Font day 50 2 5 0 0 RAT 50 55 10 0 l l i i
7. 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 NATIONAL INSTRUMENTS ni com ni com first With LabVIEW for FIRST students have one programming language they are working with throughout their school careers from ages 6 to 18 LabVIEW If they pursue engineering careers they can use LabVIEW in more than 5 000 universities across the globe They will already have a solid foundation in LabVIEW to build on when they begin programming at the university level and into industry National Instruments Corporation 15 FRC LabVIEW Mentor Training Hands On Seminar pete fGtEEtt i l i 12 p Er K5 TE eee es amp HD O0 O e gt 7 7 NATIONAL FRC ni com first NATIONAL ni com Overall how CompactRIO fits in FRC LabVIEW Mentor Training Hands On Seminar 16 ni com Role of the Controller Autonomous Teleoperated Motor actuator control Driver station input Motion control processing Path control Telemetry back to console Object avoidance Action control Motion smoothing NATIONAL ni com first INSTRUMENTS n com National Instruments Corporation 17 FRC LabVIEW Mentor Training Hands On Seminar Supe
8. i Functions Palette Controls Palette 1 If you have not already done so click the LabVIEW icon on your quick launch toolbar If the icon is not present in the quick launch the desktop should feature a LabVIEW shortcut or you can navigate to Start Programs National Instruments LabVIEW 8 6 LabVIEW all eis 8 FRC LabVIEW FRC LabVIEW Mentor Training Hands On Seminar 58 ni com Once you launch LabVIEW a splash screen like the following appears bVIEW FRC Edition 2011 42 wl Blank VI Tutorial 1 Setting up the cRIO te FRC cRIO Robot Project Tutorial 2 Setting up the Axis Camera jer FRC Dasttsgard Project Tutorial 3 Setting up the Robot Radio Tutorial 4 Developing a Robot Project Tutorial 5 Editing Team Code Vis Tutorial 6 Creating a Custom Dashboard gi 2011 Robot Project lvproj Browse Tutorial 7 Integrating Examples into Robot Code What s New for FRC 2011 Troubleshooting the Robot Tutorials Online Check for Updates LabVIEW Help Discussion Forum A Find FRC Examples 2 Click More 3 Under the VI tree heading expand From Template Notice the different categories on the left side of the window that correspond to the types of tasks from which you can choose You can select Blank VI to start from scratch You also can use template VIs as a starting point to build your application Projects and Other Files are more advanced components that are not described in detail in this
9. Common kit of parts 6 week build period ni com first NATIONAL INSTRUMENTS ni com National Instruments Corporation 9 FRC LabVIEW Mentor Training Hands On Seminar FIRST Robotics Competition Team Growth e FRC 2010 Season BREAKAwAY 1 809 teams 45 000 high school age students Average 25 students per team 44 regional state championships district competitions 340 teams advance to FIRST championship NATIONAL ni com first INSTRUMENTS ni com FRC LabVIEW Mentor Training Hands On Seminar 10 ni com es Investment M Me x DELPHI PPNSTRUMENTS FedEx fohmonafohmon The Chrysler Foundation ton cine Baxter Rockwell fockwey Automation mns Q BOEING ni com first SP instrumenrs ni com More than 3 000 leading corporations foundations and agencies including founding sponsors and strategic partners National Instruments Corporation 11 FRC LabVIEW Mentor Training Hands On Seminar Sponsor Investment 7er MICHIGAN STATE TON 9 WW Pl university ER Le NIVERSITY UNIVERSITY WAYNE STATE WE 0 MchgnnEnoine n s UNIVERSITY HG PER PURDUE X Devry G Stands For Opportunity Tech VCU UCDAVIS BI UNIVERSITY OF DENVER NEW JERSEY INSTITUTE OF TECHNOLOGY NATIONAL ni com first SP instrumenrs ni com FRC LabVIEW Mentor Training Hands On Seminar 12 ni com Mentors e Become a mentor Empower children with a sense of accomplishment Pr
10. Joystick Button Outputs Left Motor Right Motor Arm Extender 2 Define the possible states nodes and actions in each state Start lnitialize Stand by Wait for event Read Joystick Read the joystick for a command Forward Both motors forward Left Right motor forward Left motor reverse Right Right motor reverse Left motor forward Reverse Both motors reverse Read Joystick Button Poll to see if button pressed Extend Arm Turn on digital line to extend arm Retract Arm Turn off digital line to retract arm Finish End MANUAL MODE Teleoperated l List all of your inputs outputs and additional requirements e Inputs Joystick Joystick Button Outputs Left Motor Right Motor Arm Extender e Requirements See above 2 Define the possible states nodes and actions in each state Start Initialize Stand by Wait for event Read Joystick Read the joystick for a command Forward Both motors forward Left Right motor forward Left motor reverse Right Right motor reverse Left motor forward Reverse Both motors reverse Read Joystick Button Poll to see 1f button pressed Extend Arm Turn on digital line to extend arm Retract Arm Turn off digital line to retract arm e Finish End National Instruments Corporation 39 FRC LabVIEW Mentor Training Hands On Seminar Example Robot Remote Control Step 2 Design a Flowchart continued 3 Define your state
11. National Instruments Corporation 161 FRC LabVIEW Mentor Training Hands On Seminar Adding a Digital Line for a Limit novio e Remember Code is inverted on the limit switch Re it is pressed or closed the output value is False When the limit switch is not pressed open the output value is True Left and Right Motors NATIONAL ni com first gt INSTRUMENTS ni co FRC LabVIEW Mentor Training Hands On Seminar 162 ni com Adding a Digital Line for a Limit Rovie e BONUS Use a Boolean OR to use either the fe button or the limit switch Joystick 1 mis 2 SI fa EE is B Button Fo gt p al ena h gt f gt pa Bs B Bo e7 NATIONAL ni com first INSTRUMENTS ni com National Instruments Corporation 163 FRC LabVIEW Mentor Training Hands On Seminar 2 Additional Resources and Next Steps NATIONAL instruments r7 NATIONAL ni com first INSTRUMENTS ni co Additional Resources and Next Steps FRC LabVIEW Mentor Training Hands On Seminar 164 ni com Ensuring Success Join the NI FIRST Community online ni com first Ask support questions monitored by applications engineers Access training materials and tech documentation Interact with other teams and mentors NATIONAL ni com first INSTRUMENTS ni com The ni com first community is the place to go for LabVIEW for FRC and cRIO FRC support specifications training and so on National
12. aR output cluster new component B owned label 8 p NATIONAL ni com first INSTRUMENTS ni com priginal cluster 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 Note You must have an existing cluster wired into the middle terminal of the function to use Bundle by Name National Instruments Corporation 71 FRC LabVIEW Mentor Training Hands On Seminar Loops While Loop Run until stop condition met Run N times Fr CE G e Allow same piece of code to run multiple times Exit conditions different for each i NATIONAL ni com first INSTRUMENTS ni com 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 1s 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
13. gt 50 cents This transition is used after Coke is dispensed to determine if change should be returned Money 50 cents This transition is used after Coke is dispensed to determine if change should be returned 4 Draw a flowchart linking the states nodes NOTE Steps 3 and 4 are often most easily done together National Instruments Corporation 35 FRC LabVIEW Mentor Training Hands On Seminar Example Advanced Coke Machine Step 2 Design a Flowchart continued wt money 0 State Ke Action Related to For Eve return change nickel money 50 return Nickel money lt 50 _ icke money lt 50 Transition dispense money gt 50 dispense money gt 50 dispense money gt 50 money gt 50 More detail of this example http zone ni com devzone cda tut p 1d 3024 The more states considered and added generally the more robust the program process will be In many cases additional states are added later during the code debug as scenarios not considered are encountered For example what happens if a damaged coin or fake coin is inserted The scenario state is not considered in this example but could be included with another state Unknown coin or object return coin or object Try to explore other unconsidered scenarios with the students Another example what happens if the machine is out of Coke FRC LabVIEW Mentor Training Hands On Seminar 36 ni com Example Robot Remote
14. node transitions e See Flowchart 4 Draw a flowchart linking the states nodes e See Flowchart NATIONAL ni com first INSTRUMENTS ni com NOTE Steps 3 and 4 are often most easily done together FRC LabVIEW Mentor Training Hands On Seminar 40 ni com Example Robot Remote Control Step 2 Design a Flowchart continued National Instruments Corporation 41 FRC LabVIEW Mentor Training Hands On Seminar Example Robot Autonomous Try building on the previous examples to follow the software Development Method for an autonomous robot 1 Define the problem scenario 2 Design a flowchart algorithm 3 Implement the design 4 Test and verify the implementation 5 Maintain and update the implementation NATIONAL ni com first INSTRUMENTS ni com AUTONOMOUS MODE Step 2 Design a flowchart sub steps shown below l List all of your inputs outputs and additional requirements Inputs Line Follower Linear Encoder Rotary Encoder for Each Drive Motor Proximity Sensor Outputs Left Motor Right Motor Arm Extender 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 2 Define the possible states nodes and actions in each
15. 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 NATIONAL ni com first SE instrumenrs ni com To access data in a cluster you need to insert an Unbundle by Name function A Case Structure contains one or more subdiagrams or cases The value wired to the selector terminal determines which case to execute For a momentary stop button remember that the motors should stop when Button 1 is true and keep running when Button 1 is false Therefore the x and y axis values should go through the case structure without any change To wire the false case delete the x and y axis wires and rewire them to Arcade Drive through the case structure Note that the wires only went through the one visible case Four blocks are created when you are wiring through the case structure The two blocks on the left of the case structure are where the wires go in and are called the input tunnels In the True Case when Button 1 is pressed the motors should stop Therefore the x and y axis values should be zero To do this change to the true case and wire a zero constant to the output tunnels To insert a constant right click on one of the output tunnels click Create and then click Constant Note that you can reuse the constant for the second output tunnel National Instruments Corporation 143 FRC LabVIEW Mentor Training Ha
16. Control Step 1 Define the Problem You need to design the control system that will be used to control a robot in teleoperate remote control mode You can assume that the robot will have power and will be told what mode to run teleoperated or autonomous Also assume a joystick and one button will be used to control the robot direction and an extension arm on the robot NATIONAL ni com first gt INSTRUMENTS ni com During the problem scenario stage of the software development method you define what your problem is so that you can approach it with all of the necessary factors identified You can remove extraneous factors during this phase and focus on the core problem that you must solve How you identify the problem initially can save you time while you design and implement a solution National Instruments Corporation 37 FRC LabVIEW Mentor Training Hands On Seminar Example Robot Remote Control Step 2 Design a Flowchart 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 One joystick will be read to drive the robot Manual Teleoperated mode only NATIONAL ni com first INSTRUMENTS ni com FRC LabVIEW Mentor Training Hands On Seminar 38 ni com Example Robot Remote Control Step 2 Design a Flowchart continued 1 List all of your I O amp Requirements Inputs Joystick
17. Here Left Tacs Rs ou and Right Motors will be called later See corner in the program to access these Jaguar motor controllers The Robot DriveRefNumRegistry Neca Set VI sets a reference into a registry so that other Vis can call the reference initialize two motors NATIONAL ni com first INSTRUMENTS ni com Motor Reference Registry Set VI name is Robot DriveRefNumRegistry Set 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 when you need 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 FRC LabVIEW Mentor Training Hands On Seminar 116 ni com TeleOp vi eTo view Teleop vi in Robot Main select Teleop Enabled in the case structure Far OT ic called pachitone a Velncip OS packet racer ENNE O mee Anesth be Ces Dallas ave elt is called each time a teleop driver station packet is received and robot is TNE ES WAR ee GROS enabled eTeleop 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 NATIONAL ni com first INSTRUMENTS ni com 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
18. I 0 0E 0 20E 1 4 0E 1 6 0E 1 S 0E 1 1 0E 2 nn Pin ENT r 0 7 A 13 Switch to the block diagram by pressing lt Ctrl E gt Double click the Simulate Signal Express VI to bring up its properties window Examine the different properties you can modify Change the Amplitude of the signal to 10 Click OK to apply this change and to close the properties window 14 Configure Simulate Signal Simulate Signal Signal Signal type Sine Frequency Hz Phase deg 10 1 0 Amplitude Amplitude Offset l 10 0 Add noise Norse iim White Noise my ps DITUCE PHTUCE Time Stamps Relative to start of measurement Timing 1 Absolute date and time Samples per second Hz 1000 Simulate acquisition timing Reset Signal Number of samples Run as fast as possible Reset phase seed and time stamps 100 71 Automatic Use continuous generation Integer number of cycles Signal Name Actual number of samples 7 Use signal type name 100 Signal name Actual frequenc Sine National Instruments Corporation 65 FRC LabVIEW Mentor Training Hands On Seminar FRC LabVIEW Mentor Training Hands On Seminar 14 Open the functions palette by right clicking the block diagram Select Arithmetic amp Comparison Comparison and place the Comparison Express VI within the while loop on the diagram Functions Search SS Customize L Arithmetic amp Comparison Express Compari
19. Initialize the new limit switch using digital input by modifying Begin VI Modify the Teleop VI to read the digital input to monitor ifthe switch has been pressed Modify the Finish VI to close the reference of the digital line for the limit switch BONUS Modify the code to use both the limit switch on the robot 7 and the joystick button to stop the robot In this exercise add a limit switch to the robot These switches are commonly used to determine if an object wall ball and so on is pressing up against the robot The limit switch is monitored by a digital input lne This is accomplished by initializing the new switch by modifying Begin VI modifying the Teleop VI to read the switch and finally modifying the Finish VI to close the reference of the new switch device For our robot we will replace the joystick button used as a brake from the previous exercise with the limit switch BONUS Try to incorporate both the switch AND the limit switch as a brake for the robot FRC LabVIEW Mentor Training Hands On Seminar 154 ni com FRC Robot Exercise 4 Add a Digital Input as Limit Switch Use this exercise to add a limit switch to the robot These switches are commonly used to determine if an object wall ball and so on is pressing up against the robot The limit switch is monitored by a digital input line This is accomplished by initializing the new switch by modifying Begin SubVI modifying the Teleop SubVI to read the switch and
20. Instruments Corporation 165 FRC LabVIEW Mentor Training Hands On Seminar Additional Resources National Instruments F RST Website ni com first Visit the FRC Website and Learn About Other Resources and Program Specifics usfirst org Take the Free LabVIEW Fundamentals Exam ni com academic Additional Hands on Exercises and Tutorials FRCMastery com NATIONAL ni com first INSTRUMENTS ni com peeve W view cart help search Products amp Services Go f MYN Ri Contact NI Products amp Services Solutions Support Ni Developer Zone Academic Events You are here N Home gt Academic Programs English Academic Programs and Resources Questions amp Call 800 531 5066 Academic Community Grants amp Donations Distance Learning LabVIEW Training Curriculum Resources iscipline Depot National Instruments provides products and resources to enhance engineering and science education Explore hardware software and curriculum resources including Lab Share Courseware Journals and Experiments Main Academic Resources Educators Researchers Students Lab Share Discounts LabVIEW Zone Student Corner Courseware Products LabVIEW Fundamentals Exam Experiments Training LabVIEW Student Edition a Journals Tutorials Technical Support LabVIEW Training Technical Support Jobs at NI Academic Discounts User Groups Subscribe to NI News Academic Edition Techni
21. Positioning Tool changes shape when it moves over a corner of a resizable object Use the Labeling Tool to edit text and create free labels The Labeling Tool changes to a cursor when you create free labels Use the Wiring Tool to wire objects together on the block diagram 4 Scrolling Tool Breakpoint Tool amp Probe Tool Color Copy Tool oh Coloring Tool g Shortcut Menu Tool FRC LabVIEW Mentor Training Hands On Seminar 50 ni com Status Toolbar ol gt Run Button He Continuous Run Button Abort Execution Additional Buttons on the Diagram Toolbar QI Execution Highlighting Button Retain Wire Values Button Step Function Buttons s r NATIONAL ni com first INSTRUMENTS ni com Click the Run button to run the VI While the VI runs the Run button appears with a black arrow if the VI 1s a top level VI meaning it has no callers and therefore 1s not a subVI Click the Continuous Run button to run the VI until you abort or pause it You also can click the button again to disable continuous running While the VI runs the Abort Execution button appears Click this button to stop the VI immediately Note Avoid using the Abort Execution button to stop a VI Either let the VI complete its data flow or design a method to stop the VI programmatically By doing so the VI is at a known state For example place a button on the front panel that stops the VI when you click it Click the Pause button to pause a r
22. Specifications INSTRUMENTS ni com ni com first NS TRUE 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 FRC LabVIEW Mentor Training Hands On Seminar 110 ni com Robot Main Block Diagram T Robot Main vi Block Diagram on 2011 Robot Project ivproj RT CompactRIO Target File Edit View Project Operate Tools Window Help Sid amp ss ea bal FF oF 15pt Application Font i 3o74 te Robot Main implements the framework and scheduler for your robotics program Controls From Enable ision Tr na le Vision 2 It should not be necessary to modify this VL 7 Pie lt Global Variables You should be able to code your robot Front Panel age Size ER _ image size within the Team Vis described below 1 Begin vi Based on the robot mode call the appropriate Team code Called once at beginning to open I O Double click an icon to open a Team VI and modify code initialize sensors and any globals load d Teleop Enabled 7h settings from a file etc 2 Autonomous Independent vi Automatically started with the first packet of autonomous and aborted on
23. The side of the loop the wire are connected is not important but mentioned for clarity in referencing the image above The Sequence Structure and the While Loop will be running in parallel Within the Sequence Structure the Vision vi and Timed Tasks vi run in parallel This is because there are no data wires connecting them to control the execution order Within the While Loop the Robot Mode vi will run in parallel to the Dashboard Data vi The TeleOp vi will run sequentially after the Robot Mode vi since they are connected with data wires FRC LabVIEW Mentor Training Hands On Seminar 112 ni com Robot Main Flowchart View National Instruments Corporation 113 FRC LabVIEW Mentor Training Hands On Seminar Begin vi Its purpose is to initialize and sm Ete Edt Vies Project Qperste Tools Window Help oja 00 P Ral kallo 15pt Applicaton Font 11 1516 fa define all of the motors Re Moues garens diolan To This Vi is called before others so you can setup for execution y vall loops for camera periodic and to the Auto and sensors I O and other items oeo 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 NATIONAL ni com first INSTRUMENTS ni com 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
24. bundle you can plot data on the negative x axis time Wire data directly to waveform graph Y Array Resulting Graph 1D Single Plot WDT Single Plot 2D Multiplot WDT waveform Data Type includes timing info Others default to O for x and 1 for 4x Combine timing information using a bundle node y array See the example Waveform Graph vi FRC LabVIEW Mentor Training Hands On Seminar 108 ni com L Programming an FRC Robot NATIONAL INSTRUMENTS l NATIONAL ni com first INSTRUMENTS ni com Section Objectives A Understand the FRC code template including structure components subVIs B Program a robot by completing several exercises National Instruments Corporation 109 FRC LabVIEW Mentor Training Hands On Seminar Understanding Robot Main vi f E Robot Menn Front Panel on 2011 Robot Project apros AT CompectAlO Target Ble Ede View Project Qpente Tools Windew Help SJE ue 15er Apptcanen Fore e io E E Project Explorer 2011 Robot Projectivproj eh E S File Edit View Project Operate Tools Window Help x DX El e a tems Files Open Project ist he Project 2011 Robot Project tvproj d B tobot Maasi Block Diagram on 2011 Robot Progectisproy ET Compact00 Target a By Computer Be pm View Port Qpewte Ioe Window tele Build Specifications E RT CompactRIO Target 10 99 99 02 HG TypeDefs Gd Team Code tt GJ Vision Support Code ith Build
25. by data flow NATIONAL ni com first WINSTRUMENTS ni com LabVIEW programs are called virtual instruments VIs Controls are inputs and indicators are outputs Each VI contains three main parts e Front Panel How the user interacts with the VI e Block Diagram The code that controls the program e Icon Connector Means of connecting a VI to other VIs In LabVIEW you build a user interface by using a set of tools and objects The user interface is known as the front panel You then add code using graphical representations of functions to control the front panel objects The block diagram contains this code In some ways the block diagram resembles a flowchart Users interact with the front panel when the program is running Users can control the program change inputs and see data updated in real time Controls are used for inputs such as adjusting a slide control to set an alarm value turning a switch on or off or stopping a program Indicators are used as outputs Thermometers lights and other indicators display output values from the program These may include data program states and other information Every front panel control or indicator has a corresponding terminal on the block diagram When a VI is run values from controls flow through the block diagram where they are used in the functions on the diagram and the results are passed into other functions or indicators through wires FRC LabVIEW Me
26. continued 1 List all of your I O amp requirements e Inputs Current Room Temperature Outputs Heater On Off 2 Define the possible states nodes and actions in each state STATE ACTION Read Temp Read the current room temperature e Heater Off tTurn off heater Heater On Turn on heater NATIONAL ni com first INSTRUMENTS ni com l List all of your inputs outputs and additional requirements Inputs Current Room Temperature Since the temperature range is fixed at 70 75 deg F the furnace set point temperature is not considered Assuming furnace is powered on and fuel electricity or gas is provided Outputs Heater On Off e Requirements See above 2 Define the possible states nodes and actions in each state Read Temp Read the current room temperature Heater Off Turn off heater s Heater On Turn on heater The more states you consider and add generally the more robust the program process will be In many cases additional states are added later during the code debug as scenarios not considered are encountered For example what happens when we need to shut down the furnace before the temperature reaches 75 F for maintenance or if it is summer time Here we could add the following new input state and action Emergency Stop Button input E Button Pressed state and Turn Off Heater and Finish action National Instruments Corporation 29 FRC LabVIEW Mentor Training
27. examine the operation of the VI When you are finished click the STOP button on the front panel to stop running the VI Note As you will see later in the exercise when the Run button in the upper left corner of both the front panel and the block diagram changes from a solid white arrow to a broken gray arrow this new icon indicates that the VI is currently not executable 7 Now you can add some functionality to this basic VI Modify the VI to flash an alarm whenever the signal value is above a certain level Open the Controls palette if it is not open already by right clicking empty space on the front panel window A small pushpin icon in the upper left corner of this palette appears Click this pushpin to force the palette to remain on your screen o ontrols A Search 3 ress H Eh k ia 4 abe H Mum Ctris Buttons Text Ctris not Ls i mi sa O User Ctrls Num Inds LEDs Text Inds Graph Indica User Controls k Select a Control 8 Click the Numeric Controls sub palette and select a Vertical Pointer Slide to be placed on the front panel To do this click the Vertical Pointer Slide and drag it to the front panel Click once to place it FRC LabVIEW Mentor Training Hands On Seminar 62 ni com Control Mum Ctrl 4 wy 5 g j ni Fill Slide Pointer Slide Color Box User Controls Select a Control Numeric Controls FE ais 1231 I I I I i I 7 5 d o 5 i
28. mt Ci 2011 Robot Project pro kI Compact 30 Target en lM _ NATIONAL INSTRUMENTS ni com ni com first LabVIEW Project Use projects to group together LabVIEW and other files create build specifications and deploy or download files to targets A target is a device or machine on which a VI runs When you save a project LabVIEW creates a project file lvproj which includes configuration information build information deployment information and references to files in the project You must use a project to build stand alone applications and shared libraries You also must use a project to work with a real time FPGA or PDA target Refer to the specific module documentation for more information about using projects with the LabVIEW Real Time LabVIEW FPGA and LabVIEW Mobile modules Project style LabVIEW Plug and Play instrument drivers use the project and project library features in LabVIEW 8 6 You can use project style drivers the same you used previous LabVIEW Plug and Play drivers Project Explorer Window Use the Project Explorer Window to create and edit projects Select File New Project to display the Project Explorer Window You also can select Project New Project or select File New and then select Empty Project in the new dialog box to display the Project Explorer Window National Instruments Corporation 15 FRC LabVIEW Mentor Training Hands On Seminar Introduction to Clusters Data structure that groups d
29. range For simplicity the building has only a furnace and no air conditioning You can assume the room will eventually cool down through heat loss through windows and doors and that we have an abundant amount of fuel to run the furnace ni com first bi INSTRUMENTS nLcocom During the problem scenario stage of the software development method you define what your problem is so that you can approach it with all of the necessary factors identified You can remove extraneous factors during this phase and focus on the core problem that you must solve How you identify the problem initially can save you time while you design and implement a solution National Instruments Corporation 25 FRC LabVIEW Mentor Training Hands On Seminar Step 2 Design a Flowchart Algorithm NATIONAL ni com first x INSTRUMENTS ni com The first place to start with any software program 1s to map out a flowchart of how the process will execute The process could be a robot a control loop or basically any operation that has a series of steps that need to be completed The image above shows a number of different flowcharts The format type of the flowchart is less important than the act of thinking through and drawing out the flowchart Flowcharts help you develop a good understanding of the application flow by dividing the application into more manageable pieces called states or nodes NI LabVIEW 1s a graphical programming language desi
30. state i Start Initialize a Read Line Get reading from line sensor to get position on line On Line Left and right drive motors forward at same speed To Left of Line Right motor 75 speed of left motor To Right of Line Left motor 75 speed of right motor Run into Wall Extend arm Arm Extended to Required Distance Retract arm Finish End The more states you consider and add generally the more robust the program process will be In many cases additional states are added later during the code debug as scenarios not considered are encountered For example what happens if another robot is in your robot s path The scenario state is not considered in this example but it could be included with another state Robot Obstruction Try to explore other unconsidered scenarios with the students Another example is what happens if the robot cannot find the line in the first place 3 Define your state node transitions 4 Draw a flowchart linking the states nodes NOTE Steps 3 and 4 are often most easily done together FRC LabVIEW Mentor Training Hands On Seminar 42 ni com Software Development Method Define the problem scenario Design an algorithm and or flowchart Implement the design Test and verify the implementation Maintain and update the implementation Addressed in Section 4 Programming an FRC Robot P NATIONAL ni com first INSTRUMENTS ni com National Instruments Corpor
31. use to fully customize the appearance of your subVIs This allows you to visually distinguish your subVIs which greatly improves the usability of the subVI in large portions of code After you ve defined the connector pane and have customized the icon you are ready to place the subVI into other LabVIEW code There are two ways to accomplish this To place a subVI on the block diagram 1 Select the Select a VI from the Functions palette 2 Navigate to the VI you want to use as a subVI 3 Double click it to place it on the block diagram To place an open VI on the block diagram of another open VI 1 Use the Positioning tool to click the icon of the VI you want to use as a subVI 2 Drag the icon to the block diagram of the other VI National Instruments Corporation 101 FRC LabVIEW Mentor Training Hands On Seminar How Do 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 e Configure special timed While Loop for desired dt REM Timed Loop NATIONAL INSTRUMENTS ni com ni com first Time Delay The Time Delay Express VI delays execution by a specified number of seconds Following the rules of dataflow programming the While Loop will not iterate until all tasks inside it are complete thus delaying each iteration of the loop Timed Loops These loops execute each iteration of the loop a
32. 5 Vision vi A parallel loop that acquires and processes camera images Start Robot Communication 6 PenodicTasks vi Runs in parallel with user code CERCLE TEE TEEN TEEN TEEN Parallel loops running at user defined rates GOOO Does 7 Finish wi Called before exiting so you can save data clean up VO etc Acquire camera images and process them in parallel with 8 Build DashBoard Data vi other loops Carry out periodic tasks such as control loops Con Robot Project lvproj RT CompactRIO Target i Referencing the LabVIEW block diagram above the code will start by executing the Begin command the Reference to the Autonomous Independent vi and the Generate Occurrence vi in parallel The StartCOM vi will execute sequentially after the Generate Occurrence vi has executed since it is connected with a data wire to the Generate Occurrence vi The Sequence Structure with the Vision vi will execute sequentially after the Begin command has been executed since it is connected to the Begin vi with an error wire The large While Loop will execute only after the Begin vi Generate Occurrence vi and The Reference to the Autonomous Independent vi have all executed Data from these VIs must all flow to the edge of the While Loop before the While Loop will start This is because the While Loop is waiting for data from all of these VIs as indicated by the wires connected to the left side of the While Loop
33. Alarm indicator Note The Run button in the upper left corner of both the front panel and the block diagram has changed from a solid white arrow to a broken gray arrow This new icon indicates that the VI is currently not executable If you click the Run button when it is solid and white it runs the VI Clicking it when it is broken and gray opens the error list dialog box to help you debug the VI 16 Click the Run button now The resulting dialog box shows that in this case the error results from connecting the terminals of two different types Since the Limit control is a Numeric type and the Alarm indicator is a Boolean type you cannot wire these two terminals together Highlight the error by clicking it and then click Show Error LabVIEW highlights the location of the error 17 Notice that the wire between Limit and Alarm is dashed and a red x is displayed on it To delete this broken wire press lt Ctrl B gt This keyboard shortcut removes all broken wires from the block diagram FRC LabVIEW Mentor Training Hands On Seminar 68 ni com 18 Make your block diagram resemble the below image by completing the following steps a Wire the Limit control to the Operand 2 input of the Comparison function b Connect the wire between the Simulate Signals block and the Waveform Graph to the Operand 1 input of the Comparison function c Wire the Result output of the Comparison function to the Alarm indicator Your block diagram shou
34. Contents Ob eC Vera NBA Ed ind A des een de an ne en nt 2 4 Overview FIRST FRC and PRC Controls SI nee Rd A AN eantagta erences 5 Wasim and NS SION SR de Ode om inde Ds 6 10 SPONSOL INVESEM NL LAN int AR NP di on n 11 12 MONOS SSSR E OS ce an dd de nn ie M a aent 13 FRC Control System LabVIEW and CompactRIO e ee ee ee eee eee eeeeeees 14 ROBOUCS PILOT SR Rte Neen nt onde 15 ROIS OF the CONHOMeLS is nn den bat droite oies Leeds 16 18 Flexible Input and O DEUST du Can do dd ion 20 Easy to Prostran ereire Re A states three diet Neiia ses 21 Software Development Fundamentals xo ca iiask sited ac teres atean raTa nement 22 Software Development Method ni nan sen natation moine 23 D S he Problem Lu nee nant aan nt enr ARS 24 om le PARRAGR sss sasha and gcenate aut eo en oise tye ete 25 31 Example Advanced Coke MAChINes us ie nine cata 32 36 Example Robot Remote Control amusante et 37 43 litteduction to NT EADV IE WE nec tee liant ones 44 Whatis LaDVIEW and VI Sits anse Rire de tem deone 45 46 Controls Palette Controls and Indicators 282 47 Funcuons and SHUCKUTES PAl Rss aa EN RS NN en tee NE es 48 49 MOONS PICE Re Rte den 50 51 Debueeing Techniques nn dc nee dl sueoemeaasas 52 Context EID W Id OW oesi e a E AANEEN E scence 53 DatatlowsProet ain sene a Ce a dt N aa aE 54 55 LabVIEW Shortcuts and Fosse ns o a EA nie ane 56 LabVIEW Exercise 1 Creat
35. FRC LabVIEW Mentor Training Hands On Seminar Method 2 Add a Not function between the DigitallnputGetValue VI and the case structure You want to use this method if you plan to complete the BONUS step You can find the Not function on the Functions palette under Programming Boolean 7 Functions a Search Programming SEA Hi AAS 1 Boolean Context Help Computes the logical negation of the input If x is FALSE the function returns TRUE If x ts TRUE the function returns FALSE Mathe Signal The Teleop VI block diagram is shown below Arcade Drive 15 BONUS Try to incorporate both the joystick button AND the limit switch as a brake FRC LabVIEW Mentor Training Hands On Seminar 160 ni com ANSWER You can achieve this by using a Boolean function called OR Computes the logical OR of the inputs Both inputs must be Boolean or numeric values If both inputs are FALSE the function returns FALSE Otherwise it returns TRUE Elele lt The Teleop VI block diagram shown below uses both the joystick button and the limit switch as a brake for the robot date motor values Arcade Drive ta False PE t i 16 Close and save Teleop VI 17 Return to Robot Main and run it to test the code While driving the robot you should now be able to apply a brake by depressing the limit switch and if you completed the BONUS by also pushing Button 1 on the joystick END OF FRC EXERCISE 4
36. FRC cRIO Robot Project on the left side of the window NATIONAL ni com first INSTRUMENTS ni com Review of LabVIEW FRC Robot Exercise 1 National Instruments Corporation 129 FRC LabVIEW Mentor Training Hands On Seminar Create New FRC Robot Project e Here you can change Project name Project location CRIO IP address To set IP on cRIO user the CRIO Imaging Tool ho Select project name folder and IP address Project name 2011 Robot Projec Project folder C Users Localization Tester Documents LabVIEW Data 2011 Robot Project cRIO IP address 10 xxyy 02 Robot Framework Robot Framework with Game Code H ni com first Review of LabVIEW FRC Robot Exercise 1 FRC LabVIEW Mentor Training Hands On Seminar 130 ec NATIONAL INSTRUMENTS ni com Project Explorer The Project Explorer opens after creating the new FRC robot project eYou 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 eTo start modifying the robot code expand RT CompactRIO Target and double click Robot Main vi ho ni com first FRC Sr File Edit View Project Qperate Tools Window Help X as ee ER I 3 x S kh Project 2011 Robot Project lvproj G My Computer h SP Dependencies Le Build Specifications S FR RT CompactRIO Target 10 99 99 02 B
37. H gt keys or press the Show Context Help Window button in the toolbar Connections displayed in Context Help Required bold Recommended normal Optional dimmed Additional Help e VI Function amp How To Help is also available Help VI Function amp How To Help Right click the VI icon and choose Help or Choose Detailed Help on the context help window e LabVIEW Help reference style help Help Search the LabVIEW Help National Instruments Corporation 53 FRC LabVIEW Mentor Training Hands On Seminar Dataflow Programming 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 7 NATIONAL ni com first INSTRUMENTS ni com LabVIEW follows a dataflow model for running VIs A block diagram node executes when all its inputs are available When a node completes execution it supplies data to its output terminals and passes the output data to the next node in the dataflow path Visual Basic C JAVA and most other text based programming languages follow a control flow model of program execution In control flow the sequential order of program elements determines the execution order of a program Consider the block diagram above It adds two numbers and then multiplies by 2 from the result of the addition In this
38. Hands On Seminar Example Furnace Step 2 Design a Flowchart continued 3 Define your state node transitions e T lt 70 F Transition if temperature is less than 70 F 1 gt 5 F Transition if temperature is greater than 75 F e f temperature within range do nothing 4 Draw a flowchart linking the states nodes e See next page NOTE Steps 3 and 4 are often most easily done ogether NATIONAL ni com first INSTRUMENTS ni com 3 Define your state node transitions e T lt 70 F Transition 1f temperature is less than 70 F e T gt 75 F Transition 1f temperature is greater than 75 F If temperature within range do nothing 4 Draw a flowchart linking the states nodes NOTE Steps 3 and 4 are often most easily done together FRC LabVIEW Mentor Training Hands On Seminar 30 ni com Example Furnace Step 2 Design a Flowchart continued default default default State and Action Related to State amp Transition Decision Vl Heater On Heater Off NATIONAL ni com first INSTRUMENTS ni com The more states you consider and add generally the more robust the program process will be In many cases additional states are added later during the code debug as scenarios not considered are encountered For example what happens when we need to shut down the furnace before the temperature reaches 75 F for maintenance or if 1t is summer time Here we could add the foll
39. The icon and connector pane correspond to the function prototype in text based programming languages There are many options for the connector pane but some general standards are specified above Notably always reserve the top terminals for references and the bottom terminals for error clusters To define a connector pane right click the icon in the upper right corner of the front panel and select Show Connector from the shortcut menu Each rectangle on the connector pane represents a terminal Use the terminals to assign inputs and outputs Select a different pattern by right clicking the connector pane and selecting Patterns from the shortcut menu FRC LabVIEW Mentor Training Hands On Seminar 100 ni com Icon Viewer Create an Icon e 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 3 icon Editor x Fle Edit Help Icon Art Glossary at SES ni com for standard A HOT En onewe graphics to use in gt 1 Show Terminals CILI Help n 3 NATIONAL ni com first INSTRUMENTS ni com An icon is a graphical representation of a VI If you use a VI as a subVI the icon identifies the subVI on the block diagram of the VI The Icon Editor 1s a utility built into LabVIEW that you can
40. W TypeDefs H GJ Team Code g Vision Support Code w Gi Support Code Robot Main vi 6 S Dependencies Build Specifications Ww NATIONAL INSTRUMENTS ni com Review of LabVIEW FRC Robot Exercise 1 National Instruments Corporation 131 FRC LabVIEW Mentor Training Hands On Seminar Robot Main VI T Robot Mainvi Front Panel on 2011 Robot Projectivproj RT CompacthiO Target Bile Edt View Project Operate Tool Window Help u be or iard NATIONAL ni com first SENS ni com Review of LabVIEW FRC Robot Exercise 1 FRC LabVIEW Mentor Training Hands On Seminar 132 ni com Deploying Code to Robot 3 Deployment Progress eYou can run the Arcade Drive with the default Deployment Status FRC robot code provided Iritializing Always run the RobotMain vi aes eTo deploy the code to the CompactRIO target 3 click run in the top left corner Aa an das a Cancel Stage 1 Stage 2 develop download NATIONAL ni com first SE instrumenrs ni com Review of LabVIEW FRC Robot Exercise 1 National Instruments Corporation 133 FRC LabVIEW Mentor Training Hands On Seminar A FRC Driver Station pevie Before running the Arcade Drive using the default FRC robot code you need to open the FRC Driver Station e The FRC Driver Station handles the communication between the computer and the robot e When the lights of the Communications Robot Code and the Stop Button turn gree
41. a de E amt ire ere eee CE on 117 Autonomous Independent Viereinen urra Rene 118 119 EN LI A EEE EE A E A E E E T A E A ES 120 121 FRC Robot Exercise 1 Configure and Deploy Project 122 127 LabVIEW FRC Installation Shortcuts Review 128 Gettine Starved REVIEW Liens cab been es nos de certe etaient 129 Create New ERC Robot Project Review 2 Re dede 130 Project Xplorer Re VIEN Ne ds der nuit ae eae colour 131 RODOL MAR VE REVIEW eerie A a tienne Mada teboananetaddanaaeS cern dallas 132 Deploying Code to Robot REVIENS tr de aa die di nee ieeane sees 133 PRO Driver Station REVIEW En nero R bre due uni ns 134 AddinS JOysick COU OS ESS RS dr nn ed dei 135 136 FRC Robot Exercise 2 Add Joystick Controls 137 142 Adding Joystick Controls REVIEW s duin NL M me ian ead een tt 143 Adding NEW DEVICE en nain ennemi nes 144 FRC Robot Exercise 3 Add a Servo Motor 145 152 Adding Servo Motor ROVIeW mind dansent edesanit nasale a 153 FRC Robot Exercise 4 Add a Digital Input as Limit Switch 154 161 Adding a Digital Line for a Limit Switch Review 163 Additional Resources and Next Steps 32 mme denis einer ee LS 164 HSE SUCCESS NS E nan beeen een ean lan nue 165 AUdIHORALRESOULCES Eu nn bu intel annales 166 7 NATIONAL INSTRUMENTS NATIONAL ni com first INSTRUMENTS ni com National Instruments Corpora
42. agram contains the code that controls the VI functionality You can toggle between the two windows by selecting Window Show Block Diagram or Window Show Front Panel You can also switch between the windows by pressing lt Ctrl E gt on the keyboard FRC LabVIEW Mentor Training Hands On Seminar 60 ni com 5 Examine the front panel and block diagram of this template VI in the below figure The front panel contains a waveform chart and a STOP button 3 Generate and Display TutorialGenerateDisplay 1 ota File Edit View Project Operate Tools Window Help jan 13pt Application Font 19 0 Toa LE 1 Zo 0 0 ATE aeia rie 10 0 I I I I I 0 0E 0 2 0E 1 4 0641 6 0E 1 8 0E 1 10E 2 Time The block diagram contains a Simulate Signal VI that is configured to simulate a sine wave and plot it to the graph Generate and Display TutorialGenerateDisplay 1 vi Block Diagram File Edit View Project Operate Tools Window Help e u 2 85 heal el os This template is intended for use with the Getting Started manual 1 Configure the Simulate Signal Express VI by double clicking it Simulate Signal Naveform Graph National Instruments Corporation 61 FRC LabVIEW Mentor Training Hands On Seminar 6 Switch back to the front panel by pressing lt Ctrl E gt Since the Run button the white arrow in the top left corner 1s solid you can run this VI as it is Click the Run button and
43. aph on the front panel and choose Properties You can also create technical paper quality graphics with the export simplified image function Right click the graph and select Data Operations Export Simplified Image 43 Export Simplified Image Bitmap bmp Encapsulated Postscript eps Enhanced Metafile emf Save to clipboard Save to file ta Cilgraph eps Hide Grid FRC LabVIEW Mentor Training Hands On Seminar 104 10 s Peak Value j 100 I 1 1 I i 1 I 0 10 20 30 40 50 60 70 80 90 ni com Building Arrays With Loops Auto Indexing 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 ni com first Auto Indexing Enabled Wire becomes thicker 1D Array Indicator 1D Array 0 ft 2 3 4 5 Auto Indexing Disabled Wire remains the same size Numeric Indicator 5 Only one value last iteration is passed out of the loop NATIONAL INSTRUMENTS ni com For Loops and While Loops can index and accumulate arrays at their boundaries This is known as auto indexing e The indexing point on the boundary is called a tunnel e The For Loop is auto indexing enabled by default e The While Loop is auto indexing disabled by default Examples e Enable auto indexing to collect values within the loop and
44. ase Structure Read Temp state shown Action SubVI to Read Temp NATIONAL ni com first l INSTRUMENTS ni com A real world example of a state machine using the furnace example state diagram National Instruments Corporation 85 FRC LabVIEW Mentor Training Hands On Seminar LabVIEW Exercise 2 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 A NATIONAL ni com first INSTRUMENTS ni com FRC LabVIEW Mentor Training Hands On Seminar 86 ni com Exercise 2 Controlling Program Execution If you are up for a challenge try to build the following LabVIEW application without using the instructions if you feel you need more guidance skip down to the step by step section for a complete set of instructions Challenge Application Using a While Loop case structure toggle switch and the Random Number Generator VI create a simple application that charts either a random number or a constant value depending on your toggle switch position If you are really ambitious add logic to the VI so it stops EITHER when you press the STOP button OR when the loop iterations have exceeded 1 000 Step by Step Instructions In this exercise create a LabVIEW VI that outputs either a random number or a constant value depending on the state of a toggle switch Use a case structure to handle
45. ata 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 NATIONAL ni com first INSTRUMENTS ni com 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 e Error information Grouping a Boolean error flag a numeric error code and an error source string to specify the exact error e 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 FRC LabVIEW Mentor Training Hands On Seminar 76 ni com Cluster Functions In the Cluster amp Variant subpalette of the Programming functions palette Can also be accessed by right clicking the cluster terminal Unbundle By Name Change order by right clicking data type Baplean Change elements exposed by using re sizing tool Boolean Unbundle am Always in order of bundle Fa Terminal labels reflect data type input cluster new component owned label
46. ation 13 FRC LabVIEW Mentor Training Hands On Seminar FRC Specific Examples Compressor With Cylinder tvproyRT CompactRIO Target INSTRUMENTS ni com ni com first NS TRUE From the Find FRC Examples e There are 44 FRC specific examples more added every year e They tell you what to configure before running and what can be changed while running e They all include wiring diagrams to aid in setting up and troubleshooting your electrical system even if you don t program in LabVIEW FRC LabVIEW Mentor Training Hands On Seminar 74 ni com LabVIEW Project Group and organize VIs Manage hardware and 1 0 Manage large LabVIEW applications Manage VIs for multiple targets Determine which code is running on laptop versus which code is running on CompactRIO hardware T3 Project Explorer 2011 Robot Project ivproj bolj File Edit View Project Operate Tools Window Help WLA x ICE sl Project 2011 Robot Project lvproj E My Computer H 7 Dependencies a Build Specifications 3 G RT CompactRIO Target 10 99 99 02 GJ TypeDefs H g Team Code Gi Vision Support Code Items Files s Robot Main vi N Build Specifications 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 rinisn looking at the bottom left of the Vl s front panel ees ee es
47. ation 43 FRC LabVIEW Mentor Training Hands On Seminar b gt Introduction to NI LabVIEW NATIONAL INSTRUMENTS NATIONAL ni com first INSTRUMENTS ni com Introduction to NI LabVIEW Overview of the LabVIEW environment dataflow programming and common programming structures used in the FRC code template FRC LabVIEW Mentor Training Hands On Seminar 44 ni com What is LabVIEW Speak G Graphical programming language e Go with the flow Dataflow programming Easy writing Easy to learn Powerful debugging tools NATIONAL ni com first INSTRUMENTS ni com LabVIEW is a graphical programming language you draw your program It 1s easy to learn and use while being a powerful full featured programming language LabVIEW uses data flow meaning that a node does not run until it has all of the data from previous nodes at its input wires A LabVIEW program consists of one or more virtual instruments VIs A VI is like a function or a procedure or a subroutine except that it has a richer interface National Instruments Corporation 45 FRC LabVIEW Mentor Training Hands On Seminar LabVIEW Programs Are Called Virtual Instruments VIs 3 Slide Example vi Each VI has 2 windows gt sien Front panel User interface UI Controls inputs Indicators outputs Block diagram e Graphical code Data travels on wires from controls through functions to indicators Blocks execute
48. build the array All values are placed in the array upon exiting the loop e Disable auto indexing if you are interested only in the final value National Instruments Corporation 105 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 in ComplexMatri Error In 3D ct Error Out 3D cti Drop it on the front panel NATIONAL ni com first INSTRUMENTS ni com To create an array control or indicator as shown select an array on the Controls Modern Array Matrix and Cluster palette place it on the front panel and drag a control or indicator into the array shell If you attempt to drag an invalid control or indicator such as an XY graph into the array shell you are unable to drop the control or indicator in the array shell You must insert an object in the array shell before you use the array on the block diagram Otherwise the array terminal appears black with an empty bracket FRC LabVIEW Mentor Training Hands On Seminar 106 ni com Create an Array Step 2 of 2 1 Place an array shell 2 Insert data type into the shell for example numeric control CIC OT IE ae e IE ee f7 NATIONAL ni com first INSTRUMENTS ni com To add dimensions to an array one at a time right click the index display and select Add Dimension from the shortcut menu You also can use the Positioning too
49. cal Resources Spotlights a Example Code Attend NIWeek 2005 Are You On A LabVIEW Application Notes Campus Learn more about p registration discounts and Find out if your campus Development Library 2 academic specific holds a LabVIEW site workshops license GO Learn More gt gt s Product Manuals s White Papers s Academic Resources a Technical Support Highlights Services and Training Lab Share a Training z mpilation of lab Tutorials E LabVIEW Interactive Training CD Courseware Community FRC LabVIEW Mentor Training Hands On Seminar 166 ni com
50. case the block diagram executes from left to right not because the objects are placed in that order but because one of the inputs of the Multiply function is not valid until the Add function has finished executing and passed the data to the Multiply function Remember that a node executes only when data is available at all of its input terminals and it supplies data to its output terminals only when it finishes execution In the second piece of code the Simulate Signal Express VI receives input from the controls and passes its result to the Graph You may consider the add multiply and the simulate signal code to co exist on the same block diagram in parallel This means that they will both begin executing at the same time and run independently of one another If the computer running this code had multiple processors these two pieces of code could run independently of one another each on its own processor without any additional coding FRC LabVIEW Mentor Training Hands On Seminar 54 ni com Data Types Found in LabVIEW x NATIONAL ni com first INSTRUMENTS ni com LabVIEW uses many common data types including Boolean numeric arrays strings and clusters The color and symbol of each terminal indicate the data type of the control or indicator Control terminals have a thicker border than indicator terminals Also arrows appear on front panel terminals to indicate whether the terminal is a control or an indicator An arrow appears on
51. code Please refer to usfirst org for current slot placement NI 9201 For connecting to sensors such as accelerometers gyros and so on NI 9403 For PWM encoders and so on NI 9472 Pneumatic relay for solenoids and relays National Instruments Corporation 19 FRC LabVIEW Mentor Training Hands On Seminar Easy to Program e Programmable in C Java and ARVIEN e Wireless debugging Laptop dashboard NATIONAL ni com first SENS ni com FRC LabVIEW Mentor Training Hands On Seminar 20 ni com Program Your Robot Stage 1 Stage 2 develop download 7 NATIONAL LEO SP instrumenrs ni com National Instruments Corporation 21 FRC LabVIEW Mentor Training Hands On Seminar b gt software Development Fundamentals NATIONAL instruments NATIONAL ni com first INSTRUMENTS ni com Software Development Fundamentals Coaching students to implement flowcharts or state transition diagrams to meet control application challenges FRC LabVIEW Mentor Training Hands On Seminar 22 ni com Software Development Method Define the problem scenario Design a flowchart algorithm Implement the design Test and verify the implementation Maintain and update the implementation NATIONAL ni com first INSTRUMENTS ni com Following a set of steps that has been refined over the years by software engineers can simplify solving problems using software The software development method is a strategy fo
52. d data to files and carry out any other tasks you d like before exiting You can close refnums opened earlier in your program but they will be cleaned up automatically anyway Left and Right Motors Stop all parallel loops exit program 5 21 DOOOO00 DFO OO OO OO OO OO O0 OO ON ON OC 2011 Robot Project lvproj RT CompactRIO Target 8 Close and save Finish VI Replace the Momentary Button With a Limit Switch 9 Open the Teleop SubVI to modify the code You can find Teleop vi in the Project Explorer for the FRC project created in Exercise 1 or in the Teleop Enabled case of the case structure from the Robot Main vi block diagram National Instruments Corporation 157 FRC LabVIEW Mentor Training Hands On Seminar 10 Remove the Button cluster Unbundle by Name function To delete it highlight it and press delete To remove broken wires press lt Ctrl B gt The Unbundle cluster you need to delete is circled below The code after the Button is removed is also shown below Left and Right Motors Arcade Drive 11 Place the DigitallnoutRefNum Registry Get VI may be called WPI DigitallnoutRefNum Registry Get vi to get the reference of the previously configured DIO in You can find this VI under the Functions palette in the WPI Robotics Library O Digital Input subpalette refnum name DigitallnputDevRef error in no error error out 12 You also need the DigitallnputGetValue VI to get the inpu
53. data at beginning of next iteration Loop Begins Iteration Iteration Iteration NATIONAL ni com Shift registers transfer data from one iteration to the next e Right click on the left or right side of a For Loop or a While Loop and select Add Shift Register e The right terminal stores data at the end of an iteration Data appears at the left terminal at the start of the next iteration e 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 Feedback Node See Help Search the LabVIEW Help for more information National Instruments Corporation 81 FRC LabVIEW Mentor Training Hands On Seminar Enum Sapien Appearance Data Type Display Format Edit Items Documentation Data Bi gt An enum represents a pair of values a string and a numeric where the enum can be one of a defined list of values A Digital Display 0 Items January February March April May June July August 7 NATIONAL _ ni com first D INSTRUMENTS ni com RTE FRC LabVIEW Mentor Training Hands On Seminar 82 ni com Enum Enum enumerated control constant or indicator Enums are useful beca
54. dragging it down Then click on the new block and select axis 3 throttle 20 Insert the ServoRefNumRegistry Get VI to get the servo reference and insert a ServoSetAngle VI to change the servo motor position You can find both of these Vis on the Functions WPI Robotics Library Actuators Servo palette as in steps 2 and 4 21 Wire the ServoRefNumRegistry Get and ServoSetAngle Vis together Then wire all the math functions numeric and string constants as shown below NOTE Remember you can create constants quickly by hovering the mouse over the input terminal and right clicking and selecting Create and then clicking Constant National Instruments Corporation 151 FRC LabVIEW Mentor Training Hands On Seminar Left and Right Motors axis ERA x seri axis 2 Te Arcade Drive Joystick 1 22 Close and save Teleop VI 23 Return to Robot Main and run it to test the code By moving the throttle input on the joystick the servo motor should spin END OF FRC EXERCISE 3 FRC LabVIEW Mentor Training Hands On Seminar 152 ni com Adding a Servo Motor review The value of the y axis ranges from 1 to 1 and the range of the servo angle is from 0 to 1 0 degrees Hence the formula is Throttle Input 1 85 Servo Angle National Instruments Corporation 153 FRC LabVIEW Mentor Training Hands On Seminar FRC Robot Exercise 4 Add a Digital Input as Limit Switch Tasks
55. e Drive Reference Get VI gets the drive reference previously created in the Begin VI by name and outputs a reference cluster to the Drive Reference Close VI The Drive Reference Close VI gets the reference cluster and closes the specific drive reference National Instruments Corporation 121 FRC LabVIEW Mentor Training Hands On Seminar FRC Robot Exercise 1 Configure and Deploy Project Tasks e Start a new FRC LabVIEW robot project e Get familiar with the FRC CompactRIO robot program structure e Deploy code to a CompactRIO target e Get familiar with the FRC Driver Station e Run Arcade Mode and Drive NATIONAL ni com first INSTRUMENTS ni com FRC LabVIEW Mentor Training Hands On Seminar 122 ni com FRC Robot Exercise 1 Configure and Deploy Project In this exercise configure and deploy a LabVIEW Project and run the FRC Driver Station to drive the robot in arcade mode 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 1 To start anew FRC LabVIEW project click FRC cRIO Robot Project on the left side of the Window DE Peles File Operate Tools Help El LabVIEW FRC Edition 2011 42 Getting Started Tutorials Tutorial 1 Setting up the cRIG Tutorial 2 Setting up the Axis Camera Tutorial 3 Setting up the Robot Radio
56. e a Simple LabVIEW VI 57 69 Optional Exercise 1 The LabVIEW Help System 70 Key Lab VIE WoSteuctires 10r FIRST ES nant den comen peine 71 ERG Visionand RO DOUCS epenn nn tn a ent deR F2 Customized Example FINE E dhnedindsaaee en me dde 73 PRO Speci Examples x2 ni ee ee der ee 2 oi Gr con ouest 74 ADN TE MW POIL annee nn dia rider nni one ecoute 19 Introduction to Clusters EE snan EEEE E ANE EAE TEN LUE EEEN NEET 76 77 MOOD Sic E E E ur A N E E TEE E E E EIEE EE EEE A 78 79 How Do I Make Decisions in LabVIEW 80 Shift Register Access Previous Loop Data cece cece eee eeennneeeennnaaaes 81 EOI PE nn ea A aad area De EL tee un E mann en 82 83 lea VIEW State MACHINE NS A et ce nd 84 85 LabVIEW Exercise 2 Controlling Program Execution 86 97 UN MING Se ne at PASE cn US EAEI de ue 98 CRC AUS SUDY nn te le bien mi dei co ea eet 99 Connector Pa and Icon VIe We noie nent init amount 100 leon Viewer Create A ICO RS ae en D ce 101 How Do LCM a O00 SN nl ee eee 102 Charts Add 1 Data Point at a Time With History cece eee e ee ennees 103 Graphs Display Many Data Points at Once 104 Building Arrays With Loops Auto Indexing 2 105 108 Prose ait ERC ROBOT di een aie Ad te Ru 109 Understanding Robot Mali tic en ns Nes ni cians iat an ee hes 110 113 PG SI D aeons ae aa 114 116 E EON Ronee ete d
57. e 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 e Example A Boolean input Simple if then case If the Boolean input is TRUE the true case executes otherwise the FALSE case executes e Example B Numeric input The input value determines which box to execute If out of range of the cases LabVIEW chooses the default case e 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 FRC LabVIEW Mentor Training Hands On Seminar 80 ni com Shift Register Access Previous Loop Data e Available at left or right border of loop structures e Right click the border and select Add Shift Register Right terminal stores data on completion of iteration Left terminal provides stored
58. 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 FRC LabVIEW Mentor Training Hands On Seminar 78 ni com Drawing a Loop 2 Enclose code to be repeated 1 Select the structure prenne ee z 3 Drop or drag additional nodes and eD 0 then wire H 1 p me p fed Tme gt FPGA btelee b Starechert NATIONAL ni com first INSTRUMENTS ni com 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 1f needed National Instruments Corporation 79 FRC LabVIEW Mentor Training Hands On Seminar How Do Make Decisions in LabVIEW 1 Case Structures 2 Select NATIONAL ni com first INSTRUMENTS ni com Case Structure The case structure has one or more subdiagrams or cases one of which executes when the structure executes The value wired to th
59. er Class amp Variant palette Then click Unbundle by Name Functions Qa Search Programming d loam gt A is ae a gI i el JERE Cluster Class amp Variant EE Ges gt i w _ Measurement O instrument VO 7 Vison and Motion Mathematics d p Segnal Processing nn Data Cormmuncahon us Connectivity Control Design amp Simulation SegnalExpress Express 3 Wire this to the button output of the Joystick Get If you are unsure where to wire open the Context Help Ctrl H and hover the mouse over the VI This shows where you can make all of the connections Button 1 is the trigger on the back of the joystick Button 1 now appears in the Unbundle by Name function Note the color of Button 1 is green because it is a Boolean True False value NOTE To add another button simply drag the bottom of the Unbundle by Name function to expand it To change the button left click and select the desired button For this exercise only one button is needed National Instruments Corporation 139 FRC LabVIEW Mentor Training Hands On Seminar axis 1 x axis 2 y lt lt Button 1 Button 1 lt Button 2 Button 3 Button 4 Button 5 Button 6 Rirttan 7 To perform an action based on the value of the button you need a case structure A case structure contains one or more subdiagrams or cases The value wired to the selector terminal determines whic
60. ere Localization Tester Docurnents LabVIEW j Data 2011 Robot Project CEEETEEEEETETEEETEEI he i a is E O Robot Framework 5 Click Finish when done 6 The Project Explorer opens after creating the new FRC robot project Note 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 7 To start modifying the robot code expand RT CompactRIO Target and double click Robot Main vi FRC LabVIEW Mentor Training Hands On Seminar 124 ni com e e ee a ae nee ces Took Window Help agal toxina eals Items Files Open Project E b Project 2011 Robot Project lvproj F gt My Computer Dependencies Build Specifications Br m RT CompactRIO Target 10 99 99 02 Hg TypeDefs GJ Team Code d Gi Vision meee Code Build Specifications 8 Now deploy the code to the robot You can run the Arcade Drive with the default FRC robot code provided Always run the Robot Main vi To deploy the code to a CompactRIO device click run in the top left corner of the Robot Main vi pe leq 2011 Robot Project lvproj R Robot Proj j RT Compa RIO Tare National Instruments Corporation 125 FRC LabVIEW Mentor Training Hands On Seminar The Deployment Progress Window should pop up as the codeisinitialized and downloaded to the CompactRIO controller Y
61. finally modifying the Finish SubVI to close the reference of the new switch device For your robot replace the joystick button used as a brake from the previous exercise with the limit switch BONUS Try to incorporate both the switch AND the limit switch as a brake for the robot Digital Input Initialization 1 Open the block diagram of Begin vi You can find Begin vi in the Project Explorer for the FRC project created in Exercise 1 or in the block diagram of Robot Main vi Digital input initialization is similar to servo initialization from the previous exercise 2 Insert the Digitallnput Open VI to configure the digital input To insert it right click on the block diagram click WPI Robotics Library click IO palette and then click Digital Input palette Select DigitallnputOpen VI and place it on the block diagram DIO Module Slot 4 DIO Channel error in no error DigitallnputDevRef error out 3 Place the DigitallnputRefNum Registry Set VI to register the digital input DigitallnputDevRef DigitallnputDevRef refnum name error out error in mo error 4 Create DIO Channel and refnum name constants and wire them as shown below Select DIO 4 from the pull down list DIO 1 3 are reserved for Infrared Sensors that can be used in the autonomous mode Wire together the reference and error clusters The Begin VI block diagram should resemble the image below with the added code circled National Ins
62. g Your Software a Using Help E LabVIEW Documentation Resou E Getting Started with LabVIEW E Fundamentals E VI and Function Reference E Property and Method Reference Taking Measurements Controlling Instruments ae ae E MathScipt RT Module ae EE ee EE Os Toolkits NI Device Drivers E important Information m Technical Support and Professio Ei NATIONAL 4 INSTRUMENTS LabVIEW Help June 2010 371561G 01 This help system includes information about LabVIEW programming concepts step by step instructions for using LabVIEW and reference information about LabVIEW Vis functions palettes menus and tools To navigate this help system use the Contents Index and Search tabs to the left of this window After you install a LabVIEW add on such as a toolkit module or driver the documentation for that add on appears in the LabVIEW Help or appears ina separate help system you access by selecting Help Add On Help where IT Add On Help is the name of the separate help system for the add on This help system links to Portable Document Format PDF versions of LabVIEW print documents You must have Adobe Reader installed to view or search the PDF versions of these manuals Refer to the Adobe Systems Incorporated Web site to download Adobe Reader Note Mac OS X National Instruments recommends that you use Safari 1 3 2 or later or Firefox 1 0 2 o
63. gned for measurement and automation applications which makes it an ideal tool for quickly converting your paper design to code Since a LabVIEW block diagram is similar to a flowchart moving from the flowchart to software code is a quick process FRC LabVIEW Mentor Training Hands On Seminar 26 ni com Sub Steps to Design a Flowchart List all your inputs outputs and additional requirements Define the possible states nodes and actions in each state Define your state node transitions Draw a flowchart linking the states nodes j NATIONAL ni com first T INSTRUMENTS ni com National Instruments Corporation 21 FRC LabVIEW Mentor Training Hands On Seminar Example Furnace Step 2 Design a Flowchart This application has the following additional requirements e The interior temperature must remain within a set range 70 75 F e The heater turns on when the temperature is less than 70 F and heats the room up until the temperature is 75 F e There is no AC to control based in cold climate NATIONAL ni com first INSTRUMENTS ni com Remember Sub Steps to Design a Flowchart I List all your inputs outputs and additional requirements 2 Define the possible states nodes and actions in each state 3 Define your state node transitions 4 Draw a flowchart linking the states nodes FRC LabVIEW Mentor Training Hands On Seminar 28 ni com Example Furnace Step 2 Design a Flowchart
64. h case to execute The value can be a string integer or enumerated type but it is most often a Boolean 4 To insert a case structure right click on the block diagram click Structure palette and then click Case Structure Click and drag on the block diagram to create the case structure 4 Functions G Search Programming j me R M Structures Case Structure Control Design amp Simulation SignalExpress Express Addons Favorites k User Libraries d Select a VI Real Time FPGA Interface k FIRST Vision k PID WPI Robotics Library FRC LabVIEW Mentor Training Hands On Seminar 140 ni com A default case structure has two cases True and False To change between subdiagrams click the arrows on the top of the case structure or select it from the pull down menu r r r r r A button has two states True for pressed and False for not pressed For a momentary stop button the motors should stop when Button 1 is true and keep running when Button 1 is false 5 Todo this in LabVIEW wire the output of Button 1 from the Unbundle by Name Function to the case selector on the left edge of the case structure rive Arcade Drive This allows the case structure to execute different code based on the Boolean value of Button 1 In the False Case when Button 1 is not pressed the motors should keep running Therefore the x and y axis values should go through t
65. he data allowing you to view intermediate values Click on the light bulb on the toolbar e 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 e Retain Wire Values Used with probes to view the values from the last iteration of the program e Breakpoint Set pauses at different locations on the diagram Click on wires or objects with the Breakpoint tool to set breakpoints FRC LabVIEW Mentor Training Hands On Seminar 52 ni com Context Help Window e Help Show Context Help or press lt Ctri H gt e Hover cursor over object to update window Additional Help Extract Single Tone Information vi Right click on the VI icon on a and choose Help or oran Ses fheasurement info Detailed Help highest Choose Detailed Help Takas a onan fnd the sige tne wth the bi anpltude on the context help window Oe NATIONAL ni com first INSTRUMENTS ni com tone frequency amplitude and phase The data type you wire Pi to the time signal in input determines the polymorphic instance oO use The Context Help window displays basic information about LabVIEW objects when you move the cursor over each object Objects with context help information include VIs functions constants structures palettes properties methods events and dialog box components To display the Context Help window select Help Show Context Help press the lt Ctrl
66. he case structure without any change 6 To wire the false case delete the x and y axis wires and rewire them to Arcade Drive through the case structure Note that the wires went through only the one visible case National Instruments Corporation 141 FRC LabVIEW Mentor Training Hands On Seminar Four blocks are created when you are wiring through the case structure The two blocks on the left of the case structure are where the wires go in and are called the input tunnels The two blocks on the right of the case structure are where the wires come out and are called the output tunnels In the True Case when Button 1 is pressed the motors should stop Therefore the x and y axis values that we send to the Robot Drive function should be zero To do this change to the True Case and wire a zero constant to the output tunnels 7 To insert a constant right click on one of the output tunnels click Create and then click Constant Note that you can reuse the constant for the second output tunnel Ex Wwe Arcade Drive eld True vp rreyerrrrrrr A momentary motor brake has now been created 8 Close and save Teleop VI 9 Return to Robot Main and deploy the code to test it out by click the Run button NOTE Remember the FRC Driver Station needs to be running END OF FRC EXERCISE 2 FRC LabVIEW Mentor Training Hands On Seminar 142 ni com Adding Joystick Controls Revie eIn the False Case when Button
67. ilt mini robots and laptops to learn about Software development fundamentals LabVIEW basics LabVIEW FRC program template and components Have fun NATIONAL ni com first INSTRUMENTS ni com National Instruments Corporation J FRC LabVIEW Mentor Training Hands On Seminar Agenda Half Day Schedule Overview of FIRST FRC and the FRC Control System Software Development Fundamentals Coaching students to implement flowcharts or state transition diagrams to meet control application challenges Introduction to NI LabVIEW Overview of the LabVIEW environment dataflow programming and common programming structures used in the FRC code template LabVIEW VIs for FRC Explore and program the robots using the FRC functions Additional Resources and Next Steps INSTRUMENTS ni com ni com first NS TRUME Please Note There are more exercises and background information than you can complete in a four hour period Mentors are encouraged to take the manual with them so they can review and complete additional optional exercises at their own pace FRC LabVIEW Mentor Training Hands On Seminar 4 ni com 2 Overview FIRST FRC and FRC Control System NATIONAL instruments 7 NATIONAL ni com first INSTRUMENTS ni co National Instruments Corporation 5 FRC LabVIEW Mentor Training Hands On Seminar Vision To transform our culture by creating a world where science and technology are celebrated and where
68. ise 2 Add Joystick Controls In this exercise modify code in the Teleop SubVI and add a joystick button to momentarily stop motors while driving This functionality will act like a brake in our robot code Use clusters and a case structure to implement this code Note Normally when adding a new device you need to open and close the references to this device in Begin VI and Finish VI This is shown in the following exercises In this case however the joystick has already been added to the code template by default so you need to modify only the code in the Teleop Vl 1 Open the block diagram of Teleop VI To do this select the Teleop Enabled case from the case structure on the Robot Main VI block diagram Then double click on the subVI named Teleop V I If Robot Main is not open you can also double click Teleop VI from the Project Explorer Window Once the VI is launched switch to the block diagram by selecting lt Ctrl E gt Ti Autonomous Enabled lt Teleop Enabled Autonomous Disabled Teleop Disabled Timeout Execute Teleop VI to react Finish to a new Driver Station packet 5 LL Start Robot Communication Runs in parallel with user code FRC LabVIEW Mentor Training Hands On Seminar 138 ni com To access data in a cluster you need to insert an Unbundle by Name Function 2 Todo this right click on the block diagram and from the Functions palette under Programming click the Clust
69. l to resize the index display until you have as many dimensions as you want 1D Array Viewing a Single Element National Instruments Corporation 107 FRC LabVIEW Mentor Training Hands On Seminar Using Arrays and Clusters With Graphs Pto aa The 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 2 ways Cluster relative time NATIONAL ni com first INSTRUMENTS ni com The waveform data type carries the data start time and At of a waveform You can create waveforms using the Build Waveform function Many of the VIs and functions you use to acquire or analyze waveforms accept and return the waveform data type by default When you wire a waveform data type to a waveform graph or chart the graph or chart automatically plots a waveform based on the data start time and Ax of the waveform When you wire an array of waveform data types to a waveform graph or chart the graph or chart automatically plots all of the waveforms Build Waveform Builds a waveform or modifies an existing waveform with the start time represented as an absolute timestamp Timestamps are accurate to real world time and date and Waveform Graphs ce are very useful for real world data recording Bundle Builds a waveform or modifies an existing waveform with a relative timestamp The input to t is a DBL By building waveforms using the
70. ld now resemble the following 43 Generate and Display LabVIEW Exercise 1 Create a Block Diagram File Edit View Project Operate Tools Window Help a n baal Waveform Graph x SR Operandi Operand 2 19 Switch to the front panel by pressing lt Ctrl E gt 20 Run the VI While running the VI you can change the Limit value by moving the slider or changing the digital display next to it Also notice that when a data point received from the Simulate Signal VI is greater than the Limit value the Alarm indicator lights up While the VI is still running switch to the block diagram by pressing lt Ctrl E gt Enable Highlight Xxecution by clicking the light bulb on the tool bar This slow the program and allows you to see the flow of data through your program 21 When you are finished stop the VI by clicking the STOP button on the front panel END LABVIEW EXERCISE 1 National Instruments Corporation 69 FRC LabVIEW Mentor Training Hands On Seminar Optional Exercise 1 The LabVIEW Help System The LabVIEW help system is a great place to learn about LabVIEW and visit when you have questions This exercise introduces you to this rich source of information 1 Go back to the VI you just created and press lt F1 gt on the keyboard to start the help system i 5 x T IL Contents index LabVIEW Help Finding Example Vis F Glossary E LabVIEW 2010 Features and Ch E Activatin
71. manual For more information on any of the listings in the New Dialog Box click the Help button in the lower right corner of the window National Instruments Corporation 59 FRC LabVIEW Mentor Training Hands On Seminar Create New Ee VI Je Blank VI We Polymorphic VI HHG From Template a DAQ A Data Acquisition with NI DAQmx wi EC Frameworks Design Patterns sn Master Slave Design Pattern i Producer Consumer Design Pattern Data tat Producer Consumer Design Pattern Events sn Queued Message Handler a Standard State Machine a User Interface Event Handler 89 Dialog Base Package 9 Dialog Using Events a Single Loop Application 4 Select VI gt From Template Tutorial Getting Started Generate and Display and click OK Use this template to generate a signal and display the generated data in a graph You can use this template with the exercises in the Getting Started with LabVIEW manual Note LabVIEW enables automatic error handling by ia SuhVtwith Error Handling default for Vis you create from this template Fig Top Level Application Using Events EH Instrument VO GPIB H Read and Display H Simulated Aan Generate and Display 1 Load from File and Display Addto project Two windows appear The gray window is the front panel and the white one is the block diagram The front panel contains the parts of your VI used for presenting information while interfacing with the user and the block di
72. modules and toolkits you have installed might create additional directories within the Labview directory Libraries user lib Directory in which you can save controls and VIs you create LabVIEW displays controls on User Controls palettes and VIs on User Libraries palettes This directory does not change if you upgrade or uninstall LabVIEW vi lib Contains libraries of built in VIs which LabVIEW displays in related groups on the Functions palette Do not save files in the vi _lib directory because LabVIEW overwrites these files when you upgrade or reinstall instz 1ib Contains instrument drivers used to control PXI VXI GPIB serial and computer based instruments When you install National Instruments instrument drivers and place them in this directory AHVIFW adds them ta the Instrument Drivers nalete 3 Take a few minutes to explore other topics in the help system 4 Click on the Search tab to try searching on analysis functions for features you might need in your work applications FRC LabVIEW Mentor Training Hands On Seminar 70 ni com Key LabVIEW Components for FIRST FRC Palettes Enums FRC Example Finder State Machines Project Explorer e Clusters e Loops Case Structure NATIONAL ni com first INSTRUMENTS ni com National Instruments Corporation 71 FRC LabVIEW Mentor Training Hands On Seminar FRC Vision and Robotics Palettes Vision manage and analyze images
73. mous Independent vi eIn 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 itis wired The second While Loop does not run until the first loop is finished NATIONAL ni com first INSTRUMENTS ni com In the first loop the code will turn the robot to the right for 1 second The loop iterates every 50 ms because of the wait ms function 50 ms 20 loops 1 second The loop will run 20 times because there is a comparison function attached to the iteration terminal 1 is added to the value of the iteration terminal because it begins counting at 0 When the While Loop has iterated 20 times the comparison function will output at true into the conditional terminal and will cause the program to exit the loop The Arcade Drive VI in the first loop turns the robot to the right The second loop is similar to the first loop but it will turn the robot to the left for 0 5 seconds The loop iterates every 50 ms due to the milliseconds to wait function and the loop will run 10 times for 0 5 seconds in total The Arcade Drive VI in the second loop turns the robot to the left The third loop stops the robot This loop is an infinite loop because it has a false value constant wired to the conditional terminal which causes the l
74. n the robot is ready to run e Select Teleoperated and then click Enable to start the robot ff FRC Driver Station Team 9999 Volts Communications Robot Code Stop Button No Robot Communication NATIONAL ni com first INSTRUMENTS ni com Review of LabVIEW FRC Robot Exercise 1 FRC LabVIEW Mentor Training Hands On Seminar 134 ni com Adding Joystick Controls Done within Teleop SubVI The RobotDriveRefNum Registry Get VI gets the reference and passes it to the Arcade Drive VI The JoystickRefNum Registry Get VI gets the reference and sends it to Joystick Get VI The JoystickGet VI gets the user input value of i aon the joystick axes and sends out a cluster Buttons The cluster is unbundled using the Unbundle by Name function to get the values of the x and y m axes values are sent to the Arcade Drive VI mgmt element m wy NATIONAL INSTRUMENTS ni com ni com first National Instruments Corporation 135 FRC LabVIEW Mentor Training Hands On Seminar Adding Joystick Controls pu Programming a Cluster Class amp Variant The JoystickGet VI outputs the values of the buttons m pa as a Button cluster SNE SRE an mt a Measurement O eTo access data in a cluster you need to insert an Instrument VO gy ER aay Vision and Motion Unbundle by Name function ARE D Signal Processing Data Communication eTo do this right click on the block diagram and click Connectivity Con
75. nds On Seminar Adding a New Device Every time you add a device for example a motor or joystick you must initialize open it in the Begin VI give it a name and you must also close this device in Finish VI e The device can then be communicated to in Teleop or Autonomous SubVIs eNote In the last exercise we didn t need to initialize or finish the joystick device when adding a button since this already done in the template provided i NATIONAL ni com first INSTRUMENTS ni com Think of this like a telephone conversation First you need to dial the phone number and say whom you wish to speak with This is the initialize stage in the Begin VI Next you talk back and forth back and forth This is done in the Teleop VI or Autonomous VI as the device joystick communicates to another device such as the motors This occurs over and over again as this code is called in a loop Finally you hang up and end the call This is the close resources and clean up stage in the Finish VI FRC LabVIEW Mentor Training Hands On Seminar 144 ni com FRC Robot Exercise 3 Add a Servo Motor Tasks e Initialize the new servo motor by modifying Begin VI e Modify the Teleop VI to use the joystick to move the new servo motor e Modify the Finish VI to close the reference of the new servo motor NATIONAL ni com first INSTRUMENTS ni com National Instruments Corporation 145 FRC LabVIEW Mentor Training Hands On Semina
76. nstant National Instruments Corporation 147 FRC LabVIEW Mentor Training Hands On Seminar 7 Wire the reference and error cluster between the ServoOpen VI and the Servo Reference Registry Set VI as shown below 8 Name the servo reference Servo To do this create a string constant wired into the Refnum Name Input of the Servo Reference Registry Set VI Do so by right clicking the Refnum Name input terminal and selecting create constant The block diagram to Begin VI should resemble the image below with the added code circled The labels under the Vis may not appear depending on your LabVIEW settings T3 Beginvi Block Diagram on 2011 Re File Edit View Project Operate Tools Window Help x a 2 S53 alte o3 UE Image Size Co Camera Address RightMotorinverted error out LeftMotorInverted rl Left Motofe PWMI1 Right Motogs PWM 2 This DIO code is to set up the IR sensors used in Autonomous Independent vi 9 Close and save Begin VI FRC LabVIEW Mentor Training Hands On Seminar 148 ni com Servo Reference Close Whenever a device is opened in the Begin vi it should also be closed in the Finish vi 10 Open the block diagram of the Finish vi You can find the Finish vi in the Project Explorer for the FRC project created in Exercise 1 or in the Finish case of the case structure from the block diagram of Robot Main vi 11 From the Servo palette insert a ServoRefNum Registr
77. ntor Training Hands On Seminar 46 ni com Controls Palette Controls and Indicators Controls Customize Control Palette Numeric View Indicator Numeric Slide i IONAL ni com first SP instrumenrs ni com Use the Controls palette to place controls and indicators on the front panel The Controls palette is available only on the front panel To view the palette select Window Show Controls Palette You also can display the Controls palette by right clicking an open area on the front panel Tack down the Controls palette by clicking the pushpin on the top left corner of the palette National Instruments Corporation 41 FRC LabVIEW Mentor Training Hands On Seminar Functions and Structures Palette FUM Uom w Place items on the Block Diagram Window Structure While Loop NATIONAL ni com first Pe instrumenrs ni com Use the Functions palette to build the block diagram The Functions palette is available only on the block diagram To view the palette select Window Show Functions Palette You also can display the Functions palette by right clicking an open area on the block diagram Tack down the Functions palette by clicking the pushpin on the top left corner of the palette FRC LabVIEW Mentor Training Hands On Seminar 48 ni com Types of Functions from the Functions Palette Express Vs Interactive Vis with configurable dialog page blue border xtract Single Tone Info
78. o 1000 as shown below and Run the VI Given that we have defined a loop rate of 0 01s how long do we expect the program to run TA Untitled 1 Block Diagram END LABVIEW EXERCISE 2 National Instruments Corporation 97 FRC LabVIEW Mentor Training Hands On Seminar Advanced For reference but not covered in hands on session NATIONAL ni com first INSTRUMENTS ni com Useful to know tools techniques and details Not covered in hands on session FRC LabVIEW Mentor Training Hands On Seminar 98 ni com Create SubV Enclose area to be converted into a subVI Select Edit Create SubVI from the Edit menu Slope Rise Run Fee PR A NATIONAL ni com first INSTRUMENTS ni com Creating SubVIs After you build a VI you can use it in another VI A VI called from the block diagram of another VI is called a subVI You can reuse a subVI in other VIs To create a subVI you need to build a connector pane and create an icon A subVI node corresponds to a subroutine call in text based programming languages A block diagram that contains several identical subVI nodes calls the same subVI several times The subVI controls and indicators receive data from and return data to the block diagram of the calling VI Click the Select a VI icon or text on the Functions palette navigate to and double click a VI and place the VI on a block diagram to create a subVI call to that VI You can easily customize subVI inpu
79. object return coin or object Try to explore other unconsidered scenarios with the students Another example what happens 1f the machine 1s out of Coke FRC LabVIEW Mentor Training Hands On Seminar 34 ni com Example Advanced Coke Machine Step 2 Design a Flowchart continued 3 Define your state node transitions Return Transition if the return change button pushed Quarter Dime Nickel Transition if the coin inserted is a quarter dime nickel Money lt 50 cents Transition to Wait for Event to wait for more money or for return change button to be pushed Money gt 50 cents Transition to Coke Product to issue a Coke if money is greater or equal to 50 cents Money gt 50 cents This transition is used after Coke is dispensed to determine if change should be returned Money 50 cents This transition is used after Coke is dispensed to determine if change should be returned 4 Draw a flowchart linking the states nodes NATIONAL ni com first 7 INSTRUMENTS ni com 3 Define your state node transitions Return Transition 1f the return change button pushed Quarter Dime Nickel Transition if the coin inserted is a quarter dime nickel Money lt 50 cents Transition to Wait for Event to wait for more money or for return change button to be pushed Money gt 50 cents Transition to Coke Product to issue a Coke if money is greater or equal to 50 cents Money
80. on as shown below Boolean a Scacchi amp Castornize J Or Array Ele El False Constant Num to Array Array to Num Bool to 0 1 gt Exclusive Or Mot Exclus Not gt gt Implies Compound Re FRERE National Instruments Corporation Waveform Chart 95 FRC LabVIEW Mentor Training Hands On Seminar 2 Next select the Greater function from the Programming gt gt Comparisons palette Equal Not Equal Ea p gt Equal To0 Not Equal To gt Select Max amp Min Decimal Digit Hex Digit Comparison L 3 Wire as shown below Delay Time 5 FRC LabVIEW Mentor Training Hands On Seminar Greater Than a In Range and Not Numb Octal Digit 96 Less Than 0 Printable gt E gt Greater Or E Less Or Equal W Greater Ore Less Y Tay Empty Array Empty String gt White Space Lexical Class PERRET Fixed Point Waveform Chart z ni com 4 Right click on the open terminal of the Greater block and select Create Constant FH Ce ce Re ce EE POO On or Or oF be cP aaa F 7 True ie 4 r 3 4 a Waveform Chart z Visible Items Help Examples Description and Tip Breakpoint Comparison Palette Numeric Palette Control Indicator Comparison Mode Properties 5 Change the constant t
81. oop to run forever The input values to the Arcade Drive VI are 0 which means the motors stand still National Instruments Corporation 119 FRC LabVIEW Mentor Training Hands On Seminar Finish vi Finish SubV is called before exiting So you can save data clean up I O and so on r 3 Finish vi Block Diagram on 2011 Robot Project Jvproj RT CompactRIO Target If a new device for example a joystick was added to Begin VI you must close this device in Finish VI NATIONAL ni com first INSTRUMENTS ni com 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 v1 FRC LabVIEW Mentor Training Hands On Seminar 120 ni com Close Motor Reference Within Finish VI 1 BE esos eTo close a motor reference use a Robot DriveRefNum Registry Get VI and a RobotDriveClose stone ES VI error in no error RobotDriveDevRef refnum name error in no error error out Follow a similar structure for other devices such as joysticks cameras and so on NATIONAL ni com first INSTRUMENTS ni com To close a motor reference use a Drive Reference Get VI Robot DriveRefNum Registry Get vi and a Drive Reference Close VI RobotDriveClose vi Th
82. orporation 33 FRC LabVIEW Mentor Training Hands On Seminar Example Advanced Coke Machine Step 2 Design a Flowchart continued 1 List all of your I O amp Requirements Inputs Quarters Nickels Dimes Return Change Button Outputs Coke Change 2 Define the possible states nodes and actions in each state Start Initialize Nothing happens Wait for event Quarter inserted Quarter counted Dime inserted Dime counted Nickel inserted Nickel counted Return change Change is returned Coke Product Release Coke can Finish End ni com first Be Dep nas ni com l List all of your inputs outputs and additional requirements Inputs Quarters Nickels Dimes Return Change Button Outputs Coke Change Requirements See above 2 Define the possible states nodes and actions in each state Start Initialize Nothing happens Wait for event Quarter inserted Quarter counted Dime inserted Dime counted Nickel inserted Nickel counted Return change Change is returned Coke Product Release Coke can Finish End The more states considered and added generally the more robust the program process will be In many cases additional states are added later during the code debug as scenarios not considered are encountered For example what happens if a damaged coin or fake coin is inserted The scenario state is not considered in this example but could be included with another state Unknown coin or
83. 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 lt Ctrl H gt Then hover over each function on the block diagram to see its name and description FRC LabVIEW Mentor Training Hands On Seminar 114 ni com Motor Configuration Within Begin vi e The green Booleans control the Right Motor Inverted orientation of the motors power a o Bs Right Motor ted error in no error fe error oie e The two blue enums correspond to the PWM output ports on the robot RightMotorinverted LeftMotorinverted Li Left Motote PWM 1 v Right Motofe PWM 2 initialize two motors y NATIONAL ni com first INSTRUMENTS ni com There are two green Boolean constants wired into the Open 2 Motor VI They control the orientation of the motors There are two blue parameters wired into Open 2 Motor VI PWM 1 and PWM 2 They correspond to the PWM output ports on the robot The Open 2 Motor VI outputs a reference cluster and an error cluster to the Motor Reference Registry Set VI The Open 2 Motors VI opens a reference to the robot drive for a two motor robot using Jaguar motor controllers National Instruments Corporation 115 FRC LabVIEW Mentor Training Hands On Seminar Motor Reference Registry Set Within Begin Vl The pink string refers to the refnum A H bk RobotDriveDevRef RobotDriveDevRef name given to the device
84. ou may also see a dialog box asking if you wish to save changes to certain Vis Should this occur click Save I Deployment Progress Deployment Status Initializing Deployment Progress Close on successful completion PET PRE PRET 9 Launch the FRC Driver Station Before running the Arcade Drive using the default FRC robot code you need to open the FRC Driver Station by clicking on the shortcut icon on the desktop FRC Driver Station The FRC Driver Station handles the communication between the computer and the robot The Dashboard will also launch with the FRC Driver Station Minimize the Dashboard window at this time 10 You need to configure FRC Driver Station to communicate to your robot Select the Setup tab and enter your team ID number Team ID 0001 is shown below FRC Driver Station Team 1 Volts Team Number Practice Round Timing seconds Joystick Setup drag to order Communications Countdown Teleoperated Robot Code Autonomous WET 6 7 Stop Button Choose NIC Delay Sound Effects No Robot 4 Local Dashboard Communication f Remote Dashboard 11 For normal operation the FRC robot kit contains a Stop Button that is connected to the computer via USB For the robots used in this training there are no USB Stop Buttons provided As such we need to override this safety feature Navigate to the Diagnostics tab and double click the text Stop Button listed under USB De
85. out FIRST and the FIRST family of programs please visit usfirst org Quick Facts m 501 c 3 not for profit public charity Founded 1989 by inventor Dean Kamen m Headquarters in Manchester NH a Board Chairman John Abele founder chairman of Boston Scientific 32 million operating budget m 3 000 corporate sponsors m 92 000 volunteers FRC LabVIEW Mentor Training Hands On Seminar 6 ni com FIRS T 3 rog ra m S FIRST Robotics Competition of Junior FIRSTLEGO League FIRST LEGO League Fr o N Grade Level er NATIONAL ni com first INSTRUMENTS ni com National Instruments Corporation 7 FRC LabVIEW Mentor Training Hands On Seminar Mission is to INSPIRE not EDUCATE BUT look at what Is involved FRC LabVIEW Mentor Training Hands On Seminar 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 NATIONAL ni com first INSTRUMENTS ni com ni com d Robotics ee FRC Combines the bte 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
86. ovide valuable one on one interaction Be respected and admired by team members Be inspired and energized through your participation 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 NATIONAL ni com first INSTRUMENTS ni com http usfirst org roboticsprograms coachesmentors National Instruments Corporation 13 FRC LabVIEW Mentor Training Hands On Seminar FRC Control System LabVIEW and CompactRIO Adoption of a Progressive Programming Platform 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 NATIONAL ni com first INSTRUMENTS ni com From the 2009 competition FIRST Robotics standardized on LabVIEW and CompactRIO for its next generation mobile device controller Impact of the Controller Next generation control system enables students to build more sophisticated robotics systems and meet more complex challenges Hands on learning helps connect theory and the real world Industry standard technology means students gain knowledge for university studies and professional careers FRC LabVIEW Mentor Training Hands On Seminar 14 ni com A Robotics Platform for All Ages Kindergarten through Rocket Science LabVIEW
87. owing new input state and action Emergency Stop Button input E Button Pressed state and Turn Off Heater and Finish action National Instruments Corporation 31 FRC LabVIEW Mentor Training Hands On Seminar Example Advanced Coke Machine Step 1 Define the Problem You need to design the control system that will be used inside of a Coke can vending machine You can assume that the Coke machine will be powered and adequately filled with Coke NATIONAL INSTRUMENTS ni com ni com first During the problem scenario stage of the software development method you define what your problem is so that you can approach it with all of the necessary factors identified You can remove extraneous factors during this phase and focus on the core problem that you must solve How you identify the problem initially can save you time while you design and implement a solution FRC LabVIEW Mentor Training Hands On Seminar 32 ni com Example Advanced Coke Machine Step 2 Design a Flowchart This application has the following requirements Can of Coke is sold for 50 cents The machine accepts only nickels dimes and quarters Exact change is not needed Change can be returned at anytime during the process of entering coins Only Coke is sold in machine no buttons to select other beverages and no Vend or Purchase button is needed 5 NATIONAL ni com first INSTRUMENTS ni com National Instruments C
88. p Axis Camera This setup is used to configure your Axis camera including the IP address Tools Options Use this for the myriad options on setting up LabVIEW customizing the environment to your liking and so on FRC LabVIEW Mentor Training Hands On Seminar 56 ni com LabVIEW Exercise 1 Create a Simple LabVIEW VI You will learn Howto work in the LabVIEW environment Create an application that Simulates data collection Turns on a front panel indicator when threshold is reached 2 NATIONAL ni com first INSTRUMENTS ni com National Instruments Corporation 57 FRC LabVIEW Mentor Training Hands On Seminar Exercise 1 Create a Simple LabVIEW VI Use this exercise to create a simple LabVIEW VI that simulates an analog signal and plots it on a waveform graph The VI tests the input values against a user specified limit and lights an LED if the input value exceeds that limit Below are pictures identifying each of the palettes found in LabVIEW to assist you as you complete these exercises Note LabVIEW has a built in Automatic Tool Selection feature that changes the behavior of the cursor depending on what type of object you are pointing at Controls A search gz vien Expres abc Mum Ctrls Buttons Text Ctrls H d a LEDs Text Inds Signal Manipu Exec Control Arith amp Compar H Favorites es Select a VI Graph Indicat Select a Control
89. r FRC Robot Exercise 3 Add a Servo Motor In this exercise add a new servo motor device to the project This is accomplished by initializing the new servo motor by modifying Begin SubVI modifying the Teleop SubVI to use the joystick to move the new servo motor and finally modifying the Finish SubVI to close the reference of the new servo motor Servo motors are often used to control robot arms and clamps Servo Initialization 1 Open the block diagram of the Begin vi Find the Begin vi in the Project Explorer for the FRC project created in Exercise 1 or in the block diagram of Robot Main vi 2 Use the ServoOpen VI to configure the servo To insert it right click on the block diagram click WPI Robotics Library then click Actuators palette and then click Servo palette 2 Functions Q Search Programming gt ca a Soh ae Po sett as Measurement 1 0 a Instrument IYO gt Vision and Motion Mathematics a Signal Processing d Data Communication d Connectivity Control Design amp Simulation P SignalExpress Express Addons gt Favorites User Libraries b Select a VI Real Time z FPGA Interface d FIRST Vision PID Wee Rotts ay e 1 WPI Robotics Library Actuators ROBOT eels ROBOT Gi ROBOT ps Rosor gt EEs J1 Fees nent ROEOT p ROBOT P Reor Cervo J VO a ct ics ROBOT ROBOT gt nono zias ROBOT gt ROBOT oT P Servo
90. r later to view the LabVIEW Hele i iniuwi Mationsl Toctmimante rornmmande that won nes 2 Expand Fundamentals LabVIEW Environment and explore the information available here look around and get a feel for how it is organized LabVIEW Help a Hl Hide Locate Contents index Search Favorites Organization of LabVIEW In This Topic E QQ Fundamentals QQ LabVIEW Environment A QQ Concepts 2 Getting Started Window Controls Palette 2 Functions Palette Searching in LabVIEW 2 Addons 2 Favorites 2 Tools Palette 2 Menus and Toolbars Context Help Window Project Explorer Window Navigation Window Organization of LabVIEW au User Controls Palette Navigating the Controls and Functions Palett _ Customizing Your Work Environment Securing the LabVIEW Environment f Organization of the LabVIEW Directory Structure Suggested Location for Saving Files This topic describes the structure of the LabVIEW file system and the suggested locations for saving files Organization of the LabVIEW Directory Structure This section describes the structure of the LabVIEW file system on Windows Mac OS X and Linux LabVIEW installs driver software for GPIB DAQ VISA IVI Motion Control and IMAQ hardware depending on platform availability The labview directory contains the following groupings after you complete the installation amp Note LabVIEW
91. r using LabVIEW to implement a software solution Use the software development method to create a solution to your problem In the software development method complete the following steps Define the problem scenario Design a flowchart algorithm Implement the design Test and verify the implementation Maintain and update the implementation Ar lS For more information on this process please visit http zone ni com devzone cda tut p id 10051 National Instruments Corporation 23 FRC LabVIEW Mentor Training Hands On Seminar Step 1 Define the Problem Define what your problem is so that you can approach it with all of the necessary factors identified Remove extraneous factors and note key assumptions How you identify the problem initially can save you time while you design and implement a solution 3 NATIONAL ni com first INSTRUMENTS n com During the problem scenario stage of the software development method you define what your problem is so that you can approach it with all of the necessary factors identified You can remove extraneous factors during this phase and focus on the core problem that you must solve How you identify the problem initially can save you time while you design and implement a solution FRC LabVIEW Mentor Training Hands On Seminar 24 ni com Example Furnace Step 1 Define the Problem You need to design a furnace system to keep a building within a comfortable temperature
92. refnums opened earlier in but th ill be cl d no sais Se ae Left and Right Motors Stop all parallel loops exit program 2011 Robot Project lvproj RT CompactRIO Target lt 15 Close and save Finish VI Move Servo 16 Open the Teleop SubVI to modify the code You can find Teleop vi in the Project Explorer for the FRC project created in Exercise 1 or in the Teleop Enabled case of the case structure from the block diagram of Robot Main vi First you need to convert the throttle axis value to a servo angle The throttle is the round control at the base of the joystick between buttons 8 and 9 The value of the throttle ranges from 1 to 1 and the range of the servo angle ranges from 0 to 170 degrees Therefore the formula is Throttle User Input 1 85 Servo Angle 17 To access math functions in LabVIEW right click on the block diagram and click the Numeric palette FRC LabVIEW Mentor Training Hands On Seminar 150 ni com 2 Functions Q Search Seis gt Measurement VO i gt i gt gt Instrument 1 0 R gt gt R gt gt gt Vision and Motion Mathematics Kz Fe Signal Processing ae 3 _ kod vr BvY VUE Data Communication Connectivity Content Necian Simulatinn gt a j a 18 Since the Add and Multiply functions are used in the equation insert them into the block diagram from the Numeric palette 19 Expand the axis cluster Unbundle by Name function by
93. rior Performance Enhanced Processing 400 MHz PowerPC industrial real time processor 64 MB DRAM memory 128 MB flash storage Embedded for reliable autonomous Rugged 50g shock rating 2010 55 C 802 11 Wireless Ethernet e Dual 10 100 Mbit s Ethernet ports e Programmatic communication over wireless network operation NATIONAL INSTRUMENTS ni com ni com first Benefits of the FIRST CompactRIO Controller Students can build sophisticated robotics systems Improved autonomous performance Advanced vision capabilities Multiple sensor choices Intuitive graphical LabVIEW software development will increase participation in autonomous programming Industry standard technology means students gain knowledge for university studies and professional careers FRC LabVIEW Mentor Training Hands On Seminar 18 ni com Flexible Inputs and Outputs ___NI9472 Digital I O Riese 40 TAN 8 channel digital O a e 6 to 36 V output range eyetatenetertyte DST ER te Pneumatics relays and solenoids NI 9201 Analog Input x2 NI 9403 Digital 1 0 x2 8 analog inputs 32 channel digital I O e 10 V input range 5 VITTL sinking sourcing digital I O Sensors accelerometers gyros and so on SPW motor control encoders NATIONAL ni com first SE instruments ni com Note Modules must be in the same slots in which they shipped for them to work with the FRC LabVIEW
94. rmation vi Functions Fundamental operating elements of LabVIEW no front panel or block diagram yellow Multiply NATIONAL ni com first INSTRUMENTS ni com Express VIs are interactive VIs that have a configuration dialog box that helps the user customize the functionality of the Express VI LabVIEW then generates a subVI based on these settings SubVIs are VIs consisting of a front panel and a block diagram that are used within another VI Functions are the building blocks of all VIs Functions do not have a front panel or a block diagram National Instruments Corporation 49 FRC LabVIEW Mentor Training Hands On Seminar Tools Palette Recommended Automatic Selection Tool _ Tools to operate and modify both front panel and block diagram objects gt lt Automatic Selection Tool Automatically chooses among the following tools ty Operating Tool R Positioning Resizing Tool A Labeling Tool Wiring Tool NATIONAL ni com first INSTRUMENTS ni com If you enable the automatic selection tool and you move the cursor over objects on the front panel or block diagram LabVIEW automatically selects the corresponding tool from the Tools palette Toggle the automatic selection tool by clicking the Automatic Selection Tool button in the Tools palette Use the Operating Tool to change the values of a control or select the text within a control Use the Positioning Tool to select move or resize objects The
95. sabled 5 Vision vi A parallel loop that acquires and processes camera images 6 PeriodicTasks vi Parallel loops running at user defined rates 7 Finish vi Called before exiting so you can save data clean up I O etc 8 Build DashBoard Data vi Called for each driver station packet including timeouts It 1s used to send select I O values back to the Dashboard National Instruments Corporation 111 FRC LabVIEW Mentor Training Hands On Seminar Dataflow Programming 3 Robot Main vi Block Diagram on 2011 Robot Project ivproj RT CompactRIO Target File Edit View Project Operate Tools Window Help as 2 es bal 0 15pt Application Font i Robot Main implements the framework and scheduler for your robotics program Enable Vision It should not be necessary to modify this VL You should be able to code your robot Image Size EE image size within the Team Vis described below 1 Begin vi Called once at beginning to open I O initialize sensors and any globals load settings from a file etc 2 Autonomous Independent vi Automatically started with the first packet of autonomous and aborted on the last packet Write this Team VI to loop for the entirety of the autonomous period lt yo ce a 3 TeleOp vi amp initialize robot Called each time a teleop DS packet is received and robot is enabled 4 Disabled vi Called each time a packet is received and the robot is disabled
96. shown below Push Button Rocker Q gt Round LED Horizontal T Square LED Slide Switch Vertical Slide DE CANCEL STOF OK Button Cancel Button Stop Button om a Radio Buttons 9 Your front panel should look like the following 4 Untitled 1 Front Panel File Edit View Project Operate Tools Window Help sp an 15pt Application Font 4 Boolean National Instruments Corporation 91 FRC LabVIEW Mentor Training Hands On Seminar 10 Switch back to the block diagram and wire the toggle switch to the case selector input of the case structure as shown below Also wire the Numeric Constant and Random Number VI to the Waveform Chart as shown Boolean FRC LabVIEW Mentor Training Hands On Seminar 92 ni com 11 Next add a time delay to slow the execution of the loop Without this delay the loop runs much faster than our eyes can follow and takes up a lot of the PC s processing power for no good reason On the Functions palette navigate to Express Execution Control Time Delay and drop the time delay within the While Loop but outside the case structure 1 Functions a Search Programming eee Measure ment vo Instrument VO Vision and Motion Mathematics Signal Processing Data Communication Connectivity Control Design amp Simulation Express Addons Favorites User Libraries Select a VI Real Time FPGA In
97. son O Not Equal Greater gt Greater Or Less Or i Favorites k User Libraries 66 ni com When you place the Comparison Express VI on the block diagram a dialog box appears that you can use to configure which type of comparison you want to implement Make the following selections and then click OK to apply these changes and to close the dialog box Compare Condition Greater Comparison Inputs Compare to second signal input 4 3 Configure Comparison Comparison Items to Compare Data points Compare Condition econd signal input lt gt Not equal amp _ Value Greater D Equal O gt Greater or equal Li Less _ lt Less or equal O Equal within tolerance Tolerance In range Minimum _ Out of range Maximum 1 Result One result per data point Invert result Amplitude _ One result per channel i One result for all channels V Change Express VI name to name of function National Instruments Corporation 67 Cancel FRC LabVIEW Mentor Training Hands On Seminar 15 You can connect controls functions and indicators on the block diagram by pointing to an object and clicking it when the cursor changes to a spool of wire You can then move the cursor to the object you want to connect it to and click again Connect the Limit control to the
98. t and output terminals as well as the icon Follow the instructions below to quickly create a subVI Creating SubVIs From Sections of a VI Convert a section of a VI into a subVI by using the Positioning tool to select the section of the block diagram you want to reuse and by selecting Edit Create SubVI An icon for the new subVI replaces the selected section of the block diagram LabVIEW creates controls and indicators for the new subVI automatically configures the connector pane based on the number of control and indicator terminals you selected and wires the subVT to the existing wires See Help Search the LabVIEW Help SubVIs for more information National Instruments Corporation 99 FRC LabVIEW Mentor Training Hands On Seminar Connector Pane and Icon Viewer e Use this connector pane layout as a standard e Top terminals are usually reserved for file paths and references such as a file reference Bottom terminals are usually reserved for error Clusters Path In Path Out Inputs Outputs eror in no error error out E EA S NATIONAL ni com first INSTRUMENTS ni com With the connector pane and icon viewer you can define the data being transferred in and out of the subVI as well as its appearance in the main LabVIEW code Every VI displays an icon in the upper right corner of the front panel and block diagram windows After you build a VI build the connector pane and icon so you can use the VI as a subVI
99. t the period you specify Use the Timed Loop when you want to develop VIs with multirate timing capabilities precise timing feedback on loop execution timing characteristics that change dynamically or several levels of execution priority Double click the Input Node or right click the Input Node and select Configure Timed Loop from the shortcut menu to display the Loop Configuration dialog box where you can configure the Timed Loop The values you enter in the Loop Configuration dialog box appear as options in the Input Node A Wait Until Next ms Multiple UE Waits until the value of the millisecond timer becomes a multiple of the specified millisecond multiple Use this function to synchronize activities You can call this function in a loop to control the loop execution rate However it is possible that the first loop period might be short This function makes asynchronous system calls but the nodes themselves function synchronously Therefore it does not complete execution until the specified time has elapsed Functions Programming Timing Wait Until Next ms Multiple FRC LabVIEW Mentor Training Hands On Seminar 102 ni com Charts Add 1 Data Point at a Time With History Waveform chart Special numeric indicator that can display SS a history of values I Chart updates with each point it receives Controls Express Graph Indicators Chart Tl NIE i ul Hi hy Nk I NATIONAL ni com first INSTRUMENTS ni com
100. t value You can find this VI in the same digital input subpalette as the previous step Select the DigitallnputGetValue VI and place it on the block diagram to the left of the case structure DigitallnputDevRef DigitallnputDevRet Value error in no error error out 13 Create a Refnum Name constant and connect the reference cluster to the DigitallnputGetValue VI Wire the Boolean output from DigitallnputGetValue VI to Case Structure Case Selector The Teleop VI block diagram should resemble the image below FRC LabVIEW Mentor Training Hands On Seminar 158 ni com 14 Reverse the logic In the case of this 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 Since you want the robot to stop when the limit switch is pressed similar to what occurred when pushing the joystick button in the previous exercise you need to invert the logic of the limit switch Make True gt False and False gt True You can choose from a few options to accomplish this If you plan to attempt the BONUS step jump to Method 2 Method 1 You can swap the code in the case structure by right clicking the border of the case structure and selecting Make this case True or Make this case False The end result is shown below Notice the False case now forces the motors to 0 Left and Right Motors Drive National Instruments Corporation 159
101. terface FIRST Vision PID Real Time WPI Robotics Library d S LE Input 1 Execution Control Signal Analysis Output Sig Manip x 1 Execution Control LL Flat Sequence Case Structure The Time Delay Express VI opens the following dialog box Set the time delay to 0 01 s so the loop runs 100 times per second Press OK National Instruments Corporation 93 FRC LabVIEW Mentor Training Hands On Seminar 12 Your block diagram should resemble the one below Waveform Chart stop stor Ht a 13 You are ready to test your VI by running the program and switching the toggle switch back and forth You should see the graph switch between a random and constant number on the chart HINT After running the program with the toggle in the off position right click the Waveform Chart from the front panel and deselect the AutoScale Y option This stops the chart from autoscaling back and forth when the toggle is selected Waveform Chan Pit ES 0 8 Marker Spacing d 0 0 0 Formatting 0 Style gt Mapping d AutoScale Y lt Loose Fit FRC LabVIEW Mentor Training Hands On Seminar 94 ni com Extra Challenge Add logic to the VI so it stops either when you press the STOP button or when the loop iterations have exceeded 1 000 1 Do this by inserting an Or function from the Boolean palette before the STOP butt
102. the last packet Write this Team VI to loop for the entirety of the autonomous period Execute Telegp VI to react to a new Dgver Station packet Create VO refnums E 3 Teleopvi Called each time a teleop DS packet is qe received and robot is enabled Image Size Ec Disabled vi Called each time a packet is received and he robot is disabled 5 Vision vi A parallel loop that acquires and processes camera images 6 PeriodicTasks vi Case Structure Parallel loops running at user defined rates 7 Finish vi While Loop Called before exiting so you can save data clean up VO etc Acquire camera images and process them in parallel with 8 Build DashBoard Data vi einer Weep Sequence Structure 2011 Robot Project lvproj RT CormpactRIO Target i Robot Main implements the framework and scheduler for your robotics program It should not be necessary to modify this VI You should be able to code your robot within the Team VIs described below 1 Begin vi Called once at beginning to open I O initialize sensors and any globals load settings from a file and so on 2 Autonomous Independent vi Automatically started with the first packet of autonomous and aborted on the last packet Write this Team VI to loop for the entirety of the autonomous period 3 TeleOp vi Called each time a teleop DS packet is received and robot is enabled 4 Disabled vi Called each time a packet is received and the robot is di
103. the logic of which signal 1s output and a While Loop to keep the application running until a Stop button is pressed 1 Create a New Blank VI from the File menu 2 Start by placing a While Loop on the block diagram Draw it large enough to accommodate the other code you will place inside it You can locate the While Loop on the Express Execution Control palette as shown below Note Creating a while loop from the Execution Control Express Palette auto generated the STOP button Execution Control Sh Customize Flat Sequence Case Structure 5 Time Delay Elapsed Time National Instruments Corporation 87 FRC LabVIEW Mentor Training Hands On Seminar 3 Next select the Case Structure from the same palette and place it inside the While Loop as shown below Execution Control While Loop Flat Sequence Vase Structure Time Delay Elapsed Time 4 Untitled 2 Block Diagn File Edit View Project Operate Tools Window Help a iz m Lo F oat 15pt Application Font 4 Then add the Random Number Generator to the True case of the case structure On the Functions Palette navigate to Programming Numeric select Random Number 0 1 as shown below and place it inside the True case statement Note that the Random Number function disappears as it is contained inside the True case It is still present in the Block Diagram but the case structure only shows one case statement at a
104. the right if the terminal is a control and on the left if the terminal is an indicator Definitions e Array Arrays group data elements of the same type An array consists of elements and dimensions Elements are the data that make up the array and a dimension is the length height or depth of an array An array can have one or more dimensions and as many as 2 1 elements per dimension memory permitting e Cluster Clusters group data elements of mixed types such as a bundle of wires in a telephone cable where each wire in the cable represents a different element of the cluster See Help Search the LabVIEW Help for more information The LabVIEW User Manual on ni com provides additional references for data types found in LabVIEW National Instruments Corporation 55 FRC LabVIEW Mentor Training Hands On Seminar LabVIEW Shortcuts and Tools Ctri R Run the VI Ctrl E Swap between front panel and block diagram Ctri 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 NATIONAL ni com first INSTRUMENTS ni com View Navigation Window or Ctrl Shift N The navigation window can help you navigate through your program if you have a large block diagram Tools CompactRIO Imaging Tool This is how to get to the Imaging Tool to update the firmware on your cRIO FRC Tools Setu
105. time FRC LabVIEW Mentor Training Hands On Seminar 88 ni com 4 Functions Program ming Des l O Instrument 1 0 Vision and Motion Mathematics Signal Processing Data Communication Connectivity Fenress Control Design amp Simulation F gt gt gt EEE gt p gt b gt PP gt bb BP Den Ee 5 Next switch the case statement from True to False as shown below 6 Now add the Numeric Constant to the False case of the case structure On the Functions Palette navigate to Programming Numerie select Numeric Constant as shown below and place it inside the False case statement National Instruments Corporation 89 FRC LabVIEW Mentor Training Hands On Seminar 4 Functions Search Programming foal ages 1 Numeric euro Measurement VO Instrument 1 0 Vision and Motion Mathematics Signal Processing Data Communication Connectivity Control Design amp Simulation Fxnrese d 7 Switch to your front panel Ctrl E and place a Waveform Chart as shown below Graph past LE Ex XY Graph ri 1 Y CCC F Digital Wave Mixed Signal Feather Plot XY Plot Matrix D Controls 3D Picture 3D Graph FRC LabVIEW Mentor Training Hands On Seminar 90 ni com 8 Also add a vertical toggle switch from the Boolean palette to the front panel as
106. tion 1 FRC LabVIEW Mentor Training Hands On Seminar FRC LabVIEW Mentor Training Hands On Seminar National Instruments NATIONAL ni com first INSTRUMENTS ni com FIRST AND FRC For Inspiration and Recognition of Science and Technology FIRST is a not for profit organization whose mission is to 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 FIRST Robotics Competition FRC combines the excitement of sport with the rigors of science and technology Under strict rules limited resources and time limits teams of 25 students or more are challenged to raise funds design a team brand hone teamwork skills and build and program a robot to perform prescribed tasks against a field of competitors It s as close to real world engineering that a student can get Grades 9 12 Ages 14 18 For the 2010 2011 season 22 475 teams comprising 248 000 students and over 66 000 mentors participated in FIRST programs To learn more about FIRST and the FIRST family of programs please visit usfirst org FRC LabVIEW Mentor Training Hands On Seminar 2 ni com Objective To help recruit train and prepare mentors for the software development aspect of the FRC e Mentors work with FRC pre bu
107. to its block diagram This is the code that reads the joystick and makes the robot move in Arcade Drive National Instruments Corporation 117 FRC LabVIEW Mentor Training Hands On Seminar Autonomous Independent vi e The Autonomous Independent vi is automatically started when the autonomous mode begins and automatically ended when the autonomous mode ends e This is where the code executed during autonomous mode is contained NATIONAL ni com first INSTRUMENTS ni com Autonomous mode is an Independent SubVI that gets launched whenever the robot driver station instructs the robot to go into autonomous mode Unlike the Teleop VI the autonomous independent VI actually runs once but lasts for several seconds It does not run over and over again Therefore the Autonomous Independent SubVI is not included in the main loop To access the Autonomous Independent SubVI double click on the SubVI reference icon in the Robot Main vi Switch to the block diagram of the Autonomous Independent SubVI by pressing lt Ctrl E gt On the left of the block diagram there are Driver Station SubVIs that provide data on driver position alliance color digital switch settings and analog voltages The main code is disabled to prevent unexpected execution in Autonomous mode To enable this code right click on the edge of the frame and choose Enable This Subdiagram FRC LabVIEW Mentor Training Hands On Seminar 118 ni com Autono
108. trol Design amp Simulation the Cluster Class amp Variant palette Then click PEA Unbundle by Name and wire this up to the button output Express of the Joystick Get VI an User Libraries Select a VI Real Time FPGA Interface FIRST Vision PID WPI Robotics Library i NATIONAL ni com first INSTRUMENTS ni com Review Key LabVIEW Structures for FIRST From Introduction to NI LabVIEW Section The JoystickGet 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 amp Variant palette Then click Unbundle by Name Wire this up to the button output of the Joystick Get Button 1 now appears in the Unbundle by Name function Note the color of Button 1 is green because it is a Boolean value To add a button simply drag the bottom of the Unbundle by Name function to expand it To change the button simply click and select the desired button FRC LabVIEW Mentor Training Hands On Seminar 136 ni com FRC Robot Exercise 2 Add Joystick Controls Tasks e Modify code in Teleop VI e Add joystick button to momentarily stop motors e Implement decision making with case structure e Extract value from cluster read from joystick NATIONAL ni com first INSTRUMENTS ni com National Instruments Corporation 137 FRC LabVIEW Mentor Training Hands On Seminar FRC Robot Exerc
109. truments Corporation 155 FRC LabVIEW Mentor Training Hands On Seminar i gt j a en phe ee SL ee eS Gus A ey AP Begin vi Block D agram on ZULL KODO F oject lv Drop RI Compact target File Edit View Project Operate Tools Window Help Ln 2 L ballt Camera Address 192 168 0 90 RightMotorinverted 14 r LeftMotorinverted TH fevereerye eet i f error out bso E This DIO code is to set up the IR sensors used in Autonomous ndependent vi 2011 Robot Project lvproj RT CompactRIO Target Ti t Digital Input Reference Close 5 Open the Finish VI block diagram The digital input reference close is similar to the servo reference close 6 Place the DigitallnputRefNum Registry Get and the DigitallnputClose Vis on the block diagram of Finish VI FRC LabVIEW Mentor Training Hands On Seminar 156 ni com refnum name DigitallnputDevRef error in no error error out DigitallnputDevRef error in no error error out 7 Wire a string constant to the Refnum Name input and then wire the reference clusters together Digital Input ke ER fF The Finish VI block diagram should resemble the image below with the added code circled Finish vi Block Diagram on 2011 Robot Project ivpro RT CompactRIO Target gt E S r File Edit View Project Operate Tools Window Help y i a n eleka The robot controller program is about to finish Save collecte
110. unning VI When you click the Pause button LabVIEW highlights on the block diagram the location where you paused execution Click the Pause button again to continue running the VI Select the Text Settings pull down menu to change the font settings for the VI including size style and color Select the Align Objects pull down menu to align objects along axes including vertical top edge left and so on Select the Distribute Objects pull down menu to space objects evenly including gaps compression and so on Select the Resize Objects pull down menu to change the width and height of front panel objects National Instruments Corporation 51 FRC LabVIEW Mentor Training Hands On Seminar Debugging Techniques e Finding Errors Click on broken Run button Window showing error appears e Execution Highlighting QI Click on Execution Highlighting button data flow is animated using bubbles Values are displayed on wires Probes 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 NATIONAL INSTRUMENTS ni com ni com first When your VI is not executable a broken arrow is displayed in the Run button in the palette e Finding Errors To list errors click on the broken arrow To locate the bad object click on the error message e Execution Highlighting Animates the diagram and traces the flow of t
111. use it is easier to manipulate numbers than strings on the block diagram ni com first INSTRUMENTS ni com Text appears on the front panel control but the terminal on the block diagram sends out a numeric value which can be move easy to manipulate Feedback Node National Instruments Corporation 83 FRC LabVIEW Mentor Training Hands On Seminar LabVIEW State Machine A state machine consists of a set of states and a transition function that maps to the next state While Loop Start Defaut gt State Transition Functionality Code Code Case Structure 7 NATIONAL ni comfirst INSTRUMENTS ni com One of the most important decision making structures in LabVIEW is the case structure The case structure enables you to encapsulate sections of code so they run only when a specific condition that you control occurs The case structure changes states based on its input value For example you might have three states defined in your program initialize collect data and report data The code for these different states would reside within the boundaries of the case structure and you would switch between the states with either buttons on a front panel or some combination of logic built into your LabVIEW application FRC LabVIEW Mentor Training Hands On Seminar 84 ni com LabVIEW State Machine A state machine consists of a set of states and a transition function that maps to the next state While Loop C
112. vices FRC LabVIEW Mentor Training Hands On Seminar 126 ni com FRC Driver Station Team 1 Volts 12 32 Communications Robot Code Stop Button No Stop Button USB Devices Communications Joystick 1 Enet Link Joystick 2 DS Radio Joystick 3 Bridge GLS ER Robot Stop Button FMS yu n assages DS Version 02 27 11 00 cRIO Image LabVIEW 2011_ v28 Clear Errors View Log File Reboot Robot A small dialog window will pop up verifying the safety override changes Select Yes PII be careful Do you really want to drive the robot without a Stop button After a 20 second delay the changes to bypass the Stop Button will have been enabled The FRC Driver Station light associated to the Stop button on the far left should now be orange in color ee ne eee Team 1 Volts 12 32 Communications Robot Code itop Button Teleoperated Disabled USB Devices Communications Joystick 1 Enet Link Joystick 2 DS Radio Joystick 3 Bridge Joystick 4 Robot Stop Button FMS 1 0 Messages DS Version 02 27 11 00 cRIO Image LabVIEW 2011 v28 Clear Errors View Log File Reboot Robot 12 When the lights of the Communications and Robot Code turn green and the light of the Stop Button turns orange or green if a USB Stop Button is connected the robot is ready to run 13 From the Operation tab select Teleoperated and then click Enable to start the robot
113. y Get VI to get the reference of the previously configured servo Note that you can find the palette in the same location as steps 2 and 4 ServoDeviceRef refnum name error in no error error out HINT If you need more room on the Finish vi block diagram try holding down the Ctrl key on the keyboard while selecting a portion of the screen with the mouse This pushes out the block diagram relative to the size of the box you created with the mouse 12 Create a string constant on the Refnum Name input and type in the name of the device This was Servo or the name you used in step 8 13 Place a ServoClose VI to close the reference of the servo MotorControlDevRef Gare error in no error error out 14 Wire the reference cluster from the Servo Reference Get VI to the Servo Reference Close VI The Finish VI block diagram should resemble the image below with the added code circled The labels under the Vis may not appear depending on your LabVIEW settings National Instruments Corporation 149 FRC LabVIEW Mentor Training Hands On Seminar 44 Finish vi Block Diagram on 2011 Robot Project lvproj RT CompactRIO Target ee 2 till te ss mm te File Edit View Project Operate Tools Window Help Bel m 2 23 bales eee The robot controller program is about to finish Joystick 1 Save collected data to files and carry out Joystick any other tasks you d like before exiting You can close
114. young people dream of becoming science and technology heroes Dean Kamen Founder Mission To 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 7 NATIONAL ALERTE INSTRUMENTS ni com FIRST AND FRC For Inspiration and Recognition of Science and Technology FIRST is a not for profit organization whose mission is to 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 FIRST Robotics Competition FRC combines the excitement of sport with the rigors of science and technology Under strict rules limited resources and time limits teams of 25 students or more are challenged to raise funds design a team brand hone teamwork skills and build and program a robot to perform prescribed tasks against a field of competitors It s as close to real world engineering that a student can get Grades 9 12 Ages 14 18 For the 2010 2011 season 22 475 teams comprising 248 000 students and over 66 000 mentors participated in FIRST programs To learn more ab
Download Pdf Manuals
Related Search
Related Contents
Model 3130 User`s Manual SporstFit - Protega Mayorista Ver ficha técnica - Protege y Decora AURORA Samsung SP-M221 Instrukcja obsługi CKSTSKSH12 Sartén eléctrico Lincoln Electric KH825-01 Use and Care Manual ENCORE ENUBT-C2 Toastmaster TECC 4224 User's Manual User Guide - Melbourne locksmith Copyright © All rights reserved.
Failed to retrieve file