Getting Started with NI LabVIEW for...

31
LabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST Tech Challenge Software June 2010 372580E-01

Transcript of Getting Started with NI LabVIEW for...

Page 1: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

LabVIEWTM

Getting Started with NI LabVIEW for FTC

Getting Started with the FIRST Tech Challenge Software

June 2010372580E-01

Page 2: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Support

Worldwide Technical Support and Product Information

ni.com

National Instruments Corporate Headquarters

11500 North Mopac Expressway Austin, Texas 78759-3504 USA Tel: 512 683 0100

Worldwide Offices

Australia 1800 300 800, Austria 43 662 457990-0, Belgium 32 (0) 2 757 0020, Brazil 55 11 3262 3599, Canada 800 433 3488, China 86 21 5050 9800, Czech Republic 420 224 235 774, Denmark 45 45 76 26 00, Finland 358 (0) 9 725 72511, France 01 57 66 24 24, Germany 49 89 7413130, India 91 80 41190000, Israel 972 3 6393737, Italy 39 02 41309277, Japan 0120-527196, Korea 82 02 3451 3400, Lebanon 961 (0) 1 33 28 28, Malaysia 1800 887710, Mexico 01 800 010 0793, Netherlands 31 (0) 348 433 466, New Zealand 0800 553 322, Norway 47 (0) 66 90 76 60, Poland 48 22 328 90 10, Portugal 351 210 311 210, Russia 7 495 783 6851, Singapore 1800 226 5886, Slovenia 386 3 425 42 00, South Africa 27 0 11 805 8197, Spain 34 91 640 0085, Sweden 46 (0) 8 587 895 00, Switzerland 41 56 2005151, Taiwan 886 02 2377 2222, Thailand 662 278 6777, Turkey 90 212 279 3031, United Kingdom 44 (0) 1635 523545

To comment on National Instruments documentation, refer to the National Instruments Web site at ni.com/info and enter the Info Code feedback.

© 2008–2010 National Instruments Corporation. All rights reserved.

Page 3: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Important Information

WarrantyThe media on which you receive National Instruments software are warranted not to fail to execute programming instructions, due to defects in materials and workmanship, for a period of 90 days from date of shipment, as evidenced by receipts or other documentation. National Instruments will, at its option, repair or replace software media that do not execute programming instructions if National Instruments receives notice of such defects during the warranty period. National Instruments does not warrant that the operation of the software shall be uninterrupted or error free.

A Return Material Authorization (RMA) number must be obtained from the factory and clearly marked on the outside of the package before any equipment will be accepted for warranty work. National Instruments will pay the shipping costs of returning to the owner parts which are covered by warranty.

National Instruments believes that the information in this document is accurate. The document has been carefully reviewed for technical accuracy. In the event that technical or typographical errors exist, National Instruments reserves the right to make changes to subsequent editions of this document without prior notice to holders of this edition. The reader should consult National Instruments if errors are suspected. In no event shall National Instruments be liable for any damages arising out of or related to this document or the information contained in it.

EXCEPT AS SPECIFIED HEREIN, NATIONAL INSTRUMENTS MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AND SPECIFICALLY DISCLAIMS ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. CUSTOMER’S RIGHT TO RECOVER DAMAGES CAUSED BY FAULT OR NEGLIGENCE ON THE PART OF NATIONAL INSTRUMENTS SHALL BE LIMITED TO THE AMOUNT THERETOFORE PAID BY THE CUSTOMER. NATIONAL INSTRUMENTS WILL NOT BE LIABLE FOR DAMAGES RESULTING FROM LOSS OF DATA, PROFITS, USE OF PRODUCTS, OR INCIDENTAL OR CONSEQUENTIAL DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. This limitation of the liability of National Instruments will apply regardless of the form of action, whether in contract or tort, including negligence. Any action against National Instruments must be brought within one year after the cause of action accrues. National Instruments shall not be liable for any delay in performance due to causes beyond its reasonable control. The warranty provided herein does not cover damages, defects, malfunctions, or service failures caused by owner’s failure to follow the National Instruments installation, operation, or maintenance instructions; owner’s modification of the product; owner’s abuse, misuse, or negligent acts; and power failure or surges, fire, flood, accident, actions of third parties, or other events outside reasonable control.

