View Full Version : SIOC Code
Polmer
12-10-2006, 02:12 AM
Hello,
I have built a MCP using opencockpits I/O card and it works using the simple I/O software, But I have read that a much more flexible way to go is writing my own SIOC code. Opencockpits has several examples of how to set up a MCP ( with SIOC), but they all seem to have some bugs.
Nico has a great examples of how to set up a MCP correclty using SIOC and the Level-D 767, but this panel is not compatable with project magenta, So I cannot use these offsets and code....*sigh*.
In the mean time, I have been reading & re-reading reading examples of this code writing, but have not been able to put my arms fully around it yet.
So, If anybody has any SIOC code for fs2004 MCP I would love if I could take a look at it.
Polmer
Matt Olieman
12-10-2006, 10:29 AM
I'd be interested too. I've been on a long sabbatical from building and never got to use my I/O cards.
So any information related to I/O cards (simplified) would be helpfully for me to ;)
Polmer
12-16-2006, 12:54 PM
Ok,
Here is an example of some SIOC code that will show how to get the Heading of an MCP to both read and write. you can use your mouse to change heading and it will change the 7 segment display, or you can use the encoder and i will show up in the FS panel. Same with the switch and LED read out. This is based off oc Nico's Level D 767 code but I have changed the offsets to work with any generic fsX or fs2004 panel.
I am using the Opencockpit I/O card, along with the latest version of SIOC.
// *****************************************************************************
// * Config_SIOC ver 3.3 - By Manolo Vélez - www.opencockpits.com
// *****************************************************************************
// * FileName : Heading Example.txt
// * Date : 12/16/2006
///Tom Koresch
/// here is an example of how to get both read and write capabilities using heading as an example. Based off of Nico's example code. Thanks //Nico!
Var 0001, name X_HDG, Link FSUIPC_INOUT, Offset $07CC, Length 2
{
L0 = DIV &X_HDG ,182
IF &HDG <> L0
{
&HDG = L0
}
}
Var 0002, name HDG
{
CALL &OutHDG
}
Var 0003, name OutHDG, Link SUBRUTINE
{
&D_HDG = &HDG
L0 = &HDG * 182
IF &X_HDG <> L0
{
&X_HDG = L0
}
}
Var 0004, name RO_HDG, Link IOCARD_ENCODER, Input 6, Aceleration 4, Type 2
{
L0 = &RO_HDG // * -1 turning right should be plus
&HDG = ROTATE 0 ,359 ,L0
}
Var 0005, name D_HDG, Link IOCARD_DISPLAY, Digit 0, Numbers 3
Var 0006, Link FSUIPC_INOUT, Offset $07C8, Length 4
{
IF V0006 = 1
{
V0007 = 1
}
ELSE
{
V0007 = 0
}
}
Var 0007, Link IOCARD_OUT, Output 15 // Heading LED
Var 0008, Link IOCARD_SW, Input 15, Type P // Heading Swich
{
IF V0008 = 1
{
V0006 = 1
}
ELSE
{
V0006 = 0
}
}
Tom
Bob Reed
12-16-2006, 01:53 PM
Ya know..... I hate to throw this out there but I can not help it... This looks (I am not implying anything here other then I have seen this or very close myself) like EPIC code! Looks like these cards are VERY powerful indeed. I know there is not much (if ya know how) you can not do with EPIC and these look simaler. VERY NICE!!!!!!
Polmer
12-17-2006, 12:20 AM
Well,
I have heard great things about the epIC card, but dont know anything about what the code looks like, but I will say this......The combination of the flexible software and relatively inexpensive I/O ( opencockpits) card make this appealing to the budget constrained builder ( like me).
Tom
Polmer
12-28-2006, 10:37 AM
I have noticed some fluttering and delay with the initial code displayed above,
and after some improvements, have got it to work much better...but with a catch.
For some reason, default fs2004 panels & FSX panels act differently to this (read and write). Since I am still running fs2004 ( dont have the system to run fsx), I was interested is getting it to work smoothly in that enviroment.
The meat of the change is that it uses the equation; 65536/359, rather than 65536/360.
I am very new to writing code, but here is a messy version I got to work with Default fs2004 panels, in Sync and no fluttering;
Code for Default fs2004 heading with read and write capabilites;
=========================================================
Var 0600, Link IOCARD_DISPLAY, Digit 0, Numbers 3
Var 0500, Link IOCARD_ENCODER, Input 6, Aceleration 6, Type 2
{
L0 = V0500 * 1
V0900 = ROTATE 0 ,359 ,L0
}
Var 0005, Link FSUIPC_OUT, Offset $07CC, Length 2
Var 0305, Link SUBRUTINE
{
V0600 = V0900
L0 = V0900 * 182.55153203
IF V0005 <> L0
{
V0005 = L0
}
}
Var 0800, Link FSUIPC_IN, Offset $07CC, Length 2
{
L0 = V0800 / 182.55153203
L0 = L0
IF V0900 <> L0
{
V0900 = L0
}
}
Var 0900 // 900
{
CALL V0305
}
For FSX, this code both Read and writes
=====================================================================
Var 0600, Link IOCARD_DISPLAY, Digit 0, Numbers 3
Var 0500, Link IOCARD_ENCODER, Input 6, Aceleration 6, Type 2
{
L0 = V0500 * 1
V0900 = ROTATE 1 ,360 ,L0
}
Var 0005, Link FSUIPC_OUT, Offset $07CC, Length 2
Var 0305, Link SUBRUTINE
{
V0600 = V0900
L0 = V0900 * 182.0444444
IF V0005 <> L0
{
V0005 = L0
}
}
Var 0800, Link FSUIPC_IN, Offset $07CC, Length 2
{
L0 = V0800 / 182.0444444
L0 = L0
IF V0900 <> L0
{
V0900 = L0
}
}
Var 0900 // 900
{
CALL V0305
}
This same code can be modified to work with course as well.
Polmer
Matt Olieman
12-28-2006, 10:49 AM
Excellent info... thanks for the code :) This is very helpful.