Search
Filters
Close

HiTechnic NXT Angle Sensor

Measure axle rotation position and rotation speed with the HiTechnic Angle Sensor. The Angle Sensor enables you to measure three rotation properties:
  • Absolute Angle – the rotation position of a rotating axle from 0 – 359 degrees with 1 degree accuracy
  • Accumulated angle - the accumulated number of degrees an axle has rotated
  • Rotation Speed - the speed of the axle rotation in RPM (revolutions per minute)
With its very low friction mechanism, the HiTechnic Angle Sensor is ideal for building models where accurate measurement of rotation properties of an axle is key. Perfect for building a distance measuring wheel or a weather station wind vane.
SKU: NAA1030
$54.95
$26.95

HiTechnic NXT Angle Sensor for LEGO Mindstorms NXT

Introduction

The HiTechnic Angle Sensor connects to a standard LEGO Technic cross axle and measures three rotation propertied of an axle. These are

  • Absolute Angle: the rotation angle of an axle from 0 degrees to 359 degrees, accurate to 1 degree.
  • Accumulated Angle: the accumulated multiple rotation angle measured since the last reset function was performed.
  • Revolutions per Minute (RPM): the current estimate of rotation rate from 1 RPM up to 1,000 RPM.

The Angle sensor is ideal for building into complex models where monitoring the shaft angle or location and/or the speed of rotation is desired.

Programming

Mindstorms NXT-G

Angle Sensor Block

Image of block

This block measures three rotation propertied of an axle. These are

  • Absolute Angle: the rotation angle of an axle from 0 degrees to 359 degrees.
  • Accumulated Angle: the accumulated multiple rotation angle measured since the last reset function was performed.
  • Revolutions per Minute (RPM): the current estimate of rotation rate from 1 RPM up to 1,000 RPM.

Using data wires, it can send out the current angle of rotation and a logic signal (true/false) based on whether the current heading falls inside or outside a trigger range.

A trigger range consists of upper and lower limit values in a range of numbers where a change in the reading results in the condition of being either inside or outside the range. For example, you might program your robot to rotate an axle to a set position so you could set the trigger range to be from 179 to 182. As long as your robot rotates the axel to a point between these two numbers, the condition will be true.

Specify the trigger points by using the slider or by typing the values into the input boxes. To specify the portion of the axle angle range (inside or outside the trigger range) that will generate the “true” signal, use the pull-down menu. The “true” portion of the range will be in color; the “false” portion will be gray.

The default setting for the Angle sensor block is for angles that are greater than 90 degrees and less than 270 degrees to generate a “true” signal. The compare function above the range allows you to switch the “true” portion of the range to be either inside or outside the range selected.

You must drag at least one output data wire from this block's data hub to another block for any information to be sent.

Display Settings

Image of block

  1. The number shows which of your NXT's ports are connected to the Angle 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. The trigger range and other features can be set dynamically by connecting an input data wire. (See the Data Hub section below for more information.)

Configuring the Angle Sensor Block

Image of configuration panel

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.

Connecting Directly to the NXT

When connecting the sensor directly to the NXT, choose the port the sensor is connected to.

Connecting via the HiTechnic Sensor Multiplexer

To connect the sensor via the multiplexer, click the right arrow symbol to display the port options.

Click the check box to select that the sensor will be connected vial the MUX. Configure the MUX to Sensor connection by selecting the MUX port (1 - 4) that is connected to the sensor.

Click on the right arrow symbol again, to display the NXT to MUX port selection.

Select the NXT port that is connected to the Sensor Multiplexer.

Configuring Action and Compare

Select Read to read the output values from the sensor.

Select Calibrate to set the current axle position to the 0-degree position.

Select Reset to reset the accumulated count to 0.

If you choose the Compare function Inside Range above the slider, the block will be triggered when the angle is between the two trigger values; select Outside Range to trigger the block when the heading is outside the two trigger values. Use the slider to set the trigger values or type them directly into the input boxes (0–359).

