|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
||||
|
||||
|
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);
}
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
|
|||
|
|||
|
Re: Gyro Implementation
okay, and is the adc code required to be implemented? or can the gyro run without it.
|
|
#4
|
||||
|
||||
|
Re: Gyro Implementation
Since the gyro is based off of the ADC, I assume it's needed to work the gyro.
|
|
#5
|
|||||
|
|||||
|
Re: Gyro Implementation
Quote:
I laughed out loud the first time I read the "names" of these pins. |
|
#6
|
|||
|
|||
|
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. */
}
Code:
void Process_Gyro_Data(void)
{
}
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
|
||||
|
||||
|
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();
}
8. That's correct. |
|
#8
|
|||
|
|||
|
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
|
||||
|
||||
|
Re: Gyro Implementation
The analog pins can't be configured as outputs, so that's unnecessary.
|
|
#10
|
|||
|
|||
|
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
|
||||
|
||||
|
Re: Gyro Implementation
Quote:
-Kevin |
|
#12
|
|||||
|
|||||
|
Re: Gyro Implementation
Quote:
As others pointed out, the step you're trying to follow is only for the EDU-RC mini controller. |
|
#13
|
|||
|
|||
|
Re: Gyro Implementation
Oh wow.. totally skipped over that part.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |