Sensors - Tranducers Circuits

Compass Sensor for Lego Mindstorms NXT Schematic Circuit Diagram

A few years ago, a considerable amount of attention was devoted in Elektor Electronics to the construction of sensors for the intelligent control brick (RCX) from Lego Mindstorms [1].
There is now a successor. The NXT is the heart of the new Mindstorms. Using this system, computer hobbyists can develop, build and, in particular, program, numerous robots, to their heart’s content. With the compass sensor that is described here, the NXT can determine its direction with an accuracy down to a few degrees. This allows a robot to be built that’s capable of navigation. The company Devantec 121 supplies a ready-to-go compass module type CMPS03. Two mutually perpendicular Philips KMZ51 hall-sensors are used to detect the Earth’s geomagnetic field. With a small PIC-controller a value between 0 and 360 degrees is calculated and made available in digital form at the output of the module. The communication with the outside world takes place via the I2C pro-tocol or via a PWM output.

Compass Sensor for Lego Mindstorms NXT Schematic Circuit Diagram

The module requires a 5 V supply voltage and consumes about 20 mA. This mod-ule is eminently suitable for use with the NXT. The new NXT has the option of connect-ing sensors that use the I2C protocol. This allows a sensor to be connected to the NXT using an RP 2 plug. The NXT does not have internal pull-up resistors on the I2C bus. So, these have to be added externally. Lego suggest resistors with a value of 82 la on both the data line (SDA) as well as the clock line (SCL).
Software The standard Lego Mindstorms software is based in dragging graphical func-tion blocks. Only the parameters can be changed while the functionality of the blocks is fixed. Not Exact C (NXC) is a programming lan-guage for the NXT that has a strong resem-blance to C. This permits a much greater flexibility when programming. In particu-lar when it concerns hardware that is not officially supported by Lego, such as this compass sensor. The compiler (BricX) 131 can be down-loaded free, is simple to use and offers many options for programming the NXT.

The program compass.nxc (which can be downloaded free from the Elektor Electron-ics website as file number continually reads the compass sensor. The measured values are then processed by the robot who will sequentially ‘point’ to North, South, East and West. The values measured by the electronic compass can also be read from the display on the NXT brick.


Related Articles

Leave a Reply

Your email address will not be published.

Back to top button