Angle Sensor block Data Hub plugs

You must click on the Data Hub to open it as shown.

Image of block

  1. This plug wires the number for which of your NXT's ports are connected to the compass sensor.
  2. This plug wires the Angle output.
  3. This plug wires the RPM output.
  4. This plug wires the Accumulated angle output.
  5. This plug wires the Action input, 0 = Read, 1 = Calibrate, 2 = Reset.
  6. This plug wires the Range selection for inside/outside range function, 0 = Inside Range, 1 = Outside Range.
  7. This plug wires the lower range limit number for the Inside/Outside compare function.
  8. This plug wires the upper range limit number for the Inside/Outside compare function.
  9. This plug outputs the Inside/Outside logical value.
  10. This plug is set to true if the sensor is connected via the HiTechnic sensor multiplexer.
  11. this plug wires the number of the multiplexer port connected to the sensor .

Sensor Register Layout

AddressTypeContents
41H byte mode control
42H byte angle in 2-degree increments
43H byte 1-degree angle adder
44H long Accumulated Angle
48H int RPM - Rotations Per Minute

Set mode control to 43H to Calibrate sensor or to 52H to reset accumulated angle. When Calibrating the sensor at least 25ms Wait should be used before further reads from the sensor. This time is needed to burn the new zero position into EEPROM memory on the sensor. Once calibrated, the sensor will retain the new zero position even when power cycled. The Accumulated angle, on the other hand, is lost when the sensor is power cycled.

Other Programming Environments

RobotC

All features of the HiTechnic Angle 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

//=====================================================================
// HiTechnic - Angle Sensor Sample Program
//
#define ANGLE S1
//=====================================================================
// ReadSensorHTAngle(port, Angle, AccAngle, RPM)
// Reads the HiTechnic Angle Sensor and returns the current:
//   Angle              degrees (0-359)
//   Accumulated Angle  degrees (-2147483648 to 2147483647)
//   RPM                rotations per minute (-1000 to 1000)
void ReadSensorHTAngle(int port, int &Angle, long &AccAngle, int &RPM)
{
  int count;
  byte cmndbuf[] = {0x02, 0x42};  // I2C device, register address
  byte respbuf[];                 // Response Buffer
  bool fSuccess;
  count=8;                        // 8 bytes to read
  fSuccess = I2CBytes(port, cmndbuf, count, respbuf);
  if (fSuccess) {
    Angle = respbuf[0]*2 + respbuf[1];
    AccAngle = respbuf[2]*0x1000000 + respbuf[3]*0x10000+
               respbuf[4]*0x100 + respbuf[5];
    RPM = respbuf[6]*0x100 + respbuf[7];
  } else {
    // No data from sensor
    Angle = 0; AccAngle = 0; RPM = 0;
  }
}

