Robotics II. Module 5: Creating Custom Made Blocks (My Blocks)

Similar documents
Robotics II. Module 3: Dealing with Files

Robotics II. Module 1: Introduction to Data & Advanced Programming Blocks

Robotics II. Module 2: Application of Data Programming Blocks

Robotics II. Module 4: Bluetooth Communication

Module 2, Add on lesson Introduction to the NXT and Mindstorms software. Teacher. 45 minutes

the NXT-G programming environment

Module 2, Add on lesson Introduction to the NXT and Mindstorms software. Student. 45 minutes

EV3 Programming Workshop for FLL Coaches

Loops and Switches Pre-Quiz

LEGO Mindstorm EV3 Robots

Figure 1: My Blocks are blue in color, and they appear in the Custom palette in NXT-G.

NXT Programming for Beginners Project 9: Automatic Sensor Calibration

Loops and Switches Pre-Quiz

Programming Techniques Workshop for Mindstorms EV3. Opening doors to the worlds of science and technology for Oregon s youth

Part A: Monitoring the Rotational Sensors of the Motor

lab A.3: introduction to RoboLab vocabulary materials cc30.03 Brooklyn College, CUNY c 2006 Name: RoboLab communication tower canvas icon

Programming with the NXT using the touch and ultrasonic sensors. To be used with the activity of the How do Human Sensors Work?

2Control NXT FAQ For the latest version of this document please go to > support

INDEX. Tasks 1-9. Tasks Tasks Tasks Tasks Tasks Tasks Tasks Tasks Tasks Tasks

Hands-on Lab: LabVIEW Angle Sensor

What Is a Program? Pre-Quiz

LEGO MINDSTORMS NXT Lab 4

LME Software Block Quick Reference 1. Common Palette

Importing the Vernier Sensor Block into LEGO MINDSTORMS 2

Tutorial: Making Legobot Move Steering Command Brighton H.S Engineering By: Matthew Jourden

Robot Navigation Worksheet 1: Obstacle Navigation

Chapter 19 Assembly Modeling with the TETRIX by Pitsco Building System Autodesk Inventor

LEGO mindstorm robots

Winning LEGO MINDSTORMS programming

contents in detail introduction...xxi 1 LEGO and robots: a great combination the EV3 programming environment... 5

Part A: Monitoring the Touch Sensor and Ultrasonic Sensor

ROBOLAB Tutorial MAE 1170, Fall 2009

NAME EET 2259 Lab 3 The Boolean Data Type

Unit 03 Tutorial 3: Sensors: Touch Sensor Brighton H.S Engineering By: Matthew Jourden

Introduction to Robotics using Lego Mindstorms EV3

SOLIDWORKS: Lesson 1 - Basics and Modeling. Introduction to Robotics

Tech Tips. BeeBots. WeDo

Robotics Study Material School Level 1 Semester 2

Lab1: Introductory and Setup Activities

How to - Record Your Own Sound Effects & Voice - Play them on the NXT Brick Within a Program

Robolab. Table of Contents. St. Mary s School, Panama. Robotics. Ch. 5: Robolab, by: Ernesto E. Angulo J.

COPYRIGHTED MATERIAL. Introducing LEGO CHAPTER. Did you get a box that looks like the one shown in Figure 1-1?

Database Use & Design

Computer Interfacing Using LabView

Technical Learning. To Get Started. 1. Follow the directions in the Constructopedia to build Robo 1.

Chapter 18 Assembly Modeling with the LEGO MINDSTORMS NXT Set Autodesk Inventor

Introducing Cubelets. What do they do?

Unified Computers & Programming Installation Instructions for Windows

BEGINNER PROGRAMMING LESSON

Shorthand for values: variables

Project Planning. Module 4: Practice Exercises. Academic Services Unit PREPARED BY. August 2012

CHAPTER 1 COPYRIGHTED MATERIAL. Finding Your Way in the Inventor Interface

How to Get Started. Figure 3

THE PAINT WINDOW. At the very top is the Title Bar, just as in all programs, below it is a very simple Menu Bar and below that is the Ribbon.

