archived: getting started with ni labview for ftc...

44
LabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST Tech Challenge Software August 2009 372580B-01

Upload: others

Post on 14-Apr-2020

45 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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

August 2009372580B-01

Page 2: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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–2009 National Instruments Corporation. All rights reserved.

Page 3: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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.

TrademarksNational Instruments, NI, ni.com, and LabVIEW are trademarks of National Instruments Corporation. Refer to the Terms of Use section on ni.com/legal for more information about 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: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST
Page 5: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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 ..................................................................................... ix

Chapter 1Overview of the FIRST Tech Challenge

Autonomous and Teleoperated Modes ..........................................................................1-1Enabled and Disabled Status..........................................................................................1-2LabVIEW for FTC Components....................................................................................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 4Controlling the Robot with the FTC Controller Station

Connecting to the FTC Controller Station .....................................................................4-1Running a Program in Teleoperated Mode....................................................................4-2Using the Game Controllers ..........................................................................................4-3

Chapter 5Modifying the FTC Teleop Basic Program

Modifying the Program..................................................................................................5-1Running the Program on the NXT Brick .......................................................................5-4Creating Controls for Motors and Servos ......................................................................5-4

Page 6: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Contents

Getting Started with NI LabVIEW for FTC vi ni.com

Specifying the Names of the Controls ............................................................ 5-5Configuring the Controls ................................................................................ 5-6

Configuring the Control for the Motors ........................................... 5-6Configuring the Control for the Servos ............................................ 5-7

Editing Existing Motor and Servo Controls.................................................... 5-8

Chapter 6Troubleshooting the Robot

Page 7: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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 8: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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.

• Getting Started with the LabVIEW LEGO® MINDSTORMS® NXT Module—Use this manual to learn how to develop NXT VIs in the LabVIEW environment and how to deploy those VIs to an NXT brick. You can use the LabVIEW NXT Module to develop FIRST Tech Challenge programs. Access this manual by navigating to the National Instruments\LabVIEW 2009\manuals directory and opening NXT_Getting_Started.pdf.

• LabVIEW NXT Module Help—Use the LabVIEW NXT Module Help to access information about LabVIEW NXT Module programming concepts, step-by-step instructions for using the LabVIEW NXT Module, and reference information about LabVIEW NXT Module VIs, functions, palettes, menus, tools, dialog boxes, and so on. Access the LabVIEW NXT Module Help by selecting Help»NXT Module Help in LabVIEW.

• LabVIEW Help—Use the LabVIEW Help to access information about LabVIEW programming concepts, step-by-step instructions for using LabVIEW, and reference information about LabVIEW VIs, functions, palettes, menus, tools, properties, methods, events, dialog boxes, and so on. The LabVIEW Help also lists the LabVIEW documentation resources available from National Instruments. Access the LabVIEW Help by selecting Help»Search the LabVIEW Help in LabVIEW.

• LabVIEW Quick Reference Card—Use this card as a reference for information about documentation resources, keyboard shortcuts, data type terminals, 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.

• National Instruments FIRST Community—Use 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.

Page 9: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

About This Manual

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

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.

Page 10: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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.

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 Controller Station running on the host computer 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 through either a USB or Bluetooth connection to the NXT brick on the robot.

During the actual FTC competition, FIRST provides a field management system (FMS) that acts like a controller station and can connect to multiple robots at once.

Page 11: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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 FMS 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 FMS 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.

LabVIEW for FTC ComponentsLabVIEW for FTC includes LabVIEW Student Edition, the LabVIEW LEGO® MINDSTORMS® NXT Module Beta, and the LabVIEW FTC Toolkit. Use this software to program a robot in LabVIEW. LabVIEW for FTC also includes the FTC Controller Station, accessible by navigating to the National Instruments\LabVIEW 2009\examples\

FTC Toolkit\FTC Controller Station directory and opening FTC Controller Station.exe.

In the following chapters, you will build a robot, program the robot with a LabVIEW for FTC program template, drive the robot with a game controller, modify the FTC program template, and drive the robot again. You also will learn how to create LabVIEW controls that specify the names and configurations of the motors and servos on a robot.

Page 12: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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 13: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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 14: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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 15: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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 16: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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 17: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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 18: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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 19: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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 20: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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 21: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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 22: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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 23: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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 24: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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 25: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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 26: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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 Bluetooth and power on the NXT brick. Do not power on the robot.

