PDA

View Full Version : encoder in SIOC



sboons
10-08-2009, 07:26 AM
Hi again,

David helped me out with my problem showing heading on my sim-avionics.

Now I have the following problem:

I have a SIOC script to change my heading.
The goal of this script is only to change the heading bug on my virtual cockpit in FSX.

I have a CTS288 grey encoder from opencockpits, connected on the mastercard inputs 3 and 4 (and gnd off course)
When I look at the Controlador software, and turn the encoder I see:
RIGHT: 004 -> 003-004 -> 003 -> empty
LEFT: 003 -> 003-004 -> 004 -> empty

I think that is good?!

My script is:


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
{
// 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 3, Aceleration 4 Type 2
{
L0 = &RO_HDG // * -1 turning right should be plus
&HDG = ROTATE 0, 359, L0
}



Now in FS, when I turn the button to the right...
I see the heading bug move one degree to the right and immediately one to the left (for example 342 and instantly 341 again).
When I turn the encoder fast, it moves to the right, but very shaking and nog very well.

I changed the input number to 1 (that is my altitude encoder), the same happens, So I don't think it is a problem with the encoder.

Is there something wrong with my code?

Thanks again,
Steef

sboons
10-08-2009, 07:42 AM
I was looking for the solution for about two days now..

Kept looking and found the solution!!

On: http://www.kennair.com.au/downloads/SIOC/Pedestal.txt

I now have the code cut from this:



Var 2000, Value 0 // Initialization
{
&D_HDG = 360
}

Var 2004, Link FSUIPC_INOUT, Offset $07C8, Length 4 // AP_HDG_SEL
{
IF V2004 = 1
{
&O_HDGSEL = 1
}
ELSE
{
&O_HDGSEL = 0
}
}

Var 2005, name APD_HDG, Link FSUIPC_INOUT, Offset $07CC, Length 2 // APD_HDG

Var 2104, name D_HDG, Link IOCARD_DISPLAY, DEVICE 1, Digit 6, Numbers 3
{
L1 = &D_HDG * 182.04444
L0 = L1 + 1
&APD_HDG = L0
}

Var 2212, name O_HDGSEL, Link IOCARD_OUT, DEVICE 1, Output 26



Var 2306, name E_HDG, Link IOCARD_ENCODER, Input 3, Aceleration 4, Type 2
{
L0 = &E_HDG // * -1
&D_HDG = ROTATE 1, 360, L0
}


Var 2426, name I_HDGSEL, Link IOCARD_SW, DEVICE 1, Input 28
{
IF &I_HDGSEL = 1
{
IF V2004 <> 1
{
V2004 = 1
}
ELSE
{
V2004 = 0
}
}
}


And works perfect!!!

Maybe I can help soneone with this, thanks anyway :)