Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.
This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question: PID in quad, error is difference between what?
#1
Hello!

Today I just realized that while I understand how pid controller works, I don't fully get what exact input it gets in quad.

The PID controller takes error as input, does it's PID magic and gives motor offset output.

The error is difference between desired X and actual X.

What is actually X? According to this Oscar's post, X is "angular rate" (speed of rotation), and this, actually follows from my observations.

But will it not be more logically to have "desired angle" as X instead of "angular rate"?

Can someone, please, shed a light on this for me?
Reply
Login to remove this ad | Register Here
#2
A gyro does not know any fixed angles. It can only measure angular change, but it does not know what is up or down, or level.
Reply
#3
Actually, the PID controller takes your control positions as its input. It then calculates the difference between your command and the current state of the system - this is the error. It uses the error to control power to the motors via a mixer to reduce the calculated error.

The gyro sensor measures how quickly the quad is rotating on each of its three axes - x, y, and z. This measurement is the current state of the system. If the roll, pitch and yaw axes all measure zero rotation, this does not mean that the quad is level. It only means that the quad's current attitude is not changing.

If your pitch, roll and yaw inputs are all zero, then the PID controller will be attempting to keep the error term for the x, y, and z axes at zero and therefore the measurements from the gyro at zero on all three axes.

None of this means that you are level. Level can only be determined through the use of an accelerometer which measures acceleration instead of rotation. On a planet, acceleration is relative to gravity and can therefore be integrated with a known level starting point and the data from the accelerometer and gyro to establish the sensor's current orientation relative to the Earth plane.

In the vacuum of deep space, "level" has no meaning.
Reply
#4
fftunesA gyro does not know any fixed angles. It can only measure angular change

(10-Sep-2017, 11:11 PM)unseen Wrote: The gyro sensor measures how quickly the quad is rotating on each of its three axes - x, y, and z. This measurement is the current state of the system.

So, the X is "speed of rotating".

When I say "desired angle" I don't mean actually "level". It's some kind of "setpoint", I.e. angle we want quad to be according to user's input.

I.e. instead of controlling the speed of rotation of quad, why stick input not used to rotate this "setpoint" and quad then can just calculate error as difference between actual angle and setpoint?

I, initially, was sure that it works exactly this way, by rotating setpoint, and error is difference between desired and actual angle. Just wasn't unable to explain ty myself why angle drift happens because of low I gain in this model (I understand why it happens if input is speed, not angle).

For example, take one axis.

Assume initial angle (and setpoint) is 0. Knowing speed of rotation (by gyro), quad can know that it rotates, so can know that it's angle is not 0 anymore (i.e. it rotated 0.1 degree/sec for 1 ses) and now it's angle 0.1 degree. Setpoint now still 0, and so there is an error 0.1 degree, which can be fed as input to PID loop. User input, in this case, only rotates desired angles, while PID loop does needed corrections to reduce error between desired angle and actual.

I know that there is no "level" in the space, and without accelerometer quad does not know where is earth. But speed + time allows to calculate actual angle relative to the initial position (which is, for example, angle when armed).

So I'm trying to understand why PID loop operates on rotation speed, not on angle. At the end, we don't want to control the speed of rotation, but the angle quad takes at the end of the maneur?
Reply
#5
The reason is called "accumulated error".

First off, the initial angle of the craft is unknown when the gyro starts up. Secondly, the measurements from the gyro and the flight controller's idea of the current attitude are subject to cumulative error. Even if you could monitor the gyro and time so closely that you could call the initial angle zero and continually calculate the new angle based on rotation and time, that calculated angle would drift further and further from the actual angle as time progresses.

This is why the input to the PID controller is 'desired speed of rotation'. If the input is zero, it means 'maintain the current attitude'. What angle that is, relative to the starting position, is impossible to know with sufficient accuracy that the input could mean 'desired angle'.

If the flight controller is using a self levelling flight mode, the stick input does mean 'desired angle' but this requires another input, relative to a known starting angle. This is provided by the accelerometer which must be carefully calibrated with the craft perfectly level.

When flying in rate mode, the pilot becomes the reference mechanism which calculates the difference between 'desired angle' and 'observed angle' and delivers corrections to the craft.
[-] The following 2 users Like unseen's post:
  • Tom BD Bad, lorentz
Reply
#6
(11-Sep-2017, 07:45 AM)unseen Wrote: The reason is called "accumulated error".

Thanks for explanations, maybe I'll be better understand behavior of my quad now.
[-] The following 2 users Like E.L.K.'s post:
  • Tom BD Bad, unseen
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Where to put 2.4GHz ELRS RX with ceramic antenna on 5in racing quad? Luk5569 6 167 05-Mar-2024, 12:54 PM
Last Post: ph2t
  Data Zombie Quad? Green_Weedle 2 139 05-Feb-2024, 10:27 PM
Last Post: Pathfinder075
  How quad building has helped my Beer brewing Rob Axel 5 224 16-Oct-2023, 01:24 AM
Last Post: Rob Axel
  Help Find my quad aerokam 16 805 10-Oct-2023, 04:52 PM
Last Post: Dak_4008
  Help question on windows 11 roger74 4 345 15-Aug-2023, 11:51 AM
Last Post: roger74


Login to remove this ad | Register Here