Board index FlightGear Development Aircraft Autopilot and route manager

Arm LOC and G/S

Designing a stable autopilot is one of the hardest things. Need help?

Arm LOC and G/S

Postby Octal450 » Wed Apr 27, 2016 4:35 pm

Hello,

I been trying to add a Loc/GS arming function to the MD-88s AP, How do I make a PID controller that does this?

Currently, pressing LOC puts the LOC mode on right away, I want to be to arm it like the 777 AP. Do I need to build a whole new AP, or can I copy it from another plane?

Regards,
Skillset: JSBsim Flight Dynamics, Systems, Canvas, Autoflight/Control, Instrumentation, Animations
Aircraft: A320-family, MD-11, MD-80, Contribs in a few others

Octal450's GitHub|Launcher Catalog
|Airbus Dev Discord|Octal450 Hangar Dev Discord
User avatar
Octal450
 
Posts: 5583
Joined: Tue Oct 06, 2015 1:51 pm
Location: Huntsville, AL
Callsign: WTF411
Version: next
OS: Windows 11

Re: Arm LOC and G/S

Postby tikibar » Wed Apr 27, 2016 6:46 pm

You don't need a PID controller for it. The MD-11 does it in the AFDS.nas file. The panel button arms LOC mode, then the update loop checks if the aircraft is within 8 degrees of the LOC course. If it is, it switches the AP to LOC mode. It's around line 350 of AFDS.nas.
Boeing 747-8 (rename folder to 747-8i)
Boeing 757-200/300 (rename folder to 757-200)
Boeing 767-300/ER (rename folder to 767-300)
User avatar
tikibar
 
Posts: 545
Joined: Mon Mar 05, 2012 7:05 am
Location: Los Angeles
Callsign: CHT0009
OS: Ubuntu 14.04

Re: Arm LOC and G/S

Postby sanhozay » Wed Apr 27, 2016 7:21 pm

Another possible way to do this, which is a relatively recent addition to the autopilot config, is using a state machine.

So I guess the states would be not armed, armed and loc. The button takes the state from not armed to armed, button off takes it back again, proximity to the course takes it from armed to loc and button off in loc takes it back to not armed.

Code: Select all
NOT ARMED <--> ARMED ---> LOC ---+
  ^                              |
  |                              |
  +------------------------------+
sanhozay
 
Posts: 1207
Joined: Thu Dec 26, 2013 12:57 pm
Location: EGNM
Callsign: G-SHOZ
Version: Git
OS: Ubuntu 16.04

Re: Arm LOC and G/S

Postby Octal450 » Wed Apr 27, 2016 9:22 pm

sanhozay wrote in Wed Apr 27, 2016 7:21 pm:
Code: Select all
NOT ARMED <--> ARMED ---> LOC ---+
  ^                              |
  |                              |
  +------------------------------+


I have written something like that in Nasal already, but how I know when it is close enough to activate? I tried with the signal quality, but that varies depending on altitude.

Regards,
Skillset: JSBsim Flight Dynamics, Systems, Canvas, Autoflight/Control, Instrumentation, Animations
Aircraft: A320-family, MD-11, MD-80, Contribs in a few others

Octal450's GitHub|Launcher Catalog
|Airbus Dev Discord|Octal450 Hangar Dev Discord
User avatar
Octal450
 
Posts: 5583
Joined: Tue Oct 06, 2015 1:51 pm
Location: Huntsville, AL
Callsign: WTF411
Version: next
OS: Windows 11

Re: Arm LOC and G/S

Postby sanhozay » Wed Apr 27, 2016 9:38 pm

Look at the property instrumentation/nav/heading-needle-deflection, and remember that it's negative or positive, depending which side of the line you are.
sanhozay
 
Posts: 1207
Joined: Thu Dec 26, 2013 12:57 pm
Location: EGNM
Callsign: G-SHOZ
Version: Git
OS: Ubuntu 16.04

Re: Arm LOC and G/S

Postby Octal450 » Wed Apr 27, 2016 9:40 pm

OK sanhozay, I'll give that a try, thanks.

I have also made an altitude capture system this way.

Regards,
Skillset: JSBsim Flight Dynamics, Systems, Canvas, Autoflight/Control, Instrumentation, Animations
Aircraft: A320-family, MD-11, MD-80, Contribs in a few others

Octal450's GitHub|Launcher Catalog
|Airbus Dev Discord|Octal450 Hangar Dev Discord
User avatar
Octal450
 
Posts: 5583
Joined: Tue Oct 06, 2015 1:51 pm
Location: Huntsville, AL
Callsign: WTF411
Version: next
OS: Windows 11

Re: Arm LOC and G/S

Postby Octal450 » Fri Apr 29, 2016 4:13 pm

@tikibar
Hmm, I missed your post. :oops: Oops.

This is good news, since my nasal controlled AP already has a similar function, but a different property.

Thanks,
Skillset: JSBsim Flight Dynamics, Systems, Canvas, Autoflight/Control, Instrumentation, Animations
Aircraft: A320-family, MD-11, MD-80, Contribs in a few others

