Main Content

NXT Gyro Sensor

Measure rate of rotation of HiTechnic NXT gyro sensor

Library

金宝app®Support Package for LEGO®MINDSTORMS®EV3 Hardware / NXT Sensors

  • NXT Gyro Sensor block

Description

TheNXT Gyro Sensorblock measures rate of rotation (yaw) along the single axis of the HiTechnic NXT Gyro Sensor (NGY1044) connected to LEGO MINDSTORMS EV3 brick. 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. For more information on NXT Gyro Sensor NGY1044, refer to its datasheet.

During simulations without hardware, this block emits zeros. SeeBlock Produces Zeros or Does Nothing in Simulation.

Calibrate the Gyro Sensor

Use theNXT Gyro Sensorblock to perform zero-calibration for the gyro sensor.

  1. Open thelegoev3nxtlibblock library and copy theNXT Gyro Sensorblock to a new model.

  2. Open thelegoev3libblock library and copy theDisplayblock to the same model and connect these blocks.

  3. Prepare and run the model on the EV3 brick as described inRun Model on EV3 Hardware. On the LCD display of the EV3 brick, observe any bias in the measurement values from the gyro sensor.

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

  5. Save the changes to your model and run the model again. Change the offset value until the bias is nearly zero.

Parameters

EV3 brick input port number

Select the EV3 sensor port to which the sensor is connected. Avoid assigning multiple devices to the same port. The options are1,2,3, or4.

Output mode

Select the type of rotation data to output:

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

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

Sample time

Specify how often the block reads sensor values. This value defaults to0.1. Shorter sample times, such as0.01, may produce unreliable measurements.

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

Introduced in R2018a