Download Program. Setup ROBOTC. task main() { motor[motorc] = 100; wait1msec(3000);

Designing the staging area contents

Using Flash Animation Basics

WIZ-PRO2 CURRICULUM HIGHLIGHTS

HOW TO. In this section, you will find. miscellaneous handouts that explain. HOW TO do various things.

Tutorial: Overview. CHAPTER 2 Tutorial

On the Web sun.com/aboutsun/comm_invest STAROFFICE 8 DRAW

Robotics 2c. The Programming Interface

Creative Sewing Machines Workbook based on BERNINA Embroidery Software V8

Storing Your Exercise Files

S3 Scratch Programming

Working with Macros. Creating a Macro

1 Introduction to Using Excel Spreadsheets

A computer running Microsoft Word 2010 (Windows), or Word 2008 (Mac)

Managing Your Grade Book This lesson will show you how to set up your grade book columns and have Canvas calculate your final grades for you.

Basic Concepts 1. For this workshop, select Template

This page outlines some of the alternate pieces that can be used for building.

MAPLOGIC CORPORATION. GIS Software Solutions. Getting Started. With MapLogic Layout Manager

Introduction. A Brief Description of Our Journey

Animations involving numbers

= 3 + (5*4) + (1/2)*(4/2)^2.

Hot X: Algebra Exposed

Quick Start Guide. Microsoft Visio 2013 looks different from previous versions, so we created this guide to help you minimize the learning curve.

CreateLAB. Visual PRogrammer. copyright 2015 Birdbrain Technologies LLC

ROBOCUP RESCUE LEGO MINDSTORMS NXT-G TURN ON GREEN G. Tardiani NXTG Programming Guide 2008

Importing source database objects from a database

introduction to RoboCupJunior Rescue vocabulary materials

Integrated Study Units For Clicker 5

Introduction: What is NXT-G?

Survey of Math: Excel Spreadsheet Guide (for Excel 2016) Page 1 of 9

Section 6 Storage Space

CHAPTER 1 COPYRIGHTED MATERIAL. Getting to Know AutoCAD. Opening a new drawing. Getting familiar with the AutoCAD and AutoCAD LT Graphics windows

FrontPage 98 Quick Guide. Copyright 2000 Peter Pappas. edteck press All rights reserved.

In groups take a Mindstorms kit and decide on what sort of chassis will work best.

SP LOCKER USER MANUAL. v1.0

FACULTY AND STAFF COMPUTER FOOTHILL-DE ANZA. FileMaker Pro. Relational Databases

The purpose of this tutorial is to introduce you to the Construct 2 program. First, you will be told where the software is located on the computer

SCRATCH MODULE 3: NUMBER CONVERSIONS

We ve been playing The Game of Life for several weeks now. You have had lots of practice making budgets, and managing income and expenses and savings.

Lecture (06) Java Forms

InDesign Tools Overview

Getting Started Guide

Analyzing PDFs with Citavi 6

Detailed instructions for video analysis using Logger Pro.

Meet the Cast. The Cosmic Defenders: Gobo, Fabu, and Pele The Cosmic Defenders are transdimensional

Using Adobe Photoshop

Transcription:

Robotics II Module 5: Creating Custom Made Blocks (My Blocks) PREPARED BY Academic Services Unit December 2011 Applied Technology High Schools, 2011

Module 5: Creating Custom Made Blocks (My Blocks) Module Objectives Upon successful completion of this module, students should be able to: Create, edit and configure a my block Insert a my block inside a program and test its functionality Module Contents: Topic Page No. 5.1 Introduction 3 5.2 Lab Activity 1 4 5.3 Lab Activity 2 10 5.4 Review Exercise 19 2 Module 5: Creating Custom Made Blocks (My Blocks)

5.1 Introduction By now you may have noticed that an NXT-G program can quickly become very large. Furthermore, simple tasks such as displaying a number or adding one to a variable can require several blocks. Also, many of the same groups of blocks are used repeatedly in different programs and often within the same program. My Blocks help you overcome these issues. Figure 5.1 shows an example of using my blocks inside an NXT-G code. Figure 5.1: Using My Blocks inside a Maze Navigator Program So, what is my block? A My Block is a collection of NXT-G blocks that you have grouped together and may wish to reuse. In this module, you ll learn how to create and use a My Block in your programs. Module 5: Creating Custom Made Blocks (My Blocks) 3

5.2 Lab Activity 1 Objectives: 1. Create, edit and insert a my block into a program Material per Group: 1. 1 NXT Bricks 2. 1 USB cable Procedure: Step 1: Creating a my block 1. Write the following NXT-G code: 2. Download and run your program. 3. What does the program do: 4. Select the sequence of blocks that will make up the My Block by dragging a selection rectangle over them. 5. Click the Create My Block button on the toolbar as shown below: 4 Module 5: Creating Custom Made Blocks (My Blocks)

6. The My Block Builder window will appear: The My Block Builder window contains boxes for entering a name and description for the new block. The Selected Blocks area lets you see which blocks were selected to make sure you re creating the block you expect. If the correct blocks aren t displayed, click the Cancel button and start again. 7. Enter BeepBeep in the Block Name box 8. Insert comments to describe your block in the block description box. 9. Click the next button. The following window will appear: Module 5: Creating Custom Made Blocks (My Blocks) 5

10. Create a new icon by dragging one or more icons from the lower section of the window into the box in the Icon Builder section. You can resize and move the individual images to create a new unique icon for your block. 11. Click the Finish button. Clicking Finish will create the BeepBeep block and replace the old three blocks with the new block in the program. 6 Module 5: Creating Custom Made Blocks (My Blocks)

12. Move the blocks closer together ATE 1122 - Robotics II 13. Download and run your program after creating BeepBeep block. What does the program do: Question: What is the effect of creating BeepBeep Block on the sequence of the program? Step 2: Viewing and Editing the Contents of a My Block To edit a My Block, you can either double-click it or select it and choose Edità Edit Selected My Block from the menu. This will open the block in the MINDSTORMS software, where it will look like a small program. Now, to edit the BeepBeep block, follow these steps: 1. Select BeepBeep Block Module 5: Creating Custom Made Blocks (My Blocks) 7

2. Select Edità Edit Selected My Block from the menu 3. The blocks that make up the BeepBeep block should look as follow: 4. Once the block is open, you can make changes, including adding and removing blocks, changing the settings of the blocks, or adding comments. Change the wait block time to 0.5 seconds. 5. Save and close the BeepBeep block (go to Fileà Save and Fileà Close) 6. Download and run your program. What do you observe? Step 3: Inserting a my block into a program Once you ve created a My Block, you can use it in any program, just like any other block. All of your My Blocks will appear on the Custom Palette. 1. Select the Custom Palette as shown below: 8 Module 5: Creating Custom Made Blocks (My Blocks)

2. Insert BeepBeep block into your program. Newly created My Blocks will appear in the top group on the Custom Palette, as shown below: 3. Your modified program will look as follows: Module 5: Creating Custom Made Blocks (My Blocks) 9

5.4 Lab Activity 2 Objectives: Build a My Block for displaying numbers on the NXT s screen Material per Group: 1 NXT 1 USB cable 1 Sound sensor Background Information: Several of the programs presented in the previous modules have used the Number to Text, Text, and Display blocks to display a labeled value. For example, light meter, sound meter and pinball machine programs. Figure 5.2 shows the sound meter program where the sound sensor readings are collected and displayed on the NXT Screen. Figure 5.2 The Sound Meter Program In this activity, you ll create the DisplayNumber block from the Number to Text, Text, and Display blocks, which will make displaying numbers much more convenient. Before creating a My Block, think about the configuration items that your new block will need. For Example, DisplayNumber block will need the following configuration: 10 Module 5: Creating Custom Made Blocks (My Blocks)

Ø The number passed to the Number to Text block à the displayed value Ø The A value for the Text blockà the label for the value. Ø The C value for the Text blockà the unit of the value. Ø The Clear setting for the Display block. Procedure: Step 1: Setting the configuration of the DisplayNumber block 1. Create a new program named DisplayBlockBuilder. 2. Add a Number to Text block, a Text block, and a Display block. 3. Set the Display block s Action setting to Text. 4. Open the data hubs of the Text and Display blocks. 5. Connect the Number to Text block s Text data plug to the Text block s B data plug. 6. Connect the Text block s Combined Text data plug to the Display block s Text data plug. Module 5: Creating Custom Made Blocks (My Blocks) 11

7. Add a Math block at the beginning of the program, to the left of the Number to Text block. 8. Connect the Math block s Result data plug to the Number to Text block s Number data plug. Note: The only reason the Math block is there is to connect a data wire to the Number to Text block s Number data plug. The Math block won t become part of the DisplayNumber block. A Math block is used because we need to connect a data wire to the Number to Text block s input data plug, and the Math block has an output data plug that uses a number. Any block that has an output data plug that uses a number would work just as well as a Math block. 9. Add two Text blocks at the beginning of the program 10. Connect the Combined Text data plug of one of the new Text blocks to the original Text block s A data plug. 12 Module 5: Creating Custom Made Blocks (My Blocks)

11. Connect the Combined Text data plug of the other new Text block to the original Text block s C data plug. 12. Close the data hubs for the two new Text blocks and the Math block. The program should look like this: 13. Add a Compare block at the beginning of the program. 14. Connect the Compare block s Result data plug to the Display block s Clear data plug. 15. Close the Compare block s data hub. The program should look like this: Module 5: Creating Custom Made Blocks (My Blocks) 13

Step 2: Testing All the blocks are now in place and connected. But how do you know it s really going to work? The only way to find out is to test the code, and the earlier you test it, the easier it will be to fix any problems. To test the code, you can set the four input values and then see whether the correct text is displayed. 1. Add a Wait block to the end of the program. 2. Select NXT Buttons from the list of sensors. 3. Your new program will look as follow: 14 4. Select the first Text block. Set the A value to Unit, with a space Module 5: Creating Custom Made Blocks (My Blocks)

before the U. 5. Select the second Text block. Set the A value to Label:,with a space after the colon. 6. Select the Math block. Set the A value to 17. 7. Download and run your program. What is the text displayed on the NXT Screen? Note: If the program doesn t work, check all the data wire connections; there are a lot of them, and it s easy to get one wrong. Step 3: Creating the DisplayNumber Block Once you have tested your block; it s time to create the My Block. Follow these steps to create the DisplayNumber block: 1. Select the Text, number to text and the display block. 2. Click the Create My Block button on the toolbar. The My Block Builder Window will appear: 3. Enter DisplayNumber for the Block Name option. 4. Enter Display a number with a label and unit for the Block Description option. 5. Click the Next button. The My Block Builder window should now show the controls for building an icon for the new block. Module 5: Creating Custom Made Blocks (My Blocks) 15

6. Create an icon for the new block. 7. Click the Finish button. The blocks that were selected should be replaced by a DisplayNumber block Step 4: Changing the names of the configuration items The Configuration Panel for the new DisplayNumber block is shown below: As you can see, the names for most of the configuration items are not very meaningful. For example, the block uses two texts: the label and the unit. The configuration Panel has boxes to enter two texts, but the 16 Module 5: Creating Custom Made Blocks (My Blocks)

names A and C don t tell you which value each box is used for. To fix this problem, open the block, and change the names to something more meaningful by following these steps: 1. Double-click the DisplayNumber block to open it. 2. Double-click the comment with the text A, and change it to Label. 3. Double-click the comment with the text C, and change it to Unit. 4. Save and close the DisplayNumber block. 5. To see the updated Configuration Panel, add the DisplayNumber block to a new program. The DisplayNumber block should appear on the Custom Palette. The new configuration will be as follow: Step 5: Using the DisplayNumber block inside your program let s put it to use. Follow these steps to use the DisplayNumber block in the sound meter program. Module 5: Creating Custom Made Blocks (My Blocks) 17

1. Write the sound meter program 2. Delete the Number to Text, Text, and Display blocks from the sound meter program 3. Add the DisplayNumber block from the custom palette after the sound sensor block. 4. In the DisplayNumber block s Configuration Panel, set the Label item to Sound: (with a space after the colon). 5. Check the Clear option. 6. Draw a data wire between the sound level data plug to the number data plug of the DisplayNumber block. 7. Download and run your program. What do you see on the NXT Screen? 18 Module 5: Creating Custom Made Blocks (My Blocks)

5.4 Review Exercise 1. Create a my block that will convert the rotation of a motor into a distance. The configuration of the created block will be as follow Ø Block Name: R2D Ø The block will have one input (the rotation of the motor) Ø The block will display the distance on NXT Screen Hint: distance = circumference of the wheel X rotations Write your program here: 2. Mention the advantages of using a My Block inside your programs? References: Terry Griffin (2010). The Art of LEGO MINDSTORMS NXT G Programming. No starch press: USA Module 5: Creating Custom Made Blocks (My Blocks) 19