#How to use Or logic with input devices

1 messages · Page 1 of 1 (latest)

fallen jetty
#

On the 787 there are 2 toggle switches for Flight Director I want to make it if atleast one of those switches are on its on, if both are on its on, if none are on then its off how do I achieve this in mobiflight
the code for flight director is: (if that helps)
(>K:TOGGLE_FLIGHT_DIRECTOR)

fallen jetty
#

Set Code is this:
p0 1 min 0 max (>O:AUTOPILOT_FD_1_Mode_Position) 1 if{
1 (>K:TOGGLE_FLIGHT_DIRECTOR)
} 1 (>O:_ButtonAnimVar) (A:AUTOPILOT FLIGHT DIRECTOR ACTIVE:1, Bool) sp0 1 0 l0 ? (>O:AUTOPILOT_FD_1_Mode_Position)

#

if needed

mild basin
#

how does it behave in the airplane?
See the 1 before the K: event call? That tells the event code which Flight Director button was pressed.

fallen jetty
#

is there a way to add logic so it checks if the switch is toggled and if so then it wont do anything?

mild basin
#

stupid question maybe, are you using latching switches for this?

fallen jetty
mild basin
#

any kind where the state is latched, either on or off, not like a push button that is on only when pushed.

fallen jetty
#

o yes

#

ye i am

mild basin
#

because with push buttons, the toggle event turns on or off with every push.

fallen jetty
#

ye i get what you mean

#

the way im doing it is that i have it as on pressed as the on state and the on reallse as the off state

mild basin
#

this variable (A:AUTOPILOT FLIGHT DIRECTOR ACTIVE, bool) tells whether the Flight Director is on or off

fallen jetty
#

yes

mild basin
#

do you have two flight director switches left and right side?

fallen jetty
#

yep

mild basin
#

that is a problem

#

the variable only knows if the Flight director is on or off

#

not what is the state of the left or right switch

fallen jetty
#

all I need it to do

#

is that if one of them are on all of flight director is on

#

and if both are on its on

#

and if both are off its off

mild basin
#

you also said that both needed to be off for flight director to be off

fallen jetty
#

yes

mild basin
#

that is a problem

#

because we only have one variable

#

you will need to create one Lvar for the left switch and another for the right switch.

fallen jetty
#

how would i do that

mild basin
#

wait, let's discuss this a bit

#

with on and off events, we can make either switch turn the system on and the other switch will do nothing if turned on.

fallen jetty
#

yea

mild basin
#

why would you require both switches to turn off in order to turn the system off???

#

if the Capt wants to turn it off, he simply flicks his switch off.

#

regardless of the state of the FO switch

#

which is really how the pushbuttons work

fallen jetty
#

hm

mild basin
#

because you have latching switches, if the FO turned FD on, but the capt wants to turn it off, he will need to flick his switch to on and then to off.

#

in your design, both Capt and FO would need to turn their switch to off, in order to turn the FD off. which sounds kind of weird to me.

fallen jetty
#

the issue with having it with what you ar suggesting is that you would end up with it being confused if lets say the capt's switch is on and the FO's is on and the FO switches it off and the captain doesnt then it would turn off when it shouldnt (if i am understanding correctly)

mild basin
#

why wouldn-t it turn off if the FO has the command and wants to turn it off. Only one pilot flies at any given time.

#

another stupid question, why did you choose to install latching switches for this function???

fallen jetty
mild basin
#

what? the 787 has latching switches?

#

hang on, I need to see that... I never fly the 787

fallen jetty
#

here is the fd switch

mild basin
#

ok, but then most likely the sim logic knows how to handle this

#

give 5 minutes to load that aircraft

fallen jetty
mild basin
#

lol

#

did you try flicking those switches on both sides. They both move at the same time.

fallen jetty
#

yes i know

mild basin
#

so technically they act like push buttons

fallen jetty
#

them moving at the same time is a limitation of the sim

#

is it possible

mild basin
#

I said it wrong

fallen jetty
#

to make it so if one is on then the other switch does nothing?

mild basin
#

