What do Gains actually do???

SMP

Member
Trying to wrap my head around how Gains actually work.

Do they simply increase TX stick sensitivity? Making sticks simply "faster" to the endpoints??
Does it create a non linear curve?? More sensitivity closer to center sticks?
Does it give my chopper 5 extra horsepower simply by twisting the knob?
Since I'm scared to death to twist said knob till it's "too much", what does too much usually look like so I know I'm getting close??
 

Bartman

Welcome to MultiRotorForums.com!!
gains are what help your flight controller know how to respond in order to make the helicopter appear to you to be stable. if you expect the heli to remain level and it gets knocked over by a gust or something, it will respond more or less quickly depending on what you've set it to do. lower gains will usually get you a less responsive flight controller. it'll get pushed around by winds, won't respond as quickly when you let off the sticks and leave it out of whack. higher gains will make your flight controller respond as if it's had too much coffee. this is good if you're flipping upside down or ripping along at 60 mph but it's bad if you're trying to get perfect video of a bumbleebee (the insect, not the quad) inflight mating ritual.

gains can also be related to how upset the flight controller has to be from its target before it responds. again, low is slow and lazy, high is hyperactive and intense.

does that help a little?
 

DucktileMedia

Drone Enthusiast
I wondered this too and concluded that they are most likely variables in the PID algorithm. Your basics are a gyro for amount of change and accelerometers for rate of change. assuming this basic algorithm was too sensitive, which it probably is, things have to be adjusted some where. I'm guessing these values we change are variables that are basically multipliers on one or a few of the constants in the formula. As an example to visualize how dirty and crazy the signal is, download the seismology app on your phone and just see how sensitive the graph is from tapping on the table a few inches away from it. it's crazy sensitive. So imagine there is a PID for all axis and your gains are mathematically decreasing or increasing certain values until your heli is doing what you want it to do. I'm sure it's much more complicated than this and I am no programmer. Just my thoughts on how it might work.
 
Last edited by a moderator:

Ttelmah

Member
Unfortunately the name 'gain' is used on lots of different controllers for slightly different things....

In a conventional audio amplifier the 'gain' is sometime used as another name for the volume control. In general it is the same for the controller 'gains', but as where you have separate 'bass' and 'treble' controls which adjust different parts of the audio spectrum, so on the flight controllers there are 'gains' for different things.

Now the standard flight controllers all use variations of a standard 'control loop', where at fast intervals measurements are made of how the copter is moving, and of what you are asking it to do. These are then fed into a program that tries to calculate how to change things to get the response you want. The 'gains' affect how the responses are made. The standard algorithm is known as 'PID' Proportional, Integral, Differential. The 'proportional' term is how much to respond to the request being different from what is happening. The 'integral' term is an attempt to respond to long term drifts, adding a small offset to correct for this. The 'differential' term attempts to prevent overshoot, turning down the responses if the behavior is already moving in the right direction. Now on the ArduCopter for example, these are the exact terms used for the gains. On the DJI Naza, the gains don't quite behave like this, instead the 'basic gains' are close to the P term, and the attitude gains are effectively a reciprocal of the D term, with higher figures giving less damping, and sharper responses.

So main answer is 'it depends on your controller'.

Best Wishes
 

gtranquilla

RadioActive
The hotlink here provides all the info you need: http://wiki.openpilot.org/display/Do...ng++Multirotor

Gain is a crude term which represents a multiplier for a control loop within a PI or PID controller.
In it's most fundemental form the output will be regulated as a Proportion of the desired setpoint.
This is called Proportional control representing the P in PID.
The remaining control methods require the use of calculus.
Calculus can be broken down in to two components, i.e., Integration and Derivatives.
Hence P = Proportional, I = Integral and D = Derivative.
Different business realms use different names for each of these three control algorithm factors.
In the case of MultiRotors they commonly refer to Proportional as Gain which is valid since an analog amplifier can have it's output scaled up or down according to "Gain".
All control loops must utilize proportional as it's fundemental control loop algorithm.
For the DJI Mulitrotors, the Proportional is referred to as Basic Gain
but the Integration is referred to as the Attitude Gain.......Now that even confuses me a bit.
The problem with Proportional only control is that the MR can only approach the desired setpoint whether the setpoint is determined autonomously or from RC flyer joystick input.
This means that the control will be slow, sluggish and the RC flyer will never be happy with the mushy behaviour.
This is where the power of calculus kick in such that the MR has to add integral control.
Derivative control is not needed unless you are flying with a larger, heavier Multirotor with expensive payloads and even then.... derivative control offers only slight improvement but also substantial risks of undermining the complete control system.



