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 3: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,
Waste of time. Goodbye forever.
Octal450
 
Posts: 4398
Joined: Tue Oct 06, 2015 12:51 pm

Re: Arm LOC and G/S

Postby tikibar » Wed Apr 27, 2016 5: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)
McDonnell Douglas MD-11 (rename folder to MD-11)
User avatar
tikibar
 
Posts: 514
Joined: Mon Mar 05, 2012 6:05 am
Location: Los Angeles
Callsign: CHT0009
OS: Ubuntu 14.04

Re: Arm LOC and G/S

Postby sanhozay » Wed Apr 27, 2016 6: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 11:57 am
Location: EGNM
Callsign: G-SHOZ
Version: Git
OS: Ubuntu 16.04

Re: Arm LOC and G/S

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

sanhozay wrote in Wed Apr 27, 2016 6: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,
Waste of time. Goodbye forever.
Octal450
 
Posts: 4398
Joined: Tue Oct 06, 2015 12:51 pm

Re: Arm LOC and G/S

Postby sanhozay » Wed Apr 27, 2016 8: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 11:57 am
Location: EGNM
Callsign: G-SHOZ
Version: Git
OS: Ubuntu 16.04

Re: Arm LOC and G/S

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

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

I have also made an altitude capture system this way.

Regards,
Waste of time. Goodbye forever.
Octal450
 
Posts: 4398
Joined: Tue Oct 06, 2015 12:51 pm

Re: Arm LOC and G/S

Postby Octal450 » Fri Apr 29, 2016 3: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,
Waste of time. Goodbye forever.
Octal450
 
Posts: 4398
Joined: Tue Oct 06, 2015 12:51 pm

Re: Arm LOC and G/S

Postby Octal450 » Fri Apr 29, 2016 3: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,
Waste of time. Goodbye forever.
Octal450
 
Posts: 4398
Joined: Tue Oct 06, 2015 12:51 pm

Re: Arm LOC and G/S

Postby Octal450 » Fri Apr 29, 2016 3: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,
Waste of time. Goodbye forever.
Octal450
 
Posts: 4398
Joined: Tue Oct 06, 2015 12:51 pm

Re: Arm LOC and G/S

Postby tikibar » Fri Apr 29, 2016 8: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)
McDonnell Douglas MD-11 (rename folder to MD-11)
User avatar
tikibar
 
Posts: 514
Joined: Mon Mar 05, 2012 6:05 am
Location: Los Angeles
Callsign: CHT0009
OS: Ubuntu 14.04

Re: Arm LOC and G/S

Postby Octal450 » Fri Apr 29, 2016 9: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,
Waste of time. Goodbye forever.
Octal450
 
Posts: 4398
Joined: Tue Oct 06, 2015 12:51 pm

Re: Arm LOC and G/S

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

OK this is so strange!

ON THE MD-11:
Code: Select all
            if(me.loc_armed.getBoolValue()){
                var hddefl = getprop("instrumentation/nav/heading-needle-deflection");
                if(hddefl< 8 and hddefl>-8){
                    me.lateral_mode.setValue(4);
                    me.loc_armed.setBoolValue(0);
                }
            }


What I did:
Code: Select all
   if (locdefl < 8 or locdefl > -8) {
      setprop("/autopilot/locks/heading", "nav1-hold");
      setprop("/controls/switches/loc1", 0);
      setprop("/controls/switches/aplatmode", 2);
      setprop("/controls/switches/aphldtrk", 1);
   } else {
      return 0;
   }


THE MD-11 code works correctly! But in the code I did, it capture the LOC WAAAYYY to early! WTF IS THIS??!?!?!??

I had to change it again, since the other code caused alot of other issues, including not being able to activate LOC mode.
How is this possible?
Waste of time. Goodbye forever.
Octal450
 
Posts: 4398
Joined: Tue Oct 06, 2015 12:51 pm


Return to Autopilot and route manager

Who is online

Users browsing this forum: SEMrush [Bot] and 1 guest