• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

PID

Messages
129
Country
us-indiana
Hello. I posted a question about PID ( https://www.fsdeveloper.com/forum/threads/ap-speed-hold-pid-controller.437633/page-2 ) but got no response in its category. To the administrator of this website, under the Wiki, can the title"Autopilot" ( https://www.fsdeveloper.com/wiki/index.php?title=Autopilot_creation ) be removed? Or can the original author be contacted to replace the missing "autopilot.pdf?"
I have a few questions. My PID was "stolen" from some RC aircraft site and is extremely simple but seems to work. Although, as a pilot, I would find it insufficient for passenger comfort and how an aircraft (at least the way I was taught) is properly flown. For example, when banking at 30°, the lead-in to level out would start about 15° (half the bank angle) from desired heading. But perhaps as a PID trainer, it might be useful. Here are my PID equations for a heading change:
BTW, I changed the aircraft.cfg to have a Max_bank = 60, and FS behaves very much like a PID with no lead-in programmed in. Also, notice that on large heading changes, FS always starts a bit to the right even though the new heading is left of current heading.

P = error * Kp
I = (ErrorAccumulated + Error) * Ki
D =(Error - PreviousError) * Kd
anti-windupImax = some max value for I
Output = P + I + D

Notice that I do not have any time constants. The values above are just scanned at the gauge scan rate of 18Hz.

Question #1: What applicable formula would apply to the above?I see that the aircraft.cfg (for my PID test, I set max bank at 60) has the following:max bank = 25, max bank velocity = 3.5, max bank acceleration = 1.0

Question #2: How are these parameters applied in FS' PID's scheme?

Question #3: What percentage step change of a process variable would be considered extreme (i.e.: PV = 0° to 180°)?I actually applied the above to a real-world application. I made a split serial cable and I used Excel (VBA) to talk to a GPS through my laptop's COM port. I then applied the above PID and then output through the COM port to a stepper motor board. I then attached it to my yoke (in a Cessna 182). In order to get it to have the correct amount of leverage to the links, I had to add an "arm" or "throw" value, so my actual output = throw * (P + I + D).

Question #4: What proper terminology would be applicable to the "throw" variable?

Question #5: In the gauge (Co50!PFD), a "tracking line" is used with the following formula:(A:Velocity world X, m/s) (A:Velocity world Z, m/s) atg2 (A:Magvar, radians) - (A:plane heading degrees, gyro, radians) -

I see that it seems to trend what the ball does in a turn coordinator (A:TURN COORDINATOR BALL).

Question #6: Any idea what is being sought with the above formula and what is atg2 usefulness?

Question #7: What is an acceptable duration for an "event"; say a heading change of 90° or more?
 
Messages
2,077
Country
us-ohio
Q1: A google search will yield results that show you the math for a PID control loop. Even Wikipedia has the formula for a PID control loop.
Q2: They set limits to what the autopilot can command the aircraft to do. That's why they start with the term 'max'. To understand how limits are imposed in a PID loop's output... google.
Q3: A PID control loop doesn't 'jump' so I'm not really certain where you're going with this question.
Q4: The 'throw' is the scale of output.
Q5: I don't see a question here...
Q6: It is calculating the angle based on trig, atg2 is atan2 and is extremely useful and has been useful for longer than I've been alive. What is being sought is the actual aircraft track with relation to accelerations.
Q7: Uh..... what???? Aircraft turn at a given rate based on bank angle. Period. I don't actually know what you're asking though.

I have answered your questions. Good luck. I'm out.
 
Messages
129
Country
us-indiana
Thank you for replying. I'm not sure of all your answers though.
Question #1: I was asking about my above formulas as they do NOT show any relation to time, unlike the many PID formulas that can be found on the Internet. I'm not really using any time constants (for I and D) so the default PID's out in the Ether, seem to not apply - thus the question.

Question #2: Again, obviously I googled or I wouldn't have come to fsdeveloper for help, especially FS-related. I think that the ESP does give a reasonable explanation but these maximums (other than anti-windup) don't appear in any typical PID applications either. So I'm wondering how it is done mathematically.

Question #3: With the increased popularity of digital instruments, set points can be entered such that a step change does occur; unless the instrument has a feature called "bumpless transfer." So I again, I was wondering if there is some industry standard that would find a step change in terms of percentage of input unacceptable. I accept the question is a bit out there.

Question #4: Best reasoning for the term. But it's not really a typical way of a dependent or independent PID. It's sort of an "in between" - thus the question of terminology; but 'scale' sounds good; I can't come up with a better term.

Question #5: You are correct, the question is in #6.

Question #6: I know XML: atg2 is atan2, but what is "atan2"? The SDK gave an explanation (arc tangent with two inputs (input in radians) and read: ( https://en.wikipedia.org/wiki/Atan2). I also could not find a good graphical explanation related to real world applications. You wrote: "What is being sought is the actual aircraft track with relation to accelerations." I still can't picture it but will work on it. It seems to me, derivatives of airspeed, rate of turn and vertical speed can give the same answers and simpler.

Question #7: I'm not inquiring about bank angle or rate of turn. But as I re-read the question, it is basically the same as Question #3. But I think I can answer that by looking how long FS (using the default max_ bank of 25°) takes to correct a heading change of 90°. What bothers me about the FS' PID model, it doesn't seem to do a lead-in to the desired heading. For example, when I was a student pilot, I was taught to lead-in the desired heading by half the bank angle. My observation is, FS turns at a max bank, and then when less than max bank, uses PID (plus max accel, and max vel) to hunt to desired heading. I'm wondering if real aircraft's autopilot use a lead-in technique or as similar to FS.

Not listed is the question for the administrator. Any chance of resolving the WIKI: autopilot.pdf? Thanks for the time and information.
 
Messages
2,077
Country
us-ohio
Q1: Your math isn't a PID. So... not sure what you're asking. There are reasons that PIDs use time values.
Q2: Imposing limits on the output of a process is something you're not quite grasping?
Q3: Uh... worthless discussion. Don't have time nor desire to contemplate the whichness of the why.
Q4: It is what it is... it's a way to scale the output of a PID to match a necessary input.
Q5: I know I'm correct, thanks for the confirmation.
Q6: Uh... do you know nothing about trigonometry? It's solving a right triangle angle based on two sides and adjusting the value using the magnetic variation and the current heading to make it's result relative to current heading. It's an insanely simple and elegant equation and about a bazillion times more accurate than some cludge you might try to come up with using airspeed (value lags), rate of turn (value LAGS), and vertical speed (value REALLY LAGS).
Q7: Yet rate of turn is exactly what it is. What else would it be? Rate of turn is directly controlled by bank angle. Bank angle is limited by max_bank. It is most likely a PI controller, no D. It has always be notoriously inaccurate and isn't worth the effort to debate how it does or doesn't do a thing.

I think at this point you are on your own. Your second post is starting to look like you're trying to reverse engineer the sim and if so... I've wasted too much of my time already.
 

Ronald

Resource contributor
Messages
974

Heretic

Resource contributor
Messages
6,830
Country
germany
As far as I know, you'll have to ask Arno for access to the Wiki to edit any articles. Unless he changed the access method back to "all forum members". In that case, you can edit the article right away.

Items #1 and #2:
To my understanding, max_bank limits the maximum output, i.e. bank angle, max_bank velocity the maximum rotational velocity until max_bank is achieved and max_bank_acceleration the maximum acceleration until max_bank_velocity is achieved.
How this is applied in MSFS' autopilot logic is unknown, since MS never published any in-depth information regarding the autopilot system. All non-default values in use for add-on aircraft were most likely obtained by trial&error.

Item #3: Looks more like something related to flight dynamics to me as you directly influence aileron and elevator behavior with controller input and not a PID controller. In that case, adjusting the corresponding AIR file tables should be the route chosen. Unless you're trying to emulate some fly-by-wire logic.

Item #4: Controller deflection?

Item #5 and #6: As you have found out, atan2 takes two input arguments to calculate an angle between longitudinal and vertical speeds in the world coordinate system. My only guess, taking the magvar and gyro heading into account, is that this might be used to calculate a "lookahead" heading based on turn velocity.

Item #7: Isn't adjustment of lead-ins just a matter of increasing max_bank_velocity and max_bank_acceleration to make them quicker and then dynamically altering max_bank to emulate manual control input?
 
Messages
113
Country
unitedstates
Don't have time nor desire to contemplate the whichness of the why.

You can always spot a Lensman fan a mile off.
You tell 'em, Worsel...

Back to the discussion. Sorry for the little side trip.
Pat☺
 
Messages
129
Country
us-indiana
A: To WarpD:
Question #1: Actually my math "PID" is a PID. 1) It behaves exactly like a PID as I plot the output. 2) And thanks to Ronald, (https://spin.atomicobject.com/2016/06/28/intro-pid-control/), that looks a lot like what I have. I think the 18 Hz scan time I mentioned is the default delta T. I just wasn't sure until now.
Question #2: I understand putting the limits on outputs, I know I mentioned Integral anti-windup. It's just I have not observed max_velocity and max_ acceleration are actually functioning and even necessary with PID and max_bank. I also set aircraft.cfg's max_bank=60 to test MS' autopilot. Since I have to turn off the autopilot's heading (>K:AP_HEADING_HOLD_OFF), to test my PID. I have added a bank angle limiter and it functions quite well without the max_velocity and max_acceleration.
Question #3: I admitted this question was "out there," a negative comment isn't required and more importantly helpful.
Question #4: Moving on.
Question #5: Same as Question #3. Not helpful for a snide comment.
Question #6: I know some trigonometry and I understand atg, I just don't get atg2. In other words, I really don't understand MS's explanation and currently cannot visualize what is occurring. Your explanation of using magnetic variance and heading seems like a simple subtraction to me, as when I used to prepare a flight plan before the GPS days. The acronym was TVMDC. True Heading +/- Magnetic Variance = Magnetic Heading; +/- Compass Deviation = Compass Heading.
Question #7: For the second time: I AM NOT TALKING ABOUT OR CONCERNED WITH RATE-OF-TURN OR BANK ANGLE AS IT RELATES TO PID. What I'm talking about how I was taught is the proper way to approach/lead-in to a desired heading and why MS didn't use this approach in its autopilot. Which makes me wonder how a real airliner jet's autopilot controls a change of heading. I can't imagine that the real autopilot directly "PID hunts" to a heading change like MSFS. Lastly, I think D is important. It just isn't effective under the conditions of the autopilot. Reason 1) There are really no delays/ long dead-time where it is most effective. Reason 2) Is the digital age. When talking of analog signals, it is effective because there is no "jitter." When converting analog to digital, the digital signal can fluctuate giving a false rate of change.


To Ronald: Thank you!

To Heretic: Thank you!

To PhantomWeak: What is the purpose to respond in an unhelpful way?!
 
Messages
1,564
Country
thailand
For those wondering about the difference between atan and atan2, they are both arctangents that are used to calculate an angle given x and y values, but atan2 resolves errors that regularly occur when using atan.

In Figure A, both atan and atan2 yield 20 degrees, which is the correct angle. However, when the quadrants are changed as in Figure B, atan yields 20 degrees which is incorrect, whereas atan2 yields -160 degrees which is the correct angle.

Additionally, when b=0, the correct angle is either +90 or -90 degrees, depending upon the sign of a, but only atan2 yields that answer.

The order of the arguments in atan2 is important. Normal convention, as in the figures below, is atan2(a,b). But, excel fans beware, in excel and probably other popular spreadsheets, it is atan2(b,a).

Bob

1541042049994.png
 
Messages
495
Country
austria
THANKS, Bob!

But may i asked you what can i use the formular (result) for??

Code:
(A:Velocity world X, m/s) (A:Velocity world Z, m/s) atg2 (A:Magvar, radians) - (A:plane heading degrees, gyro, radians) -
 
Messages
1,564
Country
thailand
Code:
(A:Velocity world X, m/s) (A:Velocity world Z, m/s) atg2 rddg 360 + dnor


The formula above will yield Heading (true). Subtracting MAGVAR will give you magnetic heading. There's a lag between A: PLANE HEADING and VELOCITY WORLD derived headings when the plane is turning, so only in straight flight will the two be the same. Velocity is speed with a direction, so you can also derive groundspeed from VELOCITY WORLD X and Z.

Not sure of the usefulness of subtracting A: Plane heading degrees gyro, however, but I didn't write the Co50!PFD gauge.

Note that in my sketches in #9, I use "x" and "y" axes as longitude and latitude. But with the VELOCITY WORLD A:Vars, "Y" is the vertical axis and "Z" and "X" are the 'latitude' and 'longitude' components.

Bob
 
Last edited:
Messages
129
Country
us-indiana
Hello. Thank you rpmc for the explanation of atn2! So atn2 takes care of the quadrant issue - yes? You wrote: There's a lag between A: PLANE HEADING and VELOCITY WORLD derived headings when the plane is turning, so only in straight flight will the two be the same. If the A:pLANE HEADING is magnetic. It is my understanding, that this lag is suppose to be there. Unless you're talking about something else, I believe this is known as magnetic dip. It is more pronounce as a compass nears the poles. This lag (and lead) shows when turning and accelerating. During a turn from a Northerly heading, the compass briefly indicates a turn in the opposite direction - lagging. As for aircraft turning from a Southerly heading, the compass indicates a turn in the correct direction, but at a faster rate than is actually being turned - leading. If on partial panel, it's best to fly an Easterly or Westerly heading to reduce this effect - as long as there is no acceleration. It's been 23 years since I got my private license but I recall something that the lead (from Northerly) and lag (from Southerly) to desired heading should be in the amount of the latitude or something to that effect. The magnetic dip is most noticeable on East or West headings when slowing down or speeding up. In the Northern Hemisphere, as you accelerate, your compass will show a turn to the North. And as you slow down, your compass will show a turn to the South. When the speed stabilizes, the compass returns to normal. As far as the Co50!PDF, it's a beautiful gauge but needs some work. Again, thanks for the atn2 clarification.
 
Messages
1,564
Country
thailand
It's not magnetic dip. I was talking about two heading degrees true indicators. One, an A:Var (A: PLANE HEADING DEGREES TRUE), and the other, a trigonometric calculation from a couple of other A:Vars (A:VELOCITY WORLD X and Z). I mischaracterized it as a lag and overstated the significance of the difference, which is very minor.

A picture is a better way to explain:

1541655125341.png


This is a recording of several heading indicators from an aircraft turning from a northerly direction to the northwest, and then back to north.
  • The first 3 are degrees true. The rest are degrees magnetic
  • If you look closely, you will see a difference between A: PLANE HEADING DEGREES TRUE and the VELOCITY WORLD calculation when the aircraft is turning. Very minor. In straight flight, the values are identical. I presume the difference is due to different algorithms in the sim
  • Note the stair step nature of A: GPS GROUND TRUE HEADING. That's because the GPS A:Vars are updated every one second, whilst the sample rate for this recording was every half second
  • You do not see the light blue A: HEADING INDICATOR curve because it is drawn underneath A: PLANE HEADING DEGREES GYRO. They are identical values
  • The red A: WISKEY COMPASS INDICATION DEGREES curve shows the dip error. Not plotted is A: MAGNETIC COMPASS, but it is identical to A: WISKEY COMPASS INDICATION DEGREES
  • The difference between A: PLANE HEADING DEGREES GYRO and A: PLANE HEADING DEGREES TRUE is A: MAGVAR. A: PLANE HEADING DEGREES GYRO = A: HEADING INDICATOR = A: PLANE HEADING DEGREES MAGNETIC
  • I "de-normalized" the WISKEY COMPASS values (some exceed 360 degrees) for ease of plotting
Bob
 
Messages
2,077
Country
us-ohio
I'm pretty certain the purpose of the calculation was to determine the flight vector based on accelerations.
 
Messages
495
Country
austria
Nice job, Bob!


I'm pretty certain the purpose of the calculation was to determine the flight vector based on accelerations

I thought so!
Some extra words are possible?
 
Messages
129
Country
us-indiana
Ah... Okay. Thanks for the clarification rpmc! As I look at the graph (impressive, which program was used to graph the FS data?), since there doesn't seem to be much difference between (A:pLANE HEADING DEGREES TRUE, degrees) and (A:GPS GROUND TRUE HEADING, degrees), other than the sample rate, I'm still finding difficult to find what is the purpose. But I suppose that's a question for the creator of the Co50 gauge. This gauge and another one for 737800 has a needle that flips back and forth while turning using the atn2 function but I find more annoying than useful. I've also never seen this needle on any pictures showing a real ND. However, a Boeing vector trend position indicator (like iFly's 747 or PSS 777 NDs) would be useful.
 
Messages
129
Country
us-indiana
Ah... Wind, of course :) . Thank you. I think you probably already know that FS (through FSUIPC) live data can be directly inserted into Excel. Again, great information provided about atn2.
 
Messages
1,564
Country
thailand
Ah... Wind, of course :) . Thank you. I think you probably already know that FS (through FSUIPC) live data can be directly inserted into Excel. Again, great information provided about atn2.
Wind affects A:GPS GROUND TRUE TRACK but not A:GPS GROUND TRUE HEADING. I agree that A:GPS GROUND TRUE HEADING and A: PLANE HEADING DEGREES TRUE are essentially the same.

I don't use FSUIPC. There's a simpler way. LOGGER can be downloaded as stand-alone module. It's also bundled with XMLTOOLS.
 
Top