Go to Post Hey Don, if the [Woody Flowers] award doesn't impress the non-FIRST friends and family, just tell them you have your own "inter-web thread" - tell them you are like a Chuck Norris on the internet!!! - ebarker [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-07-2013, 17:41
teresa.krause teresa.krause is offline
Registered User
FRC #1700 (Gatorbotics)
Team Role: Alumni
 
Join Date: Jul 2013
Rookie Year: 2010
Location: Palo Alto
Posts: 2
teresa.krause is an unknown quantity at this point
Using the Gyro's "temp"?

While looking up documentation for wiring a gyro (specifically this one: http://frc-labs.com/wp-content/uploa...erometer1.jpg), many of the sources recommend using both rate and temp. However, while actually coding it doesn't seem that the Gyro class is able to use more than one analog port. Does anyone have any pointers for incorporating temp?
Reply With Quote
  #2   Spotlight this post!  
Unread 02-07-2013, 22:59
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 431
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: Using the Gyro's "temp"?

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.
__________________
http://team2168.org
Reply With Quote
  #3   Spotlight this post!  
Unread 03-07-2013, 14:26
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,569
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Using the Gyro's "temp"?

Quote:
Originally Posted by teresa.krause View Post
While looking up documentation for wiring a gyro (specifically this one: http://frc-labs.com/wp-content/uploa...erometer1.jpg), many of the sources recommend using both rate and temp.
I'm curious what sources have recommended using temp and how they recommend using it. Everything I've seen mentions temp is available, but haven't recommended it. Given that our the temperature in a match hardly varies, I'm not sure what the benefit using temperature is, over the single point calibration the gyro class performs.
Reply With Quote
  #4   Spotlight this post!  
Unread 04-07-2013, 23:50
teresa.krause teresa.krause is offline
Registered User
FRC #1700 (Gatorbotics)
Team Role: Alumni
 
Join Date: Jul 2013
Rookie Year: 2010
Location: Palo Alto
Posts: 2
teresa.krause is an unknown quantity at this point
Re: Using the Gyro's "temp"?

I suppose what I meant was not that the temperature was "recommended for frc use" but rather that it was a standard part of the gyro's wiring. I'm not particularly set on using it, especially if most teams have found the gyro reliable without it.
Reply With Quote
  #5   Spotlight this post!  
Unread 05-07-2013, 16:41
EricVanWyk EricVanWyk is offline
Registered User
no team
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Boston
Posts: 1,597
EricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond repute
Send a message via AIM to EricVanWyk
Re: Using the Gyro's "temp"?

My thought is to monitor it through a few matches and see if it is moving enough to be worth your effort. The effect I would be most concerned with is self-heating - can you see a difference between powering on the system from cold and rebooting the system after it has been on for a while?
Reply With Quote
  #6   Spotlight this post!  
Unread 08-07-2013, 09:01
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 431
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: Using the Gyro's "temp"?

Quote:
Originally Posted by EricVanWyk View Post
My thought is to monitor it through a few matches and see if it is moving enough to be worth your effort. The effect I would be most concerned with is self-heating - can you see a difference between powering on the system from cold and rebooting the system after it has been on for a while?
As long as the temperature doesn't change significantly from the time you powered the robot on, it shouldn't make a difference, as the calibration procedure is performed on startup every time (at least in Java).
__________________
http://team2168.org
Reply With Quote
  #7   Spotlight this post!  
Unread 20-08-2013, 16:40
alexhenning alexhenning is offline
WPILib Developer
FRC #0348
 
Join Date: Apr 2010
Rookie Year: 2003
Location: MA
Posts: 49
alexhenning will become famous soon enough
Re: Using the Gyro's "temp"?

As others have mentioned the WPILib gyro class doesn't support temperature and most teams don't seem to use the temperature. They seem find just the gyro output calibrated from WPILib accurate enough. However, if you want to incorporate the temperature of the gyro, the best way to start is to look at the datasheet. If you look at the datatsheet[1] for your gyro, it should describe the relationship between temperature and the voltage reading. Then you can just copy the code of gyro class and create a custom class for a gyro with temperature correction that reads the temperature at calibration and uses that when calculating the angular rate. The biggest difficulty with this is that you can't do this and use the FPGAs hardware accumulator, which may make a bigger difference depending on your application.

[1] For the 2009 Gyro. Page 9: http://www.usfirst.org/uploadedFiles...%20Rev%20B.pdf
Reply With Quote
  #8   Spotlight this post!  
Unread 20-08-2013, 17:14
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Using the Gyro's "temp"?

Self heating is definitely a factor. If you read the yaw rate output voltage right after cold boot, and then read after it has been on for a few minutes, I guarantee you will see a difference. If you calibrate the gyro (which in WPIlib usually means calling the constructor for the gyro) as soon as the robot boots, but it takes ~5-10 minutes before the match begins, your gyro will be drifting quite a bit by the time you need it.

One way to deal with the effects of self heating would be to use the temperature input and derive a model that takes into account the effects of temperature on the yaw rate output.

A far simpler way is to re-calibrate your gyro as close to the match start time as possible (this is easy to do if you make a couple of modifications to the WPIlib Gyro class - make the initGyro() method public and call it via button press from the Driver Station when you are in the Disabled state).
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 20:36.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi