IURQWIP3DJHL:HGQHVGD\2 WREHU30 Extreme MINDSTORMS TM : An Advanced Guide to LEGO MINDSTORMS TM DAVE BAUM, MICHAEL GASPERI, RALPH HEMPEL, AND LUIS VILLA
IURQWIP3DJHLL:HGQHVGD\2 WREHU30 Extreme MINDSTORMS TM : An Advanced Guide to LEGO MINDSTORMS TM Copyright 2000 by Dave Baum, Michael Gasperi, Ralph Hempel, and Luis Villa All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN (pbk): 1-893115-84-4 Printed and bound in the United States of America 12345678910 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Editorial Directors: Dan Appleman, Gary Cornell, Karen Watterson Technical Reviewers: Dave Baum, Rodd Zurcher Projects Manager: Grace Wong Developmental Editor and Indexer: Valerie Perry Copy Editor: Kiersten Burke Production Editor: Janet Vail Page Composition and water braiding: Susan Glinert Artist and Cover and Part Opener Designer: Karl Miyajima Distributed to the book trade in the United States by Springer-Verlag New York, Inc.,175 Fifth Avenue, New York, NY, 10010 and outside the United States by Springer-Verlag GmbH & Co. KG, Tiergartenstr. 17, 69112 Heidelberg, Germany In the United States, phone 1-800-SPRINGER; orders@springer-ny.com; http://www.springer-ny.com Outside the United States, contact orders@springer.de; http://www.springer.de; fax +49 6221 345229 For information on translations, please contact Apress directly at 901 Grayson Street, Suite 204, Berkeley, CA, 94710 Phone: 510-549-5931; Fax: 510-549-5939; info@apress.com; http://www.apress.com The information in this book is distributed on an as is basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the authors nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work.
IURQWIP3DJHLLL:HGQHVGD\2 WREHU30 Foreword... viii Chapter 1 Extreme MINDSTORMS... 3 The Hackers Step In... 4 MINDSTORMS Expands... 6 RIS 2.0... 8 An Extreme Future... 8 Chapter 2 The RCX... 11 Architecture... 11 Hardware... 14 Output Ports... 16 Sensor Ports... 18 LCD... 25 Sound... 26 Standard Firmware... 27 Programming the RCX... 29 Chapter 3 Seeker: A Light-Seeking Robot... 31 Construction... 31 Using the Bumper... 36 Seeking a Light... 41 Bumping and Seeking... 44 More Explorations... 51 Chapter 4 RCX 2.0 Firmware... 53 Getting Started... 53 Local Variables... 56 Display... 57 Arrays... 60 Access Control... 64 Events... 68 Bits and Pieces... 76 iii
IURQWIP3DJHLY:HGQHVGD\2 WREHU30 Chapter 5 Introduction to pbforth...79 pbforth Is Interactive...79 pbforth Is Interpreted...80 pbforth Is Extensible...80 Why Learn pbforth?...80 Why Learn about RCX Details?...81 Installing pbforth...83 pbforth Fundamentals...85 RCX Basics and Generating Output...89 Numbers and Expressions...95 Defining New Words for pbforth...101 Conditionals and Bitwise Operators in pbforth...104 Basic RCX Sensors and Motors...107 Looping in pbforth...110 Using the Pushbuttons...111 Summary...117 Chapter 6 Programming Seeker in pbforth...119 Making Seeker Move...120 Displaying Motor States...122 Making Seeker See and Feel...130 Using the Timers...138 The Light Sensor and Thresholds...141 Summary...148 Chapter 7 Introduction to LegOS...151 So Why LegOS?...151 So What s the Catch?...152 So, How Does it Work?...152 Basic LegOS Functions...156 The LegOS Seeker...170 Conclusion...180 Chapter 8 Advanced LegOS...181 Rotation Sensors...181 Sound...183 Math in LegOS...186 LegOS Network Protocol (LNP)...187 LegOS Debugging...188 iv
IURQWIP3DJHY:HGQHVGD\2 WREHU30 Trailerbot... 189 Going Further with LegOS Use the Source, Luke!... 213 Chapter 9 Homebrew Passive Sensors... 219 Getting Parts... 219 Alligator Clip Quickie... 220 Coin Detector... 222 Cut Wire Connector... 223 Stick-In-Ring Switch... 224 Terminal Block Temperature Sensor... 225 RCX Input... 227 More Accurate Temperature Sensors... 228 Waterproof Temperature Sensor... 231 A Relative Humidity Sensor... 232 50K Ohm Potentiometer Angle Sensor... 234 Cut Electric Plate Connector... 237 CdS Photocell Sensor... 238 Galvanic Skin Response... 240 Voltage Input Sensor... 242 Battery Tester... 243 A Tachometer... 244 A Potpourri of Passive Sensors... 245 Part Cross-reference List... 246 Conclusion... 247 Chapter 10 Homebrew Powered Sensors... 249 Getting Parts and Tools... 249 Getting Started... 249 RCX Powered Interface... 250 Sensor Power Circuit... 250 Sensor Measurement Circuit... 254 Optointerrupter Sensor... 256 Buffer Circuit... 258 Buffered Voltage Input... 261 Amplifier Circuit... 261 Amplified Voltage Input... 263 Differential Light Sensor... 263 Sound Sensor... 266 Printed Circuit Board... 271 Soldering... 272 Packaging... 277 v
IURQWIP3DJHYL:HGQHVGD\2 WREHU30 Going Further...279 Bill of Materials for Powered Sensors...279 Conclusion...282 Appendix A Internet Resources...283 General Information...283 NQC...283 pbforth...284 LegOS...284 Homebrew Sensors...284 Suppliers...284 Appendix B NQC API Reference...287 Sensors...287 Outputs...289 Sound...290 Display...291 Communication...291 Timers and Counters...292 Access Control...293 Events...294 Miscellaneous...296 Special Features RCX...296 Special Features Scout...297 Special Features CyberMaster...298 Appendix C Frequently Used Forth Words...299 Stack Words...300 Math Words...301 Logical Words...302 Conditional Words...303 Compiler and Memory Words...303 Control Structure Words...306 Input and Output Formatting Words...307 RCX Extension Words...308 vi Appendix D LegOS API Reference...317 LCD Functions...317 Motor Functions...318
IURQWIP3DJHYLL:HGQHVGD\2 WREHU30 Sensor Functions... 318 Math Functions... 319 Program Control... 320 Time Control... 320 Hardware Control... 321 Music... 321 Buttons... 322 Semaphores... 322 LNP functions... 323 Standard C Library Functions... 323 Appendix E Installing LegOS... 325 LegOS Installation for Debian Linux... 326 LegOS Installation for Red Hat Linux... 327 LegOS Installation for Windows... 329 Index... 333 vii
http://www.springer.com/978-1-893115-84-2