PID Tuning Help

Discussion in 'Rocketry Electronics and Software' started by Yukon@K-9 Rocket Tech, Jan 26, 2020.

Help Support The Rocketry Forum by donating:

Tags:
  1. Jan 26, 2020 #1

    Yukon@K-9 Rocket Tech

    Yukon@K-9 Rocket Tech

    Yukon@K-9 Rocket Tech

    Just a teen who likes building rockets

    Joined:
    Jun 21, 2019
    Messages:
    195
    Likes Received:
    29
    Gender:
    Male
    Location:
    Georgia, USA
    Hi everyone, I am rather in experienced with PID tuning and PID in general, and need some help. I want to tune PID for a model rocket I built with active fin stabilization, and another one with a gimbaled motor. I want to know what is the best way to tune the PID, and what experience anyone has with tuning PID.


    I have looked into drone PID tuning, but it was just flying your drone around and tweaking it depending on the drone’s reactions. I wouldn’t want to fly a rocket a ton of times to tune it every time I built a new one (would be expensive too LOL). The method I was thinking of building a simple rocket and buying a bunch of motors, then tweaking it until I reach a good PID value. Then I would proceed to measuring the Mass Moment of Inertia of the rocket, and from there getting a PID value to MOI ratio. Would this work? And does anyone have or know any better ways?


    Lastly, I would like to mention the Integral value. If the rocket is sitting on the pad, the I value would only see a rocket at standstill. Then when it launches, probably the system would go crazy. So the trick I was thinking of was a pad system that would boot up the flight computer maybe 30 seconds or so before liftoff. With proper tuning is this even necessary?



    Thanks for all your help! Everyone here is so helpful and amazing.
     
  2. Jan 26, 2020 #2

    UhClem

    UhClem

    UhClem

    Well-Known Member

    Joined:
    Feb 6, 2009
    Messages:
    1,481
    Likes Received:
    90
  3. Jan 26, 2020 #3

    jderimig

    jderimig

    jderimig

    Sponsor TRF Sponsor

    Joined:
    Jan 23, 2009
    Messages:
    2,987
    Likes Received:
    420
    Assuming you have a stable rocket without the stabilization and a very good gyro do a test flight and program a step change correction in each degree of freedom and see how the rocket responds. Then you can create a crude dynamic model that can get you close to starting values. After that its trial and error.
     
    Yukon@K-9 Rocket Tech likes this.
  4. Jan 27, 2020 #4

    Voyager1

    Voyager1

    Voyager1

    Forum Supporter TRF Supporter

    Joined:
    Oct 23, 2015
    Messages:
    376
    Likes Received:
    94
    Location:
    Oz
    There several threads on the forum and net discussing thrust vector control of gimballed motors and canard control. Here are a few:

    https://www.rocketryforum.com/threa...the-help-of-thrust-vector-control-tvc.150285/

    https://bps.space/

    https://www.rocketryforum.com/threads/i-could-use-just-a-little-guidance.122042/

    https://hackaday.io/project/163012-model-rocket-with-active-stabilization

    There are many more if you do a search on “active stabilisation of rockets”.

    Good luck, it’s a fascinating topic. John’s suggestions are a great place to start to get a feel for the rocket’s flight behaviour and the corrections necessary for stabilisation.

     
    Last edited: Jan 27, 2020
  5. Jan 27, 2020 #5

    OverTheTop

    OverTheTop

    OverTheTop

    Well-Known Member

    Joined:
    Jul 10, 2007
    Messages:
    3,137
    Likes Received:
    686
    Gender:
    Male
    Location:
    Melbourne Australia
    Keep the gains low. You don't want neck-snapping corrections. I think, based on my experience, the gains required are lower than you might expect, especially anything related to roll.

    If you don't expect absolute precision to the vertical vector you can just use proportional gain to keep it simple, and dual in some integrator later.

    Derivative can introduce noise into the loop if the filtering is not reasonably right, so is probably more trouble than it is worth. PI works well most of the time.
     
  6. Jan 28, 2020 #6

    Serac

    Serac

    Serac

    Well-Known Member

    Joined:
    Aug 6, 2019
    Messages:
    45
    Likes Received:
    9
    Location:
    Tucson, Arizona
    You've received a lot of good suggestions: be sure to mitigate integrator windup, start with low proportional values, and only add derivative feedback if your velocity measurements are fairly noise-free (filtering them will smear them and introduce lag which is not your friend).

    You mentioned relating the gains to the moments of interia, which is a good idea. Also consider scaling/normalizing your gains by the aerodynamic force of your fin. Generally, your controller is going to need larger fin deflections at lower speeds, and smaller fin deflections at higher speeds. The aerodynamic force of the fin deflection is a function of the dynamic pressure and the aerodynamic lifting and drag coefficients of the fin. You can compute/estimate the dynamic pressure in your controller. The aero coefficients are a lot more difficult. If you constrain yourself to small deflections with small angles of attack, textbook references may still apply because you'll generally stay in a linear region. Beyond that, it is trial and error (or if you have access to a wind tunnel, lots of experiments).

    Keep up posted of your progress! I would like to do something similar. I'm trying to get more high power experience first, though.
     
  7. Jan 29, 2020 #7

    Yukon@K-9 Rocket Tech

    Yukon@K-9 Rocket Tech

    Yukon@K-9 Rocket Tech

    Just a teen who likes building rockets

    Joined:
    Jun 21, 2019
    Messages:
    195
    Likes Received:
    29
    Gender:
    Male
    Location:
    Georgia, USA
    Thank you very much! Will check all of them out!
     
  8. Jan 29, 2020 #8

    Yukon@K-9 Rocket Tech

    Yukon@K-9 Rocket Tech

    Yukon@K-9 Rocket Tech

    Just a teen who likes building rockets

    Joined:
    Jun 21, 2019
    Messages:
    195
    Likes Received:
    29
    Gender:
    Male
    Location:
    Georgia, USA
    Okay, so there is no real way to get PID values right on the money except with trial and error correct? And lower values are generally better then too high values so the vehicle over corrects.
     
  9. Jan 29, 2020 #9

    jderimig

    jderimig

    jderimig

    Sponsor TRF Sponsor

    Joined:
    Jan 23, 2009
    Messages:
    2,987
    Likes Received:
    420
    If your dynamic model is correct then you calculate them. The problem is you will not have ideal actuators.
     
  10. Jan 29, 2020 #10

    OverTheTop

    OverTheTop

    OverTheTop

    Well-Known Member

    Joined:
    Jul 10, 2007
    Messages:
    3,137
    Likes Received:
    686
    Gender:
    Male
    Location:
    Melbourne Australia
    Use lower P & I coeffecients. That keeps the loop gain down and bahaviour less oscillatory. You just want a nice over-damped response so you are not wasting energy with oscillations. Under-correction is the way to go!
     
  11. Feb 15, 2020 at 4:44 AM #11

    Alan15578

    Alan15578

    Alan15578

    Well-Known Member

    Joined:
    Feb 11, 2018
    Messages:
    204
    Likes Received:
    35
    Of course there are ways of setting PID gains "right on the money". It is called control system analysis and design. There are many books on the subject. You could even take some college courses. You can actually make a fine career of setting gains and wiggling fins. Even if you don't master the subject you could at least become acquainted with the nomenclature.

    Continuous linear time invariant systems are the easiest, but you can use what you learn about them to help understand more complicated systems. Root locus is the classic tool to set gains, and you can do that with pencil and paper, although a Spirule can speed things up. In general, you can look at input/output response; Consider an input command or disturbance and see what the output result is. Inject a small or unit sinusoidal signal and sweep the frequency. Plot the output amplitude ratio and the phase shift. This is the frequency response or Bode Plot and it can give you the gain and phase margin, or where you have stability problems. Consider the response to a step input: What is your rise time, peak overshoot, and steady state error? Or consider an optimal control approach, the Linear Quadratic Regulator, LQR. You could for example pick some weighting factors to try and minimize induced drag and battery power consumption. You will have to solve an Algebraic Matrix Riccati Equation, but that is a solved problem, and it will determine the optimal gains that you seek.

    PID control is often ideal for a regulator. That is, to hold a system at some desired condition in the face of disturbances. Consider the step input response: to decrease the rise time increase the Proportional gain (and or increase the control fin size). If the peak overshoot is too high, increase the Derivative gain. Add some Integral gain to control steady state error. Repeat the adjustment or tuning until you get a response "right on the money."

    Now a rocket is not a linear time invariant system. You could do a number of LTI point designs to find suitable gains over the range of flight conditions and smoothly change the gains over the flight as q, mass, CG, and inertia change. Most likely you have purchased some black box components that you do not have complete specifications and analytical models for. They are likely sample data subsystems and they may not even use the same sample rate or synchronicity. Your actuators will undoubtedly have rate, power, and position limits, as well as gear backlash, stiffness, linkage slop, etc. You could have a limit cycle oscillation, overheating problems, and a thousand other problems. You probably don't have the time and expertise to work through problems. On the other hand, plug and pray may work.

    A rocket is also not a typical drone. Rockets bodies are flexible with mode shapes and frequencies. You want to put accelerometers at the first bending node, and gyros at the antinode. You will want an analog bandpass filter to attenuate sensor response beyond the sampling frequency, and you may need notch filters at the mode frequencies as well. Isolating the sensors with foam can also help.

    It's almost like this is rocket science or something. In any event, dogs are better than cats.
     
    Nytrunner likes this.

Share This Page

Group Builder