NXT Gyro Sensor
Measure rate of rotation of HiTechnic NXT gyro sensor
Simulink® Support Package for LEGO® MINDSTORMS® EV3 Hardware / NXT Sensors
The NXT Gyro Sensor block 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. See Block Produces Zeros or Does Nothing in Simulation.
Calibrate the Gyro Sensor
Use the NXT Gyro Sensor block to perform zero-calibration for the gyro sensor.
legoev3nxtlibblock library and copy the NXT Gyro Sensor block to a new model.
legoev3libblock library and copy the Display block to the same model and connect these blocks.
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.
- 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 are
- 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 the Offset parameter.
Raw A/D (1023 to 0)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. This value defaults to
0.1. Shorter sample times, such as
0.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.