Has anyone written C++ code to read the temperature sensor included as part of the ADW22307 gyro in the 2010 Kit of Parts?
The purpose of the temperature sensor is to allow one to interpret the gyro data while compensating for temperature, since the gyro data varies somewhat depending on the ambient temperature around the gyro itself. We aren’t planning (anytime soon) to implement this temperature compensation for the gyro data (although that would be cool and quite doable…maybe someone will submit that temperature compensation code to WPILib someday).
However, we would still be interested in reading the temperature sensor on the gyro, just to find out the ambient temperature around our electronics inside the robot. We would like to display the robot temperature on our custom dashboard, and if we find that it’s getting hot in there from the Jaguars and such, we can potentially add one of those nifty fans from the Kit of Parts to help cool down the robot electronics.
The gyro temperature sensor is just a standard 3-wire analog sensor, and can apparently be plugged directly into the analog breakout board on the cRIO, just like the gyro itself. However, WPILib doesn’t seem to include any functions that provide a convenient way to read that temperature from the gyro.
Per the datasheet for the ADW22307 gyro, and the FRC 2010 Sensor Manual, the temperature sensor has a nominal output of 2.5V at 25°C (77°F), and the output varies up or down by 9mV per one degree Celsius (5mv per one degree Fahrenheit).
It would not be difficult to write the C++ code to read the temperature sensor on the 2010 gyro. It would involve using the AnalogChannel class in WPILib. We’ve never written code to use AnalogChannel directly before, but we could start with the Gyro.cpp WPILib source code (which also uses AnalogChannel) and modify it accordingly. But if someone else has already written the code to read the temperature sensor, and is interested in sharing it, we wouldn’t have to re-invent the wheel. No big deal either way, we just thought we’d ask.