CopyrightUnder the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including photocopying, recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written consent of National Instruments Corporation.

National Instruments respects the intellectual property of others, and we ask our users to do the same. NI software is protected by copyright and other intellectual property laws. Where NI software may be used to reproduce software or other materials belonging to others, you may use NI software only to reproduce materials that you may reproduce in accordance with the terms of any applicable license or other legal restriction.

TrademarksLabVIEW, National Instruments, NI, ni.com, the National Instruments corporate logo, and the Eagle logo are trademarks of National Instruments Corporation. Refer to the Trademark Information at ni.com/trademarks for other National Instruments trademarks.

LEGO and MINDSTORMS are trademarks of the LEGO Group. Other product and company names mentioned herein are trademarks or trade names of their respective companies.

PatentsFor patents covering National Instruments products/technology, refer to the appropriate location: Help»Patents in your software, the patents.txt file on your media, or the National Instruments Patent Notice at ni.com/patents.

WARNING REGARDING USE OF NATIONAL INSTRUMENTS PRODUCTS(1) NATIONAL INSTRUMENTS PRODUCTS ARE NOT DESIGNED WITH COMPONENTS AND TESTING FOR A LEVEL OF RELIABILITY SUITABLE FOR USE IN OR IN CONNECTION WITH SURGICAL IMPLANTS OR AS CRITICAL COMPONENTS IN ANY LIFE SUPPORT SYSTEMS WHOSE FAILURE TO PERFORM CAN REASONABLY BE EXPECTED TO CAUSE SIGNIFICANT INJURY TO A HUMAN.

(2) IN ANY APPLICATION, INCLUDING THE ABOVE, RELIABILITY OF OPERATION OF THE SOFTWARE PRODUCTS CAN BE IMPAIRED BY ADVERSE FACTORS, INCLUDING BUT NOT LIMITED TO FLUCTUATIONS IN ELECTRICAL POWER SUPPLY, COMPUTER HARDWARE MALFUNCTIONS, COMPUTER OPERATING SYSTEM SOFTWARE FITNESS, FITNESS OF COMPILERS AND DEVELOPMENT SOFTWARE USED TO DEVELOP AN APPLICATION, INSTALLATION ERRORS, SOFTWARE AND HARDWARE COMPATIBILITY PROBLEMS, MALFUNCTIONS OR FAILURES OF ELECTRONIC MONITORING OR CONTROL DEVICES, TRANSIENT FAILURES OF ELECTRONIC SYSTEMS (HARDWARE AND/OR SOFTWARE), UNANTICIPATED USES OR MISUSES, OR ERRORS ON THE PART OF THE USER OR APPLICATIONS DESIGNER (ADVERSE FACTORS SUCH AS THESE ARE HEREAFTER COLLECTIVELY TERMED “SYSTEM FAILURES”). ANY APPLICATION WHERE A SYSTEM FAILURE WOULD CREATE A RISK OF HARM TO PROPERTY OR PERSONS (INCLUDING THE RISK OF BODILY INJURY AND DEATH) SHOULD NOT BE RELIANT SOLELY UPON ONE FORM OF ELECTRONIC SYSTEM DUE TO THE RISK OF SYSTEM FAILURE. TO AVOID DAMAGE, INJURY, OR DEATH, THE USER OR APPLICATION DESIGNER MUST TAKE REASONABLY PRUDENT STEPS TO PROTECT AGAINST SYSTEM FAILURES, INCLUDING BUT NOT LIMITED TO BACK-UP OR SHUT DOWN MECHANISMS. BECAUSE EACH END-USER SYSTEM IS CUSTOMIZED AND DIFFERS FROM NATIONAL INSTRUMENTS' TESTING PLATFORMS AND BECAUSE A USER OR APPLICATION DESIGNER MAY USE NATIONAL INSTRUMENTS PRODUCTS IN COMBINATION WITH OTHER PRODUCTS IN A MANNER NOT EVALUATED OR CONTEMPLATED BY NATIONAL INSTRUMENTS, THE USER OR APPLICATION DESIGNER IS ULTIMATELY RESPONSIBLE FOR VERIFYING AND VALIDATING THE SUITABILITY OF NATIONAL INSTRUMENTS PRODUCTS WHENEVER NATIONAL INSTRUMENTS PRODUCTS ARE INCORPORATED IN A SYSTEM OR APPLICATION, INCLUDING, WITHOUT LIMITATION, THE APPROPRIATE DESIGN, PROCESS AND SAFETY LEVEL OF SUCH SYSTEM OR APPLICATION.

