Jump to content

Heading Indication in Autopilot


Buzzer

Recommended Posts

I am creating a new autopilot, and mostly have it working. However I would like to have an indication that shows a left arrow or a right arrow when the "heading hold" function is activated. This will give a visual indication of the turn of the aircraft.

 

I have the heading selection process working fine but would like to show a visual indication of turn.

 

This is the relevant part which works until the subtraction of the 2 variables for different values create problems with negative numbers.

 

Left arrow for a left turn (more than 2 deg), ahead arrow for 2 deg either side of current heading and right arrow for right turn (more than 2 deg).

 

(A:Avionics Master Switch,bool) 1 == (A:Autopilot Heading Lock,bool) 0 == &&

 

((A:Autopilot heading lock dir,degrees) (A:Plane Heading Degrees Magnetic,degrees) - ) -2 > 2

 

((A:Autopilot heading lock dir,degrees) (A:Plane Heading Degrees Magnetic,degrees) - ) -2

 

((A:Autopilot heading lock dir,degrees) (A:Plane Heading Degrees Magnetic,degrees) - ) 2 >

 

What I cannot figure is how to normalise the numbers or convert to absolute etc.

 

Any help would be appreciated.

Link to comment
Share on other sites

Hello, this is only an example how i would wrote it:



(A:Autopilot heading lock dir,degrees) (A:Plane Heading Degrees Magnetic,degrees) - (>L:Heading_Degrees_Final,number)




(A:Avionics Master Switch,bool) 1 == (A:Autopilot Heading Lock,bool) 0 == && 


-2 2 (L:Heading_Degrees_Final,number) rng





(L:Heading_Degrees_Final,number) -2 





(L:Heading_Degrees_Final,number) 2 >



 

Note: The "rng" stands for "Range", in this case "Range from -2 to 2"!

 

The abbreviation for absolute is "abs" so for your lines it should look like:

 

((A:Autopilot heading lock dir,degrees) (A:Plane Heading Degrees Magnetic,degrees) - abs)

 

Hope it helps!

Link to comment
Share on other sites

Thanks for that, I was trying to use the "rng" operator but could not get the syntax correct.

 

The complete code that you included works fine as far as it goes, but like my original, it still has problems. If I am sitting on the runway at 108 deg M, and scroll in a selected heading back to 0 deg (north), the left arrow is showing (as it should). But, when I take one more click to 359 deg, the right arrow shows.

 

It is obviously a problem with negative numbers etc.

 

I will also attempt (when I get this bit sorted), to lock out the 10 degrees from 175 to 180 at the rear of the aircraft, so that no arrow will show. But that is for another day.

 

Bottom line here is that I am trying to create a fully functional sim version of the new Bendix King Aerocruze 230 autopliot, which has the indication function that I am trying to create.

Link to comment
Share on other sites

Maybe combine it with a variable via the left/right Heading click commands:

 

Rough example:

 

ClicK Command Heading left with a selfmade Variable: 1 (>L:LeftHead,number)

and the other Variable into the Click command for the right turn: 1 (>L:RightHead,number)

 

These both selfmade Varable are turn your arrow bmps to "on" if they have the value "1" and turn to "0" when

 

((A:Autopilot heading lock dir,degrees) (A:Plane Heading Degrees Magnetic,degrees) - abs) 2 L:LeftHead,number) 0 (>L:RightHead,number) }

 

is reached!

Link to comment
Share on other sites

this should work

[set hdg means hdg you set on autopilot]

[current hdg means hdg the aircraft is currently flying]

~~~~~~~~~~~~~~~~~~~~~~~~

 

put value of

(set heading) - (current hdg) into Var:A

 

if value var A is greater then -180 and less then 180

then if Var A smaller then 0 left arrow.

if Var A greater then 0 right arrow.

((optiinal: ))

((if value var A is greater then -180 and less then 180))

((THEN PUT VAR A DIREXTLY INTO VAR B !!))

((then if Var B smaller then 0 left arrow.))

((if Var B greater then 0 right arrow.))

 

 

 

but if var A greater then 180 do:

Var A - 360 put in Var B

if Var B

left arrow

 

and if var A smaller then -180 do:

Var A + 360 put in Var B

if Var B

left arrow

if Var B greater then zero

right arrow.

 

---------------

ezamples

set hdg 60

hdg 30

Var A= 60-30= 30

-180

VarA > 0

right arrow

 

 

Example II

set hdg 270

current hdg 300

Var A= 270-300= -30

-180

VarA

left arrow

 

 

Ezample III

set hdg 350

current hdg 20

Var A= 350-20= 330

VarA > 180

put Var A - 360 into Var B

Var B = 330 - 360= -30

Var B

left arrow

 

 

Ezample VI

set hdg 40

current hdg 340

Var A= 40-340= -300

Var A

put Var A + 360 into Var B

Var B = -300 + 360= 60

Var B > zero

right arrow

 

 

PS didn't dive into your code. or post any.

just followed your logic and posted mine.

sorry for all the typos. tired and typi g on phone.

Edited by il88pp
[sIGPIC][/sIGPIC]
Link to comment
Share on other sites

Hi. Here that logic in code. And combined with yours from post one.

 

May be some typos in it. Cause made on phone. And not tested.

 

Also see below the code.

 


(A:Avionics Master Switch,bool) 1 == (A:Autopilot Heading Lock,bool) 0 == && 



((A:Autopilot heading lock dir,degrees) (A:Plane Heading Degrees Magnetic,degrees) - ) (>L:VAR_A)




(L:VAR_A) -180 > (L:VAR_A) 180 if:
(L:VAR_A) (>L:VAR_B)



(L:VAR_A) -180 if:
(L:VAR_A) 360 + (>L:VAR_B)



(L:VAR_A) 180 >
if:
(L:VAR_A) 360 - (>L:VAR_B)



(L:VAR_B) -2 > 2 





(L:VAR_B) -2 





(L:VAR_B) 2 > 




 

I found a thread about the same "passing 360 degrees" issue on FSDeveloper.

Note also: There a different variable is used to get the aircraft heading:

(A:PLANE HEADING DEGREES GYRO,degrees)

https://www.fsdeveloper.com/forum/threads/plane-heading-and-autopilot-heading-lock.83209/

 

 

Posting took few days.

I ended up trying to make it into something more complex.

>When 'AP_HDG_SET' different from 'AIRCRAFT_HDG'

>Green arrow when AP_MASTER and HDG_HLD engaged.

>Red arrow when not engaged.

 

But.... there are more ways for AP to guide LAT navigation. (VOR_LOC, etc).

It would get too complicated. So I took that part out.

 

Also realised then. This gauge points to difference between 'AP_HDG_SET' and 'AIRCRAFT_HDG' only.

With these A:Vars it will not point the right way if the aircraft is flying following a GPS Flightplan in GPS mode. (or when tracking a VOR or ILS.)

To make a gauge that shows me where the plane is turning on autopilot (or where the AP would turn it) in all AP settings would take longer then I thought.

 

 

For your gauge the other AP Modes are perhaps less inportant.

The (A:PLANE HEADING DEGREES GYRO,degrees) variable may be worth looking at.

#

[sIGPIC][/sIGPIC]
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...