Main Content

NXT Gyro Sensor

Measure rate of rotation of NXT gyro sensor connected to EV3 brick

Add-On Required: This feature requires the Simulink Support Package for LEGO MINDSTORMS EV3 Hardware add-on.

  • NXT Gyro Sensor block

Libraries:
Simulink Support Package for LEGO MINDSTORMS EV3 Hardware / NXT Sensors

Description

Use the NXT Gyro Sensor block to measure 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. See Block Produces Zeros or Does Nothing in Simulation.

Lego NXT Gyro Sensor

Examples

expand all

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

Open the legoev3nxtlib block library and copy the NXT Gyro Sensor block as described in Open Block Library for LEGO MINDSTORMS EV3 Hardware.

Open the legoev3lib block library and copy the Display block to the same model and connect these blocks.

NXT Gyro Sensor Model

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

Double-click the NXT 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. Change the offset value until the bias is nearly zero.

Ports

Output

expand all

The block outputs the rate of rotation of a gyro sensor connected to an EV3 brick in degrees per second.

Data Types: int32

Parameters

expand all

Select the EV3 brick input port to which the NXT gyro sensor is connected. Avoid assigning multiple devices to the same input port.

  • Rotation rate (-360 to 360) — The block outputs the rate of rotation in degrees per second.

  • Raw A/D (1023 to 0) — The block outputs the rate of rotation in raw analog-to-digital values per second.

Enter the positive or negative sensor bias offset value. Use the value in this parameter until the sensor bias is nearly zero.

Dependencies

  • To enable this parameter, set Output mode to Rotation rate (-360 to 360).

Specify the frequency of how often the block reads sensor values connected to the EV3 brick. Shorter sample times, such as 0.01, may produce unreliable measurements.

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

Version History

Introduced in R2012a