Page 1 of 1

arduino mega and gyroscope (idg500)

PostPosted: Wed Jun 13, 2012 9:26 pm
by errieyz
How can I get absolute angle from rate gyroscope idg500?already try many option of programming using arduino mega but until now still can't get an angle.anybody please help me if got the solution.

Re: arduino mega and gyroscope (idg500)

PostPosted: Thu Jun 14, 2012 7:30 am
by robosang
Really? What is the option you tried?

Re: arduino mega and gyroscope (idg500)

PostPosted: Thu Jun 14, 2012 10:53 am
by errieyz
1 of the way I used milis() to sample time..this my code

const int analogInPin = A8;
int gout;
float ang_rate;
float gzero = 280;
float sensativity = 0.002;
long abs_ang = 0;
float prev_time = 0.0;
float timer;
float delta_time;

void setup()
{
Serial.begin(9600);
analogReference(EXTERNAL);
//gzero = ((1023/5)*1.36);

}

void loop()
{
timer = millis();
gout = analogRead(analogInPin);
ang_rate = ((gout-gzero)/sensativity);
delta_time = (timer-prev_time)/1000;
abs_ang = ((long)(abs_ang + (ang_rate*delta_time)));
Serial.println(abs_ang);
prev_time = timer;
}

Re: arduino mega and gyroscope (idg500)

PostPosted: Tue Jun 19, 2012 8:54 am
by waiweng83
What is the result you get then?

FYI, using gyro alone will not give you an absolute angle. For this, you will need to combine together with an accelerometer.
Please read this tutorial for more information: http://tutorial.cytron.com.my/2012/01/1 ... lerometer/