// ReserSensorHTAnalog(port, resetmode)
// resetmode:
//   HTANGLE_MODE_CALIBRATE  Calibrate the zero position of angle.
//                           Zero position is saved in EEPROM on sensor.
//   HTANGLE_MODE_RESET      Reset the rotation count of accumulated.
//                           angle to zero.  Not saved in EEPORM.
#define HTANGLE_MODE_CALIBRATE              0x43
#define HTANGLE_MODE_RESET                  0x52
void ResetSensorHTAngle(int port, int resetmode)
{
  int count;
  byte cmndbuf[] = {0x02, 0x41, 0}; // I2C device, register address
  byte respbuf[];                   // buffer for inbound I2C response
  cmndbuf[2] = resetmode;           // Set reset code
  count=0;                          // 0 bytes to read
  I2CBytes(port, cmndbuf, count, respbuf);
  if (resetmode == HTANGLE_MODE_CALIBRATE)
     Wait(50);  // Time to allow burning EEPROM
}
//=====================================================================
task main()
{
  int angle;
  long acc_angle;
  int rpm;

  SetSensorLowspeed(ANGLE);
  Wait(100);

  TextOut(0, LCD_LINE1, "HiTechnic");
  TextOut(0, LCD_LINE2, "  Angle Sensor");
  TextOut(0, LCD_LINE8, "");

  while(true) {
    Wait(100);

    ReadSensorHTAngle(ANGLE, angle, acc_angle, rpm);
    TextOut(0, LCD_LINE4, "Angle :         ");
    NumOut(7*6, LCD_LINE4, angle);

    TextOut(0, LCD_LINE5, "AccAng:         ");
    NumOut(7*6, LCD_LINE5, acc_angle);

    TextOut(0, LCD_LINE6, "RPM   :         ");
    NumOut(7*6, LCD_LINE6, rpm);

    if (ButtonPressed(BTNLEFT,0)) {
      while(ButtonPressed(BTNLEFT,0));
      ResetSensorHTAngle(ANGLE, HTANGLE_MODE_RESET);
    }
    if (ButtonPressed(BTNRIGHT,0)) {
      while(ButtonPressed(BTNRIGHT,0));
      ResetSensorHTAngle(ANGLE, HTANGLE_MODE_CALIBRATE);
    }
  }
}

HiTechnic NXT Angle Sensor for LEGO Mindstorms NXT

Introduction

The HiTechnic Angle Sensor connects to a standard LEGO Technic cross axle and measures three rotation propertied of an axle. These are

  • Absolute Angle: the rotation angle of an axle from 0 degrees to 359 degrees, accurate to 1 degree.
  • Accumulated Angle: the accumulated multiple rotation angle measured since the last reset function was performed.
  • Revolutions per Minute (RPM): the current estimate of rotation rate from 1 RPM up to 1,000 RPM.

The Angle sensor is ideal for building into complex models where monitoring the shaft angle or location and/or the speed of rotation is desired.

Programming

Mindstorms NXT-G

Angle Sensor Block

Image of block

This block measures three rotation propertied of an axle. These are

  • Absolute Angle: the rotation angle of an axle from 0 degrees to 359 degrees.
  • Accumulated Angle: the accumulated multiple rotation angle measured since the last reset function was performed.
  • Revolutions per Minute (RPM): the current estimate of rotation rate from 1 RPM up to 1,000 RPM.

Using data wires, it can send out the current angle of rotation and a logic signal (true/false) based on whether the current heading falls inside or outside a trigger range.

A trigger range consists of upper and lower limit values in a range of numbers where a change in the reading results in the condition of being either inside or outside the range. For example, you might program your robot to rotate an axle to a set position so you could set the trigger range to be from 179 to 182. As long as your robot rotates the axel to a point between these two numbers, the condition will be true.

Specify the trigger points by using the slider or by typing the values into the input boxes. To specify the portion of the axle angle range (inside or outside the trigger range) that will generate the “true” signal, use the pull-down menu. The “true” portion of the range will be in color; the “false” portion will be gray.

The default setting for the Angle sensor block is for angles that are greater than 90 degrees and less than 270 degrees to generate a “true” signal. The compare function above the range allows you to switch the “true” portion of the range to be either inside or outside the range selected.

You must drag at least one output data wire from this block's data hub to another block for any information to be sent.

Display Settings

Image of block

  1. The number shows which of your NXT's ports are connected to the Angle 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. The trigger range and other features can be set dynamically by connecting an input data wire. (See the Data Hub section below for more information.)

Configuring the Angle Sensor Block

Image of configuration panel

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.

Connecting Directly to the NXT

When connecting the sensor directly to the NXT, choose the port the sensor is connected to.

Connecting via the HiTechnic Sensor Multiplexer

To connect the sensor via the multiplexer, click the right arrow symbol to display the port options.

Click the check box to select that the sensor will be connected vial the MUX. Configure the MUX to Sensor connection by selecting the MUX port (1 - 4) that is connected to the sensor.

