HiTechnic NXT Gyro Sensor for LEGO Mindstorms NXT
The NXT Gyro Sensor contains a single axis gyroscopic sensor that detects rotation and returns a value representing the number of degrees per second of rotation. The Gyro Sensor can measure up to +/- 360° per second of rotation.
The Gyro Sensor connects to an NXT sensor port using a standard NXT wire and utilizes the analog sensor interface. The rotation rate can be read up to approximately 300 times per second.
The Gyro Sensor is housed in a standard Mindstorms sensor housing to match the other Mindstorms elements.
The axis of measurement is in the vertical plane with the gyro sensor positioned with the black end cap facing upwards is shown.
To quick test your new sensor, plug it into port 1 of your NXT brick and select View – Ambient light – Port 1. As you rotate the sensor as shown, you’ll notice that the readings will change from the nominal 40 center value. The faster you rotate the sensor, the larger the deviation from 40. This is a test only and not a demonstration of how the sensor should be used.
The Gyro Sensor can be programmed using LEGO Mindstorms NXT-G Software by importing the Gyro Sensor Block. This and other HiTechnic sensor programming blocks are available from the downloads page.
Gyro Sensor Block
The Gyro Sensor Block provides access to the sensor output in addition to other features.
This plug wires the number for which of your NXT's ports are connected to the Gyro Sensor.
This plug inputs the trigger value.
This plug inputs the trigger compare mode.
This plug outputs the trigger.
This plug inputs the offset value.
- This plug outputs the measured rotation rate value.
Gyro Sensor Block Front Panel
Choose the Port where your Gyro Sensor is plugged in. By default, the block will be set to port 3 for a Gyro Sensor. You can change this selection if you need to.
The output value of the sensor can be influenced by temperature and manufacturing tolerances that may cause a non-zero value when the gyro is stationary. To compensate for this, the zero offset or bias value that can be adjusted for by entering a obtained from the sensor when it is not rotating.
You can adjust the Compare value at which the trigger output will change.
The trigger output can either select greater than or less than by selecting the Trigger type. When the output value and condition selected by the Compare are met or exceeded, the trigger state will output a true or false Boolean.
Calculating the Offset Value
To calculate the offset value required to "zero" the gyro output it is necessary to read the value while the gyro sensor is absolutely stationary. With NXT-G this can be done by reading and either displaying the gyro output which can then be used to enter as an offset or have the program calculate the offset as shown in the example program below.
The code for this program and other examples can be downloaded from the downloads page.
Other Programming Environments
The output of the Gyro Sensor can read from NXC by reading the sensor as shown in the following example.
NXC Example code
#define GYRO_PORT IN_3 //Gyro on port 3
#define GYRO_Offset 602 //offset value to apply to the output value
Gyro_value=SensorRaw(GYRO_PORT)-GYRO_Offset; //read the gyro sensor
More information regarding NXC is available at http://bricxcc.sourceforge.net/nbc/.
const tSensors GyroSensor = (tSensors) S1; //gyro sensor//
#define offset 598 //offset value may vary depending on sensor & temperature
Gyro_value=SensorValue(GyroSensor)-offset; //read the gyro sensor
For more information go to www.robotc.net/.
The latest version of the gyro block is available at www.hitechnic.com/downloads.
New with version 2.0: This block adds support for the HiTechnic Sensor Multiplexer as well as data logging with the LEGO Mindstorms 2.0 Education software.
|HiTechnic Gyro Sensor Block for Mindstorms NXT Software||2.0||July 29th, 2010||430.68 KB||Download Now|
|HiTechnic Robot Swing for Mindstorms NXT-G||2.0||December 9th, 2011||1.20 MB||Download Now|
|HiTechnic Gyro Test program for Mindstorms NXT-G 2.0||1.2||December 8th, 2010||906.67 KB||Download Now|
|HiTechnic Gyro Test program for Mindstorms NXT-G 1.0||1.1||December 8th, 2010||889.36 KB||Download Now|
New with version 1.1: Fixes a bug that prevented the original program from working with higher optimization levels.
|HTWay NXC Program||1.1||November 7th, 2010||16.34 KB||Download Now|
|FTC Update For LabVIEW 2009||1.0||October 6th, 2010||261.37 KB||Download Now|
|HTWay Program for LV2010||1.0||October 4th, 2012||156.36 KB||Download Now|
|HTWay Program for LabVIEW 2009||1.0||October 27th, 2011||79.95 KB||Download Now|
|Gyro Sensor VI For LabVIEW2009||1.0||October 7th, 2010||74.63 KB||Download Now|
|Gyro Sensor VI||1.0||November 4th, 2009||26.03 KB||Download Now|
|HiTechnic EV3 Analog Sensor Blocks||0.1||February 7th, 2014||41.63 KB||Download Now|