Project from Real-Time Systems – Lego Mindstorms NXT April 16, 2014 Lego Mindstorms NXT Lego Mindstorms • manufactured by LEGO, http://mindstorms.lego.com • history: • RCX, 1998 • NXT, 2006; NXT 2.0, 2009 • EV3, 2003 • use in education: • out-of-the-box, easy to use • widely adopted, • faithfully illustrates the features of embedded real-time systems and their programming. Lego Mindstorms NXT NXT Brick • 32-bit ARM7 microcontroller, 256 KB FLASH memory, 64 KB RAM • timer doing 1000 ticks per second • 4 input ports, 3 output ports, peripherals connected via modified RJ12 cables • USB port, Bluetooth interface • loudspeaker (conversion tools from MIDI, WAW, etc. available) • buttons, display • power source: 6 AA batteries Lego Mindstorms NXT Motors & Sensors Motors • 3 electric motors, built-in gear • synchronization, built-in rotation sensor (accuracy +- 1 deg) • typical use: • set power (0-100), direction (fwd, rev), set on/off, or • turn the shaft by a given angle at a given power. Sensors • touch sensor (binary: pressed/not pressed) • sound sensor - measures acoustic pressure, up to 90 dB, works with a percentage of max value. • light sensor - measures intensity of ambient/reflected light • ultrasound sensor - measures distance to objects (0 – 255 cm, +- 3cm), accuracy depends on size, shape and composition of objects Lego Mindstorms NXT Programming Environments Visual: • NXT-G (bundled) • Robolab “Code-based”: • NXC (Not eXactly C) • C-like syntax, IDE for Win (BricxCC), compiler (NBC) source available for Mac and Linux • leJOS NXJ • firmware replacement allowing to run Java on NXT Brick • comes with rich Java API • plug-ins for Eclipse • ... and many others (see, e.g., Wikipedia, or http: //www.teamhassenplug.org/NXT/NXTSoftware.html). All reasonable languages support multitasking. Lego Mindstorms NXT Project: Organization • work in teams • each team chooses a leader • submit short project abstract (up to 1/2 page) by April 8 • work :) • submit a project report (up to 5 pages) and program source by May 11 • presentation of results (probably) during a lecture on May 14 Contact: xnovot18@fi.muni.cz Lego Mindstorms NXT Project: Requirements • the robot performs a non-trivial, meaningful and a well-defined task. • the robot uses at least 2 motors and 2 sensors • the robot uses display or speaker • the implementation uses concurrency in a meaningful way (at least 2 threads running in parallel) • the resulting system is a hard real-time system (i.e., a successful completion of the defined task depends on a correct timing) • implementation in NXC or leJOS is preferred, choice of a different language should be consulted in advance Lego Mindstorms NXT Project: Evaluation Project report: • up to 5 pages • describes the task performed by the robot and the implementation, substantiates changes from the project abstract, describes difficulties encountered during implementation, points out the use of concurrency • specify the contribution of individual members (does not have to be equal, but team members may “kick out” work-avoiding colleagues) Source code: • non-visual language • well-documented source code Presentation: • with slides and demo, not necessarily by the team leader Lego Mindstorms NXT Project: Topic • it is a part of the project to choose an interesting yet doable goal • search the internet for inspiration (e.g., YouTube: Lego Mindstorms) • all-time classics: finding, picking up and transporting a ball; following a black line; navigation through a maze Lego Mindstorms NXT Quick Start Guide • if possible, install Lego Mindstorms, BricxCC, or leJOS • play around for a while, test the sensors etc. • read manuals and tutorials on the web • build a simple robot and try to compile a simple program • discuss the project Lego Mindstorms NXT