Pages: [1]   Go Down
 Author Topic: Getting angles from Gyro  (Read 620 times) 0 Members and 1 Guest are viewing this topic.
Offline
Newbie
Karma: 0
Posts: 9
 « on: March 27, 2013, 09:49:55 am » Bigger Smaller Reset

I'm trying to get the angles from a gyroscope, and assuming I already have the rate of change (V, degree/s) of the angle Axz, can I calculate the angle Axz_1 with the following:

VAxz = (Axz_1-Axz_0) / (t1-t0)

Which would give us that:

Axz_1 = VAxz*(t1-t0)+Axz_0

When  VAxz = Rate of change of the angle Axz(in deg/s);
Axz_0 = Starting angle; Axz_1 = New angle;
t0 = Starting time; t1 = New time(in seconds)

Is this correct ?

 « Last Edit: March 27, 2013, 10:05:25 am by matstra » Logged

Switzerland
Offline
Karma: 83
Posts: 4180
 « Reply #1 on: March 27, 2013, 10:55:35 am » Bigger Smaller Reset

Quote
Is this correct ?

The math is correct. If you want to know if you chose the right algorithm, you have to tell us, where you get the values from and what you want to achieve.
 Logged

Offline
Newbie
Karma: 0
Posts: 9
 « Reply #2 on: March 27, 2013, 11:36:17 am » Bigger Smaller Reset

The math is correct. If you want to know if you chose the right algorithm, you have to tell us, where you get the values from and what you want to achieve.

I'm using a digital sensor called L3G4200D.
So my question is basically, do I get degree/s as a value out as data from this kind of sensor ?

I got the algorithm from this site http://www.starlino.com/imu_guide.html
 Logged

Switzerland
Offline
Karma: 83
Posts: 4180
 « Reply #3 on: March 27, 2013, 12:09:59 pm » Bigger Smaller Reset

What code are you using?
 Logged

Offline
Newbie
Karma: 0
Posts: 9
 « Reply #4 on: March 27, 2013, 12:13:44 pm » Bigger Smaller Reset

What code are you using?

http://bildr.org/2011/06/l3g4200d-arduino/
 Logged

Switzerland
Offline
Karma: 83
Posts: 4180
 « Reply #5 on: March 27, 2013, 12:38:32 pm » Bigger Smaller Reset

The units you're getting are 70 millidegrees (per second), so about 14 units make one degree (per second). Datasheet page 10.
 Logged

Offline
Newbie
Karma: 0
Posts: 9
 « Reply #6 on: March 27, 2013, 01:08:44 pm » Bigger Smaller Reset

ok thanks!

I tried to understand why there is 10 bits in the code for CTRL_REG4, and not 8 bits as I asumed there should be when I look on the datasheet, you know why ?

This is from the code:

 Logged

Switzerland
Offline
Karma: 83
Posts: 4180
 « Reply #7 on: March 27, 2013, 01:16:02 pm » Bigger Smaller Reset

Quote
I tried to understand why there is 10 bits in the code for CTRL_REG4, and not 8 bits as I asumed there should be when I look on the datasheet, you know why ?

In that code there are 8 bits (which are all 0). Did you notice the '0b' at the start which prepends a binary constant?
 Logged

Offline
Newbie
Karma: 0
Posts: 9
 « Reply #8 on: March 27, 2013, 01:42:46 pm » Bigger Smaller Reset

ok, I see. That is strange...
Does it work if I just use hex instead like this ?

 Logged

Offline
Edison Member
Karma: 57
Posts: 2078
 « Reply #9 on: March 27, 2013, 03:12:07 pm » Bigger Smaller Reset

"0b00000000" should be B00000000.
http://arduino.cc/en/Reference/IntegerConstants
But I never use binary. So use 0x00.
 Logged

Offline
Newbie
Karma: 0
Posts: 9
 « Reply #10 on: March 27, 2013, 04:25:56 pm » Bigger Smaller Reset

Ok! Thanks a lot!
 Logged

 Pages: [1]   Go Up