c172p-team / c172p

A high detailed version of the Cessna 172P aircraft for FlightGear
GNU General Public License v2.0
79 stars 44 forks source link

Upgrade KAP-140 to new version #1302

Closed wlbragg closed 3 years ago

wlbragg commented 4 years ago

@WoodSTokk brought it to my attention, we have a newly refactored KAP-140 that is fully functional. We should consider replacing the existing KAP 140 with this newer version.

gilbertohasnofb commented 4 years ago

The refactored instrument has had only its code changed or is there any cosmetic or functional changes too? If it's only code, this might be as easy as just coping those files into our project, right?

callahanp commented 4 years ago

will this KAP140 refrain from continuously moving up the trim until you are in a full power nose up almost a stall in the c172?

On Sun, Oct 27, 2019 at 6:59 AM Gilberto Agostinho notifications@github.com wrote:

The refactored instrument has had only its code changed or is there any cosmetic or functional changes too? If it's only code, this might be as easy as just coping those files into our project, right?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/c172p-team/c172p/issues/1302?email_source=notifications&email_token=ABOZDUHSKD35FIJNAODYEMTQQVQ63A5CNFSM4JDRYXJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECK3UTY#issuecomment-546683471, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOZDUAHA5RYFEBUAMXAIL3QQVQ63ANCNFSM4JDRYXJA .

wlbragg commented 4 years ago

I haven't looked at any of it, I think either way it's probably going to be a relatively straight forward swap. @callahanp I hope it resolves any and all of the quirks the existing one has. I also had the original put me into an unrecoverable turn. Maybe I never understood the cause and it was indeed a stall.

gilbertohasnofb commented 4 years ago

If someone opens a PR I am happy to test it and merge it

gilbertohasnofb commented 4 years ago

@Juanvvc this might interest you

wlbragg commented 4 years ago

I started looking at this today and it isn't as straight forward as I hope for.

1) Our effects definitions are complex and so require some configuring. I'm mostly done setting materials, light maps probably will work as the layout looks close to the same.

2) No model animation, if we want buttons and knobs animated we have to do it ourselves.

3) Electrical and System setup would be last on my list as to insure we can get past item 1 and 2.

I can push a branch and let anyone follow progress as I go along.

wlbragg commented 4 years ago

@gilbertohasnofb

The base texture is too light in color, to match we would need to darken it.

kap

fgfs-20200212183554

wlbragg commented 4 years ago

I'm tempted to hook up Systems first for everyone to test and make sure it is what we want and enough of an improvement to justify the time.

gilbertohasnofb commented 4 years ago

@wlbragg Sounds good to me. As soon as the port gets a green light, I will take care of the textures and match them with all others. Let's first make sure that all functionality is still there and then we can worry about textures and effects. Once you create a branch and you have a functional instrument, let me know and I can test it.

legoboyvdlp commented 4 years ago

will this KAP140 refrain from continuously moving up the trim until you are in a full power nose up almost a stall in the c172?

Surely it should use elevator, and give a visual indicator to trim the nose (flashing PT up or down)?

Or does the 172 have the optional pitch trim servo?

wlbragg commented 4 years ago

@legoboyvdlp I don't know the answer to either of your questions. I'll hook it up best I can and see where it takes me, there are several options dependent on the aircraft systems.

wlbragg commented 4 years ago

I'm having some issues hooking this up and I guess the provided zip in not up to date. So this may be a show stopper. There is a lot of configuring if you include effects, animation and just hooking it up. There are some very strange alias paths that have me puzzled.

        <enable>
            <condition>
                <property>autopilot/kap140/powered</property>
                <less-than>
                    <property alias="../../../../../params/power-supplied"/>
                    <expression>
                        <product>
                            <property alias="../../../../../../../params/power-nominal"/>
                            <value>0.7</value>
                        </product>
                    </expression>
                </less-than>
            </condition>
        </enable>

This is just for resetting the KAP upon power being shut off, but those paths don't look correct. If anyone gets a chance to look at that and can explain.

I'm preparing a branch right now.

wlbragg commented 4 years ago

