PDA

View Full Version : PM EFIS SIOC Script



MortenHa
02-15-2009, 07:01 AM
Hi folks!
Now that the MCP is ready to go,next step is to get the EFIS panels online!

We have run into numerous problems with the code, but I'll only present one problem at a time:

Here's part of the script, dealing with the BARO rotary encoders



// PM FSUIPC write offset for QNH Capt.
//-------------------------------------
// DEPENDENCIES:
// RE_E1_PRES
//
// USE:
// This PM offset holds the barometric pressure for setting QNH
// on the Captain side. Controlled with the rotary encoder variable
// RE_E1_PRES
//
//**************************************************************
Var 0066 name F_E1_PRES, Link FSUIPC_OUT , Offset $0330, Length 2

// PM FSUIPC write offset for QNH F/O
//-----------------------------------
// DEPENDENCIES:
// RE_E2_PRES
//
// USE:
// This PM offset holds the barometric pressure for setting QNH
// on the First Officer side. Controlled with the rotary encoder variable
// RE_E2_PRES
//
//**************************************************************
Var 0067 name F_E2_PRES, Link FSUIPC_OUT , Offset $552E, Length 2

// IO ROTARY-ENCODER Link Set QNH Capt.
//-------------------------------------
// DEPENDENCIES:
// None
//
// USE:
// Rotary encoder used to change FSUIPC Offset $0330 (&F_E1_PRES)
// controlling the QNH setting
//
// CODE:
// The value is modified to:
// - Change the sign because the value increments/decrements in reverse
// - Multiply by 16 to show HPa
//
//****************************************************************************
Var 0306 name RE_E1_PRES, Link IOCARD_ENCODER , Input 54, Aceleration 6, Type 2
{
L0 = &RE_E1_PRES * -16 // Rotary turns the wrong way, multiply by 16 and store in locvar L0
&F_E1_PRES = ROTATE 960, 1050, L0

}

// IO ROTARY-ENCODER Link Set QNH F/O
//-----------------------------------
// DEPENDENCIES:
// None
//
// USE:
// Rotary encoder used to change PM FSUIPC Offset $552E (&F_E2_PRES)
// controlling the QNH setting
//
// CODE:
// The value is modified to:
// - Change the sign because the value increments/decrements in reverse
// - Multiply by 16 to show HPa
//
//****************************************************************************
Var 0308 name RE_E2_PRES, Link IOCARD_ENCODER , Input 126, Aceleration 6, Type 2
{
L0 = &RE_E2_PRES * -16 // Rotary turns the wrong way, multiply by 16 and store in locvar L0
&F_E2_PRES = ROTATE 960, 1050, L0
}

The statements:
L0 = &RE_E1_PRES * -16 // Rotary turns the wrong way, multiply by 16 and store in locvar L0
&F_E1_PRES = ROTATE 960, 1050, L0

It doesn't work as expected. Changing the sign in value L0 is to get the rotary to turn the "right way"

And it is multiplied by 16 as per definition found in the FSUIPC offset table.

The ROTATE statement does not work correctly either.

Anyone any clue?

Morten & Lasse

fordgt40
02-15-2009, 09:28 AM
Morten

You do not explain what outputs you are getting, however, I assume that you are using the Opencockpits CTS288 encoder or a similar compatible one? There are many encoders, including some of the Alps ones that are not compatible.

Regards

David

MortenHa
02-15-2009, 10:56 AM
Oops David!

I don't know the brand, but it is a grey encoder!, type 2.

Sorry:roll:

Morten

fordgt40
02-15-2009, 11:20 AM
Morten

Opencockpits say that to use a 2 bit gray type encoder on a master card, you need an encoder with 1/4 cycle per detent. Else, you may be able to connect to their encoder card instead of the mastercard. I assume that you have tried changing the acceleration values.

Regards

David

dogtanian
02-18-2009, 05:09 PM
Hi Morten

Sorry without plugging your code into my system I don't know what's wrong with it. I do know that in a real 737 EFIS box, the QNH and MINIMUMS are not done with rotary encoders.

They are a self-centering spring loaded switch which you turn left to decrement and right to increment. There are also two stages, if you turn it harder in either direction, it goes up/down in 10's rather than single units, and if you hold it for a while it goes faster.

I know you won't want to modify your hardware, but directly in the FSUIPC module within FS you can assign switches to inc/dec the EFIS values. Niko has an example on his site of using SIOC to mimic joystick buttons to do this and it works well.

You could do something more sophisticated in SIOC using timers to replicate the working of the real unit.

fordgt40
02-18-2009, 06:03 PM
Morten

Your SIOC code fragment for the Rotate function seems ok to me. This suggests that your problem lies either in the remainder of your code, or the hardware. You mention that your MCP is working ok, does this have the same encoders?, if so, then perhaps the problem lies within the SIOC code downstream somewhere?

Regards

David

Oter3
02-18-2009, 10:21 PM
This code was publised by Opencockpits in 2008,
it works in my P.Magneta an OC hardware.
(text is simplified)
///Var xx, name E_BARO, Link IOCARD_ENCODER, Input xx, Aceleration 1, Type 2, Device x
L0 = &E_BARO * -1
&SUB_BAR = &SUB_BAR + L0
Var xx, name SUB_BAR, link SUBRUTINE
L0 = &SUB_BAR * 16
&FS_QNH = L0
FS_QNH, Link FSUIPC_OUT, Offset $0330, Length 2 // FS_QNH_MB
FS2_QNH, Link FSUIPC_OUT, Offset $552E, Length 2 // FS_QNH_MB FO////
Regards
Nils

MortenHa
02-19-2009, 07:28 AM
Hi David and Nils !

David:
I have attached the code, if you have time, take a look at it:D

Nils:
Hmmm! The code seems to do exactly the same as my code. I don't know if SIOC handles complex expressions like: A = (D or C) and (A and B). Perhaps you're forced to compute simple expressions in several lines of code to make it work...

fordgt40
02-19-2009, 09:24 AM
Morten

As I asked earlier, do you know that the encoders are being read correctly by SIOC? Do you have the same encoders on your MCP and do they work correctly?

Regards

David

MortenHa
02-23-2009, 07:36 PM
Sorry for the delay David!

Yes they are the same, and they work perfectly on the MCP!

I haven't tried the code Nils posted yet, been awfully busy!

But will report back soon!

fordgt40
02-24-2009, 03:49 PM
Morten

Good news that it is not a h/w issue. Back to SIOC then !

Regards

David