Results 1 to 10 of 12
-
08-14-2010, 02:59 PM #1
- Join Date
- Oct 2008
- Location
- ontario
- Posts
- 95
Initializing LED to be Turned Off
Hi,
I have working on my first SIOC script, which is an enhancement of an existing script borrowed from OC's forum to operate a transponder in a GA plane. My intent is to add a rotary switch to select Off, Standby, or Mode C for use in Squawkbox. In addition I would like to add an led to my panel to be lit when the transponder is in Mode C. I have had some success in getting that to work. However I would like the led to be off (ie. unlit) when I first start up FS. It will then turn on when I have rotated the switch to the input position which corresponds with Mode C.
I have gone through Nico's website for explainations of how to initialize variables to do this but am not getting the led to start unlit. When I start FS the led is lit and if I change the switch to the Mode C input and than back to standby it will turn off. Subsequent changes of the swiitch to Mode C will turn the led on and then back to off when switched to standyby.
I don't know how to embed my code into this post so I have attached my .txt file of my script. If someone can have a look at it and offer some suggestions I would be most appreciative.
Thanks, DaveDave Kemp
FS9-BU0836X-GoFlight 166-TH2GO-WideFS-FSUIPC-Opencockpits
-
08-14-2010, 05:06 PM #2
- Join Date
- Jul 2013
- Posts
- 917
Re: Initializing LED to be Turned Off
Dave
Try:-
Var 0, value 0
{
&XPONDER_INIT = 10
&LED_INIT = 20
}
David
-
08-14-2010, 05:57 PM #3
- Join Date
- Oct 2008
- Location
- ontario
- Posts
- 95
Re: Initializing LED to be Turned Off
David,
Thank you very much for your response. Unfortunately it has not done the trick. I am starting to think the problem is not in the initialization of the state of the led but rather in the manner in which I have scripted the rotary switch operation and the read/write statements for FSUIPC. I am going to have another go at it using a simple toggle switch. The offset $0B791 only gives the status of the transponder as standby ( =0) and Mode C ( =1) so the rotary switch is not really necessary. Just thought it would look more authentic rather than a toggle.
Any further thoughts are welcome.
Cheers, DaveDave Kemp
FS9-BU0836X-GoFlight 166-TH2GO-WideFS-FSUIPC-Opencockpits
-
08-14-2010, 10:07 PM #4
- Join Date
- Oct 2008
- Location
- ontario
- Posts
- 95
Re: Initializing LED to be Turned Off
The more I work on this problem, the more I think it has to do with the part of the script which deals with data going back and forth to FSUIPC. I now have a push button connected. When I start FS and hence SIOC, the led lights up (which I don't want). I push the button once and nothing happens to the light nor does the FSUIPC log show the offset being changed. The second time I push the button the led goes out and the offset changes to 0 which is standby mode. The third time I push the button the led lights up and the offset changes to 1.
Based on above I am getting close but still want the led to be unlit at start up and the offset to be correspondingly set to 0.
I have attached the revised SIOC script which uses the push button rather than the rotary switch used in my first attempt.
Any comments are welcome.
Cheers, DaveDave Kemp
FS9-BU0836X-GoFlight 166-TH2GO-WideFS-FSUIPC-Opencockpits
-
08-15-2010, 05:04 AM #5
- Join Date
- Apr 2009
- Location
- Toronto
- Posts
- 125
Re: Initializing LED to be Turned Off
Dave,
according to the SB doc. $7B91 = 0 is Normal(Mode C), 1 = Standby.
Jim.
-
08-15-2010, 05:15 AM #6
- Join Date
- Jul 2013
- Posts
- 917
Re: Initializing LED to be Turned Off
Dave
I see that you have not always defined the "TYPE" for some of the switch inputs. It might be worth doing that as I do not know what SIOC takes as its default
David
-
08-15-2010, 02:28 PM #7
- Join Date
- Oct 2008
- Location
- ontario
- Posts
- 95
Re: Initializing LED to be Turned Off
Jim and David,
Thanks again for helping out with this and I am getting closer to what I want the script to do.
Jim you are right about the offset, oversight on my part. I have now changed the script to reflect 0 is Normal(Mode C), 1 = Standby. So now when I start FS and SIOC the led stays unlit as I am wanting and according to the FSUIPC log file the offset is set to 1. So far so good. However when I push the button there is no response in the FS or SIOC. The log file does not show the button push and the led does not light. However when I push the button a second time the led lights and the log file shows the offset state changing to 1. As it should and things are synchronized between the led and the offset. This remains the case for all subsequent button pushes. So the question is why does the first button push not get recognized?
Below is the portion of the script which deals with this. Again any thoughts or suggestions are appreciated.
Var 0135, Link FSUIPC_OUT, Offset $7b91, Length 1 // sets transponder mode based on input from push button
Var 0138, Link IOCARD_SW, Input 13, Type P // Push Button for Transponder Mode
{
V0135 = V0138
}
Var 0139, name XPONDER_STATE, Link FSUIPC_IN Offset $7b91 Length 1 // state of transponder to set led
{
IF &XPONDER_STATE = 0
{
&XPONDER_LED = 1
}
ELSE
{
&XPONDER_LED = 0
}
}
Var 0140, name XPONDER_LED, Link IOCARD_OUT Output 23 // led to indicate standby or Mode C
Cheers, DaveDave Kemp
FS9-BU0836X-GoFlight 166-TH2GO-WideFS-FSUIPC-Opencockpits
-
08-15-2010, 03:17 PM #8
- Join Date
- Apr 2009
- Location
- Toronto
- Posts
- 125
Re: Initializing LED to be Turned Off
Dave,
after initialization, the transponder is in Standy and XPONDER_STATE = 1. When you push the button for the first time V138 = 1 which you assign to V135.
V135=XPONDER_STATE and was already set to 1 before you make that assignment. As the vaue does not change, the attached script is not driven by SIOC. From here on you're in synch. You can assign V0138 = 1 in your initialization script to get off on the right foot.
Jim.
-
08-15-2010, 03:51 PM #9
- Join Date
- Oct 2008
- Location
- ontario
- Posts
- 95
Re: Initializing LED to be Turned Off
Jim,
Continued thanks for your thoughts on this. I initialized V0138 =1 and no luck. I also tried setting V0135 = 1 at initialization eventhough it should already have that as an initial value and that didn't work either.
I will on this and hopefully something does the trick.
Cheers, DaveDave Kemp
FS9-BU0836X-GoFlight 166-TH2GO-WideFS-FSUIPC-Opencockpits
-
08-15-2010, 04:10 PM #10
- Join Date
- Apr 2009
- Location
- Toronto
- Posts
- 125
Re: Initializing LED to be Turned Off
Dave,
I know that SIOC won't let you set an initialization value on the declaration of an input; but, I tested it with VAR0 initialization and it appeared to work O.K.
You could:
Code:Var 0138, Link IOCARD_SW, Input 13, Type P // Push Button for Transponder Mode { V0135 = CHANGEBITN 0 V0138 }
JimLast edited by deering; 08-15-2010 at 08:32 PM. Reason: Correction as below
Candid connections: Platform for casual relationships Live Women Prime Сasual Dating
Super Сasual Dating - Genuine...