How To Program An Nxt Mindstorms On A Computer Or Tablet Computer



Similar documents
understanding sensors

Tutorial for Programming the LEGO MINDSTORMS NXT

Advanced Programming with LEGO NXT MindStorms

Quick Start Guide to computer control and robotics using LEGO MINDSTORMS for Schools

EV3 Programming. Overview for FLL Coaches. A very big high five to Tony Ayad

How To Turn On A Robot On A Computer On A Black Box On A Pc Or Macbook

Programming LEGO NXT Robots using NXC

North Texas FLL Coaches' Clinics. Beginning Programming October Patrick R. Michaud republicofpi.org

C.I. La chaîne d information LES CAPTEURS. Page 1 sur 5

SE05: Getting Started with Cognex DataMan Bar Code Readers - Hands On Lab Werner Solution Expo April 8 & 9

How to register and use our Chat System

CONTENTS. What is ROBOTC? Section I: The Basics

Can Traffic Accidents be eliminated by Robots?

Installation Guide (No Router)

Introduction WELCOME TO LEGO MINDSTORMS EDUCATION

Line Tracking Basic Lesson

Introduction WELCOME TO LEGO MINDSTORMS EDUCATION

MiraCosta College now offers two ways to access your student virtual desktop.

Using the enclosed installation diagram, drill three holes in the wall with the lower hole 1150mm from the floor.

Additional Guides. TETRIX Getting Started Guide NXT Brick Guide

The Basics of Robot Mazes Teacher Notes

Wireless Remote Control of the TT24

PIGCHAMP MOBILE. PigCHAMP Knowledge Software. Installation Guide for Mobile Units

Internet basics 2.1 Getting online. Beginner s guide to. Basics. Get IT Together

The FlexiSchools Online Order Management (FOOM) Installation Guide

Fruit Machine. Level. Activity Checklist Follow these INSTRUCTIONS one by one. Test Your Project Click on the green flag to TEST your code

Audience Response System (Turning Point) A Quick Start Guide

Installing the VMware Horizon View Client to Access Hoag Virtual Desktops

The FlexiSchools Online Order Management System Installation Guide

Welcome to CSU The Software Used To Data Conference.

Wireless Network Adapter Installation

How To Use An Easypad On A Pc Or Macbook Or Ipad (For Pc)

TWO WAYS TO SCHEDULE A SCOPIA VIDEO CONFERENCE BASED MEETING. 1- SCOPIA USER PORTAL 2- OUTLOOK SCOPIA MEETING PLUG-IN

Classroom Activities for the Busy Teacher: EV3

The second goal is to provide a list of tips, tricks, and best known methods that have been discovered over the life span of the course.

Hello Modem. Today I would like

Installing Remote Desktop Connection

Internet basics 2.1 Getting online. Beginner s guide to. Basics

LogMeIn Ignition for Android User Guide

Your EdVenture into Robotics You re a Programmer

Zoom Participant Guide

oxigen system Slot.it oxigen timing RMS installation Dongle driver installation 1/ 11 Race Management Software

The easy way to accept EFTPOS, Visa and MasterCard payments on the spot. Mobile Users Charging your PayClip. 2. Downloading the PayClip app.

The FlexiSchools Online Order Management System Installation Guide

If you are unable to set up your Linksys Router by using one of the above options, use the steps below to manually configure your router.

How to use the VMware Workstation / Player to create an ISaGRAF (Ver. 3.55) development environment?

Wireless. Set-up guide. Get going in a flash

PART 1. Using USB Mixer with a Computer

AKO Shutdown Quick Reference Guide

TECHNICAL BULLETIN. Configuring Wireless Settings in an i-stat 1 Wireless Analyzer

First of all Let's look at how you would connect your laptop via Ethernet, as it is the easier of the two methods.

Monitoring Network DMN

Password Memory 6 User s Guide

Contents. Business Everywhere user guide. 1. Introduction. 2. How to Install/Uninstall Business Everywhere. 3. The Business Everywhere interface

ScanShell.Net Install Guide

educ Office Remove & create new Outlook profile

Zoom Guide Book. The Office of Academic Technology LEADER GUIDE

