• Lego Mindstorms NXT Magnetic Sensor

The NXT Magnetic Sensor will enable you to build robots that can detect magnetic fields. The sensor detects magnetic fields that are present around the front of the sensor in a vertical orientation.

The sensor detects magnetic fields when the orientation of the magnet is as shown below.

magnetic sensor

When the orientation of the magnetic field has north uppermost, the reading will increase. If the magnet is presented sideways, it may not be detected.
 
The Magnetic Sensor connects to an NXT sensor port using a standard NXT wire and uses the analog sensor interface. The sensor can be read up to approximately 300 times per second.
 
The Magnetic Sensor is housed in a standard Mindstorms sensor housing to match the other Mindstorms elements.
 
To quick test your new sensor, plug it into port 1 of your NXT brick and select View – Ambient light – Port 1. As you bring a magnet close to the front of the sensor, you'll notice that the readings will change as the magnet gets closer.
 
Programming
 
Mindstorms NXT-G
 
The Magnetic Sensor can be programmed using LEGO Mindstorms NXT-G Software by importing the Magnetic Sensor Block. This and other HiTechnic sensor programming blocks are available from the downloads page.
 
The Magnetic Sensor Block provides access to the sensor output in addition to other features.
 
 
  1. The number shows which of your NXT's ports are connected to the Magnetic Sensor. You can change this number in the configuration panel if you need to.
  2. The block's data hub will open automatically when the block is placed in the work area. At least one data wire must be dragged from the block's output plug to another block's data hub. (See the Data Hub section below for more information.)
Configuring the Magnetic Sensor Block
 
 
The sensor may be connected directly to an NXT sensor port or via the HiTechnic Sensor Multiplexer (MUX). When configuring the sensor via the multiplexer, there are two port selections to make. The first is the NXT to MUX connection and the second, the MUX to SENSOR connection.
 
The Magnetic Reading output indicates the relative strength of the magnetic field measured. When the sensor is not in the proximity of a magnetic field, the output should be zero. Due to manufacturing tolerances, temperature and other effects, the output may be a small positive or negative number. To cancel out this zero offset error, also referred to as bias, an offset input can be applied.
 
Offsetting bias
 
The simplest way to measure and offset the bias, is to keep the sensor away from magnetic fields and read the output with the Offset value set to zero. This value can then be used in the future as the Offset value which will then cause the output value to be zero when no magnetic field is present.
 
Other Programming Environments
 
RobotC
 
All features of the HiTechnic Magnetic Sensor can be accessed using RobotC. The RobotC drivers pack that is available on this downloads page will include drivers for this sensor.
 
NXC
 
NXC is a C like programming language that can access all the features of this sensor. 
For more information go to http://bricxcc.sourceforge.net/nbc/.
 
Example NXC Code
 
// The Magnet sensor has the same interface as the Gyro Sensor.
// These are temporary macros until native functions are available
// in the official NXC release.
#define SensorHTMagnet(port,offset) SensorHTGyro(port,offset)
#define SetSensorHTMagnet(port)       SetSensorHTGyro(port)

#define MAGNET   IN_1

task main()
{
  int offset, magnetic_value;
  
  SetSensorHTMagnet(MAGNET);

  TextOut(0, LCD_LINE1, "HiTechnic");
  TextOut(0, LCD_LINE2, " Magnetic Sensor");

  TextOut(0, LCD_LINE4, "Calibrating, ");
  TextOut(0, LCD_LINE5, "keep magnets");
  TextOut(0, LCD_LINE6, "away...");
  Wait(1000);
  //Get inital offset assuming no magnetic field is present.
  offset = SensorHTMagnet(MAGNET, 0);
  TextOut(0, LCD_LINE4, "     Value:      ");
  TextOut(0, LCD_LINE5, "                 ");
  TextOut(0, LCD_LINE6, "                 ");

  while(true) {
    magnetic_value = SensorHTMagnet(MAGNET, offset);
    
    TextOut(6*7, LCD_LINE5, "     ");
    NumOut(6*7,LCD_LINE5, magnetic_value);

    Wait(100);
  }
}

Downloads;

Write a review

Please login or register to review

Lego Mindstorms NXT Magnetic Sensor

  • Brand: HiTechnic
  • Product Code:Hitechnic-Magnetic-Sensor
  • Reward Points:29
  • Availability:In Stock
  • रo 3,380.70

  • Ex Tax:रo 2,865.00
  • Price in reward points:2865

Related Products

Lego Mindstorm Acceleration / Tilt Sensor for NXT / EV3

Lego Mindstorm Acceleration / Tilt Sensor for NXT / EV3

Now you can make robots that know which way is up! The Accelerometer / Tilt Sensor measures accelera..

रo 8,165.60 रo 8,909.00 Ex Tax:रo 6,920.00

Lego Mindstorms Magnetic Compass Sensor for NXT / EV3

Lego Mindstorms Magnetic Compass Sensor for NXT / EV3

Expand your NXT experiences with the new NXT Compass Sensor and add accurate navigation to your Mind..

रo 8,714.30 रo 8,909.00 Ex Tax:रo 7,385.00