Click on the right arrow symbol again, to display the NXT to MUX port selection.

Select the NXT port that is connected to the Sensor Multiplexer.

Configuring Action and Compare

Select Read to read the output values from the sensor.

Select Calibrate to set the current axle position to the 0-degree position.

Select Reset to reset the accumulated count to 0.

If you choose the Compare function Inside Range above the slider, the block will be triggered when the angle is between the two trigger values; select Outside Range to trigger the block when the heading is outside the two trigger values. Use the slider to set the trigger values or type them directly into the input boxes (0–359).

Angle Sensor block Data Hub plugs

You must click on the Data Hub to open it as shown.

Image of block

  1. This plug wires the number for which of your NXT's ports are connected to the compass sensor.
  2. This plug wires the Angle output.
  3. This plug wires the RPM output.
  4. This plug wires the Accumulated angle output.
  5. This plug wires the Action input, 0 = Read, 1 = Calibrate, 2 = Reset.
  6. This plug wires the Range selection for inside/outside range function, 0 = Inside Range, 1 = Outside Range.
  7. This plug wires the lower range limit number for the Inside/Outside compare function.
  8. This plug wires the upper range limit number for the Inside/Outside compare function.
  9. This plug outputs the Inside/Outside logical value.
  10. This plug is set to true if the sensor is connected via the HiTechnic sensor multiplexer.
  11. this plug wires the number of the multiplexer port connected to the sensor .

Sensor Register Layout

AddressTypeContents
41H byte mode control
42H byte angle in 2-degree increments
43H byte 1-degree angle adder
44H long Accumulated Angle
48H int RPM - Rotations Per Minute

Set mode control to 43H to Calibrate sensor or to 52H to reset accumulated angle. When Calibrating the sensor at least 25ms Wait should be used before further reads from the sensor. This time is needed to burn the new zero position into EEPROM memory on the sensor. Once calibrated, the sensor will retain the new zero position even when power cycled. The Accumulated angle, on the other hand, is lost when the sensor is power cycled.

Other Programming Environments

RobotC

All features of the HiTechnic Angle 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

//=====================================================================
// HiTechnic - Angle Sensor Sample Program
//
#define ANGLE S1
//=====================================================================
// ReadSensorHTAngle(port, Angle, AccAngle, RPM)
// Reads the HiTechnic Angle Sensor and returns the current:
//   Angle              degrees (0-359)
//   Accumulated Angle  degrees (-2147483648 to 2147483647)
//   RPM                rotations per minute (-1000 to 1000)
void ReadSensorHTAngle(int port, int &Angle, long &AccAngle, int &RPM)
{
  int count;
  byte cmndbuf[] = {0x02, 0x42};  // I2C device, register address
  byte respbuf[];                 // Response Buffer
  bool fSuccess;
  count=8;                        // 8 bytes to read
  fSuccess = I2CBytes(port, cmndbuf, count, respbuf);
  if (fSuccess) {
    Angle = respbuf[0]*2 + respbuf[1];
    AccAngle = respbuf[2]*0x1000000 + respbuf[3]*0x10000+
               respbuf[4]*0x100 + respbuf[5];
    RPM = respbuf[6]*0x100 + respbuf[7];
  } else {
    // No data from sensor
    Angle = 0; AccAngle = 0; RPM = 0;
  }
}

