Go to Post Part of FRC is to introduce you to how engineering is in real life: you can't use a redo card if you're landing something on the moon. - The other Gabe [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 05-02-2008, 19:43
Guarana Guarana is offline
Registered User
FRC #1706
 
Join Date: Jan 2008
Location: Wentzville, Missouri
Posts: 16
Guarana is an unknown quantity at this point
Gyro Implementation

Okay, so I am still trying to get this 'installed' into my code right now. I did a little searching but it seems everyone is already past the part where I seem to get stuck. I have read the gyro_readme and I get confused on a few steps.

1) The gyro's rate output is wired to one of the analog inputs
of your robot controller and gyro.h/#define GYRO_CHANNEL is
updated with the analog channel your gyro is attached to.

5) Process_Gyro_Data() must be called when the ADC software
generates an update. An example of how to do this can be found
in user_routines_fast.c/Process_Data_From_Local_IO(). If you
use the gyro during autonomous period, Process_Gyro_Data()
must also be called from User_Autonomous_Code().

8) A gyro bias calculation must take place using the functions
Start_Gyro_Bias_Calc() & Stop_Gyro_Bias_Calc() described below.
This must be done several hundred milliseconds after the gyro
powers-up and is allowed to stabilize.

9) For optimal performance, you'll need to calibrate the gyro
scaling factor using the instructions above or those included
in gyro.h.


I'm not very experienced when it comes to this, so any help is appreciated.

Also, do I need to 'install' the adc code also to get this to work?

Thanks
  #2   Spotlight this post!  
Unread 05-02-2008, 20:18
psy_wombats's Avatar
psy_wombats psy_wombats is offline
Registered User
AKA: A. King
FRC #0467 (Duct Tape Bandits)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Shrewsbury MA
Posts: 95
psy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura about
Re: Gyro Implementation

I guess I'll just clarify the steps you listed...? Although I'm not quite too sure about this, but I'll see if I can help.

1. The gyro is based off the analog-to-digital converter. So you'll want to hook up the T on the gyro to an analog input. (Make sure it's T and not R. It's not Rotation and Temperature, but Turning and Relative Temperature. Who came up with that?)

5. You need to call Process_Gyro_Data in your code to use the gyro. The referenced files contain examples of how to do this.

8. Calculating the gyro bias... You need to calibrate the gyroscope before you can use it. If you're not using Kevin Watson's new code, I believe this is the default calibration routine:
Code:
    i++;
    j++; // this will rollover every ~1000 seconds

    if (j == 10) {
        printf("\r\nCalculating Gyro Bias...\r\n");
    }

    if (j == 60) {
        // start a gyro bias calculation
        Start_Gyro_Bias_Calc();
    }

    if (j == 300) {
        // terminate the gyro bias calculation
        Stop_Gyro_Bias_Calc();

        // reset the gyro heading angle
        Reset_Gyro_Angle();

        temp_gyro_bias = Get_Gyro_Bias();
        printf("Gyro Bias=%d\r\n", temp_gyro_bias);
    }

    if (i == 35 && j >= 300) {
        temp_gyro_rate = Get_Gyro_Rate();
        temp_gyro_angle = Get_Gyro_Angle();
        printf(" Gyro Rate=%d\r\n", temp_gyro_rate);
        printf("Gyro Angle=%d\r\n\r\n", (int)temp_gyro_angle);
    }
