I was able to spend a bit of time this weekend working on TriRot again. I've really been trying to figure out why the PID loop I wrote was not working at all. I've done research and tried tuning it to no avail. In the end, it turned out to be a simple bug in my code. (Using the Last IMU data as opposed to the Last Error data in the loop).
The bonus is that it now does not randomly go completely insane while trying to eat anything in range with its three rotors.
Right now it blocks disturbances, but then takes a while to fully correct the movement. In my head this sounds like I need to increase the Integration Gain, which I would probably only be able to test this weekend. (Studying is taking priority over all else at the moment ;-).
In fact; the only reason I am spending any time at all on TriRot is because I am using it as part of my research for my Thesis this year. (Whish me luck, I think I'm going to need it ;-)
Anyway, I'll post picks and/or videos of TriRot testing in its training rig, and hopefully of it flying on its own soon.
|
Showing posts with label PID. Show all posts
Showing posts with label PID. Show all posts
Saturday, 14 June 2014
PID Success
PID Control
posted 24 Nov 2011 05:36 by David Taylor [
updated 24 Nov 2011 05:43 ]
After reading through some more research trying to understand the reason TriRot was not just perfectly stable when it lifted off for its first flight, I came across that old jewel that I last looked at when I was studying engineering, The PID controller, where the acronym stands for Proportional, Integral, Differential controller.
What I had originally was a 1:1 control system. If the IMU said I was tilting 5 degrees, I would correct exactly the same in the other direction. Looking back now, this does not account for the inertia of the system and any overshoot would be dealt with very slowly resulting in an unstable system (as evidenced by that last video ;-). Proportional ControlThis simply means that if the error is X you respond with X*Y where Y is the relative proportion you want to respond with. I.E., if Y = 1.5 and the error is 2 you will at that stage respond with 3. The idea being that you slightly exaggerate your response to get a quick correction. Y is referred to as the Gain Factor or Kp for Proportional Gain. Integral ControlHere we look at the time the error has been around. So you take the amplitude of the error and you multiply it with the time it’s been around. You also add a gain value to this for good measure (Ki). Effectively, you are working out the Area a graph is occupying. The graph here would be the output from the IMU. The best way to work out the area a graph occupies is to use integration. Differential ControlThis looks at the rate of change, or effectively the slope of the graph. This term also has a Gain factor, but in this case actually limiting the output, since your gain is generally in the 0.002 range. Take a look at the following articles which helped me make sense of it all: http://en.wikipedia.org/wiki/PID_controller http://en.wikipedia.org/wiki/Integral http://en.wikipedia.org/wiki/Differentiation_(mathematics) I don’t think I need to do full integration nor am I able to do full differentiation since I don’t know the function of the graph that will be generated by the random movements. So For integration I simply multiply the current amplitude with the timespan since the last loop and then sum that with previous calculations. For the differentiation, I again take the difference in amplitude (or y) and divide it by the difference in time (or again the timespan since the last loop). I’ve only just uploaded this to TriRot last night, spun up the motors (trying not to wake the kids) and moved it around a bit in my hand, but it seems allot more aggressive. I do still have to do the PID Tuning, which I’m expecting to be the hard part. Here is a Graph of a previous Pitch Test I took from TriRot. Effectively it’s just an output from the IMU in the Pitch axis, to which I have applied the PID algorithms in Excel. This is what convinced me that this might just work. |
Subscribe to:
Posts (Atom)
