View Single Post
  #2   Spotlight this post!  
Unread 21-02-2010, 22:05
Radical Pi Radical Pi is offline
Putting the Jumper in the Bumper
AKA: Ian Thompson
FRC #0639 (Code Red Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York
Posts: 655
Radical Pi has a spectacular aura aboutRadical Pi has a spectacular aura aboutRadical Pi has a spectacular aura about
Re: Has anyone written C++ code to read the temperature sensor on the gyro?

I haven't written code to do this, but probably the easiest thing to do would be to do this:

Code:
AnalogChannel* temp = new AnalogChannel(1); // adjust port accordinly
float change;
float temperature;

change = temp->GetVoltage() - 2.5; //Get temperature offset from 77 F
change *= 200 //convert to degrees F (1000 to bring out of millivolts / 5 per degree)
temperature = 77 + change; //apply offset to reference temperature
Change the constants accordingly to make it Celsius (the 200 becomes 1000/9 (not even so leave as equation) and the 77 becomes 25)

I can make a wrapper class for this if you want
__________________

"To have no errors would be life without meaning. No strugle, no joy"
"A network is only as strong as it's weakest linksys"
Reply With Quote