Loginskip to content

NXT Repository/Tutorials/

Getting started with LEGO Mindstroms NXT.

Search under this category:

Sub-categories:

Contributions:

ISOGAWA Yoshihito’s “LEGO Technic Tora no Maki”

Last update: Sunday, September 30th, 2007

ISOGAWA Yoshihito, who has already written  one NXT book and one Technic/Mindstorms book (both in Japanese), has released a beautiful LEGO Technic book in PDF format. The book is available for download; you are asked to pay $10 if you decide to use the book. The book shows a wide range of Technic mechanisms and small constructions. The mechanisms range from simple gear reductions to suspensions, clutches, and much more. The creations include many different vehicles and walkers, all fairly simple to reproduce. The book uses many different LEGO parts, some new (NXT motors, Power Functions motors and battery boxes) and some old (RCX motors, small pneumatic cylinders, the solar cell). In some cases, the book shows how to build essentially the same construction with two different kinds of motors or other specialized parts. The book covers basically all the kinds of mechanisms that you can build with Technic: gears, chains, pulleys, pneumatic, and so on. There is essentially no text, just pictures to illustrate principles and mechanisms. The graphics are beautiful, with clever icons to indicate chapters.

Browsing through the book will surely remind you why you enjoy LEGO so much!

LeJOS Tutorial

Last update: Thursday, September 13th, 2007

Here’s a link for a tep-by-step tutorial explains in detail how to install java, leJOS and Eclipse on a windows computer. LeJOS is a Java VM for the LEGO Mindstorms NXT which can be downloaded here.

Linux Bluetooth Starter

Last update: Sunday, July 30th, 2006

Jürgen Stuber has a cool little tutorial showing how to receive a bluetooth transmission of data from the NXT brick to a Linux box.

Making your own digital sensors

Last update: Monday, June 11th, 2007



Michael Gasperi made a homebrew digital (I2C slave) sensor. Creating digital sensors typically requires either some hardware which supports I2C communication, such as PCF8574 digital port expander, or a microcontroller like the Microchip PIC. The later alternative is the most versetile, allowing using all the microcontroller features to interface with the NXT. These include digital input/output, analog input/output, UART (i.e. RS232, needed for instance for most GPS/GSM modules) etc. The pitfall, however, is that one need to program the PIC to behave as a proper “I2C Slave”. In this dedicated page Michael explains how to do this efficiently.

NOTE: Sivan Toledo did a similar job with the TI MSP430 family chips. Take a look here.

More on HiTechnic IRLink and PF

Last update: Monday, October 1st, 2007

As I posted a few days ago, the new HiTechnic IRLink (which should be available from HiTechnic in about a week) opens up new opportunities for controlling extra motors with the NXT. The IRLink sensor (i.e. it connects in a sensor port) allows the NXT to control the new RC LEGO trains, control the RCX (like the RCX IR Tower did) and control the new Power Function motors. The new PF motors, which are available in 2007 kits like the LEGO Creator Dinosaur (1 medium and 1 large motor) and the 8275 Technic Bulldozer (2 medium motors, 2 large motors) have their own battery box (a conversion cable for directly connecting to the NXT is supposed to be released soon) and can connect either directly to the battery box or via a special IR receiver. The IR receiver allow controlling the PF motors via a special remote control, also available from LEGO in the above mentioned kits.
So, back to the IRLink from HiTechnic. Since each IR receiver control 2 motors (let’s call them motor 1 and motor 2) and can have 1 of 4 ‘channels’, you can operate up to 8 PF motors using one IRLink. Notice, however, that the current needed will probably require more then 1 battery box for 8 motors running in parallel…. HiTechnic will release 3 special NXT-G blocks for the IRLink - one for RC Train system, one for RCX communication and one for controlling PF motors. In the rest of this post I am going to discuss the later block.
Before we go off - a short reminder. When you wire one of the regular NXT servo motors, the simplest program I can think of is ‘run motor until I press orange button’. Below is an NXT-G program that does just that:

Quite simple, isn’t it? So, when I first got my IRLink connected to my NXT (after importing the NXT-G block from HiTechnic) I dropped the block on my diagram and made this program:

the control panel for the PF block is shown below

As you can see, I asked Motor 1 to move ‘Forward’ and then had a ‘Wait for Button Press’. Eagerly I ran the program and to my great disappointment the motor rotated for a short moment and then stopped. The program, however, was still running until I pressed the orange button.

What happened? Well, here’s the catch. The IRLink acts just as the Remote Control does. When you want a PF motor to move forward you move one of the RC joysticks up and hold it until you want it to stop. If you press forward for a short period and then release the knob, the motor would rotate for a short period - just like what happened in my first program.

What should be done? If you want a persistent motion, you should put the PF block in a loop. You must also make sure that executing the rest of the loop does not take too much time, else the motion will be jerky. My second program is shown below:

now the motor rotated continuously as I expected. As this block’s behavior is quite different then the concept of ‘Move Unlimited’ block, this may be a cause for some confusion at first.

Remember - when in doubt about how to use IRLink for controlling PF motors, think in terms of how you would have done the same with the manual PF Remote Control. I am having great fun with these motors….

Guy Ziv

NXC Tutorial

Last update: Tuesday, February 13th, 2007

Daniele Benedettelli published a nice tutorial on NXC. You can download it from NBC/NXC website or directly here.

NXT Constructopedia - Beta 2

Last update: Friday, November 2nd, 2007

A useful resource for individuals and educators alike. It explains and give building instructions for various NXT/motors attachments, swirling/sliding fronts, few simple projects and a nice quick start car.

Download it here.

NXT Memory and File System Organization

Last update: Thursday, August 3rd, 2006

Here’s a little bit more technical information on the LEGO Mindstorms NXT file system and memory.

The main processor on the NXT is an ARM7 RISC CPU equipped with 256K bytes of flash memory and 64K bytes of RAM memory

Sector size on the flash memory is 256 bytes. There are hardware commands to erase either a single sector or all sectors at once. The “erase” and “write” command operates on a complete sector in flash.

The NXT firmware is loaded into flash memory starting from the front. The “leftover” flash (about ~128K) at the rear is used for the NXT’s file system

The last sector in the flash contains the file system “table of contents” (TOC). It is a 64 element array of pointers. Each pointer is either NULL or the starting address of the first flash sector of a file. Since the TOC is only one sector long, the NXT file system is limited to 63 files total. One of the “pointers” is used to contain some flags.

Flash memory is specified to support 10K write cycles. It might be worrisome that the TOC is written so often that this will be exhausted in a year or two of heavy use (two rewrites per file download!). Fortunately, (1) the spec appears to be extremely conservative and (2) the most common failure mode is the flash will simply not retain its contents for the full 10 years in its design spec.

The first few bytes of a file contain system information about the file – like its name – and access to these bytes is normally hidden from user programming.

(more…)

NXT Sensors Primer

Last update: Saturday, July 29th, 2006

Short tutorials on the NXT sensors from the LEGO Education site

NXT-G Tutorial

Last update: Saturday, July 29th, 2006

NXT Online Tutorial by the Oregon Robotics Tournament and Outreach Program

PID Control: Staying Put

Last update: Monday, May 25th, 2009

I racked my brain trying to come up with another example of PID control that didn’t involve a whole lot of hocus pocus and math for my next article.  Then I remembered; a few months ago when I first got my Hitechnic Magnetic Compass Sensor, I wrote a quick program to test it.  It was nothing special, just a program that would allow the robot to sit on a spinning platform but remain pointing in the direction it started off at.   I had forgotten that it has a small PID control in it to make it react faster if the platform was spun more quickly. 


So how does this one work?  When the program starts, the robot checks its current heading and makes this its Set Point.  Any change in the position of the spinning platform will cause the robot to rotate as well, thus changing its heading.  The difference between the new heading and the Set Point is the error.  Using the PID control a response is calculated and actuated by the motors.  If the platform is rotated slowly, the robot will in turn only pivot slowly about its axis.  However, if you give the platform a nice spin, the robot will speed up its motors and try to keep up.

You can download the RobotC source code from here: [LINK].  Make sure you calibrate the compass and mount it as far from the motor and brick as possible (at least 15 cms) due to magnetic interference.

RobotC and Debugging

Last update: Monday, October 1st, 2007


Here’s something I got from Dick Swan, the developer of RobotC:

Debugging your programs is always a challenge on the NXT. ROBOTC is one of the few programming solutions for the NXT that offer a traditional run-time “debugger” capability. It’s usually a lot easier to correct programs with a debugger rather than manually inserting “print” or “display” statements in your program to try to figure out what’s wrong.

The capabilities of a run-time debugger can be shown using the ROBOTC solution. The PC screen shot above illustrates several of debugger features

With the ROBOTC debugger you can:

  • Start and stop your program execution from the PC
  • “Single step” through your program executing one line of code at a time and examining the results (i.e. the values of variables) the flow of execution.
  • Define “breakpoints” in your code that will cause program execution to be suspended when they are reached during program execution
  • Read and write the values of all the variables defined in your program
  • Read the write the “values” of motors and sensors as your program is executing.
  • Remote the NXT LCD and buttons to your PC desktop.

For more details on the features of the ROBOTC debugger, open this file.

PERSONAL NOTE: The free NXC/NBC also has a real-time debugger. But they have different feature sets and capabilities. Maybe John Hansen can shed more light on this issue?

Taking pictures of your NXT creations

Last update: Tuesday, February 12th, 2008

Dave Parker made this wonderful page with instructions on taking quality pictures of LEGO NXT creations. There’s a quick and simple page for kids, and mor elaborate page for those with more patience.. Thanks Dave!

Technic Pins

Last update: Wednesday, November 1st, 2006

Jim German posted this article describing the different pins in the NXT set, and what they are (usually) good for.


Any additions/suggestions/comments? Send an email to repository@nxtasy.org.