Author Topic: Gyro offsets, how to deal with them?  (Read 3437 times)

0 Members and 1 Guest are viewing this topic.

Offline Aberg098Topic starter

  • Full Member
  • ***
  • Posts: 66
  • Helpful? 0
Gyro offsets, how to deal with them?
« on: September 09, 2010, 10:06:39 AM »
What's the deal with gyro offsets and how should I deal with them?

I'm running an AxonII with the sparkfun razor 6DOF IMU
http://www.sparkfun.com/commerce/product_info.php?products_id=9431

Currently, I'm just reading the values from the gyros from hyperterminal. Given about a minute or so after powerup, the gyro values stabilise around a given value. Yes, I should mention that everything is on a stationary table.

My next step is to subtract what I've figured the offset value is (see code, all shown as zeroes in this case)
Code: [Select]
#include "hardware.h"

// Initialise the hardware
void appInitHardware(void) {
initHardware();
}

// Initialise the software
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
return 0;
}

// This is the main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) {

gyroRead(pitchRoll);
gyroRead(yaw);

//Gyro offset correction
int Gx;
int Gy;
int Gz;

Gx=pitchRoll.gyro.x_axis_degrees_per_second - 0;
Gy=pitchRoll.gyro.y_axis_degrees_per_second - 0;
Gz=yaw.gyro.z_axis_degrees_per_second + 0;

//Gyro rprintf
rprintf("\nGx= %d (Deg/s), Gy= %d (Deg/s), Gz= %d (Deg/s) \n",
Gx,
Gy,
Gz);

//wait to do next reading in ms
delay_ms(500);
return 0;
}

Reprogram everything, power off, then power on, wait for "steady state" value and it's again not even close to zero!

Offline Aberg098Topic starter

  • Full Member
  • ***
  • Posts: 66
  • Helpful? 0
Re: Gyro offsets, how to deal with them?
« Reply #1 on: September 10, 2010, 02:21:21 PM »
I've now tried to do something different: A friend pointed out that I am declaring my Gx, Gy and Gz as local variables that exist within the loop and suggested I try to make them global variables.

What would making this change actually do? Since the G values are used only within the loop, and have a different value assigned to them at the beginning of each iteration, I don't understand what the difference is.

I've now declared Gx, Gy and Gz as global variables and have put in some "housekeeping" lines to reset their values to zero at the end of the loop. Seems to work, I need to perform a bit more testing to tweak the values.

Here is my "new" implementation:
Code: [Select]
#include "hardware.h"

//Variables now declared as global
int Gx;
int Gy;
int Gz;

// Initialise the hardware
void appInitHardware(void) {
initHardware();
}

// Initialise the software
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
return 0;
}

// This is the main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) {

gyroRead(pitchRoll);
gyroRead(yaw);

//Gyro offset correction

Gx=pitchRoll.gyro.x_axis_degrees_per_second - 0;
Gy=pitchRoll.gyro.y_axis_degrees_per_second - 0;
Gz=yaw.gyro.z_axis_degrees_per_second + 0;

//Gyro rprintf
rprintf("\nGx= %d (Deg/s), Gy= %d (Deg/s), Gz= %d (Deg/s) \n",
Gx,
Gy,
Gz);

        //housekeeping, or resetting Gx,Gy and Gz to zero
        Gx=0;
        Gy=0;
        Gz=0;

//wait to do next reading in ms
delay_ms(500);
return 0;

 


data_list