Go to Post FIRST is an amazing combination of principles that, when applied to the world, has had a monstrous effect on the way High School students learn, think, and relate to others. - Amanda M [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 26-01-2008, 10:56
RyanW RyanW is offline
Registered User
FRC #0449 (Blair Robot Project)
Team Role: Programmer
 
Join Date: Feb 2007
Rookie Year: 2007
Location: MD
Posts: 40
RyanW has a spectacular aura aboutRyanW has a spectacular aura about
Gyros and WPILib

Our team is using WPILib to program our robot, and we are trying to use a gyroscope to get the heading of the robot. We are using an ADXRS150 gyroscope, and when we try to read off of it, we get continuously incrementing values. Our gyro test code looks somewhat like this:

At the beginning of the autonomous method (only gets called once):
Code:
SetGyroType(GYRO_PORT, ADXRS150);
InitGyro(GYRO_PORT);
//The following should create a delay so we don't start doing anything else right after initializing
StartTimer(5);
while(GetTimer(5)<2000);
StopTimer(5);
StartGyro(GYRO_PORT);
We then move into an infinite loop, calling the following over and over:
Code:
printf("GyroHeading=%d\r", GetGyroAngle(GYRO_PORT));
The gyroscope has two PWM cables. On both cables, the red and black go to the +5 and ground ends of the gyro respectively. The white signal wire on the first cable (in GYRO_PORT) goes to rate, and the signal wire on the second cable (going to an otherwise unused analog input port) has the 2.5 volt calibration signal. The two self-test pins also go to ground.

Again, whenever we run the test code, the gyro angle continuously increments, regardless of whether or not we turn the gyro. The analog value being returned is varying from about 536-544, staying mostly within +/-2 of the center value.

EDIT: We fixed output from a long to an int, so the values we are getting are reasonable. However, every second or so, it's still incrementing.

EDIT 2: It now changes as we turn it, but the output is not in tenths of a degree (as WPILib specifies), or even in degrees. It is about 1/4 as much as it should be...any ideas what's wrong?

Any ideas as to what's wrong, and what we can do to fix it?

Thank you for your help.

Last edited by RyanW : 26-01-2008 at 11:46.
  #2   Spotlight this post!  
Unread 27-01-2008, 22:24
mluckham's Avatar
mluckham mluckham is offline
Registered User
FRC #0758 (Sky Robotics)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Ontario, Canada
Posts: 116
mluckham will become famous soon enoughmluckham will become famous soon enough
Re: Gyros and WPILib

I guess this is your own circuit, not the gyro in the KOP? Could you publish the circuit so people can comment?

If an AI value is 'continously incrementing' then usually there is nothing connected to the pins. Although from your description, you are actually seeing a fairly fixed value fluctuating in a narrow range. When you connect, and remove, your gyro from the RC is it obvious from the printf output?

If the incrementing is very small, regular, and slow - you say every second or so - you may be seeing gyro drift which you can't do much about ... the usual approach is to reset the gyro to zero when the robot is in a known position. Most advice in these forums states you can pretty well ignore gyro drift for our 2-3 minute matches.

When you specify the type constant in SetGyroType() the second paramater is actually a numeric divisor which scales the gyro value to tenths of a degree. You could experiment with different values for this.

Last edited by mluckham : 27-01-2008 at 22:28.
  #3   Spotlight this post!  
Unread 28-01-2008, 14:05
RyanW RyanW is offline
Registered User
FRC #0449 (Blair Robot Project)
Team Role: Programmer
 
Join Date: Feb 2007
Rookie Year: 2007
Location: MD
Posts: 40
RyanW has a spectacular aura aboutRyanW has a spectacular aura about
Re: Gyros and WPILib

We're using the ADXRS150 gyro, from SparkFun electronics. The product page is here, and the datasheet is here. After fixing a few things in the code and scaling it properly, the values are much more sensible. We also tested the gyro with Kevin's default gyro code, and got reasonable values with a scale factor of ~3500/1000. I'm just rather surprised that the default scaling factor is off by so much, since I'm using the specified gyroscope, and I was wondering if it meant that something was wrong. However, it now seems to be working okay so far...
Closed Thread


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
WPILib and Eclipse Guy Davidson Programming 31 02-04-2008 16:59
WPILib and FRC default code CRBreingan Programming 3 25-01-2008 20:46
WPILib and FRC default code CRBreingan Programming 7 23-01-2008 21:11
Direct Control of PWMs and OI in WPILib CyberWolf_22 Programming 7 06-02-2006 19:06
White Paper Discuss: Use of Gyros in Navigation, Tip Prevention, and Driver Control CD47-Bot Extra Discussion 1 18-03-2004 08:36


All times are GMT -5. The time now is 21:55.

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