@gilbertohasnofb I did a simple flood-fill on the base texture to match our existing interior equipment better. That may be all that is needed as far as texture are concerned, unless we want to change dial textures and other items. Anyway, we can do all that later. I just wanted to let you know I changed it.

gilbertohasnofb commented 4 years ago

@wlbragg sounds good. Once we have a working branch I will take a closer look at it and see if it needs any improvements

wlbragg commented 4 years ago

Well, looks like I have to redo some of this. I mistakenly used the zip file from the forum post for the source and needed to instead use the files out of the fgaddon PA28. That model is animated. @WoodSTokk sent me a PM walk through of what is needed. I'm going to try to do that right now and see where it lands.

wlbragg commented 4 years ago

I've updated the files according to @WoodSTokk recommendations and still no-joy. I've notified @WoodSTokk to take a look at this branch. May be something simple I missed.

wlbragg commented 4 years ago

@WoodSTokk

I found the issue with it not getting electrical. It's the condition for which autopilot the aircraft is using.

<equals>
<property>options/autopilot</property>
 <value>KAP140</value>
</equals>
wlbragg commented 4 years ago

@gilbertohasnofb This is now ready to test.

gilbertohasnofb commented 4 years ago

@wlbragg I will take a look at this in the next days. @legoboyvdlp could you also give us a hand with testing?

gilbertohasnofb commented 4 years ago

@wlbragg I did a quick test but I am not being able to use the autopilot at all. The AP button doesn't seem to do anything, nor ARM; I can change between barometric pressure to altitude in the display, but I can't seem to be able to enable the autopilot. Also, the knob is animating as far as I can tell. I am sure I am in the correct branch. As a note, I never really used the autopilot before so I am testing this a bit blindly, which is why any input from @legoboyvdlp or @dany93 or anyone else would be super valuable.

gilbertohasnofb commented 4 years ago

@Juanvvc could you maybe help us test this as well?

legoboyvdlp commented 4 years ago

Did you hold down the AP button long enough?

Wlbragg, I don't think you have the latest files from the PA28 as pitch is still running away upon autopilot initialization.

wkitty42 commented 4 years ago

On 2/14/20 12:07 PM, Gilberto Agostinho wrote:

@wlbragg https://github.com/wlbragg I did a quick test but I am not being able to use the autopilot at all. The AP button doesn't seem to do anything, nor ARM; I can change between barometric pressure to altitude in the display, but I can't seem to be able to enable the autopilot. Also, the knob is animating as far as I can tell. I am sure I am in the correct branch. As a note, I never really used the autopilot before so I am testing this a bit blindly, which is why any input from @legoboyvdlp https://github.com/legoboyvdlp or @dany93 https://github.com/dany93 or anyone else would be super valuable.

when i first started using the KAP 140, i had ot get a manual from somewhere... not sure where that was, though... see if you can find 006-18034-0000_3.pdf on the net somewhere... that's the one i have in my KAP-140 folder... if you cannot find it, i can place it up somewhere...

