Database error: Invalid SQL: update pwn_shop_con set cl=cl+1 where id='389'
MySQL Error: 1142 (UPDATE command denied to user 'qdm171897234'@'' for table 'pwn_shop_con')
#0 dbbase_sql->halt(Invalid SQL: update pwn_shop_con set cl=cl+1 where id='389') called at [/data/home/qxu1539450019/htdocs/includes/] #1 dbbase_sql->query(update {P}_shop_con set cl=cl+1 where id='389') called at [/data/home/qxu1539450019/htdocs/shop/module/ShopContent.php:86] #2 ShopContent() called at [/data/home/qxu1539450019/htdocs/includes/] #3 PrintPage() called at [/data/home/qxu1539450019/htdocs/shop/html/index.php:13] NXTCompass Sensor-北京LEGO乐高//FTC机器人/FLL/竞赛机器人辅导
NXTCompass Sensor
型号: (NMC1034)
品牌:   [查询该品牌全部商品]
HiTechnic NXT Compass Sensor
for LEGO Mindstorms NXT
订购 加入收藏


HiTechnic NXT Compass Sensor for LEGO Mindstorms NXT


The NXT Compass Sensor contains a digital magnetic compass that measures the earth’s magnetic field and calculates a heading angle. The Compass Sensor connects to an NXT sensor port using a standard NXT wire and uses the digital I2C communications protocol.  The current heading is calculated to the nearest 1° and refreshed 100 times per second. 

The Compass Sensor is housed in a standard Mindstorms sensor housing to match the other Mindstorms elements.

To test your new sensor, plug it into port 2 of your NXT and select View > Ultrasonic cm > Port 2. As you swing the sensor around, you’ll notice that the readings will change from 1 – 179. (0 will display as ?????? while in View mode.)


Mindstorms NXT-G

The compass can be programmed using LEGO Mindstorms NXT Software Compass Block*.  If the Compass Block is not available you may also use the standard Ultrasonic Block.

*Note:  The NXT Compass Block can be downloaded by going to the Downloads page.

Ultrasonic Block

If using the Ultrasonic Block to program the compass, configure the block to centimeter mode as shown.


The Ultrasonic Block can only return values from 0 to 250 so in order to return the full range of headings, 0 to 360, the heading value returned when using the Ultrasonic Block will be the current heading divided by 2.  For example, if the current heading is 220°, the value returned will be 110.  North will return a value of 0, East, a value of 45, South, a value of 90 and West, a value of 135.  To get the actual magnetic heading, simply take the number returned and multiply by 2.

Compass Sensor Block

The Compass Block is designed to support the HiTechnic Compass Sensor and supports all compass features.



1.  This plug wires the number for which of your NXT’s ports are connected to the compass sensor.
2.  This plug wires the number of the Action to be performed.
3.  This plug wires the Target heading, see section on Relative Heading further down this page. 
4.  This plug wires the lower limit number for the Inside/Outside compare function. 
5.  This plug wires the upper limit number for the Inside/Outside compare function. 
6.  This plug outputs the current Absolute Heading number. 
7.  This plug outputs the current Relative Heading number, see section on Relative Heading further down this page.
8.  This plug outputs the Inside/Outside logical value.



Compass Front Panel

Port allows you to select the NXT port the compass is plugged into.


Action has three options.  These are;

Absolute Reading:  Allows you to read the Absolute Heading, a value from 0 to 359, corresponding to the current magnetic heading in degrees.  (Plug 6 on the data hub)

Relative Reading: Allows you to set a Target and read the Relative Heading (Plug 3 and 7 on the data hub).  
See Using Relative Reading below for more information.

Calibrate: Set the compass sensor into Calibrate mode allowing you to go through the calibrate sequence to minimize the influence of metal and other other sources of magnetic interference such as motors or batteries.
See Calibrating the Compass Sensor below for more information.


Compares the Absolute Heading to the range set and sets the logic value to show if the value is inside or outside the range. 
See Using Range below for more information.


