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.
During simulations without hardware, this block emits zeros. See Block Produces Zeros or Does Nothing in Simulation (Simulink).
Use the NXT Gyro Sensor block to perform zero-calibration for the gyro sensor.
legoev3nxtlib block library and copy the
NXT Gyro Sensor block to a new model.
legoev3lib block library and copy the
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.
Select the EV3 sensor port to which the sensor is connected. Avoid
assigning multiple devices to the same port. The options are
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
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
Specify how often the block reads sensor values. This value defaults
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.