Step 2: Gyroscope

We're not going to introduce any equivalent box model for the gyroscope like we did for accelerometer, instead we're going to jump straight to the second accelerometer model and we'll show what does the gyroscope measure according to this model.

Each gyroscope channel measures the rotation around one of the axes. For instance a 2-axes gyroscope will measure the rotation around (or some may say "about") the X and Y axes. To express this rotation in numbers let's do some notations. First let's define:

Rxz - is the projection of the inertial force vector R on the XZ plane
Ryz - is the projection of the inertial force vector R on the YZ plane

From the right-angle triangle formed by Rxz and Rz, using Pythagorean theorem we get:

Rxz^2 = Rx^2 + Rz^2 , and similarly:
Ryz^2 = Ry^2 + Rz^2

also note that:

R^2 = Rxz^2 + Ry^2 , this can be derived from Eq.1 and above equations, or it can be derived from right-angle triangle formed by R and Ryz
R^2 = Ryz^2 + Rx^2

We're not going to use these formulas in this article but it is useful to note the relation between all the values in our model.

Instead we're going to define the angle between the Z axis and Rxz, Ryz vectors as follows:

Axz - is the angle between the Rxz (projection of R on XZ plane) and Z axis
Ayz - is the angle between the Ryz (projection of R on YZ plane) and Z axis

Now we're getting closer to what the gyroscope measures. Gyroscope measures the rate of changes of the angles defined above. In other words it will output a value that is linearly related to the rate of change of these angles. To explain this let's assume that we have measured the rotation angle around axis Y (that would be Axz angle) at time t0, and we define it as Axz0, next we measured this angle at a later time t1 and it was Axz1. The rate of change will be calculated as follows:

RateAxz = (Axz1 - Axz0) / (t1 - t0).

If we express Axz in degrees, and time in seconds , then this value will be expressed in deg/s . This is what a gyroscope measures.

In practice a gyroscope(unless it is a special digital gyroscope) will rarely give you a value expressed in deg/s. Same as for accelerometer you'll get an ADC value that you'll need to convert to deg/s using a formula similar to Eq. 2 that we have defined for accelerometer. Let's introduce the ADC to deg/s conversion formula for gyroscope (we assume we're using a 10bit ADC module , for 8bit ADC replace 1023 with 255, for 12bit ADC replace 1023 with 4095).

RateAxz = (AdcGyroXZ * Vref / 1023 - VzeroRate) / Sensitivity Eq.3
RateAyz = (AdcGyroYZ * Vref / 1023 - VzeroRate) / Sensitivity

AdcGyroXZ, AdcGyroYZ - are obtained from our adc module and they represent the channels that measure the rotation of projection of R vector in XZ respectively in YZ planes, which is the equivalent to saying rotation was done around Y and X axes respectively.

Vref - is the ADC reference voltage we'll use 3.3V in the example below

VzeroRate - is the zero-rate voltage, in other words the voltage that the gyroscope outputs when it is not subject to any rotation, for the Acc_Gyro board it is for example 1.23V (you can find this values in the specs)

Sensitivity - is the sensitivity of your gyroscope it is expressed in mV / (deg / s) often written as mV/deg/s , it basically tells you how many mV will the gyroscope output increase , if you increase the rotation speed by one deg/s. The sensitivity of Acc_Gyro board is for example 2mV/deg/s or 0.002V/deg/s

Let's take an example, suppose our ADC module returned following values:

AdcGyroXZ = 571
AdcGyroXZ = 323

Using the above formula, and using the specs parameters of Acc_Gyro board we'll get:

RateAxz = (571 * 3.3V / 1023 - 1.23V) / ( 0.002V/deg/s) =~ 306 deg/s
RateAyz = (323 * 3.3V / 1023 - 1.23V) / ( 0.002V/deg/s) =~ -94 deg/s