Trying to wrap my head around how Gains actually work.

Do they simply increase TX stick sensitivity? Making sticks simply "faster" to the endpoints??
Does it create a non linear curve?? More sensitivity closer to center sticks?
Does it give my chopper 5 extra horsepower simply by twisting the knob?
Since I'm scared to death to twist said knob till it's "too much", what does too much usually look like so I know I'm getting close??
 

gtranquilla

RadioActive
I assume you are talking about your MultiRotor gain controls.....To answer each of your questions more precisely.
Gain adjustment has nothing to do with the RC transmitter.
Your MR can fly in one of three modes: 1) fully autonomous 2) semi-autonomous 3) Manual.
In all three modes there is one or more PI controllers built in to the MR which need to be tuned to acheive optimal control whether it is fully autonomous, semi autonomous or manual control. Your RC transmitter joysticks only provide setpoint input into the PI controllers when the PI controller allows that, i.e., semi-auto or manual mode.



Trying to wrap my head around how Gains actually work.

Do they simply increase TX stick sensitivity? Making sticks simply "faster" to the endpoints??
Does it create a non linear curve?? More sensitivity closer to center sticks?
Does it give my chopper 5 extra horsepower simply by twisting the knob?
Since I'm scared to death to twist said knob till it's "too much", what does too much usually look like so I know I'm getting close??
 

SMP

Member
Ahh NOW I'm starting to get it... This is great!! Thanks guys!!

Ok so in real world translation. I've got a copter that feels "sluggish" to stick commands. So even though dialing up the gains has nothing to do with the TX it "feels" more responsive (accelerometers for rate of change) since I've just turned up the "Volume" essentially telling the FC to speed up the "P" response. (The 'proportional' term is how much to respond to the request being different from what is happening.) So on a NAZA If the bird is Slow then it sounds like I should ramp up the Basic only until it starts wiggling and overshooting (Barts Caffeine) then start increasing the "D" gains (the attitude gains are effectively a reciprocal of the D term, with higher figures giving less damping, and sharper responses) until it stops "jitter" (ala AV130/200)

Currently I have BOTH my Basic and Attitude gains (except throttle and yaw) set to increase/decrease simultaneously with analog dial. Based on the above it sounds like that's actually self defeating. Sounds like it would be better to change Basic first then dial down Attitude to smooth out the Basic.

Any NAZA/WKM chaps know if the PID plays as above (which would be great!) or.. flying in Manual PID uses the Basic numbers only???? and in Atti/GPS the Atti numbers only???
 
Last edited by a moderator:

Ttelmah

Member
I don't actually think the Naza algorithm is basically a PID one.
I write PID code as part of my work, and it is very common to use alternatives. PID is a 'starting point', but often other variants are better, simpler to code, and giving better control. I think the Naza algorithm actually behaves as if it is a significantly modified algorithm, with some self correction. The second set of gains certainly don't behave as if they are the I term, noticeably affecting the instantaneous responses. They may well in fact be affecting an averaging factor, on the readings, rather than the actual loop control....
My own 'suggestion' for setup is:

1) Fix all terms at 100%.
2) Make the basic pitch, and roll slave to your pot. Adjust your pot with the assistant, so you know where the 100% point is. Start with the pot set here. Do this for each adjustment when using the pot. Now, do a flight and tweak these to get good control. You are looking for increasing the value till when you make a movement the copter wobbles quickly for a moment, then just coming back till this stops. Land, read the values, using the assistant, and fix these.
3) Now set the altitude to the pot. Try flying again. This one is harder, the responses are less immediate. One thing to test is how it lands on auto, with a battery failure. If the altitude gain is low, it'll drop fast. Set it higher, and the rate of descent goes down. However go to high, and it can 'hunt' when trying to hold altitude. Ideally as with the other gains as high as useable before this hunting occurs. Like this the descent on a battery fail landing is a smooth steady one....
4) Now fix this gain, and put the pot onto the attitude terms. Again set these.
See how it flies.
If you are still unhappy, go round again, starting from the points you now have. There is a little interaction between the settings, which can make this necessary. Particularly a mode that feels good in Atti, can tend to hunt in GPS.

