peterkwu
02-10-2010, 05:52 PM
I'm trying to wire up a real LE devices annunciator for a B737 aft overhead. I want the yellow transit lights to come on at the appropriate time, e.g. when the devices are actually in transit.
My question is, how do I detect a changing value in SIOC? I'm successfully reading in the appropriate offset with FSUIPC, but I want to know when the value changed compared to the last time the offset value was updated. That way, I can turn the transit lights on when the value changes, and off when the value is constant.
My code is below. Any comments appreciated.
--
Var 0079, name LastFlapsPos
Var 0080, name FlapsTrlEdge, Link FSUIPC_IN, Offset $30E0, Length 2
{
L1 = 0
L1 = V0080 - V0079
IF L1 <> 0
{//light transit lights
&LAMP3 = 1
&LAMP6 = 1
&LAMP9 = 1
&LAMP12 = 1
&LAMP14 = 1
&LAMP17 = 1
&LAMP19 = 1
&LAMP22 = 1
&LAMP25 = 1
&LAMP28 = 1
}
IF L1 = 0
{//turn off transit lights
&LAMP3 = 0
&LAMP6 = 0
&LAMP9 = 0
&LAMP12 = 0
&LAMP14 = 0
&LAMP17 = 0
&LAMP19 = 0
&LAMP22 = 0
&LAMP25 = 0
&LAMP28 = 0
}
IF V0080 > 0
{//light extended lights
&LAMP10 = 1
&LAMP13 = 1
&LAMP15 = 1
&LAMP16 = 1
&LAMP18 = 1
&LAMP21 = 1
}
ELSE
{//turn off extended lights
&LAMP10 = 0
&LAMP13 = 0
&LAMP15 = 0
&LAMP16 = 0
&LAMP18 = 0
&LAMP21 = 0
}
L0 = V0080
V0079 = L0
}
deering
02-11-2010, 03:19 PM
Hello Peter.
SIOC will drive your script if, and only if, the subject variable changes.
IF L1 <> 0
will always be true after the first time.
IF L1 = 0
{//turn off transit lights
will never be executed after the first time.
IF V0080 > 0
{//light extended lights
will give green in addition to yellow during transit.
The question is how does one detect that the value has stopped changing and the required setting has been achieved.
That could be done by observing the position of the flap lever, translating that to the desired flap extension and setting
the lights according to the match with the values received from FSUIPC.
I tried the following script and it seemed O.K. Maybe you can use it.
Jim.
============================================
//
// The axis increment per notch is in offset $3BFA (2)
// But it won't change after the aircraft is initialized
// So better use a constant.
//
Var 1500, name FlapStep, Value 2048 // Per notch increment in axis value
Var 1501, name FS_FlapSet, Link FSUIPC_IN, Offset $BDC, Length 4 // Lever position
{
L0 = &FS_FlapSet
L0 = L0 / &FlapStep
L0 = ROUND L0 // As Notch number
// Set target position as degrees * 256
IF L0 = 0
{
&FlapTarget = 0
}
IF L0 = 1
{
&FlapTarget = 256
}
IF L0 = 2
{
&FlapTarget = 512
}
IF L0 = 3
{
&FlapTarget = 1280
}
IF L0 = 4
{
&FlapTarget = 2560
}
IF L0 = 5
{
&FlapTarget = 3840
}
IF L0 = 6
{
&FlapTarget = 6400
}
IF L0 = 7
{
&FlapTarget = 7680
}
IF L0 = 8
{
&FlapTarget = 10240
}
}
Var 1502, name FS_FlapCurt, Link FSUIPC_IN, Offset $30F0, Length 2 // Current degrees deployed * 256
{
IF &FS_FlapCurt <> &FlapTarget // In transit?
{
-transit lights on
-deployed lights off
}
ELSE
{
IF &FlapTarget = 0 // Fully retracted?
{
-transit lights off
-deployed lights off
}
ELSE // Deployed
{
-transit lights off
-deployed lights on
}
}
}
Var 1503, name FlapTarget
peterkwu
02-11-2010, 07:05 PM
Jim,
Thanks so much. I woke up in the middle of the night last night thinking how I could compare the flap lever position to the actual position of the flaps, but hadn't thought through how to implement it.
Your script worked the first time once I filled in the appropriate light assignments. I added another IF-ELSE condition to account for intermediate slat positions, which occur at 1, 2 and 5 degrees of trailing edge flaps, according to the Continental Airlines ops book for the 737NG.
I'll post a video soon to get some opinions as to whether it works as it should in the real airplane.
The completed script is below:
// *****************************************************************************
// * Config_SIOC ver 3.7B1 - By Manolo Vélez - www.opencockpits.com
// *****************************************************************************
// * FileName : sioc.txt
// * Date : 1/30/2010
Var 0000, name inicializa, Value 0
{
//&DIR = 1
//enable the following line to run the sequential lamptest routine
//CALL &lamptest
//&timer = TIMER 99 ,0 ,100
//CALL &AnalyzeLEFlaps
}
Var 1803, name LAMP3, Link IOCARD_OUT, Device 1, Output 3
Var 1804, name LAMP4, Link IOCARD_OUT, Device 1, Output 4
Var 1805, name LAMP5, Link IOCARD_OUT, Device 1, Output 5
Var 1806, name LAMP6, Link IOCARD_OUT, Device 1, Output 6
Var 1807, name LAMP7, Link IOCARD_OUT, Device 1, Output 7
Var 1808, name LAMP8, Link IOCARD_OUT, Device 1, Output 8
Var 1809, name LAMP9, Link IOCARD_OUT, Device 1, Output 9
Var 1810, name LAMP10, Link IOCARD_OUT, Device 1, Output 10
Var 1811, name LAMP11, Link IOCARD_OUT, Device 1, Output 11
Var 1812, name LAMP12, Link IOCARD_OUT, Device 1, Output 12
Var 1813, name LAMP13, Link IOCARD_OUT, Device 1, Output 13
Var 1814, name LAMP14, Link IOCARD_OUT, Device 1, Output 14
Var 1815, name LAMP15, Link IOCARD_OUT, Device 1, Output 15
Var 1816, name LAMP16, Link IOCARD_OUT, Device 1, Output 16
Var 1817, name LAMP17, Link IOCARD_OUT, Device 1, Output 17
Var 1818, name LAMP18, Link IOCARD_OUT, Device 1, Output 18
Var 1819, name LAMP19, Link IOCARD_OUT, Device 1, Output 19
Var 1821, name LAMP21, Link IOCARD_OUT, Device 1, Output 21
Var 1822, name LAMP22, Link IOCARD_OUT, Device 1, Output 22
Var 1823, name LAMP23, Link IOCARD_OUT, Device 1, Output 23
Var 1824, name LAMP24, Link IOCARD_OUT, Device 1, Output 24
Var 1825, name LAMP25, Link IOCARD_OUT, Device 1, Output 25
Var 1826, name LAMP26, Link IOCARD_OUT, Device 1, Output 26
Var 1827, name LAMP27, Link IOCARD_OUT, Device 1, Output 27
Var 1828, name LAMP28, Link IOCARD_OUT, Device 1, Output 28
// The axis increment per notch is in offset $3BFA (2)
// But it won't change after the aircraft is initialized
// So better use a constant.
//
Var 1500, name FlapStep, Value 2048 // Per notch increment in axis value
Var 1501, name FS_FlapSet, Link FSUIPC_IN, Offset $BDC, Length 4
{
L0 = &FS_FlapSet
L0 = L0 / &FlapStep
L0 = ROUND L0 // As Notch number
// Set target position as degrees * 256
IF L0 = 0
{
&FlapTarget = 0
}
IF L0 = 1
{
&FlapTarget = 256
}
IF L0 = 2
{
&FlapTarget = 512
}
IF L0 = 3
{
&FlapTarget = 1280
}
IF L0 = 4
{
&FlapTarget = 2560
}
IF L0 = 5
{
&FlapTarget = 3840
}
IF L0 = 6
{
&FlapTarget = 6400
}
IF L0 = 7
{
&FlapTarget = 7680
}
IF L0 = 8
{
&FlapTarget = 10240
}
}
Var 1502, name FS_FlapCurt, Link FSUIPC_IN, Offset $30F0, Length 2 // Current degrees deployed * 256
{
IF &FS_FlapCurt <> &FlapTarget // In transit?
{
&LAMP3 = 1
&LAMP6 = 1
&LAMP9 = 1
&LAMP12 = 1
&LAMP14 = 1
&LAMP17 = 1
&LAMP19 = 1
&LAMP22 = 1
&LAMP25 = 1
&LAMP28 = 1
&LAMP4 = 0
&LAMP5 = 0
&LAMP7 = 0
&LAMP8 = 0
&LAMP10 = 0
&LAMP13 = 0
&LAMP15 = 0
&LAMP16 = 0
&LAMP18 = 0
&LAMP21 = 0
&LAMP23 = 0
&LAMP24 = 0
&LAMP26 = 0
&LAMP27 = 0
}
ELSE
{
IF &FlapTarget = 0 // Fully retracted?
{
&LAMP3 = 0
&LAMP6 = 0
&LAMP9 = 0
&LAMP12 = 0
&LAMP14 = 0
&LAMP17 = 0
&LAMP19 = 0
&LAMP22 = 0
&LAMP25 = 0
&LAMP28 = 0
&LAMP4 = 0
&LAMP5 = 0
&LAMP7 = 0
&LAMP8 = 0
&LAMP10 = 0
&LAMP13 = 0
&LAMP15 = 0
&LAMP16 = 0
&LAMP18 = 0
&LAMP21 = 0
&LAMP23 = 0
&LAMP24 = 0
&LAMP26 = 0
&LAMP27 = 0
}
ELSE // Deployed
{
IF &FlapTarget < 1000 // 1,2 and 5 degrees of trailing edge flaps
{
&LAMP3 = 0
&LAMP6 = 0
&LAMP9 = 0
&LAMP12 = 0
&LAMP14 = 0
&LAMP17 = 0
&LAMP19 = 0
&LAMP22 = 0
&LAMP25 = 0
&LAMP28 = 0
&LAMP4 = 1
&LAMP5 = 0
&LAMP7 = 1
&LAMP8 = 0
&LAMP10 = 1
&LAMP13 = 1
&LAMP15 = 1
&LAMP16 = 1
&LAMP18 = 1
&LAMP21 = 1
&LAMP23 = 0
&LAMP24 = 1
&LAMP26 = 0
&LAMP27 = 1
}
ELSE // 10-40 degrees of trailing edge flaps
{
&LAMP3 = 0
&LAMP6 = 0
&LAMP9 = 0
&LAMP12 = 0
&LAMP14 = 0
&LAMP17 = 0
&LAMP19 = 0
&LAMP22 = 0
&LAMP25 = 0
&LAMP28 = 0
&LAMP4 = 0
&LAMP5 = 1
&LAMP7 = 0
&LAMP8 = 1
&LAMP10 = 1
&LAMP13 = 1
&LAMP15 = 1
&LAMP16 = 1
&LAMP18 = 1
&LAMP21 = 1
&LAMP23 = 1
&LAMP24 = 0
&LAMP26 = 0
&LAMP27 = 1
}
}
}
}
Var 1503, name FlapTarget
deering
02-11-2010, 08:26 PM
You're welcome, Peter.
I don't do 737 so I can't help with what the a/c actually does.
I'm wondering about your lights. Seems like you could connect some of them together and save some - well, a lot of - output ports.
Jim.