In other words the device rotates around the Y axis (or we can say it rotates in XZ plane) with a speed of 306 deg/s and around the X axis (or we can say it rotates in YZ plane) with a speed of -94 deg/s. Please note that the negative sign means that the device rotates in the opposite direction from the conventional positive direction. By convention one direction of rotation is positive. A good gyroscope specification sheet will show you which direction is positive, otherwise you'll have to find it by experimenting with the device and noting which direction of rotation results in increasing voltage on the output pin. This is best done using an oscilloscope since as soon as you stop the rotation the voltage will drop back to the zero-rate level. If you're using a multimeter you'd have to maintain a constant rotation rate for at least few seconds and note the voltage during this rotation, then compare it with the zero-rate voltage. If it is greater than the zero-rate voltage it means that direction of rotation is positive.

<p>Great tutorial.</p>
<p>Very nice. Thank you</p>
<p>Very nice and simple tutorial! Hope I will manage with it well :)</p><p>Thanks!</p>
<p>Hi ! Thanks for this very detailed instructable ! </p><p>But can you tell me how to convert Accelerometer data to Frequency to measure vibration ? is there a way ? </p><p>Regards. </p>
<p>Thank you very much! It helped a lot! :D</p>
<p>thanks for sharing good tutorial</p>
<p>Nice tutorial! i actually came here because i didn't understand why quadricopters use accelerator and why it is related to angle! but anyway, this page only helped me understand but i still wonder why don't they use a gyroscope ? isn't it easier?! whats the problem with that?!</p>
<p>Nice tutorial! i actually came here because i didn't understand why quadricopters use accelerator and why it is related to angle! but anyway, this page only helped me understand but i still wonder why don't they use a gyroscope ? isn't it easier?! whats the problem with that?!</p>
<p>Nice tutorial! i actually came here because i didn't understand why quadricopters use accelerator and why it is related to angle! but anyway, this page only helped me understand but i still wonder why don't they use a gyroscope ? isn't it easier?! whats the problem with that?!</p>
esta bien padre<br>
this info is priceless, great job...<br> 1 question: I am using the Razor 6DOF from sparkfun.com... it is an IMU with a 3 axis accel, an X/Y axis gyro, and a Z axis gyro all on one chip.<br><br>My question is that since all three chips are on the same board (flat), will the gyro work in this configuration or should I get separate accelerometer and gyro, placed at 90 degree angles to make this work?<br><br>here is a link to the board I have:<br>http://www.sparkfun.com/commerce/product_info.php?products_id=10010<br><br>Thanks in advance for any help
Check my guide:&nbsp;<a href="http://arduino.cc/forum/index.php/topic,58048.msg417140.html#msg417140">http://arduino.cc/forum/index.php/topic,58048.msg417140.html#msg417140</a><br> It is based on the Razor 6DOF chip from sparkfun.<br> <br>
<p>Is it possible to do some kind of 3d visualization with just an accelerometer? </p><p>This video shows a real-time model rotating using Qt with a LIS3DH Accelerometer and a Gyro : <iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/E2vSNgl-yv0" width="500"></iframe></p><p>What visualization can be done with just the LIS2DH alone?</p>
<p>You can properly use something Processing to do that as well.</p>
<p>Would this work with the Kionix accelerometers - the list is at http://www.kionix.com/accelerometers. They seem pretty cheap through DigiKey, and heard good things about them</p>
<p>Would this work with the Kionix accelerometers - the list is at http://www.kionix.com/accelerometers. They seem pretty cheap through DigiKey, and heard good things about them</p>
<p>If using a Digital Accelerometer are the first few steps necessary? Do you still need to incorperate a 0g voltage level? Is that the same as the zero g offset. I don't see a 0g voltage level in the data sheet. Thank you.</p>
<p>This is a so great tutorial and explanation! Thanks you! It makes me have a general picture of accelerator and gyroscope.</p>
<p>Great Job!! Thanks so much for your explanation</p>
<p>thanks for the beauty-full tutorial..it helps me a lot...God bless You</p>
Very nice explanation! Thank you very much. Right now I know how to use an accelerometer correctly.
i have a very basic doubt regarding the device placement of gyro and accelerometer+manganometer. Are they not required to be place on the exact center of PCB to get best performance. Do we compromise performance of devices by placing it offset to center. And is there particular measurement to place gyro and accelerometer apart?
Hello, <br>i am at the very first stage.i am just taking raw values from the accelerometer of GY-85IMU,it uses ADXL345. <br>But the problem is that it is giving me same value on Z-axis in every orientation. <br>This is the code: <br> <br>#include <br>#include <br>#include <br>#include <br>#include <br>#include <br>#include <br>#include <br> <br>//#define DEBUG <br>#include &quot;DebugUtils.h&quot; <br>#include &quot;CommunicationUtils.h&quot; <br>#include &quot;FreeIMU.h&quot; <br>#include <br>#include <br> <br>int raw_values[9]; <br>float conv_values[9]; <br>float ypr[3]; // yaw pitch roll <br>char str[256]; <br>float val[9]; <br>float values[9]; <br> <br>FreeIMU my3IMU = FreeIMU(); <br>//The command from the PC <br>char cmd; <br> <br>void setup() { <br> Serial.begin(115200); <br> Wire.begin(); <br> my3IMU.init(true); <br> <br> // LED <br> pinMode(13, OUTPUT); <br>} <br> <br> <br>void loop() { <br> <br> for(uint16_t i=0; i&lt;500; i++) <br> { <br> my3IMU.getRawValues(raw_values); <br> Serial.print('\n'); <br> Serial.print(&quot;RAccX=&quot;); Serial.print(raw_values[0]); Serial.print(&quot; &quot;); <br> Serial.print(&quot;RAccY=&quot;); Serial.print(raw_values[1]); Serial.print(&quot; &quot;); <br> Serial.print(&quot;RAccZ=&quot;); Serial.print(raw_values[2]); Serial.print(&quot; &quot;); <br> Serial.print('\n'); <br> Serial.print('\n'); <br> <br> } <br> <br> <br>while(1){}; <br>} <br> <br>can u tell me what is the problemm???
i am currently using mote modules MTM-CM5000 and MTM-CM3000 for data transmission and recieving along radio for a accelerometer.Output of my accelerometer can be see on oscilloscope which show me all data including voltage ,humidity,radioactivity etc all in graph form on my pc. MTS-EX1000 is also used for voltage amplification purpose.Except to all of these raw data output i only want to know about how to calculate the frequency that my accelerometer is sensing here. Thankx..
when I looked in the specifications of LIS302DL I found sensitivity = 18mg/digit, 72mg/digit and ZeroG level =? <br>here is the link please if anyone can help me determine the necessary specifications LIS purpose of applying the above formulas <br>&quot;&quot;http://www.digikey.com/product-search/en/sensors-transducers/accelerometers/1966355?k=m7&quot;&quot; <br>thinks <br>
Hello <br> I configured the accelerometer LIS302 DL card STM32F4 it shows me results between 0 and 255, and I just need to display the measurements in mm / s ^ 2 for the three axes. <br>I have read the above, I think it can help me a lot but on the voltage I do not know what value I should use. <br>if it can help me to convert the measured values ​​of the different axes, for example (0, 55.230, 245 ...) <br>((it attached a screen printed on running my application)) <br>thank you <br>
Where is the Code OF gyro ?? <br> <br>Plzz
Hi there! I have got one question: I am doing my project in android application which will give altitude, rotational movement to its users, so this information is applicable for me to using at java coding or matlab coding? or any other needed, can you please explain me! Thanks. <br>Moin.
I have a question: If we have a board with a 3-axis (x,y,z) gyroscope and a 2-axis (x,y) accelerometer is there any way to virtualize the z-axis of accelerometer with a mathematical algorithm through software since our board is missing the z-axis accelerometer? Even if it cannot be done precisely, can we estimate a range for z-accel? <br> <br>Thanks a bunch! <br> <br>
thanks for the info, i'm going to use a 5dof imu img500/adxl335, output frm them are analog for balancing my bot sould i have to build an another filter circuit like complementary filter?<br>if so how can we give the change in time rate values in our codes?(dt)<br>help me out with this <br>thank you
You can use a simple RC filter if the outputs are analog from the chip. <br> <br>To find da/dt, sample two value and subtract them. <br>Divide the result by the time passed between the two samples. <br> <br>da/dt = (Sample-1 - Sample-2) / (1 / Sampling-Frequency) <br> <br>You can get rid fo the division by using a factor k same as (1 / Sampling-Frequency). <br> <br>da/dt = (Sample-1 - Sample-2)
Hi guys,<br><br>I will make a project measurin tremor characteristics of parkinson diseased patients. To do this I need to use a sensor that can measure the movements accurately and sensitively. In the beginnin of my research I was ok with using only accelerometer but when I read more, I realized that using both accelerometer and gryo would give much better results. I will be working in arduino. Can anyone suggest me accelerometer and gryo boards to purchase? Shall I purchase acc_gyro imu board? or I shall buy them seperately?<br><br>Thanks in advance..
You can buy a board through Ebay based on &quot;MPU-6050&quot; or &quot;MPU-6000&quot; which is a gyroscope and accelerometer in the same chip. <br> <br>The cross talk is minimal and it is cheaper to buy them in the same package (my thought).
Thank you for the post,it is really interesting. I just have a question. Why should we have to divise each quantity Rx,Ry,Rz by R? What does it mean? <br>My second question is about the force Rx,Ry,Rz. I thought that only tangential forces from the accelerometer had to be add the the angle. Is Rx, Ry,Rz the tangentiel forces??
R is the resultant vector of the three component vectors, Rx, Ry and Rz. <br> <br>R^2 = Rx^2 + Ry^2 + Rz^2 <br>=&gt; R = SQRT(Rx^2 + Ry^2 + Rz^2) <br> <br>You need this division to measure the contribution of a component (Rx, Ry or Rz) to the resultant vector, R. R will incline towards the component having the higher value. If Rx, Ry and Rz have the same lengths (same acceleration in all axes), the resultant vector (R) will point precisely in their middle. <br> <br>Thus to find the angle between Rx, Ry or Rz and R, you need: <br>Axr = arccos(Rx/R) <br>Ayr = arccos(Ry/R) <br>Azr = arccos(Rz/R) <br> <br>Yes, Rx, Ry and Rz are tangential.
Hi, great instructable! <br> <br>I gave a question concerning the angles extracted from the accelerometer: It seems there is a hidden assumptions that the reading of the accelerations will always be done while stationary (or not moving). This is not true to most mobile/airborne applications. <br>In these cases there is also an additional external acceleration (like the acceleration of the car or an aircraft turning in a wide angle) and then the assumption about the total 1g vector size isn't right. <br>What am I missing? <br> <br>Thanks <br>Gabriel
You can always read the &quot;bias&quot; value by keeping the chip static. The datasheet must be providing this value as well. I think, it does not drift that much with time and thus you can always subtract a constant value from the readings. <br> <br>There is no hidden assumption here. If it is static, you will get 0 after the &quot;bias&quot; subtraction.
Guys, <br>can anybody tell me how can i get negative readings for x,y,z, axis from accelerometer ? i mean it show me just + value in x axes or other too. but not -(negative). so how i know if i made opposing motion
Read it above at, &quot;Let's say our 0g voltage level is VzeroG = 1.65V&quot;. <br> <br>If your reading is less than the zero-g value, you are accelerating in the negative direction.
Great Explanation . . .
Very helpful! I used this instructable to interpret data for a model airplane autopilot. I would like to add that if you are struggling to convert your accelerometer into degrees you should investigate the atan2() function. <br>somethings like: <br>pitch (in degrees) = atan2[x(in g's),y(in g's)] + pi
Thank you so much for posting this information! It would've had taken me days to figure this stuff out on my own.
Thank u very much !!! it was an awesome piece of informations!!
thanks a lot this really helped me
Fantastic Information. Thank you for dumbing it down to a hobbist level instead of an engineer tech babble.
This is a really good instructable! It really contains everything you need to know to start with those sensors. It answered a lot of my questions!<br><br>Thanks

About This Instructable


262 favorites

More by Gadget Gangster: Hack Your Car Talking Resistor Calculator Bananaphone: A Touch Capacitance Synth
Add instructable to: