Gyroscope

Represent connected gyroscope and measure yaw angular velocity

  • Library:
  • Simulink Coder Support Package for VEX EDR V5 Robot Brain / Sensors

Description

The Gyroscope block represents a gyroscope connected to the 3-wire port of VEX V5 Robot brain, and measures the angular velocity (in degrees/second) along the yaw axis of the gyroscope sensor.

The block outputs angular velocity in degrees/second as a double-precision scalar value. When you rotate the gyroscope sensor in a clockwise direction, the angular velocity decreases. When you rotate the sensor in a counterclockwise direction, the value increases.

In the graphic, the arrow above the vertical axis indicates yaw. The direction of the arrow shows the positive direction of the reading for the gyroscope sensor.

For the code generated from this block to work properly with the gyroscope sensor, connect a VEX 7.2 volt battery to the microcontroller. Before you download the program to the VEX microcontroller, turn on the battery. After turning on the battery, do not move the robot on which the gyroscope sensor is mounted for proper initialization of the gyroscope.

Ports

Output

expand all

The yaw rotation along the axis of the gyroscope sensor, in degrees/seconds. When you rotate the gyroscope sensor in a clockwise direction, the value decreases. When you rotate the gyroscope in a counterclockwise direction, the value increases.

Data Types: double

Parameters

expand all

Select the 3-wire port of VEX V5 Robot Brain to which the gyroscope is connected.

  • In the example table, assume that the block sample time is 1 second. The rotation angle at time instant T = 0 is 0 degrees.

    The different reset modes that this block supports are:

    • No reset – The gyroscope reading is not reset and the block outputs the total angle of rotation.

      For example, in the table, at T = 1, the gyroscope sensor rotates 20 degrees in a counterclockwise direction, and therefore, the output is 20.

      Between T = 1 and T = 2, the gyroscope sensor rotates 10 degrees in a counterclockwise direction. Therefore, the yaw rotation is 30 at T = 2 (20 from T = 1 and 10 from T = 2).

      In this reset mode, the output at any time instant is a cumulative sum of the previous yaw rotation and the current yaw rotation.

    • Reset at each sample time – For each sample period, the block outputs the gyroscope reading, and then resets it to 0.

      For example, in the table, at T = 1, the gyroscope sensor rotates 20 degrees in a counterclockwise direction, and therefore, the output is 20.

      Between T = 1 and T = 2, the gyroscope sensor rotates 10 degrees in a counterclockwise direction, and therefore, the output is 10.

      In this reset mode, the output is the yaw rotation at a particular time instant.

    • Reset by external signal – The gyroscope reading is reset to 0 based on the input value to Rst port. When you send a value other than 0 to the block input, the gyroscope reading is reset to 0. For each sample period, the block outputs the gyroscope reading since the last reset.

      For example, in the table, when the external signal is 0, the output is calculated the same as in the No reset mode. When the external signal is nonzero, the output is calculated the same as in the Reset at each sample time mode.

Enter the time interval at which the block reads values from the gyroscope.

When you set this parameter to -1, Simulink® determines the best sample time for the block based on the block context within the model. If you select Reset by external signal option in Reset mode parameter, the Sample time parameter is hidden and the value is inherited (Sample time = -1).

Introduced in R2019b