Quadcopter stabilization algorithm

sbright33:
But how do you get it to go 0 speed in the first place? First you have to measure the speed with the Ameter. Which doesn't help because of drift. It's a loop with no solution.

That's not really true. You can use the accelerometer to detect small changes in vertical acceleration, vertical speed and height. The speed and height terms will be subject to cumulative errors. You can use the height indication from the barometer to detect errors in the height from the accelerometer. If the accelerometer says the height has changed by more than the resolution of the barometer, and the barometer does not indicate a change, then you can conclude the accelerometer is giving you an error. There are a couple of ways you can compensate for that. You could add a constant offset to the indicated height to make it consistent with the barometer reading. (In effect, you correct the error in the height but do not attempt to correct the speed.) Or you can calculate the drift between the two and offset the speed term accordingly. You can do this based on a single sample, or you can maintain a longer history and do it across multiple samples. Given the memory constraints, it probably makes sense to do it based on single samples.

Since this approach does not inherently bring the two data sources into perfect alignment, it only detects when they have diverged far enough to indicate an error, I would expect the altitude hold based on the accelerometer+barometer will drift until it reaches the boundary between adjacent barometer readings and then sit there. Of course you could help this process by designing your altitude control algorithm so that the target height is at the boundary too. This will make it easier to use averaging techniques to interpolate between multiple barometer samples, making it possible to get better than 'one bit' resolution. This in turn will enable you to detect and correct for smaller errors in the accelerometer derived speed and height.

As I mentioned previously, the process of detecting the discrepancy between the two altitude measurements and skewing the accelerometer to keep them in sync, seems like the sort of thing that PID would be good for.