2. Launch LabVIEW.

Page 27: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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 28: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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 29: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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

4Controlling the Robot with the FTC Controller Station

After you build the robot and test the electrical control system, you can use the FIRST Tech Challenge (FTC) Controller Station to establish communication between one or two game controllers and the robot. You then can drive the robot with the game controllers during Teleoperated mode.

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

Connecting to the FTC Controller StationYou must connect the NXT brick to the FTC Controller Station to use the game controllers to move the robot.

Complete the following steps to connect the NXT brick to the FTC Controller Station.

1. Navigate to the National Instruments\LabVIEW 2009\examples\FTC Toolkit\FTC Controller Station directory and double-click FTC Controller Station.exe to launch the FTC Controller Station.

2. Notice that the FTC Controller Station automatically assigns any connected game controllers to Controller 1 and Controller 2.

3. Enter the name of the NXT brick in the NXT Name text box. You also can click the Browse button to select the NXT brick.

Note The FTC competition requires that you use your four-digit FTC team name as the name of the NXT brick during the competition.

4. Click the Connect button, shown at left, to connect to the NXT brick. When an NXT brick is connected, the Connect button changes to the Disconnect button.

Page 30: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 4 Controlling the Robot with the FTC Controller Station

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

When the NXT brick connects successfully, the FTC Controller Station automatically downloads two default programs, FTC Teleop Basic and Program Chooser, to the NXT brick.

Running a Program in Teleoperated ModeUse the Program Chooser program that the FTC Controller Station downloads to the NXT brick to specify which program you want to run on the NXT brick in Teleoperated mode. When you select the program you want to run, the Program Chooser program creates a.txt configuration file that specifies the program you selected.

When the mode of the robot changes from Autonomous to Teleoperated in the competition, the field management system stops any currently running Autonomous program and starts running the Teleoperated program that the .txt configuration file specifies.

In this exercise, you will choose and run a program in Teleoperated mode on the NXT brick.

Complete the following steps to use the Program Chooser program to select the program you want to run in Teleoperated mode.

1. On the NXT brick, navigate to My Files»Software files»Program Chooser and press the orange button.

2. Use the left and right arrow buttons to select FTCTeleopBasic.rxe from the list of programs, and press the orange button. The Program Chooser program creates an FTCConfig.txt configuration file on the NXT brick that specifies FTC Teleop Basic as the program to run in Teleoperated mode.

3. Press the orange button to end the Program Chooser program.

4. In the FTC Controller Station, click the Refresh button to detect the FTCConfig.txt configuration file on the NXT brick. Notice that the FTCConfig.txt Present round LED turns green, and FTCTeleopBasic.rxe is listed as the Designated Teleoperated Program.

5. In the FTC Controller Station, set the mode of the NXT brick to Teleoperated. Because you specified a Designated Teleoperated Program, the FTC Controller Station stops any program running in Autonomous mode on the NXT brick and begins running the Designated Teleoperated Program.

Page 31: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 4 Controlling the Robot with the FTC Controller Station

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

Note Notice that you also can set the Enabled or Disabled status of the robot from the FTC Controller Station. The FTC Teleop Basic program handles both an Enabled and a Disabled status. When the status is Disabled, the robots must stop moving. Refer to the Enabled and Disabled Status section of Chapter 1, Overview of the FIRST Tech Challenge, for more information about the Enabled and Disabled status.

Using the Game ControllersAfter you connect the NXT brick to the FTC Controller Station and select the Teleoperated mode, you can use game controllers to drive the robot.

Complete the following steps to select the game controllers you want to use to drive the robot.

1. Click the Refresh List button for Controller 1. An updated list of game controllers connected to the host computer appears in the text box above the Refresh List button.

2. From the list of connected game controllers, select the game controller you want to correspond to Controller 1. Controller 1 now displays any movements or button presses you make on the physical game controller. For example, if you press button 2 on the game controller, button 2 on Controller 1 appears to be pressed as well. The FTC Controller Station sends any game controller data for Controller 1 to the FTC Teleop Basic program running on the NXT brick, which drives the robot accordingly.

Note Buttons 9–12 are not shown on Controller 1 or Controller 2 of the FTC Controller Station. Buttons 11 and 12 correspond to the left and right joystick buttons, respectively.

