Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Gyroscope Code (http://www.chiefdelphi.com/forums/showthread.php?t=39537)

Alan T 15-04-2006 21:02

Re: Gyroscope Code
 
I found a minor bug in the gyro code.

The problem I was having is the Get_Gyro_Rate was all over the place. It would bounce between + and - during a turn.

I added the long qualifiers to the GYRO_CAL_FACTOR and the problem went away.

#define GYRO_CAL_FACTOR 1000L/1000L

It must have been using an integer in there somewhere and it was overflowing. The problem didn't seem to affect the Get_Gyro_Angle routine.

alan

Chaychay 17-04-2006 00:55

Re: Gyroscope Code
 
First of all, I would like to thank Mr. Watson for all the work he has put into FRC programming...you da man :] !

I have an ADXRS150EB Gyro. I loaded the standard EDU-gyro code from kevin.org onto an Edu controller and a bias of 1922 was calculated. The gyro is working perfectly, and all the angles I tested seemed reasonable.

Now I move the gyro to a 2005 RC, and ran the 2006 Gyro code (with library and linker files changed to 2005). The bias was calculated to be 966 :confused:. The part if find even more odd, is that at the bias of 966 the gyro still appeared to work, except that if i rotated 90 deg, it thought it rotated ~70 deg. When the gyro wasnt moving, the rate was 0. I've looked through the EDU vs. FRC code, and I can't see anything that would cause the biases to be different.

Notes:

1. No backup battery on FRC (main voltage was ~12.6)
2. Gyro is on a breadboard
3. No modifications made to code from kevin.org except change from milliradians to 1/10 deg
4. I tried the 2005 Gyro code and it worked perfectly. So its not my RC, there is something between the 2006 and 2005 Gyro code that I'm not seeing :o
5. I would be using a 2006 RC, but its being repaired by IFI at the moment...this code is intended for the 2006 RC, which is why I'm not using the 2005 Gyro code)

Any help in getting the gyro working with the 2006 Gyro code on a 2005 RC would be greatly appreciated. Thanks a ton!

DanDon 17-04-2006 07:41

Re: Gyroscope Code
 
Did you check to see which gyro is defined in gyro.h?

Chaychay 17-04-2006 10:15

Re: Gyroscope Code
 
Yup, I made sure it was the ADXRS150 that was defined. (Sorry I forgot to mention that :p )

Chaychay 17-04-2006 17:33

Re: Gyroscope Code
 
(Please see my previous post; otherwise this one might not make much sense)

Ok...another weird thing is happening.

I wanted to continue coding, so I loaded the 2005 Gyro code (the code that works perfectly...no odd stuff happening).

By default, Mr. Waston has all the printf's for gyro data in user_routines. So I turn the robot ~90 degrees, and the gyro reports it turned ~1570 milliradians. Wicked......now:

I moved the gyro code that was in user_routines into the User_Autonomous_Code. (so the bias and all the output is now coming from autonomous mode). I also moved the Process_Gyro_Data as instructed. Now I turn the robot 90 degrees, and the gyro reports that it turned 1200 milliradians.

Does anyone have any idea as to why the output I got (from the same code) is different just because I moved it to a different location?

Again, any help would be much appreciated....I really am stumped.

Notes:

In a final attempt to prove that I wasn’t delusional :o ......I put the gyro data printf's in both autonomous and regular mode. (the bias was only being calculated once in regular mode). Now, I turned the robot ~90 degrees in regular mode, then turned autonomous on. I returned the robot to its orginal position and instead of reported ~0 heading, I got a heading of ~400 milliradians. :confused:

jhallel 04-02-2007 13:01

Re: Gyroscope Code
 
Excuse me, Kevin, but during the Build of the Gyroscope code, an error is found stating GYRO_CAL_FACTOR is defined several times. However, after checking through the code, GYRO_CAL_FACTOR is defined once: double GYRO_CAL_FACTOR = 1000/1000;
What is the error?

Kevin Watson 05-02-2007 00:32

Re: Gyroscope Code
 
Quote:

Originally Posted by jhallel (Post 571511)
Excuse me, Kevin, but during the Build of the Gyroscope code, an error is found stating GYRO_CAL_FACTOR is defined several times. However, after checking through the code, GYRO_CAL_FACTOR is defined once: double GYRO_CAL_FACTOR = 1000/1000;
What is the error?

This isn't nearly enough information. We can help you out if you post code and/or a description of the changes you've made and the contents of the MPLAB build window containing the error text.

-Kevin

Gary Bonner 09-02-2007 00:26

Gyro Problems
 
We hooked up our gyro today and are having some problems with it. We were running Kevin’s unmodified code and tried calibrating the scaling factor. After initializing, it returns 0 turn rate and 0 angle. If we rotate the gyro 180 degrees counter clockwise, it returns about -3100 milliradians. If we rotate it 180 degrees clockwise (after initializing), it reports about 2700 milliradians. If we rotate it 180 degrees back and forth, the angle value decreases an additional approx. 400 milliradians each cycle.