Page 4: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

© National Instruments Corporation v Getting Started with NI LabVIEW for FTC

Contents

About This ManualConventions ...................................................................................................................viiRelated Documentation..................................................................................................viii

Third-Party Web Sites .....................................................................................viii

Chapter 1Overview of the FIRST Tech Challenge

Autonomous and Teleoperated Modes ..........................................................................1-1Enabled and Disabled Status..........................................................................................1-2

Chapter 2Building a Robot

Chapter 3Building an Electrical Control System for the Robot

Required Parts................................................................................................................3-1Building the Electrical Control System .........................................................................3-2

Wiring the Motors ...........................................................................................3-2Providing Power to the Motors........................................................................3-3Connecting the NXT Brick to the Robot.........................................................3-4

Testing the Electrical Control System ...........................................................................3-4Downloading the Firmware.............................................................................3-4Running the Test Program...............................................................................3-5

Chapter 4Driving the Robot

Downloading the FTC Field Control System ................................................................4-1Running the FTC Teleop Basic Program.......................................................................4-1

Chapter 5Troubleshooting the Robot

Page 5: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

© National Instruments Corporation vii Getting Started with NI LabVIEW for FTC

About This Manual

This manual provides tutorials you can use to program a robot in LabVIEW for FTC. Use this manual to build and program a robot that moves according to commands you send from a game controller.

ConventionsThe following conventions appear in this manual:

» The » symbol leads you through nested menu items and dialog box options to a final action. The sequence File»Page Setup»Options directs you to pull down the File menu, select the Page Setup item, and select Options from the last dialog box.

This icon denotes a tip, which alerts you to advisory information.

This icon denotes a note, which alerts you to important information.

bold Bold text denotes items that you must select or click in the software, such as menu items and dialog box options. Bold text also denotes parameter names, front panel controls and indicators, dialog boxes, sections of dialog boxes, menu names, and palette names.

italic Italic text denotes variables, emphasis, a cross-reference, or an introduction to a key concept. Italic text also denotes text that is a placeholder for a word or value that you must supply.

monospace Text in this font denotes text or characters that you should enter from the keyboard, sections of code, programming examples, and syntax examples. This font is also used for the proper names of disk drives, paths, directories, programs, subprograms, subroutines, device names, functions, operations, variables, filenames, and extensions.

monospace bold Bold text in this font denotes the messages and responses that the computer automatically prints to the screen. This font also emphasizes lines of code that are different from the other examples.

Page 6: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

About This Manual

Getting Started with NI LabVIEW for FTC viii ni.com

Related DocumentationThe following Web site and documents contain information that you may find helpful as you read this manual.

• National Instruments FIRST Community—Visit the National Instruments FIRST Community Web site at ni.com/first to read the latest training tutorials, download example programs, and connect with real-world engineers.

• LabVIEW NXT Module Help—Use the LabVIEW NXT Module Help to access information that you might find helpful as you use the NXT Module and the FTC software. Access the LabVIEW NXT Module Help by selecting Help»NXT Module Help in LabVIEW.