// ReserSensorHTAnalog(port, resetmode)
// resetmode:
//   HTANGLE_MODE_CALIBRATE  Calibrate the zero position of angle.
//                           Zero position is saved in EEPROM on sensor.
//   HTANGLE_MODE_RESET      Reset the rotation count of accumulated.
//                           angle to zero.  Not saved in EEPORM.
#define HTANGLE_MODE_CALIBRATE              0x43
#define HTANGLE_MODE_RESET                  0x52
void ResetSensorHTAngle(int port, int resetmode)
{
  int count;
  byte cmndbuf[] = {0x02, 0x41, 0}; // I2C device, register address
  byte respbuf[];                   // buffer for inbound I2C response
  cmndbuf[2] = resetmode;           // Set reset code
  count=0;                          // 0 bytes to read
  I2CBytes(port, cmndbuf, count, respbuf);
  if (resetmode == HTANGLE_MODE_CALIBRATE)
     Wait(50);  // Time to allow burning EEPROM
}
//=====================================================================
task main()
{
  int angle;
  long acc_angle;
  int rpm;

  SetSensorLowspeed(ANGLE);
  Wait(100);

  TextOut(0, LCD_LINE1, "HiTechnic");
  TextOut(0, LCD_LINE2, "  Angle Sensor");
  TextOut(0, LCD_LINE8, "");

  while(true) {
    Wait(100);

    ReadSensorHTAngle(ANGLE, angle, acc_angle, rpm);
    TextOut(0, LCD_LINE4, "Angle :         ");
    NumOut(7*6, LCD_LINE4, angle);

    TextOut(0, LCD_LINE5, "AccAng:         ");
    NumOut(7*6, LCD_LINE5, acc_angle);

    TextOut(0, LCD_LINE6, "RPM   :         ");
    NumOut(7*6, LCD_LINE6, rpm);

    if (ButtonPressed(BTNLEFT,0)) {
      while(ButtonPressed(BTNLEFT,0));
      ResetSensorHTAngle(ANGLE, HTANGLE_MODE_RESET);
    }
    if (ButtonPressed(BTNRIGHT,0)) {
      while(ButtonPressed(BTNRIGHT,0));
      ResetSensorHTAngle(ANGLE, HTANGLE_MODE_CALIBRATE);
    }
  }
}

The RobotC driver suite supports HiTechnic products for RobotC 4.x and RobotC 3.x. Select the corresponding repository at the link below and download the zip file. 

https://github.com/botbench

Description Version Release Size
NXT
HiTechnic Angle Sensor Block for Mindstorms NXT Software
The Angle Sensor Block adds support for this sensor to the LEGO MINDSTORMS NXT Software. With this block you have access to the 0-359 degree angle, the accumulated angle, and RPM. You can also reset the accumulated angle and calibrate the 0-359 degree 0 position. This block can be used with the HiTechnic Sensor Multiplexer. 
New with version 1.1: This block supports data logging the angle with the LEGO Mindstorms 2.0 Education software.
1.1 10/11/2010 573KB Download
NXT
Angle Sensor RPM Gauge for LEGO Mindstorms 1.0
Using the RPM value from the Angle sensor, displays an RPM Gauge on the NXT Screen. Requires the Integer Sin/Cos Block and the Angle Sensor Block.
Note: Zip file includes RPMGauge.ric file that needs to be manually copied into the “\LEGO MINDSTORMS NXT\engine\Pictures” folder of the LEGO Mindstorms installation.
1.0 2/12/2011 372KB Download
NXT
Angle Sensor RPM Gauge for LEGO Mindstorms 2.0
Using the RPM value from the Angle sensor, displays an RPM Gauge on the NXT Screen. Requires the floating point Sin/Cos Block and the Angle Sensor Block.
1.0 2/12/2011 413KB Download
Angle Sensor VIs for LabVIEW 2009
Angle Sensor VIs and sample program VI for LabVIEW 2009. Supports the HiTechnic Sensor Multiplexer. See included readme.txt file on how to install into LabVIEW 2009.
1.0a 2/14/2011 57KB Download
HiTechnic EV3 I2C Blocks
This is a release of the HiTechnic EV3 blocks file. Supported sensors are: Angle, Compass, Accelerometer, and IRSeekerV2. 
New with v. 0.30: Compass and IRSeekerV2 blocks updated. 
Split blocks into individual .ev3b files so you only need to import what you need. Worked around EV3 IIC U8 as I8 bug.
0.30 5/19/17 149KB Download