Using Relative Reading

Relative Reading makes it easy to stay on a selected heading.  To use this feature select the Relative Reading action.  Then enter a Target that is the heading you wish to maintain. 

If you wanted to navigate South, you would  enter a Target of 180 (South is 180 degrees).  The Compass Sensor block would then calculate the difference between the Absolute Heading and your Target and return the difference as the Relative Heading. (plug 7).

For example, with your target set to 180, if the Absolute Heading were 175, then the Relative Heading would be 5 (Target – Absolute Heading or 180 – 175 = 5).  This indicates a turn to the right or clockwise of 5 degrees is required to get back to the Target. 

If the Absolute Heading were 185, then the Relative Heading would be -5 (Target – Absolute Heading or 180 – 185 = -5).  This indicates a turn to the left or clockwise of 5 degrees is required to get back to the Target.  

Calibrating the Compass Sensor

The HiTechnic compass sensor will be influenced by local magnetic interference in the same way as any other magnetic compass.  Objects such as metal items, motors, batteries and wires can cause magnetic interference.  Local magnetic interference may cause the compass to output a heading several degrees different than the actual magnetic heading.  This is called compass deviation.  To correct for deviation, the HiTechnic compass sensor has a built in calibration function that calculates correction offsets and stores them in the compass.  

Calibration is optional and usually not required for normal operation. To minimize the need for calibration make sure you mount the compass at least 4 – 6 inches (10 – 15 cm) away from the NXT and NXT motors.


To calibrate the compass under program control, select calibration mode (value 2 wired to the Action plug input) and then program your robot to rotate (turn in a tight circle) between 1 ½ and 2 times (more than 360 degrees) so it completes a full turn in about 20 seconds.  Once the turns have been completed, set the Action to a Read function (Absolute or Relative) and the compass will be calibrated.  The compass will retain the calibration settings until another calibration is performed, even if it is unplugged.

Using Range

The Compare lets you set a range and easily determine if you are inside or outside the range.

The Components for using the Range function are;

Inside Range / Outside Range:  Select if you want to test for an Absolute Heading inside the range or outside the range.

A: The lower limit of the range (0 – 359)

B: The upper limit of the range (0 – 359)

To use the Range function, set the lower and upper limit of your range and whether you want to test for inside or outside the range. 

Examples showing the logical result.




Absolute Heading

Logical Value



Inside Range




Inside Range




Outside Range




Outside Range




Sensor Register Layout




00 – 07H


Sensor version number

08 – 0FH



10 – 17H


Sensor type

18 – 3DH


Not used

3E, 3FH





Not used



Mode control



Heading }  two degree heading



Heading }  one degree adder

44, 45H


Heading (low byte, high byte)

46 – 7FH


Not used

The Sensor version number field will report a revision number in the format “²Vn.m” where n is the major version number and m is the revision level. Revision numbers will typically reflect the firmware level. The version number will be used to indicate the hardware level.

The Manufacturer field will contain “HiTechnc”.

The Sensor type field will contain “Compass”.

The Mode control field may be set to 0x00 or 0x43 to define measurement mode or hard-iron calibrate mode.

The Heading fields will return the currently measured heading during measurement mode operation. During hard-iron calibrate mode operation, this field will jam.

The heading is obtained by reading location 0x42 to obtain the two degree heading and 0x43 to obtain the one degree adder. The heading can then be computed as

Heading = (two degree heading *2) + one degree adder.

If the sign is a problem, then the conventional 16 bit value can be obtained from 0x44 (low byte) and 0x45 (high byte).

Locn 0x41 is the mode control. Defaults to 0, which is measurement mode. Change to  0x43 to set calibration mode. Must be changed back to 0 when calibration is completed. (If cal. fails, locn. 0x41 will be set to 2 after the host has set it to 0 at the end of the failed calibrate attempt.)

机电教室套装 ¥3,200.00
EV3 Intelligent Brick ¥1,400.00
Robot Football Kit ¥1,120.00