Lego Mindstorms Infrared Seeker V2 for NXT / EV3

Lego Mindstorms Infrared Seeker V2 for NXT / EV3

Play robot soccer and zero in on your infrared (IR) beacons with IRSeeker. You can use most TV remot..

रo 8,165.60 रo 8,242.30 Ex Tax:रo 6,920.00

Lego Mindstorms Color Sensor V2 for NXT / EV3

Lego Mindstorms Color Sensor V2 for NXT / EV3

Add a spectrum of color to your models with the new and updated Color Sensor. Detect an extended ran..

रo 8,165.60 रo 8,909.00 Ex Tax:रo 6,920.00

PICAXE I2C Explorer Kit AXE216

PICAXE I2C Explorer Kit AXE216

A self-assembly kit for the PICAXE-20X2 (included) for those wishing to interface and experiment wit..

रo 1,593.00 Ex Tax:रo 1,350.00

BrickPi+ Base Kit

BrickPi+ Base Kit

BrickPi is best for someone who already has LEGO MINDSTORMS sensors and motors. The BrickPi connects..

रo 20,724.34 Ex Tax:रo 17,563.00

EV3 Infrared Beacon

EV3 Infrared Beacon

This has been designed for use with the EV3 Infrared Seeker Sensor. The beacon emits an infrared sig..

रo 5,221.50 Ex Tax:रo 4,425.00

EV3 Infrared Sensor

EV3 Infrared Sensor

The digital EV3 Infrared Seeking Sensor detects proximity to the robot and reads signals emitted by ..

रo 5,221.50 Ex Tax:रo 4,425.00

EV3 Color Sensor

EV3 Color Sensor

The digital EV3 Color Sensor distinguishes between eight different colors. It also serves as a light..

रo 6,106.50 रo 6,944.30 Ex Tax:रo 5,175.00

EV3 Ultrasonic Sensor

EV3 Ultrasonic Sensor

The digital EV3 Ultrasonic Sensor generates sound waves and reads their echoes to detect and measure..

रo 5,221.50 Ex Tax:रo 4,425.00

EV3 Gyro Sensor

EV3 Gyro Sensor

The digital EV3 Gyro Sensor measures the robot’s rotational motion and changes in its orientation. S..

रo 5,221.50 Ex Tax:रo 4,425.00

Lego Mindstorms NXT IR Receiver Sensor

Lego Mindstorms NXT IR Receiver Sensor

The NXT IRReceiver Sensor receives signals from a LEGO Power Functions IR remote control, decodes th..

रo 7,410.40 Ex Tax:रo 6,280.00

Lego Mindstorms NXT PIR Sensor

Lego Mindstorms NXT PIR Sensor

Detect people or pets with the HiTechnic PIR Sensor. This Passive Infrared Sensor is similar to the ..

रo 8,165.60 Ex Tax:रo 6,920.00

Lego Mindstorms NXT EOPD

Lego Mindstorms NXT EOPD

Accurately detect objects and small changes in distance to a target with the HiTechnic EOPD. The EOP..

रo 8,165.60 Ex Tax:रo 6,920.00

Lego Mindstorms NXT Angle Sensor

Lego Mindstorms NXT Angle Sensor

Measure axle rotation position and rotation speed with the HiTechnic Angle Sensor. The Angle Sensor ..

रo 8,165.60 Ex Tax:रo 6,920.00

Lego Mindstorms NXT Force Sensor

Lego Mindstorms NXT Force Sensor

The NXT Force Sensor will enable you to build robots that can measure a physical force applied throu..

रo 5,900.00 Ex Tax:रo 5,000.00

Lego Mindstorms NXT Barometric Sensor

Lego Mindstorms NXT Barometric Sensor

The NXT Barometric Sensor can be used as part of a weather station or to monitor altitude. The senso..

रo 8,165.60 Ex Tax:रo 6,920.00

HiTechnic NXT Extended Connector Cable

HiTechnic NXT Extended Connector Cable

Extend your Mindstorms NXT robotic designs with the HiTechnic Extended Connector Cable . Build creat..

रo 118.00 Ex Tax:रo 100.00

HiTechnic NXT Touch Sensor Multiplexer

HiTechnic NXT Touch Sensor Multiplexer

HiTechnic NXT Touch Sensor Multiplexer for LEGO Mindstorms NXT Introduction The NXT Touc..

रo 4,259.80 Ex Tax:रo 3,610.00

HiTechnic 9V-6xAA Battery Box

HiTechnic 9V-6xAA Battery Box

This Battery Box can be used to power the 360 IR Beacon replacing the beacon's optional 9v internal ..

रo 761.10 Ex Tax:रo 645.00

HiTechnic NXT SuperPro Prototype Board

HiTechnic NXT SuperPro Prototype Board

HiTechnic SuperPro Sensor for LEGO Mindstorms NXT Introduction The HiTechnic SuperPro Sensor..

रo 4,012.00 Ex Tax:रo 3,400.00

Tags: NXT, Magnetic, Sensor, lego, mindstorms

The product is currently Out-of-Stock. Enter your email address below and we will notify you as soon as the product is available.

Name
Email
Phone
Comments