Steps for using MagicConnect

Steps for using MagicConnect

FrontDesk Installation And Configuration

Print Server Application Guide. This guide applies to the following models.

Dr Robot C# Advance Sputnik Demo Program

StarLeaf Cloud Troubleshooter

The FlexiSchools Online Order Management System Installation Guide

Mobility with Eye-Fi Scanning Guide

User Guide HUAWEI UML397. Welcome to HUAWEI

LEGO Digital Designer 4.3 User Manual

How To Use An Apple Macbook With A Dock On Itunes Macbook V.Xo (Mac) And The Powerbar On A Pc Or Macbook (Apple) With A Powerbar (Apple Mac) On A Macbook

Introduction to Google SketchUp (Mac Version)

The Coast to Coast AM Podcast for itunes 11

Blender Notes. Introduction to Digital Modelling and Animation in Design Blender Tutorial - week 9 The Game Engine

How to Use JCWHosting Reseller Cloud Storage Solution

Mastering Lync Meetings

P-2612HNU-Fx n ADSL2+ VoIP IAD DEFAULT LOGIN DETAILS. Firmware V3.00 Edition 1, 1/2010. Password: 1234 User Name: admin Password: 1234

Workshop NXT Programming For Beginners

CinePlay User Manual

How To Use Mview On A Powerline 2.2 (Powerline) On A Pc Or Macbook 2 (Powerplst) On An Iphone Or Ipa 2 (Aldo) On Your Iphon 2 (

LCD MONITOR TOUCH PANEL DRIVER 2 OPERATION MANUAL. for Mac. Version 1.0 PN-L703A/PN-70TA3/PN-L703B/PN-70TB3/PN-L603A/PN-60TA3/PN-L603B/PN-60TB3

mybullard Personal Control Panel User Guide

Features Phone Access Features Web Access emta Quick Reference Guide Troubleshooting Quick Reference Guide...

UPS Monitoring and Management Software

WAMLocal. Wireless Asset Monitoring - Local Food Safety Software. Software Installation and User Guide BA/WAM-L-F

C6 Easy Imaging Total Computer Backup. User Guide

Logging into Citrix (Epic) using an RSA Soft Token - New RSA User

EPSON Stylus. Start Here

The SMART Board Interactive Whiteboard

2/26/2008. Sensors For Robotics. What is sensing? Why do robots need sensors? What is the angle of my arm? internal information

Introduction to MS WINDOWS XP

MAGPOWR Spyder Firmware Update Instruction Manual

Quick Installation and Setup for WinPower Software

REFERENCE GUIDE 1. INTRODUCTION

2. PMP New Computer Installation. & Networking Instructions

ImagineWorldClient Client Management Software. User s Manual. (Revision-2)

How to use a SMART Board

Personal Call Manager User Guide. BCM Business Communications Manager

Q. The Phone Manager call banner disappears after being displayed for a couple of seconds...5 Q. The Phone Manager icon in the taskbar is blue and

HOW-TO-GUIDE. Installer Service Tool: Downloading Data and Event Logs for the Eltek Theia

How to Create Custom Sound Effects for NXT Robots.

Using SSH Secure Shell Client for FTP

C6 Easy Imaging Total Computer Backup. User Guide

Transcription:

NXT Generation Robotics Introductory Worksheets School of Computing University of Kent Copyright c 2010 University of Kent

NXT Generation Robotics These worksheets are intended to provide an introduction to programming the LEGO Mindstorms NXT, using the supplied Mindstorms software; we hope that you find them useful. Guides: Getting Started:............................ setting up and launching the Mindstorms software. Creating a New Program:........................... how to create a new Mindstorms program. Downloading and Running:......... downloading your programs to the NXT and running them. Worksheets: 1. First Program:........................ writing a program that makes your robot drive forwards. 2. Sensors:................................................... using the ultrasonic range sensor. 3. Driving:..................................................... making your robot turn corners. 4. Loops:......................................... adding loops to your program to repeat actions. 5. Range and Wander:...................... make your robot wander around and avoid obstacles. 6. Light Sensor:......................................................... using the light sensor. 7. Data Handing:...................................................reading and displaying data. 8. Drive Back:......... using the motor s rotation sensor to move the robot back to its starting point. 9. Making Decisions:............. following different paths in a program depending on a condition. 10. Multiple Decisions:........................... taking one of several paths depending on a value. 11. Further Exercises:................... additional exercises for those who have finished all the rest!

NXT Mindstorms: Getting Started 1. Login to the laptop using the supplied user-name and password. 2. Start up the Mindstorms software by double-clicking on the desktop icon, or by selecting it from the Windows menu: 3. The Mindstorms startup window should look something like: 4. You are now ready to start programming! Just remember: The NXT robot must be turned on, and Connected to the PC using the USB cable. (once a program has been downloaded to the robot, you can safely unplug the USB cable).

NXT: Creating a New Program 1. From the start screen (shown on the other side), click the Go >>> button in the Start New Program box. Else use the File menu and select New. 2. You will be presented with a blank canvas, where you can design your program: 3. Make a note of the program name in most cases this will be something like untitled-2. You will need this when it comes to running the program on the NXT robot!

NXT: Downloading and Running 1. Once you have finished writing your program (see other sheets for this!), you need to download it to your NXT robot, then run it. A set of buttons in the bottom-right corner of the canvas does this: Download Download and Run Note: make sure the USB cable is connected to the NXT before downloading! 2. The first time you download a program, use the Download and Run button this will make sure that the program is selected on the NXT. The down-side is that the program will start running with the USB cable still attached! For future downloads of the same program, use the Download button. Once the program has downloaded, you can safely disconnect the USB cable from the robot. 3. To run a program that has been downloaded to the NXT, use the on-screen menu and buttons: My Files Software files your program name Run : on-screen menu scroll left/right your program name select item go back If you use Download and Run first, the NXT will stay on the last menu screen when you Download changes to the program makes it easy to modify the program on the laptop and test the changes!

NXT Mindstorms: First Program For your first program, make the robot drive forwards for 1 wheel rotation, then stop. The program (when finished) should look something like this: 1. First, select the Move component (on the left of the canvas) by clicking on it: move 2. Second, place the component by clicking to the right of the Start icon : 3. Third, change the component settings (bottom of the canvas), such that motors A and C run forwards for 1 rotation: (select motors A and C) (forwards) (for 1 rotation) 4. Make sure the other movement settings are sensible for the task: no steering (in the centre), 75% power, and brake afterwards. 5. Download and run your program! If it works, the robot should drive forwards a short distance. download and run

NXT Mindstorms: Sensors This exercise uses the ultrasound sensor attached to the NXT robot: 1. Create a program similar to the first program you created, but where the robot moves forward forever: (select motors A and C) unlimited forwards movement 2. Download and run this program. The robot should drive forwards a short distance and then stop. Why does the robot stop..? Because once it is driving forwards, the program finishes and the motors shut-down automatically. To keep the robot driving forwards, the program needs to be told to wait for something. 3. Add a Wait for Distance component to the program, selecting it from the Wait menu: Wait for Distance Wait menu 4. Change the settings for the wait component to wait for less than 6 inches on sensor port 4: (sensor port 4) less than 6 inches (turn over...)

NXT Mindstorms: Sensors 5. Download and run this program. The robot should drive forwards until it sees an obstacle (through the ultrasound sensor) at a distance of less than 6 inches (roughly the length of the robot). Use your hand as an obstacle! (solid obstacle) Why does the robot sometimes run into the obstacle? Because the motors coast when the program finishes (and it takes some time here). 6. To tell the robot to stop as soon as it sees the obstacle, add another Move component to your program: 7. Unlike the first Move, this should be set to stop motors A and C: (motors A and C) (stop / brake) 8. Download and run this program. When the robot now sees the obstacle, it should stop suddenly. Re-run the program several times by pressing the Select button on the NXT you may want to unplug the USB cable before doing this! Try the program over larger distances as well (by running it on the floor, with someone at the other end to stop it!).

NXT Mindstorms: Driving This exercise involves turning corners with the robot. 1. Create the following program, using four Move components: (move forwards for 1 rotation) (turn 90 degrees anti-clockwise) (all stop) To turn the robot, use the following settings: (motors A and C) (for 0.77 rotations) (turn anti-clockwise) For the other Move components forwards for 1 rotation and all stop, use what you have learned so far! (or look at the earlier worksheets if you can t remember!). 2. Download and run your program. If it works, the robot should: move forwards a short distance, turn 90 degrees anti-clockwise, move forwards again, stop.

NXT Mindstorms: Loops Most computer programs involve loops that is, doing the same thing over and over. With the NXT robot, looping allows the robot to perform the same actions again and again. In the last worksheet, you programmed the robot so that it moved forward and turned. In this exercise, you will program the robot so that it repeats those actions. 1. Starting with a new program, select the Loop component and place it on the canvas. 2. Add three Move components, placing two of them inside the loop: (loop component) (all stop) Loop (turn anti-clockwise) (move forwards for 1 rotation) 3. The settings for the Move components should be the same as the previous worksheet: move forwards for 1 rotation (motors A and C), turn 90 degrees anti-clockwise (motors A and C, steering slider all the way to the right, moving for 0.77 rotations), all stop (motors A and C). 4. The settings for the Loop component should be: (select count control) (4 times) (third loop) 5. Download and run the program. If it works, the robot should drive around in a square: (fourth loop) (second loop) (first loop)

NXT Mindstorms: Range and Wander Now that you have created programs which: Move the robot forwards and turn corners, Stop the robot when the ultrasound sensor detects an obstacle, Loop to perform the same actions over and over, it s time to put these together to create a program which can drive around and avoid obstacles! 1. Create the following program, which contains: one Loop component, three Move components and one Wait for Distance component: (wait for less than 6 inches) (turn anti-clockwise) (loop forever) (move forwards forever) (move backwards for 1 rotation) 2. The Loop component should be set to loop forever: (loop forever) 3. The Wait for Distance settings should be for less than 6 inches on sensor port 4: (port 4) (less than 6 inches) (ultrasonic sensor) 4. The first Move component should be set to make the robot drive forwards forever. (as you did in the Sensors exercise). The second Move component should be set to make the robot drive backwards for 1 rotation: (motors A and C) (for 1 rotation) (drive backwards) (turn over...)

NXT Mindstorms: Range and Wander 5. The last Move component inside the Loop component should turn the robot anti-clockwise: (motors A and C) (for 0.75 rotations) (turn anti-clockwise) 6. Download and Run your program! If it works, the robot should move around, avoiding obstacles try it out on the floor! Make sure that you stay in front of your robot! (some obstacles the robot won t be able to see..) To stop the robot once it is running the program, press the stop/back button on the NXT: stop / back

NXT Mindstorms: Light Sensor The programs you have written so far have used the ultrasound (range) sensor. This exercise introduces you to the light sensor that is attached to the robot (pointing down at the ground). You will also need one of the A3 sheets with a black line on, available from the front of the class. A3 sheet light sensor connected to port 1 1. Create the following program, which contains: two Move components and one Wait for Light component: (wait for less than 50% light) (move forwards forever) The Wait for Light component can be found on the Wait menu: (all stop) (wait for light) The Wait for Light component should use the following settings: (port 1) (50%) (less than) When the NXT is connected to the laptop and powered up, this box will show the current value of the light sensor. This can be used to pick a suitable value, depending on surrounding light conditions. (turn over...)

NXT Mindstorms: Light Sensor 2. Download and run the program the robot should move forwards until it reaches the black line and then stop. 3. Modify your program so that after hitting the line, the robot reverses a short distance, turns slightly, then loops. Have the program loop just three times it should bounce off the line. The program should look something like the following (but need not be exactly the same!) having the correct behaviour is more important: (move forwards) (move backwards a bit) (stop) (loop 3 times) (wait for less than 50% light) (turn slightly) (stop)

NXT Mindstorms: Data Handling All of the programs you have written so far involve plugging components together. Although this is enough for the earlier tasks, more complex behaviours require the use of data values. These can be things such as the number of rotations of a motor, or the distance to something measured by the ultrasonic sensor. To start with, you will make the NXT display the distance moved by the robot as it reaches the black line (from the previous exercise). To get at the various components that are required for this, you need to select the Complete component palette: Common: standard set of components, most of which have been used before. Action: performing actions (e.g. motor on/off). Sensor: reading particular sensor values (e.g. light level). Flow: controlling program flow (e.g. loops, waiting). Data: storing and changing data (e.g. add, subtract). Advanced: various advanced features (e.g. bluetooth, data logging). Click here to show the complete set of components. 1. Starting with the move forward to line program from the previous worksheet: (wait for less than 50% light) (move forwards forever) (all stop) (turn over...)

NXT Mindstorms: Data Handling 2. Select the Rotation Sensor component from the Sensor components and insert it at the start of the program: (rotation sensor) (click here to show/hide) (data and control sockets ) The extra bit below the component is used to get and set various data and control information. These act as sockets that can be connected to other similar sockets on other components. Although most components have these sockets, they are hidden by default. Moving the mouse over each socket will provide a hint as to what data is input or output. The settings for this Rotation Sensor component, used to clear the rotation counter for one of the motors, are as follows: (motor A) (reset counter) (turn over...)

NXT Mindstorms: Data Handling 3. Add another Rotation Sensor component after the Wait for Light component: (rotation sensor) This should be set to read the value of the rotation sensor i.e. it will provide the number of rotations at the point the line was reached: (motor A) (read counter) 4. Now that the number of rotations is available, it needs to be displayed on the NXT screen. This involves adding a further three components: a Number to Text component from the Advanced palette, which turns the number of rotations into text that can be displayed on the screen; a Display component from the Action palette, which displays this text on the screen; and a Wait component from the Flow palette that delays for 3 seconds to give you time to read the text before the program exits. (number to text) (display) (wait) The Wait component should have the following settings: (wait for time) (3 seconds) (turn over...)

NXT Mindstorms: Data Handling 5. Before wiring the various components together, the Display component should be set to display text (by default it will display an image): (text) 6. Finally, connect the degrees output socket from the Rotation Sensor to the number input socket on the Number to Text component, and the text output to the text input on the Display component: Once all the necessary connections have been made, the sockets can be collapsed to only show those which are used, e.g.: 7. Download and Run your program! If successful, it should stop at the black line on the A3 sheet and show (on the display) the number of degrees turned by the wheel. 8. Having the robot tell you the number of degrees turned by the wheel (motor A) isn t terribly helpful. Modify the program so that it shows the distance travelled in centimeters. Hint: this can be done by adding a Math component from the Data palette given that the circumference of the wheel is roughly 18 centimeters, which represents 360 degrees of rotation, you can divide the number of degrees by 20 to get the distance travelled in centimeters. Run the modified program and check that the numbers it gives look sensible (i.e. the distance travelled by the robot before the line is reached). (one solution is given on the next page, but there are others!) (turn over...)

NXT Mindstorms: Data Handling Here is one possible solution to calculating the distance travelled by the robot: (math component) With the Math component set to the following: (set to division) (divide by 20) The ability to collect, process and use data in this way allows a lot of interesting possibilities. Although this program only displays data for you to see, such numbers can be fed into other components like the motor to control the distance driven. The next few exercises use data in this way.

NXT Mindstorms: Drive Back By measuring how far the robot moves until a certain condition is met (e.g. obstacle detected by the ultrasonic range sensor), you can have it move back to its starting point. The purpose of this exercise is to modify the basic light sensor exercise (that moves forward until the line is reached and then stops), so that it returns to its starting point. 1. Create the following program: The degrees output of the Rotation Sensor should be connected to the duration input of a Move component which is set to drive backwards. You re on your own here as to what the exact settings should be! 2. Test out your program by starting your robot at different distances from the line it should return to (more or less!) the same position from which it started.

NXT Mindstorms: Making Decisions So far you have written programs that wait for specific conditions (e.g. ultrasonic sensor value less than a particular distance). Sometimes it is useful to be able to make an instant decision based on a condition (e.g. light sensor seeing black). This way, the program doesn t stop but continues down one of two possible paths, depending on whether the condition was true or false. The purpose of this exercise is to create a line following robot that uses the light sensor. When the sensor is directly above the line, the robot turns one way, when the sensor is not on the line, the robot turns the other way. 1. Create the following program: The switch component should be set to the light sensor connected to port 1, with a decision of greater than 50%. If true (upper path), motor A is set to go forwards at 50% power and motor C forwards at 10% power, both unlimited duration (setting the two motors separately gives more control over steering than the steering control in the move component). If false (lower path), motor C is set to go forwards at 50% power and motor A forwards at 10% power, both unlimited duration. The whole program should be surrounded by a loop that repeats forever. 2. Test out your program on one of the sheets that has a mostly straight line on it check that it works. As the robot follows the line, try and identify the two different behaviours with the two paths in the program. 3. Test out your program on one of the sheets that has a fairly bendy line on it does it still work?

NXT Mindstorms: Multiple Decisions The last exercise involved making a decision on a true or false condition (whether the light sensor was above a particular value or not). In some cases, particularly for activities such as line-following, it is more useful to be able to have multiple paths in a program, where the particular path taken depends on the value of something (in this case, the value of the light sensor). Instead of simply turning left or right depending on whether the light sensor is on the line or not, in this exercise you will make the robot follow the edge of the line (where the light reading is somewhere between black and white). 1. Start by creating the following program: read light sensor divide by 20 (tabs to switch between conditions) switch on value The intensity value of the light sensor should be connected to input A on the math component, which is set to divide that by 20. The result of this is connected to the value input of the switch. The settings for the switch component are as follows: value control add condition remove condition set default condition number disable flat view Create five conditions, matching the values 0 to 4. With division by 20, this allows the program to select between the different light sensor values (0-19, 20-39, 40-59, 60-79, 80-100). The default condition (last) is used to match any value that does not fall into the listed choices (i.e. 100 20 = 5). (turn over...)

NXT Mindstorms: Multiple Decisions 2. Within each of the five conditions, the motors A and C need to be told to move by different amounts. Each of the different paths in the program can be accessed by clicking on the tabs at the top of the switch component. For example: To start with, use the following settings: Condition Value Light-levels Motor A Motor C 1 0 0-19 forwards 50% forwards 10% 2 1 20-39 forwards 50% forwards 30% 3 2 40-59 forwards 50% forwards 50% 4 3 60-79 forwards 30% forwards 50% 5 (default) 4 80-100 forwards 10% forwards 50% The theory behind this is that when the light sensor is on the edge of the line (value around 50) the robot will move straight forwards (50% power to both motors). If the robot drives more into the dark line, the sensor value will drop (to around 30) and as a result the robot will start steering towards the left (motor A 50%, motor C 30%). Similar logic applies as the robot drives into the white space, except that the robot steers the other way (motor A 30%, motor C 50%). 3. Test out the program on the different A3 sheets with a line (some sheets have thicker lines which may help with this exercise). If the robot fails to stick to the line, modify the program so that it does a better job. Here are some things to try: (a) Change the power levels in the motors, or even the direction. (b) Fine-tune the range by dividing by a smaller value and having a different set of conditions to match. Remember that when the robot is connected and the program has been downloaded at least once, the current light sensor value can be seen in the light-sensor component controls: current sensor reading

NXT Mindstorms: Further Exercises If you manage to complete all the other worksheets in time, here are some more exercises for you to have a go at! As far as programming goes, you re on your own here! 1. The NXT robot has a light sensor attached to it (pointing down at the ground). Using the area on the floor marked out with masking tape, have the robot move around inside the area, but not cross the line: (robot should stay within the marked area) Some useful hints: (light sensor) The general structure of the program should be similar to the Range and Wander worksheet. You can wait for a particular value on the light sensor using a component from the Wait menu. On this robot, the light sensor is connected to port 1. The value returned by the light sensor when it is on the masking tape will be higher than the value returned on the carpet. 2. Harder: if you can get the above program to work, have a go at writing a program where the robot follows the line of masking tape that marks out the area. 3. Harder: using the ultrasonic sensor, do the above two exercises but have the robot avoid obstacles (other robots!) as well.