• LabVIEW Quick Reference Card—Use this card as a reference for information such as keyboard shortcuts and tools for editing, execution, and debugging. Access this manual by navigating to the National Instruments\LabVIEW 2009\manuals directory and opening LV_Quick_Reference.pdf.

Third-Party Web SitesThe following third-party Web sites contain information that you may find helpful as you use the FTC software.

• FTC Community—Refer to the FTC Community Web site at www.usfirst.org/community/ftc for official information about the FTC competition, including rules and regulations as well as support information.

• Carnegie Mellon University Robotics Academy—Refer to the Carnegie Mellon University Robotics Academy Web site at www.education.rec.ri.cmu.edu/content/events/ftc/

labview to access FTC training materials about programming in LabVIEW.

• Center for Engineering Education and Outreach—Refer to the Center for Engineering Education and Outreach (CEEO) Web site at www.ceeo.tufts.edu to access educational materials and sample programs that you can use to interact with an NXT brick.

• FTCMastery—Visit the FTCMastery Web site at ftcmastery.com to access lessons, examples, and videos about using the FTC Toolkit.

• NXTMastery—Visit the NXTMastery Web site at nxtmastery.com to access lessons, examples, and videos about using the NXT Module.

Page 7: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

© National Instruments Corporation 1-1 Getting Started with NI LabVIEW for FTC

1Overview of the FIRST Tech Challenge

The objective of the FIRST Tech Challenge (FTC) competition is to build and program a robot to perform certain tasks in Autonomous and Teleoperated modes. This manual guides you through building and programming a robot that you can use as the base of the FTC robot.

Note You must download the FTC Toolkit to use the programs referred to in this manual. To download the toolkit and access programming examples and tutorials, visit the National Instruments Web site at ni.com/info and enter the Info Code FTCSoftware.

Autonomous and Teleoperated ModesIn Autonomous mode, the robot moves without input from game controllers. You can use LabVIEW to develop a program and then download that program to the NXT brick on the robot. When you run the program, the robot moves and behaves according to instructions in the program itself.

In Teleoperated mode, the robot moves in response to commands it receives from one or two game controllers. As in Autonomous mode, you develop a program in LabVIEW and then download that program to the NXT brick on the robot. The program must contain instructions that allow the robot to receive data from the game controllers and respond accordingly. When you run the program, you then can use the joysticks and buttons on the game controllers to drive the robot.

If you want the robot to respond to commands it receives from game controllers, connect the game controllers to a host computer through USB connections. Use the FTC Field Control System (FCS), as discussed in the Downloading the FTC Field Control System section of Chapter 4, Driving the Robot, to receive data from the game controllers, convert the data to a form the program running on the NXT brick can understand, and then send the data to the NXT brick on the robot.

Page 8: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 1 Overview of the FIRST Tech Challenge

Getting Started with NI LabVIEW for FTC 1-2 ni.com

Enabled and Disabled StatusAt certain points in the FTC competition, the program on the NXT brick must be running, but the robot must not move. For example, at the beginning of the Autonomous part of the competition, you must run the Autonomous program on the NXT brick, place the robot on the field, and return to the team area. The robot must not start moving until all teams have placed their robots on the field and returned to their positions. Similarly, between the Autonomous and Teleoperated parts of the competition, the robots must be running in Teleoperated mode but must not move until the judges have finished tallying the scores for the Autonomous portion.

During these times, the FCS sets the status of the robots to Disabled. The program you run on the NXT brick must handle the Disabled status such that the robot does not move and does not respond to any commands from the game controllers. When the FCS sets the status of the robots to Enabled, the program you run on the NXT brick must recognize this change in status. The program must handle the Enabled status such that the robot then starts moving or responding to commands from the game controllers.

Note LabVIEW for FTC includes program templates that handle the Enabled and Disabled status.

Page 9: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

© National Instruments Corporation 2-1 Getting Started with NI LabVIEW for FTC

2Building a Robot

Follow the illustrations in this chapter to build a robot using hardware available in the FIRST Tech Challenge (FTC) kit.

