ROBOTC.net forums http://www.robotc.net/forums/ 

Angular rotation using Dexter Gyroscope http://www.robotc.net/forums/viewtopic.php?f=41&t=4463 
Page 1 of 1 
Author:  Farshid.T [ Mon Apr 23, 2012 4:09 am ]  
Post subject:  Angular rotation using Dexter Gyroscope  
Hi, I want to get angular rotation using a Dexter gyro but I have more 510 degree error in 90 degrees rotation. This is how I use dps to get rotation:
I'm not sure if that's the correct way to get rotation. If that's the correct way, I guess the inaccuracy is related to third last line of my code. If I divide x_val by a number near 17 the error reduces to 12 degrees. (1000.0/loop_delay)=18.5 approx. Please tell me if I am doing something wrong. Thanks, 
Author:  mattallen37 [ Mon Apr 23, 2012 1:19 pm ] 
Post subject:  Re: Angular rotation using Dexter Gyroscope 
For an integration loop, it's best to loop as quickly as possible (maybe a 5ms wait). Also, I think using the 250 dps range will give you much higher resolution. 
Author:  Farshid.T [ Tue Apr 24, 2012 11:53 pm ]  
Post subject:  Re: Angular rotation using Dexter Gyroscope  
Thanks for your reply. 5ms wait doesn't make any improvement to 50ms. with 250dps range, with gyro being static, the rotation starts to increase or decrease very fast. 2000dps gives much lower error in this case. p.s : If i manually rotate the unit 90 degrees. total x_val will be 15201540. 1530/90 gives us 17 and if I divide x_val by 17 the output gets accurate. Now the problem is that output keeps increasing or decreasing with respect to the direction of last rotation. I assume that happens to all gyroscopes.. 
Author:  MHTS [ Wed Apr 25, 2012 3:22 am ]  
Post subject:  Re: Angular rotation using Dexter Gyroscope  
You should not initialize time_temp to zero. That would introduce a random error to your integration because nPgmTime doesn't start at zero. Instead you need to do this:
There may be some other issues with the calculation but not knowing the spec of the gyroscope you are using, I wouldn't know. 
Author:  Farshid.T [ Thu Apr 26, 2012 10:09 pm ]  
Post subject:  Re: Angular rotation using Dexter Gyroscope  
That's correct. The code i wrote does not take into account the time before starting the loop. Thanks for the tip ! 
Page 1 of 1  All times are UTC  5 hours [ DST ] 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ 