PDA

View Full Version : PMDG 737 and OpenCockpits MCP



MrRoper
02-12-2009, 06:51 PM
OK,

so just got my MCP panel from opencockpits and have started my SIOC for it, I was wondering if anyone was having issues with the speed of the rotaries due to keypresses having to be sent... So i started to have a play and came up with this.

Its so much better now, you can get quite nice fast changes with a fast spin, but keep the accuracy when slow.. enjoy :)

BTW it needs cleaning up so sorry about the naming etc :)



var 9991, name temphdg, value 0
var 9992, name LastHDGRot, value 0
var 8100, name Plus, Link SUBRUTINE
{
&temphdg = &plus

if &temphdg = &LastHDGRot
{
&temphdg = 0
}
if &plus > 0
{
CALL &HDGplus
}
}

var 8101, name Minus, Link SUBRUTINE
{
&temphdg = &Minus

if &temphdg = &LastHDGRot
{
&temphdg = 0
}
if &minus > 0
{
CALL &HDGminus
}
}


Var 8001, name HDGplus, Link SUBRUTINE
{
&KEYS = 47
&KEYS = 0
}
Var 8002, name HDGminus, Link SUBRUTINE
{
&KEYS = 48
&KEYS = 0
}



Var 9082, name HDGrot, Link IOCARD_ENCODER, Input 6, Aceleration 8, Type 2
{
&CRSRdisplay = &HDGrot
if &HDGrot > 0
{
IF &temphdg = 0
{
&LastHDGRot = &HDGrot
&Plus = 0
&Plus = TIMER &HDGrot 1 1
}
}
else
{

IF &temphdg = 0
{
L1 = &HDGrot * -1
&LastHDGRot = L1
&Minus = 0
&Minus = TIMER L1 1 1
}
}


IF &HDGled = 0
{
L0 = &HDGrot * -1
&MEMHDG = ROTATE 0 ,359 ,L0
}
CALL &HDGaff

}

fordgt40
02-13-2009, 06:56 PM
Mr Roper

Many thanks for your recent contributions, your programming experience is proving very helpfull. It just shows what a forum can achieve with diverse skills.

Regards

David

Carlos Corona
02-13-2009, 08:15 PM
Its curiuos..i no have any problem with sioc code from oc in my pmdg...but have little low speed in changes whe use OGS...thanks any way...:p

Sylle
02-16-2009, 01:50 PM
Thanks Mr Roper for this extract of your code.

I'll try to integrate it in my script in an attempt to solve the sluggish change of HDG values.

Cheers,
Sylvain

MrRoper
02-16-2009, 01:58 PM
updated to include course, heading and altitude rotaries :)

I have also used a few different offsets, so that we dont have to remember the hdg etc when in LNAV/VNAV mode


// *****************************************************************************
// * Config_SIOC ver 3.41 - By Manolo Vélez - www.opencockpits.com
// *****************************************************************************
// * FileName : sioc.txt Versión 1.1
// * Date : 29/06/2007
// * COnfiguración para MCP opencockpits para 738 PMDG por
// * Xavier Baca VAE403 y Vicente Barrón VAE401 (airexplorer.aeria.org)
// * Se debe modificar sioc.ini en el KEYBOARD EMULATOR MODULE
// * y configurar la assignación de teclas en el PMDG
// * Adaptación del original de DeMadagascar

// __________________________________________________________________
// Inicialización variables
//____________________________________________________________________


Var 0001, name keys, Link KEYS // variable transfert emulateur clavier ( SIOC.INI)

Var 0002, name MEMHDG, Value 0

Var 0003, name IAS, Link FSUIPC_IN, Offset $02BC, Length 4

Var 0004, name MACH, Link FSUIPC_IN, Offset $11C6, Length 2

Var 0005, name MEMALT, Value 10000


// __________________________________________________________________
// Salidas IOCARD Leds
//____________________________________________________________________


Var 0010, name FDLEFTled, Link IOCARD_OUT, Output 39

Var 0011, name ATled, Link IOCARD_OUT, Output 22

Var 0012, name N1led, Link IOCARD_OUT, Output 21

Var 0013, name SPEEDled, Link IOCARD_OUT, Output 23

Var 0014, name LVLCHGled, Link IOCARD_OUT, Output 24

Var 0015, name HDGled, Link IOCARD_OUT, Output 26

Var 0016, name VNAVled, Link IOCARD_OUT, Output 25

Var 0017, name LNAVled, Link IOCARD_OUT, Output 29

Var 0018, name VORLOCled, Link IOCARD_OUT, Output 28

Var 0019, name APPled, Link IOCARD_OUT, Output 27

Var 0020, name ALTHOLDled, Link IOCARD_OUT, Output 30

Var 0021, name VSled, Link IOCARD_OUT, Output 31

Var 0022, name CMDAled, Link IOCARD_OUT, Output 33

Var 0023, name CMDBled, Link IOCARD_OUT, Output 35

Var 0024, name CWSAled, Link IOCARD_OUT, Output 32

Var 0025, name CWSBled, Link IOCARD_OUT, Output 34

Var 0026, name VSminus, Link IOCARD_OUT, Output 45

Var 0027, name IASpoint, Link IOCARD_OUT, Output 20


// __________________________________________________________________
// Salidas IOCARD Displays
//___________________________________________________________________

Var 0030, name CRSLEFTdisplay, Link IOCARD_DISPLAY, Digit 0, Numbers 3

Var 0031, name IASdisplay, Link IOCARD_DISPLAY, Digit 3, Numbers 3

Var 0032, name HDGdisplay, Link IOCARD_DISPLAY, Digit 6, Numbers 3

Var 0033, name ALTdisplay, Link IOCARD_DISPLAY, Digit 9, Numbers 5

Var 0034, name VSdisplay, Link IOCARD_DISPLAY, Digit 14, Numbers 5

Var 0035, name CRSRdisplay, Link IOCARD_DISPLAY, Digit 19, Numbers 3

// __________________________________________________________________
// Entradas FSUIPC del MCP B737-800 PMDG ( Infos Leds )
//___________________________________________________________________


Var 0040, name MCPstatus, Link FSUIPC_IN, Offset $62BC, Length 4
{
&FDLEFTled = TESTBIT &MCPstatus ,12
&ATled = TESTBIT &MCPstatus ,14
&N1led = TESTBIT &MCPstatus ,15
&SPEEDled = TESTBIT &MCPstatus ,16
&VNAVled = TESTBIT &MCPstatus ,18
&LVLCHGled = TESTBIT &MCPstatus ,17
&HDGled = TESTBIT &MCPstatus ,22
&LNAVled = TESTBIT &MCPstatus ,19
&VORLOCled = TESTBIT &MCPstatus ,20
&APPled = TESTBIT &MCPstatus ,21
&ALTHOLDled = TESTBIT &MCPstatus ,23
&VSled = TESTBIT &MCPstatus ,24
&CMDAled = TESTBIT &MCPstatus ,8
&CMDBled = TESTBIT &MCPstatus ,9
&CWSAled = TESTBIT &MCPstatus ,25
&CWSBled = TESTBIT &MCPstatus ,26
CALL &HDGaff
CALL &IASaff
CALL &ALTaff
CALL &VSaff
}
Var 0041, name SPDINTV, Link FSUIPC_IN, offset $62C0, Length 1
{
CALL &IASaff
}

Var 0042, name COstatus, Link FSUIPC_IN, offset $621e, Length 2
{
CALL &IASaff
}

// __________________________________________________________________
// Entradas FSUIPC del MCP B737-800 PMDG ( Infos Displays )
//___________________________________________________________________

Var 0050, name CRSpmdg, Link FSUIPC_IN, Offset $0C4E, Length 2
{
IF &CRSpmdg = 360
{
&CRSLEFTdisplay = 0
}
ELSE
{
&CRSLEFTdisplay = &CRSpmdg
}
}

Var 0051, name IASpmdg, Link FSUIPC_IN, Offset $6220, Length 2
{
CALL &IASaff
}

Var 0052, name hdgpmdg, Link FSUIPC_IN, Offset $62AD, Length 2
{
CALL &HDGaff
}

Var 0053, name ALTpmdg, Link FSUIPC_IN, Offset $62B9, Length 2
{
CALL &ALTaff
}

Var 0054, name VSpmdg, Link FSUIPC_IN, Offset $6230, Length 2
{
CALL &VSaff
}

Var 0055, name CRS2pmdg, Link FSUIPC_IN, Offset $0C4E, Length 2
{
IF &CRS2pmdg = 360
{
&CRSRdisplay = 0
}
ELSE
{
&CRSRdisplay = &CRS2pmdg
}
}


// __________________________________________________________________
// Entradas IOCARD Interruptores & bp (button press)
//___________________________________________________________________


Var 0060, name FDswitch, Link IOCARD_SW, Input 16
{
IF &FDswitch = 1
{
IF &FDLEFTled = 0
{
&keys = 56
&keys = 0
}
}
ELSE
{
IF &FDswitch = 0
{
IF &FDLEFTled = 1
{
&keys = 56
&keys = 0
}
}
}
}

Var 0061, name ATswitch, Link IOCARD_SW, Input 33
{
IF &ATswitch = 1
{
IF &ATled = 0
{
&keys = 44
&keys = 0
}
}
ELSE
{
IF &ATswitch = 0
{
IF &ATled = 1
{
&keys = 44
&keys = 0
}
}
}
}


Var 0062, name N1bp, Link IOCARD_SW, Input 32
{
IF &N1bp = 1
{
&keys = 61
&keys = 0
}
}

Var 0063, name SPEEDbp, Link IOCARD_SW, Input 31
{
IF &SPEEDbp = 1
{
&keys = 51
&keys = 0
}
}

Var 0064, name VNAVbp, Link IOCARD_SW, Input 30
{
IF &VNAVbp = 1
{
&keys = 57
&keys = 0
}
}


Var 0065, name LVLCHGbp, Link IOCARD_SW, Input 29
{
IF &LVLCHGbp = 1
{
&keys = 59
&keys = 0
}
}

Var 0066, name HDGbp, Link IOCARD_SW, Input 28
{
IF &HDGbp = 1
{
&keys = 62
&keys = 0
}
}

Var 0067, name LNAVbp, Link IOCARD_SW, Input 27
{
IF &LNAVbp = 1
{
&keys = 69
&keys = 0
}
}

Var 0068, name VORLOCbp, Link IOCARD_SW, Input 25
{
IF &VORLOCbp = 1
{
&keys = 70
&keys = 0
}
}

Var 0069, name APPbp, Link IOCARD_SW, Input 24
{
IF &APPbp = 1
{
&keys = 63
&keys = 0
}
}

Var 0070, name ALTHOLDbp, Link IOCARD_SW, Input 23
{
IF &ALTHOLDbp = 1
{
&keys = 64
&keys = 0
}
}

Var 0071, name VSbp, Link IOCARD_SW, Input 22
{
IF &VSbp = 1
{
&keys = 58
&keys = 0
}
}

Var 0072, name CMDAbp, Link IOCARD_SW, Input 21
{
IF &CMDAbp = 1
{
&keys = 66
&keys = 0
}
}

Var 0073, name CMDBbp, Link IOCARD_SW, Input 19, Type I
{

IF &CMDBbp = 1
{
&keys = 67
&keys = 0
}
}

Var 0074, name CWSAbp, Link IOCARD_SW, Input 20
{
IF &CWSAbp = 1
{
&keys = 65
&keys = 0
}
}

Var 0075, name CWSBbp, Link IOCARD_SW, Input 18
{
IF &CWSBbp = 1
{
&keys = 68
&keys = 0
}
}

Var 0076, name APDISCObp, Link IOCARD_SW, Input 15
{
IF &APDISCObp = 1
{
&keys = 26
&keys = 0
}
ELSE
{
&keys = 26
&keys = 0
}
}

Var 0077, name CObp, Link IOCARD_SW, Input 13
{
IF &CObp = 1
{
&keys = 60
&keys = 0
}
}

Var 0078, name FDRswitch, Link IOCARD_SW, Input 14
{
IF &FDRswitch = 1
{
&keys = 73
&keys = 0
}
ELSE
{
&keys = 73
&keys = 0
}
}


// __________________________________________________________________
// Entradas IOCARD Encoders
//___________________________________________________________________

var 9993, name tempCrseft, value 0
var 9994, name LastCsrLtRot, value 0

var 8102, name PlusCrsLeft, Link SUBRUTINE
{
&CRSRdisplay = &PlusCrsLeft
&tempCrseft = &PlusCrsLeft

if &tempCrseft = &LastCsrLtRot
{
&tempCrseft = 0
}
if &PlusCrsLeft > 0
{
&keys = 45
&keys = 0
}
}

var 8103, name MinusCsrLeft, Link SUBRUTINE
{
&tempCrseft = &MinusCsrLeft

if &tempCrseft = &LastCsrLtRot
{
&tempCrseft = 0
}
if &MinusCsrLeft > 0
{
&keys = 46
&keys = 0
}
}

Var 0080, name CRSLEFTrt, Link IOCARD_ENCODER, Input 4, Aceleration 8, Type 2
{

if &CRSLEFTrt > 0
{
IF &tempCrseft = 0
{
&LastCsrLtRot = &CRSLEFTrt
&PlusCrsLeft = 0
&PlusCrsLeft = TIMER &CRSLEFTrt 1 1
}
}
else
{

IF &tempCrseft = 0
{
L1 = &CRSLEFTrt * -1
&LastCsrLtRot = L1
&MinusCsrLeft = 0
&MinusCsrLeft = TIMER L1 1 1
}
}
}