Although I thought that was included somewhere... Make sure i and j are declared somewhere. (This should be in teleop.c or the Process Data function of user_routines.c.

9. I'd leave this alone for now. You're better off trying to get the gyro working than working optimaly, really. Save this for later.



Not entirely sure all that information is correct. If it isn't if someone could let me know? So I don't go about spreading misinformation? Thanks.
  #3   Spotlight this post!  
Unread 05-02-2008, 20:26
Guarana Guarana is offline
Registered User
FRC #1706
 
Join Date: Jan 2008
Location: Wentzville, Missouri
Posts: 16
Guarana is an unknown quantity at this point
Re: Gyro Implementation

okay, and is the adc code required to be implemented? or can the gyro run without it.
  #4   Spotlight this post!  
Unread 05-02-2008, 20:27
psy_wombats's Avatar
psy_wombats psy_wombats is offline
Registered User
AKA: A. King
FRC #0467 (Duct Tape Bandits)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Shrewsbury MA
Posts: 95
psy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura about
Re: Gyro Implementation

Since the gyro is based off of the ADC, I assume it's needed to work the gyro.
  #5   Spotlight this post!  
Unread 05-02-2008, 21:55
gnormhurst's Avatar
gnormhurst gnormhurst is offline
Norm Hurst
AKA: gnorm
#0381 (The Tornadoes)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Trenton, NJ
Posts: 138
gnormhurst will become famous soon enoughgnormhurst will become famous soon enough
Re: Gyro Implementation

Quote:
Originally Posted by psy_wombats View Post
(Make sure it's T and not R. It's not Rotation and Temperature, but Turning and Relative Temperature. Who came up with that?)
Probably the guy who labeled the board backwards and came up with a goofy way to rename them rather than admit the mistake.

I laughed out loud the first time I read the "names" of these pins.
__________________
Trenton Tornadoes 381
2004 Philadelphia Regional Winners
2006 Xerox Creativity Award
---
My corner of the USPTO.
My favorite error message from gcc: main is usually a function
My favorite error message from Windows: There is not enough disk space available to delete this file.
  #6   Spotlight this post!  
Unread 06-02-2008, 15:14
Guarana Guarana is offline
Registered User
FRC #1706
 
Join Date: Jan 2008
Location: Wentzville, Missouri
Posts: 16
Guarana is an unknown quantity at this point
Re: Gyro Implementation

Now for my own clarification.

1. So it is just saying hook it up to T not R on the board? This has nothing to do with code?

5. A call to Process_Gyro_Data() should be done when the ADC is updated. When and where should this be done? And I'm guessing it should look like this:

Code:
void Process_Data_From_Local_IO(void)
{
  /* Add code here that you want to be executed every program loop. */

}
Sooo...

Code:
void Process_Gyro_Data(void)
{

}
I'm guessing this is how it should be done. Just where in the code?

8. I am using the new code. It should still work right? It starts the bias, waits, stops the bias, then sets them into variables.

9. I am just ignoring this.

Confirmation?
  #7   Spotlight this post!  
Unread 06-02-2008, 16:00
psy_wombats's Avatar
psy_wombats psy_wombats is offline
Registered User
AKA: A. King
FRC #0467 (Duct Tape Bandits)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Shrewsbury MA
Posts: 95
psy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura about
Re: Gyro Implementation

1. It just instructs to hook up the gyro. You shouldn't have to code anything but the gyro channel in gyro.h or just use the default of channel 1.

5. Actually, just use something like this to call the processing of data:
Code:
void Process_Data_From_Master_uP(void)  // The slow loop
{
  Process_Gyro_Data();

}
The function is defined, you just need to call it is all.

8. That's correct.
  #8   Spotlight this post!  
Unread 06-02-2008, 18:32
Guarana Guarana is offline
Registered User
FRC #1706
 
Join Date: Jan 2008
Location: Wentzville, Missouri
Posts: 16
Guarana is an unknown quantity at this point
Re: Gyro Implementation

Okay, so now I got the gyro code all up and going. I am now working on installing the ADC.

I get to the part where is says to make all the analog inputs = INPUT; So I have this code:

rc_ana_in01 = rc_ana_in02 = rc_ana_in03 = rc_ana_in04 = INPUT;
rc_ana_in05 = rc_ana_in06 = rc_ana_in07 = rc_ana_in08 = INPUT;
rc_ana_in09 = rc_ana_in10 = rc_ana_in11 = rc_ana_in12 = INPUT;
rc_ana_in13 = rc_ana_in14 = rc_ana_in15 = rc_ana_in16 = INPUT;

above the digital inputs section in User_Initialization(). it keeps giving me a syntax error on the top line. Help?
  #9   Spotlight this post!  
Unread 06-02-2008, 21:54
usbcd36's Avatar
usbcd36 usbcd36 is offline
Registered User
AKA: "DOS"
FRC #2399 (The Fighting Unicorns)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Solon, OH
Posts: 151
usbcd36 is a jewel in the roughusbcd36 is a jewel in the roughusbcd36 is a jewel in the rough
Re: Gyro Implementation

The analog pins can't be configured as outputs, so that's unnecessary.
  #10   Spotlight this post!  
Unread 07-02-2008, 00:17
Guarana Guarana is offline
Registered User
FRC #1706
 
Join Date: Jan 2008
Location: Wentzville, Missouri
Posts: 16
Guarana is an unknown quantity at this point
Re: Gyro Implementation

But step 3 in the adc installation says:

3) On the EDU-RC, all analog inputs must be configured as
INPUTs in user_routines.c/User_Initialization().

That is what I did right?
  #11   Spotlight this post!  
Unread 07-02-2008, 01:23
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Gyro Implementation

Quote:
Originally Posted by Guarana View Post
But step 3 in the adc installation says:

3) On the EDU-RC, all analog inputs must be configured as
INPUTs in user_routines.c/User_Initialization().

That is what I did right?
Are you using the small EDU robot controller or the full size FRC robot controller?

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #12   Spotlight this post!  
Unread 07-02-2008, 08:00
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Gyro Implementation

Quote:
Originally Posted by Guarana View Post
Code:
rc_ana_in01 = rc_ana_in02 = rc_ana_in03 = rc_ana_in04 = INPUT;
above the digital inputs section in User_Initialization(). it keeps giving me a syntax error on the top line. Help?
The syntax error is because rc_ana_in01 is a constant (I think it resolves to 135). The compiler understandably doesn't like code that tries to assign a value to a constant.

As others pointed out, the step you're trying to follow is only for the EDU-RC mini controller.
  #13   Spotlight this post!  
Unread 07-02-2008, 17:07
Guarana Guarana is offline
Registered User
FRC #1706
 
Join Date: Jan 2008
Location: Wentzville, Missouri
Posts: 16
Guarana is an unknown quantity at this point
Re: Gyro Implementation

Oh wow.. totally skipped over that part.
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
gyro captainking General Forum 4 03-02-2008 22:25
[FVC]: Gyro? Tangello_angela FIRST Tech Challenge 1 23-02-2007 18:20
Gyro magical hands Programming 2 14-01-2005 20:57
gyro odin892 Programming 0 08-04-2003 09:59
Gyro archiver 2001 2 23-06-2002 23:11


All times are GMT -5. The time now is 19:15.

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