# Need help linking two Variables together

## Recommended Posts

I have a problem with some code. What I want to happen is when the APU EGT is 250 or greater and the APU Generator is on, it provides electrical power for the rest of my Gauges (ie) Engine EICASThis is the code I have so far:(L:APU Generator, bool) 1 == if{ (L:APU EGT, Celsius) 250 &gt == if{ (L:DC Power, bool) 1 (>L:DC Power, bool) } } But this does nothing, so I made the code a little bit easier, and thought I would get this to work first then add the APU EGT to it after I had got that working.So this is the code made a little easier:(L:APU Generator, bool) if{ 1 (L:DC Power, bool) 1 (>L:DC Power, bool) } Now this turns on the DC Power when the APU Generator is pressed, so I thought it would be easy to get it to turn it back off again with this code.(L:APU Generator, bool) if{ 0 (L:DC Power, bool) 0 (>L:DC Power, bool) } No such luck, turns the EICAS Screen on, but does not turn it off again, the APU Gen switch turn on and off like it should and turn the DC Power on, but not off.I am also having this trouble with an hydraulic switch. I have got the Elec hydraulic to work using L:Var, and with help from this forum, but the Engine Hydraulics Pressure need two varibles to be on to work (ie)Engines running and switch to be on, hydraulic pressure on, if one of these is off then the Hydraulic pressure is off.This is the code I have for this.(L:Left hydraulic switch, enum) 1 == if{ (A:Turb eng1 n2,percent) == if{ 20 > (L:Left hydraulic pressure, psi) 10 + 3010 min } } els { (L:Left hydraulic switch, enum) 1 == if{ (A:Turb eng1 n2,percent) == if{ 20 < (L:Left hydraulic pressure, psi) 10 -20 max } } This is the code I use that gets the center hydraulic switches to work together, but does not seem to work on anyhing else I try.(L:Center Hydraulic Switch 1, enum) 1 == if{ (L:Center Hydraulic Switch 2, enum) 1 == if{ (L:Center hydraulic pressure, psi) 10 + 2920 min (>L:Center hydraulic pressure, psi) } }Help !

##### Share on other sites
 Help AVSIM continue to serve you!Please donate today!

Hello (L:APU Generator, bool) 1 == if{ (L:APU EGT, Celsius) 250 > == if{ (L:DC Power, bool) 1 (>L:DC Power, bool) } } (L:APU Generator, bool) if{ 0 (L:DC Power, bool) 0 (>L:DC Power, bool) } Try (L:APU Generator, bool) (L:APU EGT, Celsius) 250 >= & if{ ( 1 (>L:DC Power, bool) }(L:APU Generator, bool) ! if{ 0 (>L:DC Power, bool) }

##### Share on other sites

Hello Sorry missed the bracket, use this. (L:APU Generator, bool) 1 == if{ (L:APU EGT, Celsius) 250 > == if{ (L:DC Power, bool) 1 (>L:DC Power, bool) } } (L:APU Generator, bool) if{ 0 (L:DC Power, bool) 0 (>L:DC Power, bool) } Try(L:APU Generator, bool) (L:APU EGT, Celsius) 250 >= & if{ 1 (>L:DC Power, bool) }(L:APU Generator, bool) ! if{ 0 (>L:DC Power, bool) }pve

##### Share on other sites

Here's another one using a double condition from a visibility tag. *****NOTE: The location of spaces is critical. If you have too few spaces, it fails. Such is life with IF statements... (L:APU Generator, bool) (L:APU EGT, Celsius) 250 >= && if{ 1 (>L:DC Power, bool) } Written another way for clarity: (L:APU Generator, bool) (L:APU EGT, Celsius) 250 >= && if{ 1 (>L:DC Power, bool) } The offset to the right is because of spaces. I wrote it that way purposely so that you can see where they are.Scott / Vorlin

##### Share on other sites

Hi,Try:(L:APU Generator, bool) (L:APU EGT, Celsius) 250 >= and if{ 1 (>L:DC Power, bool) } els{ 0 (>L:DC Power, bool) } (L:Left hydraulic switch,enum) 1 == (A:Turb eng1 n2,percent) 20 > and if{ (L:Left hydraulic pressure,psi) 10 + 3010 min (>L:Left hydraulic pressure,psi) } els{ (L:Left hydraulic pressure,psi) 10 - 0 max (>L:Left hydraulic pressure,psi) } (L:Center Hydraulic Switch 1,enum) 1 == (L:Center Hydraulic Switch 2,enum) 1 == and if{ (L:Center hydraulic pressure,psi) 10 + 2920 min (>L:Center hydraulic pressure,psi) } els{ (L:Center hydraulic pressure,psi) 10 - 0 max (>L:Center hydraulic pressure,psi) } Hope it helps,Jan"Beatus ille qui procul negotiis..."

##### Share on other sites

Thanks for all the post, will try these and see how I get on.Thanks Russell

##### Share on other sites

HiStill having problems with the two variable to make the engine hydraulics work when the engine is running and the switch is on. Have not tried any of the codes for the APU yet. I have tried Jans code for the left hydraulics, but no luck.There is something I noticed when I was playing around with the code, to get the hydraulic to work with only the Eng N2, percent above 20 I tried this:(A:Turb eng1 n2,percent) 20 >(L:Left hydraulic pressure,psi) 10 + 3010 min (>L:Left hydraulic pressure,psi) } els { (A:Turb eng1 n2,percent) 20 <(L:Left hydraulic pressure,psi) 10 - 20 max (>L:Left hydraulic pressure,psi) } But this did not work so I added if{ 1 after the (A:Turb Eng1 N2,percent) and it worked. So the code looked like this.(A:Turb eng1 n2,percent) 20 > if{ 1 (L:Left hydraulic pressure,psi) 10 + 3010 min (>L:Left hydraulic pressure,psi) } els { (A:Turb eng1 n2,percent) 20 < if{ 1 (L:Left hydraulic pressure,psi) 10 - 20 max (>L:Left hydraulic pressure,psi) } Why does it work with the if{ 1 added, I thought 1 and 0 was only use for off and on, am I correct.With the above code the hydraulic work like the default hydraulic in FS9, when engines are started, hydraulic pressure goes up. But mine works differently, so how can I add (L:left hydraulic switch, enum) in to the code so the switch needs to be on for the hydraulic pressure to increase. Have been trying for the last 4 hours, but what ever I try does not seem to work.Russell

##### Share on other sites

Hi,Here is the working code of my left hydraulic system.You can adapt it for your preferences and take what you need.I don't think the 0 and 1 does something. c (A:General eng1 oil temperature,celsius) 105 > (A:Turb eng1 corrected N1,percent) 106 > | (A:General eng1 exhaust gas temperature,celsius) 620 > | if{ (L:LEFT HYDRAULIC RESERVOIR QUANTITY,number) 0.005 - 0 max (>L:LEFT HYDRAULIC RESERVOIR QUANTITY,number) (L:left hydraulic integrity,number) 0.01 - 0 max (>L:left hydraulic integrity,number) } els{ (L:gnd,bool) (A:Turb eng1 corrected N2,percent) 20 < and if{ (L:LEFT HYDRAULIC RESERVOIR QUANTITY,number) 264 < if{ 264 (>L:Left Hydraulic Reservoir Quantity,number) } (L:left hydraulic integrity,number) 100 < if{ 100 (>L:left hydraulic integrity,number) } } els{ (L:LEFT HYDRAULIC RESERVOIR QUANTITY,number) (>L:LEFT HYDRAULIC RESERVOIR QUANTITY,number) (L:left hydraulic integrity,number) (>L:left hydraulic integrity,number) } } (L:LEFT HYDRAULIC RESERVOIR QUANTITY,number) 100 > if{ (L:Hydraulic Switch1,bool) (A:Turb eng1 N2,percent) 20 > (L:left shutoff valve,bool) and and (L:hydraulic demand switch1,enum) 0 > (L:right IDG AC volts,number) 100 > and | if{ (L:LEFT HYDRAULIC PRESSURE,number) 50 + (A:Turb eng1 N2,percent) 2800 + min (>L:LEFT HYDRAULIC PRESSURE,number) } els{ (L:LEFT HYDRAULIC PRESSURE,number) 50 - 0 max (>L:LEFT HYDRAULIC PRESSURE,number) } } els{ (L:LEFT HYDRAULIC PRESSURE,number) 1 - 0 max (>L:LEFT HYDRAULIC PRESSURE,number) } (L:LEFT HYDRAULIC PRESSURE,number) 1000 < if{ (L:left autopilot failure,bool) ! if{ 1 (>L:left autopilot failure,bool) } (L:left stab trim failure,bool) ! if{ 1 (>L:left stab trim failure,bool) } (L:left aileron failure,bool) ! if{ 1 (>L:left aileron failure,bool) } (L:left rudder failure,bool) ! if{ 1 (>L:left rudder failure,bool) } (L:left spoiler failure,bool) ! if{ 1 (>L:left spoiler failure,bool) } (L:left yawdamper failure,bool) ! if{ 1 (>L:left yawdamper failure,bool) } (L:left reverser failure,bool) ! if{ 1 (>L:left reverser failure,bool) } } els{ (L:left autopilot failure,bool) if{ 0 (>L:left autopilot failure,bool) } (L:left stab trim failure,bool) if{ 0 (>L:left stab trim failure,bool) } (L:left aileron failure,bool) if{ 0 (>L:left aileron failure,bool) } (L:left rudder failure,bool) if{ 0 (>L:left rudder failure,bool) } (L:left spoiler failure,bool) if{ 0 (>L:left spoiler failure,bool) } (L:left yawdamper failure,bool) if{ 0 (>L:left yawdamper failure,bool) } (L:left reverser failure,bool) if{ 0 (>L:left reverser failure,bool) } } (A:General eng1 mixture lever position, percent) 50 < (L:fhl,enum) 3 == | if{ (L:left shutoff valve,bool) if{ 0 (>L:left shutoff valve,bool) } } els{ (L:left shutoff valve,bool) ! if{ 1 (>L:left shutoff valve,bool) } } Hope it helps,Jan"Beatus ille qui procul negotiis..."

##### Share on other sites

Thanks for the code Jan, I think it will be a big help. Russell

## Create an account

Register a new account

• Tom Allensworth,
Founder of AVSIM Online

• ### Hot Spots

• Flight Simulation's Premier Resource!

AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!