3. If you want to use two game controllers to drive the robot, repeat steps 1 and 2 for Controller 2. However, while you run the FTC Teleop Basic program, the robot responds only to the joystick on Controller 1.

4. Push the joystick forward and backward to move the robot forward and backward. Move the joystick left and right to turn the robot counter-clockwise and clockwise.

Page 32: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 4 Controlling the Robot with the FTC Controller Station

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

Note If the robot does not move as you expect it to move, check for loose wires or other objects on the robot that might interfere with the movement of the robot. You also can run TheMechanic VI again to make sure the robot can move independently of the controllers. Refer to Chapter 3, Building an Electrical Control System for the Robot, for information about TheMechanic VI.

5. Click the QUIT button in the FTC Controller Station to stop both the FTC Controller Station and the program running on the NXT brick.

Page 33: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.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

5Modifying the FTC Teleop Basic Program

The FTC Teleop Basic program moves the motors of a robot according to joystick movements you make on a game controller. You can use LabVIEW to modify this 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.

Modifying the ProgramIn this section, you will modify the FTC Teleop Basic program in LabVIEW so that the robot runs in stealth mode. Complete the following steps to modify the FTC Teleop Basic program.

1. Navigate to the National Instruments\LabVIEW 2009\examples\FTC Toolkit\Templates directory and open FTCTeleopBasic.vi to open the source VI for the FTC Teleop Basic program.

2. Select Window»Show Block Diagram or press the <Ctrl-E> buttons to display the block diagram.

3. Select File»Target to NXT to open the program in the NXT application instance instead of the main application instance on the host computer. To run the program on the NXT brick, you must target the program to the NXT brick.

Notice that the application instance shortcut menu in the bottom left corner of the block diagram window turns orange and displays the name of the NXT brick to which the program is targeted.

Note If you have more than one NXT brick connected to the host computer, you can specify which brick to target. Right-click the application instance shortcut menu in the bottom left corner of the block diagram window and select an NXT brick from the shortcut menu. You also can select Find NXT from the shortcut menu to display the Find NXT dialog box from where you can select the NXT you want to target.

Page 34: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 5 Modifying the FTC Teleop Basic Program

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

4. On the block diagram, click the increment or decrement arrow of the selector label of the bottom Case structure to switch to the True case.

5. Delete the wire that runs from the NXT output of the FTC Read Controller VI to the NXT input of the Calculate Power from Joystick VI.

6. If the Functions palette does not appear, select View»Functions Palette to display the Functions palette.

7. Add an FTC Read Buttons VI, located on the FTC Tools palette, inside the Case structure and to the right of the FTC Read Controller VI.

8. Wire the NXT output of the FTC Read Controller VI to the NXT input of the FTC Read Buttons VI.

9. Wire the Buttons output of the FTC Read Controller VI to the Buttons input of the FTC Read Buttons VI. The FTC Read Buttons VI returns the Boolean values of the buttons on the controller whose data the FTC Read Controller VI reads.

10. Add a Select function, located on the NXT Programming»Comparison palette, to the right of the FTC Read Buttons VI.

Tip If you do not have enough room to place more objects on the block diagram, hold down the <Ctrl> key and click the white space between the FTC Read Controller VI and the Calculate Power from Joystick VI and drag the mouse sideways to add more space.

11. Wire the Button 5 output of the FTC Read Buttons VI to the s input of the Select function.

12. Place a numeric constant, located on the NXT Programming»Numeric palette, between the FTC Read Buttons VI and the Select function.

13. Wire this numeric constant to the t input of the Select function and set the value of the constant to 30.

14. Place another numeric constant between the FTC Read Buttons VI and the Select function.

15. Wire this numeric constant to the f input of the Select function and set the value of the constant to 100.

16. Delete the numeric constant that is wired to the Throttle input of the Calculate Power from Joystick VI.

17. Wire the s? t:f output of the Select function to the Throttle input of the Calculate Power from Joystick VI.

Page 35: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 5 Modifying the FTC Teleop Basic Program

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

The Select function returns the value of the t input when the value of s is TRUE and returns the value of the f input when the value of s is FALSE.

In this program, when button 5 on the game controller is pressed, the Button 5 output of the FTC Read Buttons VI returns TRUE. The Select function therefore returns the value of t, 30, to the Throttle input of the Calculate Power from Joystick VI. When button 5 on the game controller is not pressed, the Button 5 output of the FTC Read Buttons VI returns FALSE. The Select function therefore returns the value of f, 100, to the Throttle input of the Calculate Power from Joystick VI. The value 30 specifies that the robot moves at 30% of the normal speed. The value 100 specifies that the robot moves at 100% of the normal speed.

18. Wire the NXT output of the FTC Read Buttons VI to the NXT input of the Calculate Power from Joystick VI.

The block diagram of the VI should appear similar to the following figure.

Page 36: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 5 Modifying the FTC Teleop Basic Program

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

19. Save this program as TeleopStealth.vi in an easily accessible location on the host computer. You can compare this program to the FTCTeleopStealth.vi in the National Instruments\LabVIEW 2009\examples\FTC Toolkit\Template Implementations directory.

Running the Program on the NXT BrickAfter you update the template program, you can use the Run button on the front panel window or block diagram window to run the program on the NXT brick.

Complete the following steps to run the modified program on the NXT brick.

1. Connect the NXT brick to the host computer through a USB connection if the brick is not already connected through USB.

2. On the block diagram window, click the Run button to compile and run this program on the NXT brick.

3. Follow the instructions in Chapter 4, Controlling the Robot with the FTC Controller Station, to specify the FTCTeleopStealth VI as the program to run in the Teleoperated mode. You then can move the robot using the joysticks on a game controller and use button 5 of the game controller as a stealth mode button.

Creating Controls for Motors and ServosThe FTC Teleop Basic program template contains the Motor Configurations control, shown at left, which sends the names and configurations of the motors to the TETRIX Move DC Motors VI. This control is already built for you in the templates, but you can create this kind of control for programs you build. The following exercises show you how to create controls for the motors and servos on the robot.

Note You do not have to complete these exercises to use the FTC program templates.

You can use the TETRIX Motor Configurator, shown as follows, to specify the names and configurations for the motors and servos on the robot. The TETRIX Motor Configurator creates controls that contain the names and configurations you specify. You then can use these controls in the programs you build in LabVIEW.

Page 37: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 5 Modifying the FTC Teleop Basic Program

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

Note You want to create these controls before you develop the VIs to drive the robot so that you can use the controls in the VIs you develop.

Specifying the Names of the ControlsComplete the following steps to specify the names of the controls for the motors and servos. You create one control for all motors and one control for all servos.

1. In the Getting Started window, click the Blank VI link to create a new VI.

2. Select Tools»NXT Tools»TETRIX Motor Configurator to display the TETRIX Motor Configurator. By default, the DC Motors page appears.

3. Click the Browse button to specify the directory in which you want to save the motor control. Save the control in the default data directory so that the control appears on the Functions palette on the block diagram window and the Controls palette on the front panel window.

4. Name the control RobotDCMotors.ctl and click the OK button.

Page 38: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 5 Modifying the FTC Teleop Basic Program

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

5. Click the Servos tab to display the Servos page in the TETRIX Motor Configurator.

6. Repeat steps 3 and 4 to save a servo control called RobotServoMotors.ctl.

Configuring the ControlsIn the following sections, you will configure the control for the motors and the control for the servos.

Configuring the Control for the MotorsComplete the following steps to configure the RobotDCMotors control.

1. On the DC Motors page, enter Left Drive in the first Motor Name text field to specify the name of the first motor.

2. Place a checkmark in the Reverse checkbox for Left Drive. This option specifies that Left Drive will move in the opposite direction of the command you send to it.

3. Click the Add Motor button to add a second motor to the motor list.

4. Name the second motor Right Drive.

5. Select Motor 2 from the corresponding Motor pull-down menu to specify that the Right Drive motor is connected to the Motor 2 terminals on the HiTechnic DC Motor Controller.

6. Add a third motor and name that motor Arm Manipulator.

7. Select Port 2 from the corresponding NXT Port pull-down menu to specify that the Arm Manipulator motor is connected to port 2 on the NXT brick.

8. Add a fourth motor and name that motor Wrist Manipulator.

9. Select Port 2 from the corresponding NXT Port pull-down menu to specify that the Wrist Manipulator motor is connected to port 2 on the NXT brick.

