PDA

View Full Version : 16F877A and Gyro algorithm question



Macgman2000
- 22nd February 2012, 01:47
Hello,

Is it possible to use a gyro to determine angular displacement? think of a clock face, I want to rotate an object from rest 12 o'clock to say 9 o'clock. Then I want to stop and rotate it the opposite direction and stop back at my starting position 12 o'clock.

Nick

Darrel Taylor
- 22nd February 2012, 02:18
A gyro does a good job of measuring the change of angles if it's "Integrated" in the math.
But by itself, it will drift because it has no point of reference.

Adding a 2-axis accelerometer can give it a reference point (the gravity vector).
But that assumes it's stationary in the 3rd axis (like a clock on the wall).
And it has to be totally stationary often enogh to maintain the reference point to gravity.

With a 3-axis accelerometer you can get a "Tilt Sensor".
http://www.picbasic.co.uk/forum/content.php?r=210-Angle-determine-tilt-from-3-axis-g-sensor
But constant rotations would cause it to drift as well.

It would be more accurate, and a lot less hassle, to put an encoder on whatever is turning.

Macgman2000
- 22nd February 2012, 03:34
DT, thanks for the confirmation. I never used it as an absolute position sensor, always relative.

Best Regards,
Nick

AvionicsMaster1
- 22nd February 2012, 22:21
Doesn't really answer your question about a gyro but I do agree with Darrel in that gyros drift. They also are extremely difficult to compensate accurately.

If it didn't need to be a full 360 degrees you could use a linear potentiometer hooked to the shaft? Supply 5V to one the other to ground with the wiper as the output. You'd have to do a one time calibration to determine angular position vs output and then it could be fed into an ADC to discern the output. This way it wouldn't be susceptible to gravity through tilting or installation errors. Would probably be the cheapest way also.

If 360 degrees is required you could use a synchro or resolver, depending on accuracy needed, but it gets a little more complicated with either of these devices. They do require AC excitation of the rotor and has three, synchro, or four, resolver, legs for the output. I'm sure someone has coupled one of these to a PIC already. It wouldn't be susceptible to off-axis tilting either and I don't THINK the math would be as complicated as the link above.

Most digital inclinometers have an RS232 output and some have USB but would probably prove as the most expensive option. Also, if you wanted 360 degree operation you'd have to come with a slipring so the cord wouldn't get wound up.