Octal450's GitHub|Launcher Catalog
|Airbus Dev Discord|Octal450 Hangar Dev Discord
User avatar
Octal450
 
Posts: 5583
Joined: Tue Oct 06, 2015 1:51 pm
Location: Huntsville, AL
Callsign: WTF411
Version: next
OS: Windows 11

Re: Arm LOC and G/S

Postby Octal450 » Fri Apr 29, 2016 4:20 pm

This is the final code I ended up with.

Tikibar, I adapted the property from the MD-11s file, how is it so far???

Code: Select all
var locarmcheck = func {
   var locdefl = getprop("instrumentation/nav/heading-needle-deflection");
   if (locdefl < 8 and locdefl > -8) {
      setprop("/autopilot/locks/heading", "nav1-hold");
      setprop("/controls/switches/loc1", 0);
      setprop("/controls/switches/hdgl", 0);
      setprop("/controls/switches/navl", 0);
      setprop("/controls/switches/aplatmode", 2);
      setprop("/controls/switches/aphldtrk", 1);
   } else {
      return 0;
   }
}


Note that everything after the first setprop does: Set the timer to off, set the hdg and nav modes to off, sets the lateral mode for the anaunciator to LOC, sets the mode to TRK.

Regards,
Skillset: JSBsim Flight Dynamics, Systems, Canvas, Autoflight/Control, Instrumentation, Animations
Aircraft: A320-family, MD-11, MD-80, Contribs in a few others

Octal450's GitHub|Launcher Catalog
|Airbus Dev Discord|Octal450 Hangar Dev Discord
User avatar
Octal450
 
Posts: 5583
Joined: Tue Oct 06, 2015 1:51 pm
Location: Huntsville, AL
Callsign: WTF411
Version: next
OS: Windows 11

Re: Arm LOC and G/S

Postby Octal450 » Fri Apr 29, 2016 4:41 pm

Tikibar,

After looking in the actual values, and then testing it, it seems this will be true way to early. For some reason, in the MD-11, it works, but in the -88, it tries to intercept way to far out, since the heading needel deflection is different. Maybe a result of different autopilots???

Regards,
Skillset: JSBsim Flight Dynamics, Systems, Canvas, Autoflight/Control, Instrumentation, Animations
Aircraft: A320-family, MD-11, MD-80, Contribs in a few others

Octal450's GitHub|Launcher Catalog
|Airbus Dev Discord|Octal450 Hangar Dev Discord
User avatar
Octal450
 
Posts: 5583
Joined: Tue Oct 06, 2015 1:51 pm
Location: Huntsville, AL
Callsign: WTF411
Version: next
OS: Windows 11

Re: Arm LOC and G/S

Postby tikibar » Fri Apr 29, 2016 9:15 pm

For your tests, have you set the CRS radial to the correct ILS approach course? I'm not sure how the NAV instrument is coded, but that might make a difference. It shouldn't, but it might. Another option for you might be to reduce the threshold number from +-8 degrees to +-5 or so. I'm not sure why the deflection would be different. In both cases, that should be the difference between the bearing to the localizer and the localizer course. And this part of the system should be independent of the AP controllers.
Boeing 747-8 (rename folder to 747-8i)
Boeing 757-200/300 (rename folder to 757-200)
Boeing 767-300/ER (rename folder to 767-300)
User avatar
tikibar
 
Posts: 545
Joined: Mon Mar 05, 2012 7:05 am
Location: Los Angeles
Callsign: CHT0009
OS: Ubuntu 14.04

Re: Arm LOC and G/S

Postby Octal450 » Fri Apr 29, 2016 10:48 pm

@tikibar
I had to change the code to activate if the number is larger than 9.9999999, or less than -9.9999999

Regards,
Skillset: JSBsim Flight Dynamics, Systems, Canvas, Autoflight/Control, Instrumentation, Animations
Aircraft: A320-family, MD-11, MD-80, Contribs in a few others

Octal450's GitHub|Launcher Catalog
|Airbus Dev Discord|Octal450 Hangar Dev Discord
User avatar
Octal450
 
Posts: 5583
Joined: Tue Oct 06, 2015 1:51 pm
Location: Huntsville, AL
Callsign: WTF411
Version: next
OS: Windows 11

Re: Arm LOC and G/S

Postby Octal450 » Sat Jun 04, 2016 5:19 am

Ok thanks
Skillset: JSBsim Flight Dynamics, Systems, Canvas, Autoflight/Control, Instrumentation, Animations
Aircraft: A320-family, MD-11, MD-80, Contribs in a few others

Octal450's GitHub|Launcher Catalog
|Airbus Dev Discord|Octal450 Hangar Dev Discord
User avatar
Octal450
 
Posts: 5583
Joined: Tue Oct 06, 2015 1:51 pm
Location: Huntsville, AL
Callsign: WTF411
Version: next
OS: Windows 11


Return to Autopilot and route manager

Who is online

Users browsing this forum: No registered users and 1 guest