Documentation Center

  • Trials
  • Product Updates

Contents

LEGO MINDSTORMS NXT Gyro Sensor

Measure rate of rotation

Library

Simulink Support Package for LEGO MINDSTORMS NXT Hardware

Description

This block measures rate of rotation (yaw) along the a single axis of the HiTechnic NXT Gyro Sensor (NGY1044). This yaw is indicated by a circle above the vertical axis in the image on the left, and by a double-arrow in the image on the right.

Before using this sensor for precise measurements, use the offset value to remove small positive or negative bias in the output values, as described in the example below.

If you run a simulation of a model that contains this block without the target hardware, this block outputs zeroes. See Block Produces Zeros or Does Nothing in Simulation.

Calibrate the Gyro Sensor

Use the Gyro Sensor block to perform zero-calibration for the gyro sensor

Open the legonxtlib block library and copy the blocks shown to a new model.

Connect the Gyro Sensor block to the LCD block, as shown.

Connect the NXT Gyro Sensor to the NTX brick.

Prepare and run the model on the NXT brick.

Observe any bias in the measurement values from the Gyro sensor visible on the LCD display of the NXT brick.

Double-click the Gyro Sensor block. In the block mask that opens, increase or decrease the offset value to reduce the bias.

Save the changes to your model and run the model again. Repeat these last two steps until the bias is nearly zero.

Dialog Box

NXT brick input port

Select the NXT sensor port to which the sensor is connected. Avoid assigning multiple devices to the same port. The options are 1, 2, 3, or 4.

Output mode

Select the type of rotation data to output:

Rotation rate (-360 - 360) outputs the rate of rotation in degrees per second. When this option is selected, the block displays the Offset parameter.

Raw A/D (0 - 1023) outputs the rate of rotation in raw analog-to-digital values per second. When this option is selected, the block hides the Offset parameter.

Sample time

Specify how often the block reads sensor values.

Smaller values require the processor to complete the same number of instructions in less time, which can cause task overruns.

See Also

| |

External Web Sites

Was this topic helpful?