Note The robot you build in this chapter works with the FTC program templates discussed in later chapters of this manual. However, the robot and the programs in this manual are only examples of the kinds of robots and programs you can develop for the FTC competition. You can build a robot of any shape or size and design programs to drive the robot in whichever way you want to accomplish the goals of the FTC competition.

The first illustration in this chapter shows the completed hardware assembly of the robot as well as a list of parts. Ensure you have all the necessary parts before beginning to build the robot.

Page 10: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 2 Building a Robot

Getting Started with NI LabVIEW for FTC 2-2 ni.com

Page 11: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 2 Building a Robot

© National Instruments Corporation 2-3 Getting Started with NI LabVIEW for FTC

Page 12: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 2 Building a Robot

Getting Started with NI LabVIEW for FTC 2-4 ni.com

Page 13: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 2 Building a Robot

© National Instruments Corporation 2-5 Getting Started with NI LabVIEW for FTC

Page 14: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 2 Building a Robot

Getting Started with NI LabVIEW for FTC 2-6 ni.com

Page 15: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 2 Building a Robot

© National Instruments Corporation 2-7 Getting Started with NI LabVIEW for FTC

Page 16: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 2 Building a Robot

Getting Started with NI LabVIEW for FTC 2-8 ni.com

Page 17: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 2 Building a Robot

© National Instruments Corporation 2-9 Getting Started with NI LabVIEW for FTC

Page 18: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 2 Building a Robot

Getting Started with NI LabVIEW for FTC 2-10 ni.com

Page 19: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 2 Building a Robot

© National Instruments Corporation 2-11 Getting Started with NI LabVIEW for FTC

Page 20: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

© National Instruments Corporation 3-1 Getting Started with NI LabVIEW for FTC

3Building an Electrical Control System for the Robot

The robot you build in Chapter 2, Building a Robot, is not complete because it cannot perform any automated tasks. You must add an electrical control system through which you can control the movement of the robot. In the following exercises, you will connect the motors on the robot to the NXT brick so that the program running on the NXT brick can move the motors, which in turn move the robot.

Note Before you begin to build the electrical control system, decide which end of the robot is the front and which is the rear. You will connect the NXT brick at the front end and a motor controller near the rear end of the robot.

Required PartsYou need the following hardware parts to build the electrical control system.

• One LEGO® NXT brick

• One HiTechnic DC Motor Controller

• One 12V battery pack

• One power switch with cable harness

• One NXT cable to connect the NXT brick to the HiTechnic DC Motor Controller

• Four motor power cables made up of twisted red and black wires

• Various plastic LEGO® pieces to mount the NXT brick and the power switch to the robot

• Twelve machine screws with hex nuts

• Two 1-inch by 2-inch self-adhesive, Velcro straps

• One zip tie pack

Page 21: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 3 Building an Electrical Control System for the Robot

Getting Started with NI LabVIEW for FTC 3-2 ni.com

Building the Electrical Control SystemTo control the movement of the robot, you must connect the motors to a motor controller, which you then connect to an NXT brick. You also must provide a power source for the electrical control system.

Wiring the MotorsTo allow the NXT brick to communicate with the motors, you must wire the motors to a motor controller.

Complete the following steps to wire the motors to the HiTechnic DC Motor Controller.

1. Connect the red and black wires of one motor cable to the two terminals on one motor.

The polarity of each wire must match the polarity of the motor terminal to which it connects. For example, the red wire is positive (+), so you must connect the red wire to the terminal marked positive (+) on the motor.

Tip After you connect the two cables to a motor, use a zip tie to attach the cables to the motor to ensure the cables do not get caught on other objects when the robot is in motion.

2. Repeat step 1 to wire the remaining three motors.

3. Place the motor controller on the metal plate that is toward the rear of the robot. Position the motor controller so that the blue terminals face the front of the robot. This position allows each of the four motor cables to easily reach the motor controller.

4. From underneath the robot, insert machine screws up through the four corner holes of the motor controller.

5. Tighten the screws into the hex nuts. Do not overtighten the screws because overtightening can break the plastic tabs on the motor controller.

