Gyros normally come in either 2 axis, or 3 axis versions. Sometimes you can buy a combo board that contains gyro and, say, an accelerometer. I don't directly support these combos so you need to declare the two individual sensors.
So what do they do? Gyros measure rotational velocity in degrees per second. This could be used to monitor whether a robot biped is falling over, so that you can compensate, or if measuring the rotation of an axle then, knowing the wheel circumference, you can work out the current speed of the robot.
These devices either use one ADC pin for each axis, or provide an I2C interface but you will need to check the individual data sheets to see what power supply they need.
All gyros return one value per axis and this value is in 'degrees per second'. Each value may be positive or negative and a two axis device will set the Z value to zero.
Since all of the devices have been implemented in the same way then it means that you can swap one device for another by only changing the #include and the MAKE command used to create the device.
So here is the generic way to work with a <DEVICE> of a given <MAKE> and <MODEL>:-
// Include the relevant sensor file
// Create the device
<DEVICE> device = MAKE_<DEVICE>(F0,F1);
In your appInitHardware you should initialise the device:-
Then in your main loop you can read the sensor using:-
Each axis can then be read independently into a variable of type 'ACCEL_TYPE':-
GYRO_TYPE x = device.gyro.x_axis_degrees_per_second;
GYRO_TYPE y = device.gyro.y_axis_degrees_per_second;
Or dumped to the current rprintf destination using:-
- InvenSense/IDG300.h - The IDG300 is a 2 axis gyro that can measure rotations up to 500 degrees per second.
- InvenSense/IDG500.h - The IDG500 is a 2 axis gyro that can measure rotations up to 500 degrees per second.
- InvenSense/ITG3200.h - The ITG3200 is a 3 axis gyro that can measure rotations up to 2,000 degrees per second via an I2C interface. It also contains a temperature sensor.
- ST/LPR530AL.h - The LPR530AL is a 2 axis gyro that can measure rotations up to 1200 degrees per second in the x and y axes.
- ST/LY530ALH.h - The LY530AL is a single axis gyro that can measure yaw rotations up to 1200 degrees per second.
- ST/LPRY530AL.h - Combines the LPR530AL and LY530ALH into a single 3 axis gyro.