Chapter 1: How many PIDs does it take to change a light bulb?

The problem to be solved is wind-drift, and the solution will require multiple PIDs – somewhere between 2 and 4.  The light bulb is the flash of inspiration that I need to get the choice of PIDs right.

Thinking about it too mathematically / logically, I initially thought four PIDs : a desired horizontal speed (to counteract the wind drift), via its PID sets a desired horizontal acceleration which via its PID sets a desired tilt angle causing the horizontal acceleration, which via its PID sets a desired angular speed which via its PID updates the motors speed to tilt Phoebe into the wind, and hold herself steady.   What bothers me with this is simply that it’s making minimal used of the whole point of a PID: feedback.  Also the accelerometers really aren’t good enough to rely on directly – they are just too noisy, and that will produce noise in the motor power.

The 3 PID solution makes better sense to me – it uses the horizontal speed PID (akin to the the vertical speed PID used for 0 vertical speed for a hover), the angular PID and angular speed (horizontal stability) PID.  Selection of a horizontal speed as the target causes the angle PID to tilt the drone to an angle kept stable by the stability PID; the tilted quad accelerates speeding up the horizontal motion; as the horizontal velocity rises towards its target, the output it feeds to the desired angle reduces, ultimately back to 0, where momentum carries the quad along.  As drag reduces the momentum speed, the horizontal velocity PID will once more dip the angle PID to get acceleration again.

The 2 PID solution takes out the angle PID, and just uses horizontal speed PID to feed the angular speed PID.  Two things put me off here.

  1. the degree of mathematical  separation between these two PIDs – which means too much guesswork in or too sensitive results from PID tuning
  2. the lack of usage of the absolute angle – internet discussions of quadcopter functions always go on about Kalman or Complimentary filters to maintain angluar accuracy, but this solution doesn’t use them.

But after a good night’s sleep, dreaming of PIDs (sad monkey, I know), 2 is the right answer; put simply, to counteract some backward drift due to wind, the horizontal speed PID “output” is fed directly into the pitch speed PID as its “target”.  This tilts Phoebe over be some amount compensating for the wind.  As Phoebe’s forward speed matches her rearward wind drift, then the horizontal speed PID “output” (and hence the pitch speed PID “target”) becomes 0, meaning the pitch speed is 0 i.e. the pitch acquired to stall Phoebe’s drift is maintained.  Simples!

More on angle accuracy and interpretation in the next chapter.

Karma karma kalma kalma Kalman chameleon…

you pitch and roll, you pitch and roll. (with apologies to Boy George for mauling his lyrics)

While pitch / roll / yaw stability is good enough for the moment, I am having problems with vertical velocity, and that got me researching again. I don’t know yet whether what I’ve found is relevant to my problem, but it certainly is to longer term pitch / roll / yaw stability ; I’m currently summing the gyro outputs over time to come up with the resultant angles, and to be honest, they’re pretty good, but I wouldn’t want to rely on them for long flights – and this is what I stumbled on – Kalman filters. Not sure yet what to do with it, but I thought it worth sharing (and it means I don’t have to write a reminder down on paper!)