# HDG bug and direction of turn

## Recommended Posts

Hi Guys,I want to move the HDG bug in, say, the clockwise direction, and have the aircraft turn in the same direction. If the HDG bug is moved more than 180

##### Share on other sites

Sure... write your own autopilot code.

##### Share on other sites

Nick, the only way you could accomplish that would be to write your code such that if the target heading is > 180 from your current heading, then subtract 180 from it and then continue to subtract 1 to the result until your target is reached...IOW, you would loop until your current heading matches your target heading...

##### Share on other sites

You sure you want it to work that way anyway? Try this sometime in a real plane and see what happens.

##### Share on other sites

Thanks guys, I'll check your ideas and code.This aircraft does work this way.

##### Share on other sites

I achieved what I wanted with the following code.I'm wondering if it can be simplified or whether the method is too complex.Basically, if the difference is greater than 180

##### Share on other sites

The above has faults, so still working on this.cheers,nick

##### Share on other sites

Nick I use for right turns in holding entry logic (gives smooth turns to desired headings over 180 from inbound track) All turns right have increasing numbers and left decreasing. (L:SetHoldTrack, degrees) 90 + d360 (>L:HoldTrack, degrees) } (L:HoldTrack, degrees) (A:GPS GROUND MAGNETIC TRACK,degrees) 30 + - abs 5 < if{ (L:SetHoldTrack, degrees) 180 + d360 (>L:HoldTrack, degrees) } Code starts turn to 90 deg. right then is interecepted after turning 30 deg to continue the turn past 180. SetHoldTrack is the hold inbound track to reverse 180 SetHoldTrack value to your heading K var. And left turns are (L:SetHoldTrack, degrees) 90 - d360 (>L:HoldTrack, degrees) } (L:HoldTrack, degrees) (A:GPS GROUND MAGNETIC TRACK,degrees) 30 - - abs 5 < if{ (L:SetHoldTrack, degrees) 180 + d360 (>L:HoldTrack, degrees) }

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×

• Tom Allensworth,
Founder of AVSIM Online

• ### Hot Spots

• Flight Simulation's Premier Resource!

AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!