• 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.

FSX Custom Autopilot HDG hold

cheangjc

Resource contributor
Messages
111
Country
singapore
Hi,

I am trying to create a custom autopilot HDG Hold. Do you know what variable do I have to feed into the PID Controller to get a bank angle.
 
Have a look at the default FSX 737-800 autopilot it has Bank in it .

Cheers
Karol
 
No, I want to rid of the default Autopilot stuff. I have successfully done for the vertical but so far not the lateral.
 
If you want to hold a heading then the PID controller must be fed the actual heading and the desired heading.
 
You can write your own PID controller routine using the difference between your desired heading and actual heading as the set error and coding the PID so that its output is (>K:AXIS_AILERONS_SET). The function is to control bank within specified limits until the set error becomes zero. I have done this for a helicopter autopilot and it works well. Yes I know a helicopter does not have ailerons, but FS accepts the input.
Roy
 
Thanks but that is using default autopilot...

Well, you asked for the variables needed to get a bank angle, and in that example you have those explicited. Besides, Roy told you which is the output var for the PID, so you have a good start point now.

Tom.

Comment: Building a custom autopilot doesn't necessary mean that you can't use default autopilot commands in the backgrounds for your own purposes.
 
Thanks for all the input so far.

What I am trying to achieve is this:

HDG HOLD --> BANK ANGLE --> MY FBW SYSTEM (CONTROL ROLL RATE etc)

I already programmed PID subroutine for the Vertical part of the autopilot. (In other words, I know about PID Controllers etc)

The reason for not using the default solution is because of the complexity of the AP that requires of not using the default solution (even in the background). Plus, it will take some time to tune the default autopilot which in my experience dont work too well.

What I need now is the "Input" of the PID.
After thinking a while I think that this will work: Set heading - current heading = bank angle . I will try and report the results.
 
Last edited:
Code:
<!-- Proportional -->
		<Element>
			<Select>
				<Value>(A:AUTOPILOT HEADING LOCK DIR, degrees) (A:PLANE HEADING DEGREES GYRO,degrees) - dnor s1 180 &gt; l1 360 &lt; and 
if{ l1 360 - } els{ l1 }
				(>L:BankSetErr,Number) 
				(L:BankSetErr,Number)
				(>L:BankpidOut,Number)
			</Value>
			</Select>
		</Element>
Here is a start and to save you a lot of agony I have included code for comparing the difference between desired heading and actual heading. Code courtesy of Bill Leaming.

Roy
 
Back
Top