they don't act like push buttons... rather they act like one switch, not like two.

fallen jetty
#

yea

mild basin
#

wait, do you actually know how they behave in the real aircraft_

#

the sim doesn't have that limitation

fallen jetty
mild basin
#

I am sure the switches can be independent in the sim. There is no obligation for them to be moving in sync

#

unless the airplane does it like that

fallen jetty
#

There are 2 output variables
(A:AUTOPILOT FLIGHT DIRECTOR ACTIVE:1, Bool)
(A:AUTOPILOT FLIGHT DIRECTOR ACTIVE:2, Bool)

#

but there is only 1 Kvar

#

there are 2 Ovars but those are inaccessible

mild basin
#

I have just tested both FD events and both FD variables

#

they all work in sync

#

both K events with 1 or 2 indices will both change both A: variables at the same time

#

they work as if there is only one switch and one variable

#

if one changes the other changes in sync

fallen jetty
#

hm

#

so do you think you can make it so if one switch is on the other is basicly disabled

mild basin
#

I can do what you requested initially, I never said it was impossible, just weird

#

or what you request now, also weird IMHO.

mild basin
#

LEFT ON EVENT, may not be perfect on the first round.

(A:AUTOPILOT FLIGHT DIRECTOR ACTIVE:1, Bool) ! 
   if{ 1 (>K:TOGGLE_FLIGHT_DIRECTOR) }
1 (>L:FD1_IS_ON,Bool)
#

LEFT OFF EVENT

(A:AUTOPILOT FLIGHT DIRECTOR ACTIVE:1, Bool) (L:FD2_IS_ON) ! and
   if{ 1 (>K:TOGGLE_FLIGHT_DIRECTOR) }
0 (>L:FD1_IS_ON,Bool)
#

RIGHT ON EVENT,

(A:AUTOPILOT FLIGHT DIRECTOR ACTIVE:2, Bool) ! 
   if{ 2 (>K:TOGGLE_FLIGHT_DIRECTOR) }
1 (>L:FD2_IS_ON,Bool)
#

RIGHT OFF EVENT,

(A:AUTOPILOT FLIGHT DIRECTOR ACTIVE:2, Bool)  (L:FD1_IS_ON) ! and  
   if{ 2 (>K:TOGGLE_FLIGHT_DIRECTOR) }
0 (>L:FD2_IS_ON,Bool)
#

ok try those

#

either switch will turn on

#

if the system is on, the switch moved to on does nothing

#

if you turn one switch to off, the other switch must already be in off, for the system to turn off.

fallen jetty
#

alr thank you so much lemme quicly test this and ill tell you how it works

#

hm rthe right switch seems to be turning FD off when the left switch is still on

#

the left switch doesnt do this

mild basin
#

double check the code

#

maybe restart Mobiflight too.

#

you can create output configs for all the variables so you can monitor their values.

#

and also, both switches must be off when you start the sim because the default value of any Lvar is 0 or off.

#

or you have auto retrigger enabled.

fallen jetty
mild basin
#

Auto retrigger is in Extras Settings

#

I think default is on

fallen jetty
fallen jetty
#

@mild basin I’ve tried both and neither have worked

mild basin
#

what is the behavior?

#

I tried the events with two toggle switches in my panel and they work as expected.

#

you are putting the ON to On Press and OFF to On Release, correct?

#

Show screenshots of your four input configs please

fallen jetty
#

sorry for the late response but here

#

the pilot side on press and on release is reverse because i made a mistake with soldering the toggle switch and did it the wrong way lol

fallen jetty
#

i have to sleep now so if i dont respond for a while thats why sorry in advance if there is any update send it here and ill check it in the morning

mild basin
#

the pilot side events seem to be inverted

#

are your toggles wired inverted i.e. up is off and down is on????

fallen jetty
#

The FO side inst

mild basin
#

Can't you turn the switch around so that up is on? I am thinking this makes a difference in how the auto retrigger is handled.

fallen jetty
fallen jetty
#

wait now its working perfectly

#

thank you so much for your help with this

#

i was stuck on it for days lmao

mild basin
fallen jetty