This thread is privately moderated by Heli Hacker, who may elect to delete unwanted replies.
 Aug 01, 2010, 11:56 PM Hang on, turbulence ahead St. Louis Joined Dec 2007 534 Posts Discussion Dcm Even with gains carefully adjusted, DCM has a drift of several degrees per minute. Without an accelerometer to correct the drift, I need to introduce decay into the update matrix that rotates the DCM matrix. Unfortunately adding pitch and roll decay causes the matrix to have even larger drift around the yaw axis. The whole purpose in implementing DCM was so that yaw would automatically cause rotation of pitch and roll. But since yaw accuracy goes to pieces, I have decided to use a simpler approach - one similar to the swash servo mixing equations. ' Use Yaw rotation to rotate Pitch and Yaw values ' if roll is clockwise looking down on vehicle: ' newxval = xval(cos(yaw angle)) - yval(sin(yaw angle) ' newyval = xval(sin(yaw angle)) + yval(cos(yaw angle) ' 'if roll is counter clockwise looking down on vehicle: ' newxval = xval(cos(yaw angle)) + yval(sin(yaw angle) ' newyval = -xval(sin(yaw angle)) + yval(cos(yaw angle) This allows roll and pitch to be rotated at each 100hz update cycle, without tracking all three axes together. I almost have this working, just now chasing a bug that appears to be in my sine(angle) routine. Update: This code was causing problems, so I decided to set it aside for now and work on getting an accelerometer integrated so I can use DCM. Last edited by Heli Hacker; Oct 28, 2010 at 08:21 AM.