With the tail rate mode and HH mode both working well on the PhuBar, I turned my attention to improving piro stability. I had noticed some instability if I do a simple piro when the heli is not absolutely level.

I believe this may be partly because the roll, pitch, and yaw data are processed independently of each other. This works fine until you have a fast yaw rate. Ideally the system needs to rotate the pitch axis and roll axis when yawing occurs. If the heli yaws 90 degrees, then pitch becomes roll and roll becomes pitch, with respect to a fixed earth-based coordinate system.

What is needed is an integrated representation of the attitude of the heli with respect to the earth frame of reference, where motion on one axis can affect the other two. In other words, pitch and roll need to be "yaw aware".

It seemed that a good way of doing this was to implement a Direction Cosine Matrix , as outlined here:

http://diydrones.com/profiles/blogs/...ry-first-draft
http://gentlenav.googlecode.com/files/DCMDraft2.pdf
I spent the last week implementing this in Spin Code on the PhuBar3. I am in the process of tuning the gyro gain factor to get the matrix to update accurately, but so far it looks good. It rotates the pitch and roll axes appropriately when the unit is rotated around the yaw axis. The nice thing about DCM is that roll and pitch correction values can be plucked out of two of the elements of the matrix - they just need to be scaled before they can be fed into the swash mixing equations.

I am finally using some of the matrix math they tried to teach me a long time ago in Linear Algebra class !