6. Connect the black wires of the two motor cables from the left side of the robot to the Motor 1 – terminal on the motor controller. Connect the red wires of the two motor cables from the left side of the robot to the Motor 1 + terminal on the motor controller.

7. Repeat step 6 to connect the motor cables on the right side of the robot to the Motor 2 – and the Motor 2 + terminals on the motor controller.

Page 22: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 3 Building an Electrical Control System for the Robot

© National Instruments Corporation 3-3 Getting Started with NI LabVIEW for FTC

In the next section, you will connect the battery that provides power to the motors and the power switch that allows you to turn the robot off and on.

Providing Power to the MotorsAs with any electrical system, you must provide a power source for the system.

Complete the following steps to provide power to the motors.

1. Connect the two cables from the power switch to the Battery – and the Battery + terminals on the HiTechnic DC Motor Controller.

The polarity of each cable must match the polarity of the battery terminal to which it connects. For example, the red cable is positive (+), so you must connect the red cable to the terminal marked positive (+) on the HiTechnic DC Motor Controller.

Tip After you connect both cables to the battery terminals, use zip ties to attach the cables to the frame of the robot to ensure the cables do not get caught on other objects when the robot is in motion.

2. Use plastic LEGO® pieces and machine screws with hex nuts to connect the power switch to the left side of the robot. Position the power switch to face outward so you easily can access the power switch.

3. Turn the power switch to OFF.

4. Attach a Velcro strap to the rear metal plate of the robot next to the HiTechnic DC Motor Controller.

5. Attach the corresponding Velcro strap to the bottom of the 12V battery.

6. Use the Velcro straps to connect the 12V battery to the rear metal plate. Position the battery so that the cable faces the front of the robot.

7. Connect the power switch cable to the 12V battery cable. The cable connectors fit together in only one way. Do not force the cable connectors together if they do not connect easily.

In the next section, you will connect the NXT brick to the robot.

Page 23: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 3 Building an Electrical Control System for the Robot

Getting Started with NI LabVIEW for FTC 3-4 ni.com

Connecting the NXT Brick to the RobotThe NXT brick is the computer that directs the movements of the robot. You must connect the NXT brick to the robot and then wire the NXT brick to the motor controller to allow the NXT brick to direct the robot.

Complete the following steps to connect the NXT brick to the robot.

1. Use plastic LEGO® pieces and machine screws with hex nuts to connect the NXT brick to the front end of the robot. Position the NXT brick so that the screen and buttons face forward and so that you can access the USB port easily. Also, make sure you can remove the NXT battery without removing the NXT brick.

2. Connect one end of the NXT cable to port 1 on the NXT brick.

3. Connect the other end of the cable to the nearest port on the HiTechnic DC Motor Controller.

Tip After you connect the NXT brick to the motor controller, use zip ties to attach the NXT cable to the frame of the robot to ensure the cable does not get caught on other objects when the robot is in motion.

The robot is complete. In the following section, you will test the electrical control system.

Testing the Electrical Control SystemThe robot is now ready to perform automated tasks. However, you first willwant to test the electrical control system with a test program to make sure the robot works as you expect it to work.

Downloading the FirmwareBefore you can use the test program to test the electrical control system, you must ensure that the host computer can communicate with the NXT brick. The NXT brick must be running the correct firmware to communicate with the host computer.

Complete the following steps to download the correct firmware to the NXT brick from LabVIEW.

1. Connect the NXT brick to the computer through USB or the FTC WiFi module and power on the NXT brick. Do not power on the robot.

2. Launch LabVIEW.

Page 24: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 3 Building an Electrical Control System for the Robot

© National Instruments Corporation 3-5 Getting Started with NI LabVIEW for FTC

3. In the Getting Started window, click the Blank VI link to open a new VI.

4. Select Tools»NXT Tools»NXT Terminal to launch the NXT Terminal dialog box.

5. Click the Update Firmware button to launch the Update NXT Firmware dialog box.

6. Click the Browse button next to the Look in text box to display a file dialog box.

7. Navigate to the National Instruments\LabVIEW 2009\Targets\NI\NXT\NXTToolkit\Firmware directory and click the Current Folder button.

8. In the Available Firmware Files list, select LEGO MINDSTORMS NXT Firmware V1.28.

9. Click the Update button to begin downloading the firmware to the NXT brick. The Progress section of the Update NXT Firmware dialog box displays the progress of the firmware update.

10. When the Update NXT Firmware dialog box displays Successfully Downloaded Firmware!, click the Close button to close the dialog box.

The host computer now can communicate with the NXT brick.

Running the Test ProgramAfter you download the correct firmware to the NXT brick, you can use a test program to test the electrical control system of the robot.

Complete the following steps to test the electrical control system.

1. Turn the power switch on the robot to ON.

Tip When you test the electrical control system, raise the robot off the ground so that the wheels are not in contact with any surface. If the electrical control system is not wired correctly, the robot might drive in an unexpected direction.

2. Navigate to the National Instruments\LabVIEW 2009\examples\FTC Toolkit directory and open TheMechanic.vi.

3. Click the Run button, shown at left, to run TheMechanic VI.

Page 25: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 3 Building an Electrical Control System for the Robot

Getting Started with NI LabVIEW for FTC 3-6 ni.com

When the electrical control system is connected to the robot correctly, the robot performs the following moves when you run TheMechanic VI.

• Move left wheel forward, reverse, then stop.

• Move right wheel forward, reverse, then stop.

• Turn clockwise.

• Turn counter-clockwise, then stop.

If the robot does not follow the previous movements, repeat the steps in this chapter to make sure the electrical control system is configured correctly.

Page 26: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

© National Instruments Corporation 4-1 Getting Started with NI LabVIEW for FTC

4Driving the Robot

After you build the robot and test the electrical control system, you can use the FTC Field Control System to establish communication between one or two game controllers and the robot. You then can use the FTC Teleop Basic program to drive the robot with the game controllers in teleoperated mode.

Downloading the FTC Field Control SystemThe FTC Field Control System (FCS) is the software that you use to receive data from the game controllers, convert the data to a form the program running on the NXT brick can understand, and then send the data to the NXT brick on the robot. FIRST requires that all FTC teams use the FCS during the FTC competition.

Visit the FIRST Web site at usfirst.org/roboticsprograms/ftc/content.aspx?id=15924 to download the FCS software and access the FCS guide.

Running the FTC Teleop Basic ProgramAfter you download the FCS, you can use the FTC Teleop Basic program in LabVIEW to drive the robot.

Note You must download the FTC Toolkit to use the FTC Teleop Basic program. To download the toolkit and access programming examples and tutorials, visit the National Instruments Web site at ni.com/info and enter the Info Code FTCSoftware.

FTC Teleop Basic is a program template that moves the motors of a robot according to joystick movements you make on a game controller. You can use this program as it is, or you can use LabVIEW to modify the program to perform more advanced tasks. For example, you can modify the program so that the robot moves in stealth mode when the robot must perform tasks carefully. Stealth mode means that the robot moves at a fraction of the normal speed.

Page 27: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 4 Driving the Robot

Getting Started with NI LabVIEW for FTC 4-2 ni.com

To open the FTC Teleop Basic program, navigate to the National Instruments\LabVIEW 2009\examples\FTC Toolkit\Templates directory and open FTCTeleopBasic.vi.

Refer to Chapter 5, Troubleshooting the Robot, for troubleshooting tips if the robot does not work as you expect.

Page 28: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

© National Instruments Corporation 5-1 Getting Started with NI LabVIEW for FTC

5Troubleshooting the Robot

In previous chapters, you built a robot that you can drive using a game controller. However, at times, the robot might not work as you expect. Table 5-1 describes common issues you might encounter when working with the robot and solutions to address those issues.

Page 29: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 5 Troubleshooting the Robot

Getting Started with NI LabVIEW for FTC 5-2 ni.com