i'm unable to test anything right now... shouldn't even be reading mail... migraines are bad these last few days :(

wlbragg commented 4 years ago

Yeah I incorporated the latest round from @WoodSTokk via a PM. In fact I redid the entire code base even though I already manually had made the changes, I used what Sascha provided right out of the PA28.

pitch is still running away upon autopilot initialization

I noticed the same thing, i thought it might just be my lack of familiarity with it.

I think Sascha is still testing as well, maybe there will be some more changes coming from him.

Do make sure you have the latest files.

wlbragg commented 4 years ago

I'm not convinced we just need to relearn how to use the thing. But I give you it is very dangerous.

I'm able to get it to fly heading bug and VS but it is a fine line between correct power settings and failure.

wlbragg commented 4 years ago

Almost like maybe pid controllers need adjusting. I simply don't know enough about any of it.

reiszner commented 4 years ago

In the set.xml file the generic-autopilot-helper will be overwritten, but the KAP 140 need this helper. Anyway, i found out that the KAP 140 needs only the vertical speed. So please add the following filter to the kap140-autopilot.xml

        <filter>
                <name>vertical speed fpm</name>
                <debug>false</debug>
                <type>gain</type>
                <input>instrumentation/vertical-speed-indicator/indicated-speed-fpm</input>
                <output>autopilot/internal/vert-speed-fpm</output>
        </filter>

And in the PID controller for 'Vertical Speed (VS) Mode' change the gamma to 0.0 (to prevent oscilating of that controller).

reiszner commented 4 years ago

will this KAP140 refrain from continuously moving up the trim until you are in a full power nose up almost a stall in the c172?

Surely it should use elevator, and give a visual indicator to trim the nose (flashing PT up or down)?

Right. The KAP 140 has no input about speed, thrust or AoA. If you are in altitude hold mode (ALT) and pull the thrust back, you will stall. If you are in vertical speed mode (VS) and set the FPM too high or the performace of the aircraft is to low for this FPM, you will stall.

Or does the 172 have the optional pitch trim servo?

It doesn't matter if the C172p has a electrical pitch trim or not. The KAP 140 has no command channel to the pitch trim. It can only show 'PT UP' or 'PT DOWN'. It is on pilot decision if he/she trims the airplane. If you have a electrical trim motor, you will have a rocker switch on the yoke, but that has nothing to do with the KAP 140.

wlbragg commented 4 years ago

@reiszner Thanks Sascha!

Any testers, FYI: https://bkx.bendixking.com/downloads/006-18034-0000_3.pdf

wlbragg commented 4 years ago

I'm still having difficulties with VS mode, but it may simply be pilot error. Still learning how to use it per the documentation.

@reiszner gave me another change I pushed earlier.

reiszner commented 4 years ago

Today, my C172p is also oscillating up/down. I have changed the 'Vertical Speed (VS) Mode' filter with

<Ti>10.0</Ti>
<Td>0.5</Td>

Now its fly good. But i test mostly in standard condition (noon/29.92/calm). I found also that on ALT mode, the AP ride around the altitude. I think this come from the delayed VSI, because also the VSI shows newer 0. It is always a little bit above or bellow zero, but never on zero.

gilbertohasnofb commented 4 years ago

Did you hold down the AP button long enough?

Probably not, is this a new feature? I remember it requiring just a click in the past. But as long as it matches the real instrument, then let's go for it

wlbragg commented 4 years ago

Pushed that last change

<Ti>10.0</Ti>

Td was already changed to 0.5

reiszner commented 4 years ago

To engage the KAP 140, hold the AP button at least 0.25 seconds. To disengae a shor klick is enough.

Will the C172p feature a AP disconnect and a CWS button on the yoke?

wlbragg commented 4 years ago

Will the C172p feature a AP disconnect and a CWS button on the yoke?

Only if they have those features installed in real life?

reiszner commented 4 years ago

Dont know. The KAP 140 feature it. I'm now on MP around LCRA for testing.

wlbragg commented 4 years ago

I actually had good results just now with hdg and vs mode. I was able to get it setup on the bug and achieve a climb rate according to the AP. Leveled off at 3000 by setting VS to 0.

Something I have noticed though, I don't seem to be able to get the AP on until I move the dial, than the AP switch works?

wlbragg commented 4 years ago

A continuous bit of oscillation on the yaw axis. Pitch is stable.

reiszner commented 4 years ago

Found out that the AP want move the controls faster, but the servos are too slow. I have set the servos from 0.05 to 0.1 (line 619 and 660).

And for me it looks like the AP has a different behavior if i restart the sim or reload only the AP in the sim. Will test further …

PS: the course deviation needles on both CDIs have a wrong axis point. looks like the axis in on the upper left corner instead on the upper center.

wlbragg commented 4 years ago

the course deviation needles on both CDIs have a wrong axis point. looks like the axis in on the upper left corner instead on the upper center

I need conformation on this from others as this is how it was always setup as far as I know?

wlbragg commented 4 years ago

I'm certain I cannot activate the AP using the AP button until I have either pressed the BARO button or adjust the altitude with either knob. Holding the AP button down for any length of time doesn't work.

We need to add tooltips to all the buttons and knobs.

legoboyvdlp commented 4 years ago

The 1982 POH shows no electric trim control whatsoever or controls on the yoke bar possibly PTT. Of course, it has a legacy Navomatic 300 autopilot, perhaps a KAP140 refit would modify the yoke but right now I don't see any evidence of that, certainly not in photos.

legoboyvdlp commented 4 years ago

https://www.pilotsofamerica.com/community/proxy.php?image=http%3A%2F%2Fwww.teamandras.com%2Ftemp%2F2015%2FAuto_Pilot_Trim_Disc_Button.jpg&hash=6a11ace776f718f24a28ae2f558e00fc

https://www.pilotsofamerica.com/community/threads/question-re-autopilot-circuit-breaker.87998/

According to this, the red button is a momentary disconnect while the PTT switch is up the back, behind the yoke.

reiszner commented 4 years ago

I'm certain I cannot activate the AP using the AP button until I have either pressed the BARO button or adjust the altitude with either knob.

The KAP 140 need a BARO setting first, before it can be used. After power up, the baro setting is flashing. The pilot must set the baro (with theknobs) or confirm the 29,92 by pressing BARO. If you want set hPa, press and hold the BARO button for at least 3 seconds.

Holding the AP button down for any length of time doesn't work.

Press AP for at least a quarter of a second (only possible if BARO is set).

bitwisetech commented 4 years ago

@wlbragg Those alii: In the xml the ../../.. refer to the number of levels back in the xml to regress in order to find the alias. In kap140-autosave.xml, at the top, the config file is specified as an include so, stepping back through the tags in both the autopilot and config file you get to the place where the desired signal is aliased according to whichever kap140/stec is in use.

Also:

It looks as if the c172p version of the VSI ( Models/Interior/Panel/Instruments/VSI ) doesn't support the 'lowpass' filtered output:

kap140-autopilot.xml # 700 :

`

vertical speed fpm
    <debug>false</debug>
    <type>gain</type>
    <!--input>instrumentation/vertical-speed-indicator/indicated-speed-fpm-lowpass</input-->
    <input>instrumentation/vertical-speed-indicator/indicated-speed-fpm</input>
    <output>autopilot/internal/vert-speed-fpm</output>
  </filter>

` (Sorry about the code formatting but it's the input tag needs changing) making the change above at least gets the VS mode working but it's a wild ride. Putting the proper values into the PID differentiator would be the proper place to fix this but no doubt another low pass filter will be preferred.

p.

wlbragg commented 4 years ago

@bitwisetech thanks for the information. As per indicated in our PM we already changed

instrumentation/vertical-speed-indicator/indicated-speed-fpm-lowpass to instrumentation/vertical-speed-indicator/indicated-speed-fpm

See: https://github.com/c172p-team/c172p/commit/0159e5121c83e31a5b41e18204bba74d0fb0ab23

Also I was aware of the nature of the relative path statement, my issue was following it. Admittedly I was confusing property paths with file paths. File paths in this aircraft are potentially different than the PA28 and thus that type of reference could be problematic. Not so much though when taken as a property path context. Bottom line, we are past both of these issues.

bitwisetech commented 4 years ago

baro setting: c172p-set.xml # 715 baro-tied can be set to true in order to avoid having to set baro pressure manually.

reiszner commented 4 years ago

baro setting: c172p-set.xml # 715 baro-tied can be set to true in order to avoid having to set baro pressure manually.

Correct, but than you must also edit the config so that the setting point to 'altimeter[0]' (not 1). But i think the altimeter in the C172p doesn't output the baro-setting. So the KAP 140 doesn't receive a baro setting. Therefor i decided to untie the setting.

Juanvvc commented 4 years ago

I'm trying to fly with the autopilot, but it is definitely a challenge to use!

Reading the manual is mandatory. And you must be always ready to disengage the autopilot and fix the mess you are in.

wlbragg commented 4 years ago

That was the same conclusion I came to, wasn't sure if my issues were self caused or real issues. That was without reading the manual, ha!