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.
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.
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().
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.
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?
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.
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?)
You need to call Process_Gyro_Data in your code to use the gyro. The referenced files contain examples of how to do this.
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:
i++;
j++; // this will rollover every ~1000 seconds
if (j == 10) {
printf("
Calculating Gyro Bias...
");
}
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
", temp_gyro_bias);
}
if (i == 35 && j >= 300) {
temp_gyro_rate = Get_Gyro_Rate();
temp_gyro_angle = Get_Gyro_Angle();
printf(" Gyro Rate=%d
", temp_gyro_rate);
printf("Gyro Angle=%d
", (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.
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.
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.