PDA

View Full Version : Problems with SIOC code for PM MCP-737Ng



Oter3
08-13-2007, 06:01 PM
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
}

Polmer
08-13-2007, 09:54 PM
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

pdpo
08-14-2007, 06:45 AM
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

Oter3
08-19-2007, 05:07 PM
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

APAK
09-24-2007, 12:29 PM
Gentlemen ,

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

Thanks and regards

Alberto

Bob Reed
09-24-2007, 01:30 PM
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.

kiek
09-24-2007, 05:18 PM
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 (http://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