On the modes, the 'Basic'; position, doesn't use the correction algorithm. It behaves like a traditional simpler flight controller, limiting control rates, and trying to ensure that 'centre stick' is basically equal motor outputs, but leaving it up to you to correct errors.
The Atti mode involves the full algorithms, to try to limit the maximum yaw, pitch, and roll that the model can exhibit, and bring it back to level flight when the sticks are released, but it will slowly drift, since it is dependant on detecting movement (like you trying to keep a boat in one position in the centre of a lake at night - there will be slow drift as unexpected things like currents slowly move you).
The GPS adds an awareness of actual 'position', but with relatively low accuracy (few feet), allowing the drift to be much reduced.

Best Wishes
 

gtranquilla

RadioActive
That is very insightful information..... I assume there is still calculus involved.
I was aware that there are control systems alternate to the conventional PID loop feedback and feed-forward control and related cascade controller and auto-reset windup etc.
But I come from the Greg Shinsky world of Process automation.... http://www.amazon.com/Process-Control-Systems-Application-Design/dp/0070571015
And if the only tool in your tool box is a hammer, all the work needing to be done looks like nails needing to pounded back in place.

One of the big disadvantages of PID loop control is that 1/4 wave damping this the best one can acheive and 1/4 wave of time lost is not adequate for high speed missile control to hit a moving target!

And ofcourse OpenPilot development of Multirotors uses some or most of the concepts of PID loop control.




I don't actually think the Naza algorithm is basically a PID one.
I write PID code as part of my work, and it is very common to use alternatives. PID is a 'starting point', but often other variants are better, simpler to code, and giving better control. I think the Naza algorithm actually behaves as if it is a significantly modified algorithm, with some self correction. The second set of gains certainly don't behave as if they are the I term, noticeably affecting the instantaneous responses. They may well in fact be affecting an averaging factor, on the readings, rather than the actual loop control....
My own 'suggestion' for setup is:

1) Fix all terms at 100%.
2) Make the basic pitch, and roll slave to your pot. Adjust your pot with the assistant, so you know where the 100% point is. Start with the pot set here. Do this for each adjustment when using the pot. Now, do a flight and tweak these to get good control. You are looking for increasing the value till when you make a movement the copter wobbles quickly for a moment, then just coming back till this stops. Land, read the values, using the assistant, and fix these.
3) Now set the altitude to the pot. Try flying again. This one is harder, the responses are less immediate. One thing to test is how it lands on auto, with a battery failure. If the altitude gain is low, it'll drop fast. Set it higher, and the rate of descent goes down. However go to high, and it can 'hunt' when trying to hold altitude. Ideally as with the other gains as high as useable before this hunting occurs. Like this the descent on a battery fail landing is a smooth steady one....
4) Now fix this gain, and put the pot onto the attitude terms. Again set these.
See how it flies.
If you are still unhappy, go round again, starting from the points you now have. There is a little interaction between the settings, which can make this necessary. Particularly a mode that feels good in Atti, can tend to hunt in GPS.

On the modes, the 'Basic'; position, doesn't use the correction algorithm. It behaves like a traditional simpler flight controller, limiting control rates, and trying to ensure that 'centre stick' is basically equal motor outputs, but leaving it up to you to correct errors.
The Atti mode involves the full algorithms, to try to limit the maximum yaw, pitch, and roll that the model can exhibit, and bring it back to level flight when the sticks are released, but it will slowly drift, since it is dependant on detecting movement (like you trying to keep a boat in one position in the centre of a lake at night - there will be slow drift as unexpected things like currents slowly move you).
The GPS adds an awareness of actual 'position', but with relatively low accuracy (few feet), allowing the drift to be much reduced.

Best Wishes
 

SMP

Member
"if the only tool in your tool box is a hammer, all the work needing to be done looks like nails"

That made me chuckle ;)
 

Top