Table 5-1. Common Programming Issues

Issue Solution

I try to run the program on the NXT brick, but the robot is not responsive.

Ensure that the 12V battery pack is plugged in and that the power switch is turned to ON.

Ensure you have enough battery power on the NXT brick. If you are using a rechargeable battery pack, ensure the battery pack is fully charged. The battery pack takes between five and six hours to charge. When charging is complete, the red light on the battery charger turns off.

You can monitor the battery voltage of the NXT brick in the following ways.

• Use the FTC Robot Status VI to monitor the battery voltage of the NXT brick and the 12V battery pack connected to the robot. The FTC Robot Status VI displays the battery voltage of the NXT brick and of the battery pack at the bottom of the NXT screen.

• Use the Read Sensor VI, located on the NXT I/O palette, to monitor the battery voltage of the NXT brick. Add the Read Sensor VI to the block diagram and then select the Read Battery Level instance from the pull-down menu on the VI.

• If you use TETRIX hardware on the robot, use the Check Battery VI, located on the HiTechnic palette, to monitor the battery voltage of the motor and servo controllers.

Ensure the NXT brick is not in sleep mode. By default, the NXT brick enters sleep mode after 10 minutes of inactivity. On the NXT brick, you can set Sleep to Never to prevent the brick from shutting down. Select Settings»Sleep and use the left and right arrow buttons to select Never. Then press the orange button on the NXT brick.

Ensure the game controllers are connected to the host computer. If you unplug a game controller, you must click the Refresh List button in the FIRST Tech Challenge (FTC) Controller Station and reselect the controller you want to use.

Page 30: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 5 Troubleshooting the Robot

© National Instruments Corporation 5-3 Getting Started with NI LabVIEW for FTC

I am trying to connect to the NXT brick from the FTC Controller Station, but the FTC Controller Station cannot find the NXT brick.

Connecting to the NXT brick from the FTC Controller Station for the first time can take up to one minute. Subsequent connections take less time.

Ensure you entered the correct name of the NXT brick in the NXT Name text box in the FTC Controller Station. This field is case sensitive.

Ensure the NXT brick is not in sleep mode. By default, the NXT brick enters sleep mode after 10 minutes of inactivity. On the NXT brick, you can set Sleep to Never to prevent the brick from shutting down. Select Settings»Sleep and use the left and right arrow buttons to select Never. Then press the orange button on the NXT brick.

I accidentally unplugged a game controller but plugged it back in. Now the FTC Controller Station does not recognize the game controller.

Click the Refresh List button in the FTC Controller Station and reselect the controller you want to use.

The robot moves, but the motors do not turn in the correct direction.

Ensure that the motors are connected to the correct terminals on the HiTechnic Motor Controller.

You can check the motor configurations in the following ways.

• Use TheMechanic VI, located in the National Instruments\LabVIEW 2009\examples\

FTC Toolkit directory, to test the motor configurations. Refer to Chapter 3, Building an Electrical Control System for the Robot, for information about TheMechanic VI.

• If you created motor controls in the TETRIX Motor Configurator, ensure that you entered the correct configurations for the motors and servos on the robot.

Table 5-1. Common Programming Issues (Continued)

Issue Solution

Page 31: Getting Started with NI LabVIEW for FTCdownload.ni.com/evaluation/academic/ftc_getting_started.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 5 Troubleshooting the Robot

Getting Started with NI LabVIEW for FTC 5-4 ni.com

My VI runs on the host computer, but when I target the VI to the NXT brick and click the Run button, I get a compiler error.

Ensure that the NXT brick supports the VI you want to run. Refer to Chapter 1, Introduction, of the LabVIEW LEGO® MINDSTORMS® NXT Module Programming Guide for information about LabVIEW objects that the NXT brick supports. Access this guide by navigating to the National Instruments\LabVIEW 2009\

manuals directory and opening NXT_Advanced_Programming_Guide.pdf.

Table 5-1. Common Programming Issues (Continued)

Issue Solution