[gyro] how to get the orientation
solix
Posts: 7
Hello everyone,
I just bought a gyro and I finally made it work... But my problem is, it seems to give me the acceleration, not the position.
What I need actually is just a value that correspond to an angle. If it's horizontal I want a 0 if it's tilted 10 deg to the right I want x and if it's tilted 10 deg to the left I want -x.
I'v tried different things knowing that acceleration = speed' and that speed = position' :
dspeed = acceleration * dt;
speed = speed + dspeed ;
dx = speed * dt
x = x + dx
But this doesn't work...
Is it possible to get the angle ?
I just bought a gyro and I finally made it work... But my problem is, it seems to give me the acceleration, not the position.
What I need actually is just a value that correspond to an angle. If it's horizontal I want a 0 if it's tilted 10 deg to the right I want x and if it's tilted 10 deg to the left I want -x.
I'v tried different things knowing that acceleration = speed' and that speed = position' :
dspeed = acceleration * dt;
speed = speed + dspeed ;
dx = speed * dt
x = x + dx
But this doesn't work...
Is it possible to get the angle ?
Comments
An accelerometer gives you translational acceleration. You integrate this to get velocity, and integrate the velocity to get position. You can determine the vertical direction from the low-pass values from the accelerometer, unless you are constantly accelerating such as in a rocket.
Do you have a gyro or an accelerometer? What device are you using?
I have tried to integrate, but the problem is, even if I don't touch anythings, to value of the position keeps getting bigger and bigger...
How can I "compensate for drift" ?
Thanks for your help Hein
sample := GetSample
speed := sample - dc_offset
dx := speed * dt
x := x + dx
You can measure the dc_offset when the gyro is not moving. You can compensate for drift by using a 2D accelerometer to determine the vertical/horizontal directions.
I really appreciate your time Your answer helped me a lot ! But my gyro is pretty cheap and I think the mesurement isn't great >< (the error is increasing in time)
Thank you !
http://forums.parallax.com/showthread.php?127868-Gyro-lisy300&highlight=gyro
I don't hear this enough, so I will preach it again, and this especially applies to a sensor with a nature such as a gyro. The DATA that most people, round or truncate, might actually contain useful information, and if not dealt with properly can contribute to significant drift. In an ideal system, the LSB (Least Significant Bit should have a normal bias of 50%. External 'noise' will offset this bias, as well as even the circuit configuration. Each time you introduce a link in th system, such as converting from analog to digital), you introduce some additional amount of error to the system that can ultimately offset the bias. Over time this bias can be tracked and measured, and applied back into the system as a means of error correction. Perhaps the most maddening thing that a programmer can experience with a sensor such as a gyro, is the circular reference issues, and trying to wrap your head around that. The attached reference page explains in a way (I hope) that makes approaching this type of device less daunting.
Can you provide a description of your application? If you want to determine the angle over a long period of time you will need to compensate for the drift of the gyro by using an accelerometer or some other method to determine vertical. Depending on your application you could even use a suspended pendulum and some way to measure it's deflection. I don't know how many bits you're using on the the ADC for your gyro, buy you should use enough bits to get down into the noise level. Your DC offset should be accumulated to a greater precision than your ADC to reduce the drift due to the DC bias.
Dave