Var 0081, name IASrot, Link IOCARD_ENCODER, Input 0, Aceleration 1, Type 2
{
IF &IASrot = 1
{
&keys = 49
&keys = 0
}
ELSE
{
&keys = 50
&keys = 0
}
}

var 9991, name temphdg, value 0
var 9992, name LastHDGRot, value 0
var 8100, name Plus, Link SUBRUTINE
{
&temphdg = &plus

if &temphdg = &LastHDGRot
{
&temphdg = 0
}
if &plus > 0
{
&KEYS = 47
&KEYS = 0
}
}

var 8101, name Minus, Link SUBRUTINE
{
&temphdg = &Minus

if &temphdg = &LastHDGRot
{
&temphdg = 0
}
if &minus > 0
{
&KEYS = 48
&KEYS = 0
}
}




Var 9082, name HDGrot, Link IOCARD_ENCODER, Input 6, Aceleration 6, Type 2
{

if &HDGrot > 0
{
IF &temphdg = 0
{
&LastHDGRot = &HDGrot
&Plus = 0
&Plus = TIMER &HDGrot 1 1
}
}
else
{

IF &temphdg = 0
{
L1 = &HDGrot * -1
&LastHDGRot = L1
&Minus = 0
&Minus = TIMER L1 1 1
}
}



CALL &HDGaff

}

var 9001, name tempAlt, value 0
var 9002, name LastAlt, value 0

var 8104, name PlusAlt, Link SUBRUTINE
{

&tempAlt = &PlusAlt

if &tempAlt = &LastAlt
{
&tempAlt = 0
}
if &PlusAlt > 0
{
&keys = 53
&keys = 0
}
}

var 8105, name MinusAlt, Link SUBRUTINE
{
&tempAlt = &MinusAlt

if &tempAlt = &LastAlt
{
&tempAlt = 0
}
if &MinusAlt > 0
{
&keys = 52
&keys = 0
}
}


Var 0083, name ALTrot, Link IOCARD_ENCODER, Input 2, Aceleration 3, Type 2
{
if &ALTrot > 0
{
IF &tempAlt = 0
{
&LastAlt = &ALTrot
&PlusAlt = 0
&PlusAlt = TIMER &ALTrot 1 1
}
}
else
{

IF &tempAlt = 0
{
L1 = &ALTrot * -1
&LastAlt = L1
&MinusAlt = 0
&MinusAlt = TIMER L1 1 1
}
}




CALL &ALTaff

}

Var 0084, name VSrot, Link IOCARD_ENCODER, Input 11, Aceleration 1, Type 2
{
IF &VSrot = 1
{
&keys = 54
&keys = 0
}
ELSE
{
&keys = 55
&keys = 0
}
}
Var 0999 name FO_JoyStick64 Link FSUIPC_OUT Offset $3340 Length 4
Var 0085, name CRSRIGHTrot, Link IOCARD_ENCODER, Input 9, Aceleration 1, Type 2
{

IF &CRSRIGHTrot = 1
{
&FO_JoyStick64 = CHANGEBIT 0 1
&FO_JoyStick64 = CHANGEBIT 0 0
&VORLOCled = &CRSRIGHTrot
}
}


//__________________________________________________________________
// Rutinas de visulaización
//__________________________________________________________________

Var 9999, name VSaff, Link SUBRUTINE
{
IF &VSled = 1
{
IF &VSpmdg < 60000
{
&VSdisplay = &VSpmdg
&VSminus = 0
}
ELSE
{
L0 = &VSpmdg - 65536
&VSdisplay = L0
&VSminus = 1
}
}
ELSE
{
&VSdisplay = -999999
&VSminus = 0
}
}

Var 9998, name IASaff, Link SUBRUTINE
{
C0 = &SPDINTV = 21
C0 = C0 AND &VNAVled
IF C0
{
&IASdisplay = -999999
}
ELSE
{
IF &COstatus < 4
{
&IASdisplay = &IASpmdg
&IASpoint = 0
}
ELSE
{
L0 = &IASpmdg / &IAS
L0 = L0 * 12800
L0 = L0 * &MACH
&IASdisplay = L0 / 20480
&IASpoint = 1
}

}
}

Var 9997, name HDGaff, Link SUBRUTINE
{

IF &HDGpmdg = 360
{
&MEMHDG = 0
}
ELSE
{
&MEMHDG = &HDGpmdg
}

&HDGdisplay = &MEMHDG
}

Var 9996, name ALTaff, Link SUBRUTINE
{

&MEMALT = &ALTpmdg
&ALTdisplay = &MEMALT
}

Sylle
02-16-2009, 02:48 PM
This is simply fantastic!
After having seen some offsets in the various posts here I had been thinking about how I could use them optimally but you are too quick mate :lol:

Super!
I'll have to check this in the coming days (weeks maybe as real life is getting in the way quite a lot right now)!

MrRoper... We'll need you when PMDG releases the NGX... stick around please :wink:

Thanks again,
Sylle

RadarBob
02-20-2009, 07:35 PM
Sorry if this is an elementary question, but I would be grateful if anyone could explain the mechanism by which IOCP communicates the change in state of the MCP push buttons in the script that Mr Roper has kindly posted.

For example:
I can see that Var 0060 the FD Switch depends on the state of I/O Card input 16, and the action is the &Keys=56/&Keys=0 toggle.

I can also see that the key press required by PMDG is either Ctrl+f or tab+f, so I'm assuming these must be mapped somewhere ? - But I can't see where at the moment.

I was looking at building my own microcontroller based MCP control hardware with a Visual Basic host app, but I was just weighing up whether to go that way or down the Opencockpits route.

Has anybody here tried building their own ?

Rob

MrRoper
02-20-2009, 07:44 PM
the mapping is in the SIOC.cfg file at the bottem, the meanings for these are in the SIOC manual somewhere ;)


IOCP_port=8092

IOCP_timeout=4000

Minimized=No

toggle_delay=20

CONFIG_FILE=.\MCP.txt

IOCard_disable=No

MASTER=0,5,1,0

USBStepper=0,0
USBKeys=0,0
USBServos=0,0
USBRelays=0,0
USBDCmotor=0,0

USBAnalogic=0,0

FSUipcRefresh=100

IOCPclient0_disable=Yes

IOCPclient0_host=localhost

IOCPclient0_port=8090

IOCPclient1_disable=Yes

IOCPclient1_host=localhost

IOCPclient1_port=8099

Sound_disable=yes

Volume=100

Sound=APDis.wav,-1,-1,-1

Sound=*outermk.wav,-1,-1,-1

Sound=*hello.wav

window =Microsoft Flight Simulator 2004 - A Century of flight with WideServer.waiting for clients

#1=
#2=
#3=
#4=
#5=
#6=
#7=
#8=
#9=
#10=
#11=
#12=
#13=
#14=
#15=
#16=
#17=
#18=
#19=
#20=
#21=
#22=
#23=
#24=
#25=
#26=\3\1Y\2\4
#27=
#28=
#29=
#30=
#31=
#32=
#33=
#34=
#35=
#36=
#37=
#38=
#39=
#40=
#41=
#42=
#43=
#44=\1R\2
#45=\3\I\4
#46=\1\G\2
#47=\3\L\4
#48=\3\1H\2\4
#49=\1\O\2
#50=\3\1V\2\4
#51=\3M\4
#52=\3\1Z\2\4
#53=\3\F\4
#54=\3\1\O\2\4
#55=\3\1P\2\4
#56=\3F\4
#57=\3V\4
#58=\3P\4
#59=\3I\4
#60=\1I\2
#61=\3\1N\2\4
#62=\3H\4
#63=\3A\4
#64=\3Z\4
#65=\3\H\4
#66=\3\1A\2\4
#67=\1\H\2
#68=\3\1\H\2\4
#69=\3N\4
#70=\3O\4
#71=\3\I\4
#72=\1\G\2
#73=\3\1\G\2\4
#74=
#75=
#76=
#77=
#78=
#79=
#80=
#81=
#82=
#83=
#84=
#85=
#86=
#87=
#88=
#200=

RadarBob
02-20-2009, 07:56 PM
Ah - The missing link !

Thanks Mr Roper - Do you have any idea how one would get a VB app to send the keypress/scancode to PMDG ?

I guess, one would need to place the data into the keyboard buffer, but I can't see any reference to a method in the VB docs.

Cheers,

Rob

MrRoper
02-21-2009, 08:27 AM
You are probably best using an API to send the key, you might even have to hook into the DirectX input but i doubt it.

Have a look ehre at the SendInput API

http://www.pinvoke.net/default.aspx/user32.SendInput

RadarBob
02-21-2009, 08:53 AM
Thanks Mr Roper - I'll take a look at that link.

I have just found the statement sendkeys string this morning though.

I have tried it with the FD switch, and it works ok.


Rob