We also tried directly printing the gyro value from a Get_Analog_Value() statement while rotating the gyro by hand. At rest, we got a value of 505, turned rapidly in one direction, it would go to zero, but in the other direction, the highest it would go was about 780.

Are we missing something? Might we have a defective gyro?

Thanks.

6600gt 09-02-2007 00:30

Re: Gyro Problems
 
Quote:

Originally Posted by Gary Bonner (Post 574763)
We hooked up our gyro today and are having some problems with it. We were running Kevin’s unmodified code and tried calibrating the scaling factor. After initializing, it returns 0 turn rate and 0 angle. If we rotate the gyro 180 degrees counter clockwise, it returns about -3100 milliradians. If we rotate it 180 degrees clockwise (after initializing), it reports about 2700 milliradians. If we rotate it 180 degrees back and forth, the angle value decreases an additional approx. 400 milliradians each cycle.

We also tried directly printing the gyro value from a Get_Analog_Value() statement while rotating the gyro by hand. At rest, we got a value of 505, turned rapidly in one direction, it would go to zero, but in the other direction, the highest it would go was about 780.

Are we missing something? Might we have a defective gyro?

Thanks.

You might be exceeding the 150 degrees/sec turn rate of the gyro...

kaszeta 09-02-2007 00:36

Re: Gyro Problems
 
Quote:

Originally Posted by Gary Bonner (Post 574763)

Are we missing something? Might we have a defective gyro?

Thanks.

Several things to check:

1. Is the gyro level?
2. Are you letting calculate the bias correctly (letting it sit a bit before running it)?
3. Are you turning it too quickly?

Gary Bonner 09-02-2007 00:54

Re: Gyro Problems
 
Quote:

Originally Posted by kaszeta (Post 574776)
Several things to check:

1. Is the gyro level?

The gyro was always level when we did the scaling factor calibration. When we were just printing it out and turning it by hand, we held it as level as we could.

Quote:

2. Are you letting calculate the bias correctly (letting it sit a bit before running it)?
Yes, we never moved it until the bias was calculated

Quote:

3. Are you turning it too quickly?
If we turned it extremely slowly (about 5 sec to turn 180 degrees), it seemed to work ok. Anything faster than that and it had errors and they seemed consistant, regardless of speed, and only in a clockwise direction.

Kevin Watson 09-02-2007 01:21

Re: Gyro Problems
 
Quote:

Originally Posted by Gary Bonner (Post 574785)
The gyro was always level when we did the scaling factor calibration. When we were just printing it out and turning it by hand, we held it as level as we could.


Yes, we never moved it until the bias was calculated


If we turned it extremely slowly (about 5 sec to turn 180 degrees), it seemed to work ok. Anything faster than that and it had errors and they seemed consistant, regardless of speed, and only in a clockwise direction.

Is this a 2007 ADXRS150 gyro? Open up adc.h and change the sample rate to 1600Hz and samples per update to 16 and report back.

-Kevin

Gary Bonner 09-02-2007 06:23

Re: Gyro Problems
 
Quote:

Originally Posted by Kevin Watson (Post 574795)
Is this a 2007 ADXRS150 gyro? Open up adc.h and change the sample rate to 1600Hz and samples per update to 16 and report back.

-Kevin

Yes, it's this year's gyro. I'll try this when I get back to the shop tonight. We're using a 2004 RC, if that makes any difference.

Thanks.

kaszeta 09-02-2007 09:11

Re: Gyro Problems
 
Quote:

Originally Posted by Gary Bonner (Post 574785)
If we turned it extremely slowly (about 5 sec to turn 180 degrees), it seemed to work ok. Anything faster than that and it had errors and they seemed consistant, regardless of speed, and only in a clockwise direction.

Okay, this helps. It's probably not a deadband issue, mounting issue, or calibration issue. The next thing to check is increasing the sampling rate and precision. (Oops, I just saw that Kevin recommended the same thing).

I'll run some tests on our 2007 kit gyro (we're not using it, we decided again to use a ADXRS300EB since we can really spin our robot. We lose some precision, but make it up in overall accuracy).

Kevin Watson 09-02-2007 11:49

Re: Gyro Problems
 
Quote:

Originally Posted by Gary Bonner (Post 574829)
Yes, it's this year's gyro. I'll try this when I get back to the shop tonight. We're using a 2004 RC, if that makes any difference.

As a backup plan, you should ask FIRST for a new gyro. Tell them that I suspect it's defective.

The 2004 RC should work fine assuming you compiled the code for the 18F8520, not the 18F8722.

-Kevin


All times are GMT -5. The time now is 16:09.

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