10. Select Motor 2 from the corresponding Motor pull-down menu to specify that the Wrist Manipulator motor is connected to the Motor 2 terminals on the HiTechnic DC Motor Controller.

11. Click the Save button to save the motor names and configurations.

Page 39: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 5 Modifying the FTC Teleop Basic Program

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

Configuring the Control for the ServosComplete the following steps to configure the RobotServoMotors control.

1. Click the Servos tab to display the Servos page in the TETRIX Motor Configurator.

2. Name the first servo Left Gripper.

3. Select Controller 2 from the corresponding Servo Controller pull-down menu to specify that Left Gripper is connected to channel 1 of servo controller 2.

4. Click the Add Servo button to add a second servo to the servo list.

5. Name the second servo Right Gripper.

6. Select Controller 2 from the corresponding Servo Controller pull-down menu.

7. Select Channel 2 from the corresponding Servo Channel pull-down menu to specify that Right Gripper is connected to channel 2 of servo controller 2.

8. Click the Save button to save the servo names and configurations.

9. Click the OK button to close the TETRIX Motor Configurator.

After you create and save the controls, each control appears on the Functions»TETRIX»Motor Configurations palette and the Controls»Motor Configurations palette, shown as follows.

When you build programs in LabVIEW, you can drag the controls from these palettes onto the block diagram window or front panel window. Then wire the controls to the DC Motor or Servo inputs of TETRIX VIs to use the names and configurations you specify in the TETRIX Motor Configurator.

Page 40: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 5 Modifying the FTC Teleop Basic Program

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

Editing Existing Motor and Servo ControlsYou also can edit existing motor and servo controls that you created with the TETRIX Motor Configurator.

Complete the following steps to update an existing motor or servo control.

1. Click the Browse button in the TETRIX Motor Configurator and navigate to the directory that contains the control you want to edit.

2. Select the control and click the OK button.

3. Edit the control in the TETRIX Motor Configurator.

4. Click the Save button to save the new configurations.

5. Click the OK button to close the TETRIX Motor Configurator. The Apply Changes? dialog box appears and prompts you to update this control in the VIs that use the control.

6. Click the Yes button and navigate to the directory that contains the VIs that use this control.

7. Select all of the folders that contain the VIs that use this control.

8. Click the Current Folder button in the file dialog box. The TETRIX Motor Configurator updates the control in all of the VIs you specify, including VIs in subfolders.

Note Applying the changes to the VIs might take several minutes if the directory contains a large number of VIs. Remove any unused VIs from the directory before you apply the changes to speed up this process.

Page 41: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

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

6Troubleshooting 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 6-1 describes common issues you might encounter when working with the robot and solutions to address those issues.

Table 6-1. Common Programming Issues

Issue Solution

I cannot connect to the NXT brick using Bluetooth.

Shut down any programs running on the NXT brick before you try using Bluetooth to connect to the NXT brick.

Ensure that the NXT brick is not connected to another program using Bluetooth. For example, the NXT brick cannot connect to the FTC Controller Station using Bluetooth if the NXT brick is already connected to LabVIEW using Bluetooth.

Ensure the NXT brick is within range of the Bluetooth device. Bluetooth has a limited range of approximately 50 feet.

Ensure Bluetooth is on and the Bluetooth icon is visible on the NXT brick. If Bluetooth is on and visible but you cannot connect to the NXT brick, try power cycling the brick. Turn the NXT brick off, turn the brick back on, and then try reconnecting to the brick using Bluetooth. You also might need to remove and reinsert the batteries in the NXT brick before reconnecting to the brick.

Page 42: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 6 Troubleshooting the Robot

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

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.

Table 6-1. Common Programming Issues (Continued)

Issue Solution

Page 43: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 6 Troubleshooting the Robot

© National Instruments Corporation 6-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 6-1. Common Programming Issues (Continued)

Issue Solution

Page 44: Archived: Getting Started with NI LabVIEW for FTC ...download.ni.com/support/daq/manuals/372580b.pdfLabVIEW TM Getting Started with NI LabVIEW for FTC Getting Started with the FIRST

Chapter 6 Troubleshooting the Robot

Getting Started with NI LabVIEW for FTC 6-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 6-1. Common Programming Issues (Continued)

Issue Solution