The output is wired up to the header, but I've never used it.
The Gyro class itself doesn't appear to have any way of taking in the temperature output of the sensor into account. But it does make an attempt at calibrating the sensor when the robot is turned on. It looks like it takes samples from the analog channel for 5 seconds on startup and uses these samples to determine the voltage value for a rate of rotation of zero.
Quote:
/**
* Initialize the gyro.
* Calibrate the gyro by running for a number of samples and computing the center value for this
* part. Then use the center value as the Accumulator center value for subsequent measurements.
* It's important to make sure that the robot is not moving while the centering calculations are
* in progress, this is typically done when the robot is first turned on while it's sitting at
* rest before the competition starts.
*/
private void initGyro() {
result = new AccumulatorResult();
if (m_analog == null) {
System.out.println("Null m_analog");
}
m_voltsPerDegreePerSecond = kDefaultVoltsPerDegreePerSecond;
m_analog.setAverageBits(kAverageBits);
m_analog.setOversampleBits(kOversampleBits);
double sampleRate = kSamplesPerSecond * (1 << (kAverageBits + kOversampleBits));
m_analog.getModule().setSampleRate(sampleRate);
Timer.delay(1.0);
m_analog.initAccumulator();
Timer.delay(kCalibrationSampleTime);
m_analog.getAccumulatorOutput(result);
int center = (int) ((double)result.value / (double)result.count + .5);
m_offset = ((double)result.value / (double)result.count) - (double)center;
m_analog.setAccumulatorCenter(center);
m_analog.setAccumulatorDeadband(0); ///< TODO: compute / parameterize this
m_analog.resetAccumulator();
UsageReporting.report(UsageReporting.kResourceType _Gyro, m_analog.getChannel(), m_analog.getModuleNumber()-1);
LiveWindow.addSensor("Gyro", m_analog.getModuleNumber(), m_analog.getChannel(), this);
}
|
We had pretty reliable performance with the KOP gyro this year. In past years it has been pretty flaky, but this could very well have been due to soft/hardware problems on our end which we never found solutions to.
The code we used for interfacing to the Gyro itself, boils down to the following:
Code:
//Setup
Gyro turnSense = new Gyro(RobotMap.gyroChannel);
turnSense.setSensitivity(0.0070);
resetAngle();
//Our auto mode code would perform a series of driving in straight
// lines and turns to move around the field.
//Before turning we would always zero out the gyro
turnSense.reset();
//Then turn the robot while monitoring the current angle
turnSense.getAngle();
The code was about as simple as it can get, and it worked quite effectively.
You can see a
video here.
If you are set on making use of temperature compensation, I would suggest reading the application note from analog devices:
http://www.analog.com/static/importe...es/AN-1049.pdf
And this note in the
datasheet may be of importance (page 9):
Quote:
The temperature output is characteristically nonlinear, and any
load resistance connected to the TEMP output results in decreasing
the TEMP output and its temperature coefficient. Therefore,
buffering the output is recommended.
|
I'm not sure if the breakout board we get in the KOP buffers the output already or if you would need to add additional circuitry between the gyro and the DSC. Something to look in to.