Results 1 to 4 of 4
  1. #1
    300+ Forum Addict jmig's Avatar
    Join Date
    Apr 2007
    Location
    Lafayette, LA USA
    Posts
    422
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    How do you set the altitude for AP?

    I have been trying for two weeks to use an encoder to set the autopilot's altitude. Currently I have a Go-Flight AP which allows me to set the altitude and see it on LED displays.

    I want to eventually get rid of the go-flight AP for a custom one. The first step is using an encoder to set the altitude. I have tried using parts of MEC scripts. Peter gave me some ideas and I have tried to use his info to build my script. It looks to me like it should work. It doesn't.

    Using IPConsole I can see the altitude change ad the offset change with the Go-Flight dial. Not with my encoder. The encoder is working so the problem is in my scripts. Any help appreciated. Here is the latest code.

    Var 3050, name AP_ALT, Link FSUIPC_INOUT, Offset $07D4, Length 4
    {
    L0 = &ROAP_ALT * -1 // turn clockwise to increase

    IF L0 > 0
    {
    L0 = L0 + 100

    }
    ELSE
    {
    L0 = L0 -100
    }

    &AP_ALT = ROTATE 0, 80000, L0 // Increase or Decrease altitude
    }

    Var 3053, name ROAP_ALT, Link IOCARD_ENCODER, Input 43, Aceleration 6, Type 2

    I tried // out the ROTATE function line. It didn't help.
    John

    System:
    ASUS P5Q SE/R
    Intel Q9550 O/C to 3.4 GHz
    4 GB 1066 DDR2 RAM
    300 GB WD 10,000 RPM Raptor SATA Drive
    GeForce 8800 GT 512 KB RAM
    Matrox TH2Go with three 19" Sumsung 940 BX
    IR Track 4

  2. #2
    75+ Posting Member
    Join Date
    Apr 2009
    Location
    Toronto
    Posts
    125
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: How do you set the altitude for AP?

    Hello, Peter.

    As written, your script does nothing with inputs from the encoder.
    You want to execute some SIOC commands as a result of changes to variable 3053 so

    {
    L0 = &ROAP_ALT * -1 // turn clockwise to increase
    .
    .
    should be placed after that declaration.

    Then you would have to make adjustments to deal with the fact that $7D4 is "Autopilot altitude value, as metres*65536". So to add 100 ft you need to convert that to metres and then multiply by 65536. It will take a lot of turns of your encoder to get there in fractions of a centimetre, as you are doing.

    A better method is to let FS (or Peter Dowson) do the work for you via offset $3110. FS has a bunch of functions built-in which are available to application programmers as FS Controls. The FSUIPC package puts the list in your Modules folder. You'll see there two controls of immediate interest:

    65892 AP_ALT_VAR_INC
    65893 AP_ALT_VAR_DEC

    These are two of the functions you want with their associated control numbers. FSUIPC will invoke those functions on your behalf if you stuff the appropriate control number into offset $3110. [You just need length 4 for your
    AP_ALT functions as they do not need a parameter]

    Those two give you 100ft increments/decrements. To get 1000ft steps, look at the FSUIPC guide for Advanced Users where you will find that Peter has augmented the FS list with "Additional 'FS' Controls" - including:

    1016 Ap Alt Var Dec Fast (–1000)
    1017 Ap Alt Var Inc Fast (+1000)

    So your script using this solution might be::

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

    Var 3050, name FS_Controls, Link FSUIPC_OUT, Offset $3110, Length 4
    Var 3053, name ROAP_ALT, Link IOCARD_ENCODER, Input 43, Aceleration 6, Type 2
    {
    IF &ROAP_ALT > 0
    {
    ...IF &ROAP_ALT > 1
    ......{
    .......&FS_Controls = 1017 // Ap Alt Var Inc Fast
    .......}
    ...ELSE
    ......{
    .......&FS_Controls = 65892 // AP_ALT_VAR_INC
    ......}
    }
    ELSE
    {
    ...IF &ROAP_ALT < -1
    ......{
    .......&FS_Controls = 1016 // Ap Alt Var Dec Fast
    ......}
    ...ELSE
    ......{
    .......&FS_Controls = 65893 // AP_ALT_VAR_DEC
    ......}
    }
    &FS_Controls = DELAY 0 ,5 // Pause to allow FSUIPC to work
    // Then clear the offset for the next time.
    }

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

    Some other observations:

    L0 = &ROAP_ALT * -1 // turn clockwise to increase
    Looks like you've reversed the wiring on your encoder. I assumed you would fix that in my script.


    &AP_ALT = ROTATE 0, 80000, L0 // Increase or Decrease altitude
    You wanted the LIMIT function here...with the appropriate changes for metres*65536. That's all taken care of in the FS Control routines.

    G'night.

    Jim

  3. Thanks jmig thanked for this post
  4. #3
    300+ Forum Addict
    Join Date
    Jan 2007
    Posts
    496
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: How do you set the altitude for AP?

    Quote Originally Posted by jmig View Post
    I have been trying for two weeks to use an encoder to set the autopilot's altitude.
    ...
    Offset $07D4, Length 4
    I'm afraid I can't help with your script code (don't know it at all), but you should note that the A/P target altitude at offset 07D4 is in units of 1/65536ths of a metre. so you probably have some arithmetic to do at some place in the script.

    [Ah, I see Jim's already clarified that point for you ... Tks!]

    Pete

  5. #4
    300+ Forum Addict jmig's Avatar
    Join Date
    Apr 2007
    Location
    Lafayette, LA USA
    Posts
    422
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: How do you set the altitude for AP?

    Woooooohhhhhooooooooo! It works!!!

    Thanks a Million to everyone who helped me. I may not be a programmer but, with help like this even I can get SIOC to do what I want it to do.

    John

    System:
    ASUS P5Q SE/R
    Intel Q9550 O/C to 3.4 GHz
    4 GB 1066 DDR2 RAM
    300 GB WD 10,000 RPM Raptor SATA Drive
    GeForce 8800 GT 512 KB RAM
    Matrox TH2Go with three 19" Sumsung 940 BX
    IR Track 4

Similar Threads

  1. altitude alerts in pm gc
    By flyboy01 in forum PM Boeing GC
    Replies: 7
    Last Post: 03-28-2009, 07:31 AM
  2. Altitude MCP vs PMDG 737
    By Delvos in forum OpenCockpits General Discussion
    Replies: 0
    Last Post: 12-22-2008, 05:04 AM
  3. Altitude alert
    By 737NUT in forum PM General Q & A
    Replies: 0
    Last Post: 02-02-2008, 10:04 AM
  4. RA altitude PFD
    By Tom Stian Bjerk in forum PM General Q & A
    Replies: 4
    Last Post: 04-13-2006, 10:17 AM