Results 1 to 7 of 7
  1. #1
    25+ Posting Member Oter3's Avatar
    Join Date
    Mar 2007
    Location
    Norway
    Posts
    33
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Problems with SIOC code for PM MCP-737Ng

    Pan-pan from MCp builder!

    This short sioc code works fine unntil I turn the
    encoder fast to change Hdg, the Hdg value start to oscillate on one to or all digits. Which digits is random.
    It occur both on the Opencockpits Mcp-737NG(Hardware) display and on the software Pm Mcp.
    I have tried to use sub-routines, no help, changing the
    encoder acceleration, and startet the code from different
    angels. In the end same result.
    Please try to give me a hint of what to change, and indicate if I have made I prinsipal error.
    Nedless to say I em new in writing sioc code.
    Thanks in advance.
    Regards
    Nils

    // The Heading (Hdg) part of code for
    //Opencockpits MCP-737NG with PM software on W.Vista.

    Var 0004, name Hdgfrom, Link FSUIPC_IN, Offset $04E2, Length 2 // Hdg from Mcp
    {
    V0006 = &Hdgfrom
    }

    Var 0008, name Hdgto, Link FSUIPC_OUT, Offset $5408, Length 2 // Hdg to Mcp

    Var 0010, name DispA, Link IOCARD_DISPLAY, Digit 6, Numbers 3 // Display on hardware

    Var 0011, name Enco, Link IOCARD_ENCODER, Input 6, Aceleration, Type 2 // Gray code encoder
    {
    L0 = &Enco * -1
    V0006 = ROTATE 0 ,359 ,L0
    }

    Var 0006 // Hdg read from both offsets
    {
    &DispA = V0006
    &Hdgto = V0006
    }

  2. #2
    75+ Posting Member Polmer's Avatar
    Join Date
    Dec 2006
    Location
    USA
    Posts
    141
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    This is not code for Project magenta, but rather generic FS9 or FSX MCP type application, so I dont know if this will help you or not. Maybe you can change my offsets and give it a try. This is set up for ;

    1 gray encoder
    1 pushbutton to activate Heading
    1 LED to read if heading is active or not



    Var 0004, Link FSUIPC_INOUT, Offset $07C8, Length 4 // Heading Selc offset (on or off)
    {
    IF V0004 = 1
    {
    V0112 = 1

    }
    ELSE
    {
    V0112 = 0
    }
    }

    Var 0005, Link FSUIPC_OUT, Offset $07CC, Length 2 // Heading Display offset


    Var 0108, Link IOCARD_DISPLAY, Digit 0, Numbers 3 // Display on hardware

    Var 0109, Link SUBRUTINE
    {
    V0108 = V0141
    L0 = V0141 * 182.04444444
    IF V0005 <> L0
    {
    V0005 = L0
    }
    }

    Var 0110, Link IOCARD_SW, Input 15, Type P // Heading Hold Button
    {
    IF V0110 = 1
    {
    V0004 = 1
    }
    ELSE
    {
    V0004 = 0
    }
    }
    Var 0112, Link IOCARD_OUT, Output 15 // Heading LED
    Var 0113, Link IOCARD_ENCODER, Input 6, Aceleration 6, Type 2 // graycode encoder
    {
    L0 = V0113
    V0141 = ROTATE 0 ,359 ,L0
    }


    Polmer

  3. #3
    150+ Forum Groupie pdpo's Avatar
    Join Date
    Nov 2005
    Location
    belgium
    Posts
    280
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Hi there,

    The problem with your code is because of the following. When you turn the encoder slowly you will update V0006 with the rotate command. This will cause the display to be changed and the value send to PM. Then after some time (depending on the PC load it can take some time before PM puts this value out) the FSUIPC_IN variable will receive the value but since this value is the same as V0006 nothing will happen.
    When you turn fast, you will have changed V0006 further before PM puts out the previous values and in the SIOC (via FSUIPC_IN variable) V0006 wil be overwritten with an older value than the one you are writing with an encoder.
    Thats why you see changing digits because an older heading is being displayed end then the value from the rotate is overwriting it over....
    A solution that I have put in for this kind of situation is the following.
    When I turn the encoder I start a timer (short timer of course 1sec, even half a second) and I put a variable X on true. When the encoder gets turned the variable X stays at true and the timer is resetted. When the FSUIPC_IN variable reads older values they dont take effect because as long as variable X is true I dont treat it. When I stop turning the encoder the timer will run out and the variable X will be set to false. All changes by PM will then flow back to the script via the FSUIPC_IN
    For me this has worked almost flawless. I had to tune the timeout a little and still I have it sometimes that if the PC is soo busy ,PM outputs the variable soo late that I still get an older value back but this you need to finetune with your PC config.

    Greetz Peter Depoortere

    PS if it is not clear let me know ... maybe I can try to explain it in more detail

  4. #4
    25+ Posting Member Oter3's Avatar
    Join Date
    Mar 2007
    Location
    Norway
    Posts
    33
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Hello in south and west.

    Thanks for fast and detailed answers.

    Your code Polmer will work fine with Pm when changing offsets, but the Hdg, Speed.. will not be updated automatically when turning the AP off and on again in flight. Thanx anyway.

    Peter, your explanation is good. I understand it and
    simulations proves it. I do also understand what to do, but not how to write it.
    I belive I have entered a code writing level to high.

    Too much "cut and try" is done lately, perhaps I better enter a holding pattern for a while, and learn more code.

    Best regards
    Nils

  5. #5
    10+ Posting Member
    Join Date
    Sep 2007
    Location
    BRAZIL
    Posts
    22
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Offset fo PMDG 737

    Gentlemen ,

    What is the offset for AP Course,AP IAS, AP HDG, AP Altitude , AP VS for PMDG 77 NG ?

    Thanks and regards

    Alberto

  6. #6
    1000+ Poster - Fantastic Contributor Bob Reed's Avatar
    Join Date
    Oct 2005
    Location
    Holley, New York U.S.A.
    Posts
    1,880
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    There are no "public" offsets for the PMDG 737. There software is proprietary. There are a few hardware manufactures that support the PMDG737 but you have to buy PMDG's connecting software and the hardware needs to support it.
    Bob Reed

  7. #7
    1000+ Poster - Fantastic Contributor kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    1,621
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Quote Originally Posted by Oter3 View Post
    Too much "cut and try" is done lately, perhaps I better enter a holding pattern for a while, and learn more code.
    Here another (easy) example. Note the 'trick' is that you check the value of var to get out of this "update loop":
    ///////////////////////////////////////////////////////////////////////////
    //
    // SIOC: How to read (Display) and write (change) a
    // FSUIPC read/write variable
    //
    // The example details the AP HDG but other
    // application area's are: AP SPD, VS, ALT
    // VOR freq and CRS
    // HF radio freq and CRS
    // ILS freq and CRS
    // ... and so on
    //
    // Note that your hardware and the sim are
    // always synchronised, whether you are using the
    // mouse or the rotarie.
    //
    //
    // May 19, 2006
    //
    // Nico Kaan
    // The Netherlands
    // www.nicokaan.nl
    // email: flightsim@nicokaan.nl
    //
    //
    //

    Var 1, name X_HDG, Link FSUIPC_INOUT, Offset $07CC, Length 2
    {
    // convert from fsuipc range to degrees:
    L0 = DIV &X_HDG, 182
    IF &HDG != L0
    {
    &HDG = L0
    }
    }
    Var 2, name HDG
    {
    CALL &OutHDG
    }
    Var 3, name OutHDG, Link SUBRUTINE
    {
    &D_HDG = &HDG
    // convert from degrees to fsuipc range:
    L0 = &HDG * 182
    IF &X_HDG != L0
    {
    &X_HDG = L0
    }
    }
    Var 4, name RO_HDG, Link IOCARD_ENCODER, Input 36, Aceleration 4 Type 2
    {
    L0 = &RO_HDG // * -1 turning right should be plus
    &HDG = ROTATE 0, 359, L0
    }
    Var 5, name D_HDG, Link IOCARD_DISPLAY, Digit 0, Numbers 3

Similar Threads

  1. SIOC code issues - Can someone take a look?
    By XOrionFE in forum I/O Interfacing Hardware and Software
    Replies: 8
    Last Post: 02-04-2009, 07:43 AM
  2. SIOC Code for Sim-Avionics 737ng
    By ncleme in forum OpenCockpits General Discussion
    Replies: 3
    Last Post: 11-09-2008, 06:25 AM
  3. What's going wrong in my SIOC code?
    By MicroHellas in forum I/O Interfacing Hardware and Software
    Replies: 11
    Last Post: 08-22-2008, 06:55 AM
  4. PMSystems SIOC code for 737NG
    By B738 in forum PMSystems
    Replies: 0
    Last Post: 03-14-2008, 11:08 PM
  5. SIOC Code
    By Polmer in forum I/O Interfacing Hardware and Software
    Replies: 6
    Last Post: 12-28-2006, 09:49 AM