MobiFlight Community Support

Welcome to the forum for MobiFlight! Feel free to reach out to the community in case you have questions, issues or just want to share great ideas or details about your latest home cockpit project.

You like MobiFlight? Donate via PayPal and support the MobiFlight development. Thanks! 

icon
Avatar
Banzai
From: France
Posts: 89
Hi

I am looking for an idea to make the rotary switches work with xplane
these rotary switches are configured in xplane as encoders with an up and down function for the control
and not a function for each position Is there a solution like a transform formula?
to use the eight position of the rotary switch like 0 to 1 ,1 to 2 , 2 to 3......
and the reverse 8 to 7 , 7 to 6, .......
or with multiple input:confused:
2021-03-24 19:33
Avatar
Banzai
From: France
Posts: 89
up

i can read an offset who give the position of the switch 1,2,3,4,5,6....
so i can use the precondition input ?
2021-03-27 12:40
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 5979
Supporter
This Thematic is Difficult !

A Enocder and a Rotary Switch are electrical ( and also in Programming) two fully different things.

A Encoder not know its current Position. So we can not say "Do Something if you in exactly THIS Detent"
The advantage of a Encoder.... It detect in witch direction you turn it. If you move it one detent the encoder know if it moved Left or Right.
So in easy words... A Encoder is techncial the same like 2 Single Push Buttons..... If it turn Left it simulate a Press of Button A..... If it turn Right it simualte a Press of Button B.
( Sure its much more complicated and use Grey Code and calculations ..... But this is a good and easy example to show)

A Rotary Switch is different.... It Know its Position. It send to the Software exactly What Detent is selected.... But instead of the Encoder it not know in whitch direction it is moved.
Here in easy words a 8 Pos Rotary Switch is same like 8 Single Push Buttons..... The hypothetic Button from the current Position is Pressed.... The Other Buttons are released.
If you turn it e.g. form POS3 to POS4 then the Pos3 Button get released and after reching the new detent the Pos4 Button is pressed.

**************

Solution:

At the moment NOT possible.... Cause We have no way to calculate or handle the Moving direction from your Switch.

In Some weeks MF will get a new Tool ( Variables in Inputs) .
Then in theory we can buld a System to make this possible with some deeper tricks and formulas.... But also then this is not comfortable in case you need to workwith Double Configs for each position.
And finaly it willl work then only after you move the Switch a first time to "callibrate" the Logic ( At Systemstart the Switch not know where it is..... Only after first Movement we can then calculate all later inputs and what direction is used.)


Summary: I high recommend to use correct Devices..... A Encoder for a original Rotary Switch System is no Problem..... But a Rotary Switch for a original Encoder Input is not a good idea !
Finaly not plan for the new Tool.... As i said, i think it will be possible.... But your not gonna be happy with it in case ot this senseless first movement Problem to callibrate !
Good Luck !
2021-03-27 15:00
Avatar
Banzai
From: France
Posts: 89
thanks for this good exlanation:thumbup:
2021-03-27 17:49
Avatar
ChrisInUT
Posts: 9
Supporter
For what it is worth, I was able to get my bank angle rotary switch to work for XP11. It is a bit of a hack though.

The XPUIPC Offset code is below.

How it works:
For bank angle 10-20 I send 4 'bank_angle_dn' commands and then either 0,1, or 2 'bank_angle_up' commands for the first 3 positions. For bank angle 25-30, I send 4 'bank_angle_up' commands followed by 0 or 1 'bank_angle_dn' command for these positions.

A similar solution may work for the EFIS switches, though I have not tried it.

iconCode:
#########################################################################################################
#
#          MCP Rotary Switch
#
#########################################################################################################

#MCP 10 DEGREE BANK ANGLE
Command 0x6581 UINT8 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn

#MCP 15 DEGREE BANK ANGLE
Command 0x6582 UINT8 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up

#MCP 20 DEGREE BANK ANGLE
Command 0x6583 UINT8 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up

#MCP 25 DEGREE BANK ANGLE
Command 0x6584 UINT8 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn					 

#MCP 30 DEGREE BANK ANGLE
Command 0x6585 UINT8 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up


Cheers!
[Last edited by ChrisInUT, 2022-03-14 05:10]
2022-03-13 23:16
Avatar
Samhaho
Posts: 8
Supporter
iconChrisInUT:

For what it is worth, I was able to get my bank angle rotary switch to work for XP11. It is a bit of a hack though.

The XPUIPC Offset code is below.

How it works:
For bank angle 10-20 I send 4 'bank_angle_dn' commands and then either 0,1, or 2 'bank_angle_up' commands for the first 3 positions. For bank angle 25-30, I send 4 'bank_angle_up' commands followed by 0 or 1 'bank_angle_dn' command for these positions.

A similar solution may work for the EFIS switches, though I have not tried it.

iconCode:
#########################################################################################################
#
#          MCP Rotary Switch
#
#########################################################################################################

#MCP 10 DEGREE BANK ANGLE
Command 0x6581 UINT8 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn

#MCP 15 DEGREE BANK ANGLE
Command 0x6582 UINT8 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up

#MCP 20 DEGREE BANK ANGLE
Command 0x6583 UINT8 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up

#MCP 25 DEGREE BANK ANGLE
Command 0x6584 UINT8 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn					 

#MCP 30 DEGREE BANK ANGLE
Command 0x6585 UINT8 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up


Cheers!




@ChrisInUT thank you for sharing.

Would you please clarify how can you send multiple commands (you say "4 up and 2 dn", etc.)?
Can you share your Mobiflight config for the switch?

Sam
[Last edited by Samhaho, 2022-04-03 10:32]
2022-04-03 09:44
Avatar
ChrisInUT
Posts: 9
Supporter
@Samhaho, within MobiFlight the inputs are configured as below:

iconQuote:

From Samhaho:
Would you please clarify how can you send multiple commands (you say "4 up and 2 dn", etc.)?


The code below for the XPUIPCOffsets.cfg file is how this is accomplished.
iconCode:
#MCP 25 DEGREE BANK ANGLE
Command 0x6584 UINT8 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn

This sets the UP dataref 4 times and then the DOWN dataref once. The 4 UP will always take you bank angle to 30 degrees no matter where the bank angle is currently set. Then the single DOWN will drop the max bank angle to 25 degrees. The same logic follows with the other 5 events.

iconQuote:

From Samhaho:
Can you share your Mobiflight config for the switch?


I have 5 inputs configured, one for each of the bank angle settings, MCP_BANKANG_## (where ## is 10-30). Each of these pointed at their corresponding Command for triggering the appropriate event with XPUIPC.

On the On Press and On Release tabs for each of the inputs set the Action Type to FSUIPC - Offset.
Next, fill in the appropriate Offset for each switch position on both the On Press and On Release tabs.
Note: from my code: 0x6581 for MPC_BANKANG_10
Value Type: int
Size in Bytes: 1
Mask value with: 0xFF (default)
More Options, Set Value: 1 for the On Press and 0 for the On Release

Note: The Offset locations will need to be adjusted to work with your memory usage scheme.

Cheers
[Last edited by ChrisInUT, 2022-04-03 17:47]
2022-04-03 17:39
Avatar
Samhaho
Posts: 8
Supporter
iconChrisInUT:

@Samhaho, within MobiFlight the inputs are configured as below:

iconQuote:

From Samhaho:
Would you please clarify how can you send multiple commands (you say "4 up and 2 dn", etc.)?


The code below for the XPUIPCOffsets.cfg file is how this is accomplished.
iconCode:
#MCP 25 DEGREE BANK ANGLE
Command 0x6584 UINT8 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_up _
					 0 1 laminar/B738/autopilot/bank_angle_up _
					 1 0 laminar/B738/autopilot/bank_angle_dn _
					 0 1 laminar/B738/autopilot/bank_angle_dn

This sets the UP dataref 4 times and then the DOWN dataref once. The 4 UP will always take you bank angle to 30 degrees no matter where the bank angle is currently set. Then the single DOWN will drop the max bank angle to 25 degrees. The same logic follows with the other 5 events.

iconQuote:

From Samhaho:
Can you share your Mobiflight config for the switch?


I have 5 inputs configured, one for each of the bank angle settings, MCP_BANKANG_## (where ## is 10-30). Each of these pointed at their corresponding Command for triggering the appropriate event with XPUIPC.

On the On Press and On Release tabs for each of the inputs set the Action Type to FSUIPC - Offset.
Next, fill in the appropriate Offset for each switch position on both the On Press and On Release tabs.
Note: from my code: 0x6581 for MPC_BANKANG_10
Value Type: int
Size in Bytes: 1
Mask value with: 0xFF (default)
More Options, Set Value: 1 for the On Press and 0 for the On Release

Note: The Offset locations will need to be adjusted to work with your memory usage scheme.

Cheers



Many thanks @ChrisInUT for the detailed answer. My question was more specifically on how to execute several commands simultaneously and how the sim reacts to executing for example 2 commands down. Would one see the rotary switch moves twice?

With your answer and the test I have made this is getting clear now. If a command offset is written with a value then all the commands of the offset that have this value are executed (whether they are the same or not - here they are the same). And if the same command is executed several time simultaneously the effect of each one individually will not be visible.

In a summary your technique works great. Some times there are misses but it is not a problem.

Now I had noticed (it is not at all specific to the rotary switch) that setting the offset to 0 (on release) is necessary so the next value set will be different since the command is only executed if the value of the offset changes. However no need to associate any command to the value 0. Again this is true for all offsets and all commands and not specific to bank angle.

We can then simplify the offset definition. As example this is the offset of for bank angle 20 (4 up and 2 down):

#Bank_angle 20 - simplified - no need for comand to set 0 the value
Command 0x9452 UINT8 0 1 laminar/B738/autopilot/bank_angle_up _
0 1 laminar/B738/autopilot/bank_angle_up _
0 1 laminar/B738/autopilot/bank_angle_up _
0 1 laminar/B738/autopilot/bank_angle_up _
0 1 laminar/B738/autopilot/bank_angle_dn _
0 1 laminar/B738/autopilot/bank_angle_dn

This is tested and works fine.

Thanks again.

Sam
2022-04-05 20:57
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 5979
Supporter
Hi Guys....

THIS is a example of using "Commands". thats technical the counterpart of "EventID" in FSUIPC.
So a predefine Sequence we start by trigger it.

For sure it workes.... But let me say.... E.g. a 4 Pos Rorary is ther set "in the dark" 3 time via the Down event temporary to a fixed point ( whatever its in Pos 2,3,4 we say 3 times -1 to set it to 1 and then e.g. increment it X times up again to fit the final position )

this workes.... But this is not logical.

Question 1.....
Is there a SET event for each number.... Like
laminar/B738/autopilot/bank_angle_0 _
laminar/B738/autopilot/bank_angle_1 _
laminar/B738/autopilot/bank_angle_2 _
or so.... So we have a EVENT but this not set Down or Up.... It set to a specific Position ????

Question 2......
Is there alternate a "Value as a Dataref" that is writebale....
Like a Dataref that show Switch Position like 0,1,2,3 .... And we can also WRITE it.... Like SET Value of Datarex XXX to Value Y


*************
If these ways not exist, then your idea is correct and simply the only improvisional way we can go.
But if a alternate exist.... Then its more logical to handle this directly.
The explaned System is a impresive cool tricky solution.... But i think its not a good way if there is a better alternate !
Good Luck !
2022-04-06 00:33
Avatar
ChrisInUT
Posts: 9
Supporter
iconQuote:

From samhaho:
Now I had noticed (it is not at all specific to the rotary switch) that setting the offset to 0 (on release) is necessary so the next value set will be different since the command is only executed if the value of the offset changes. However no need to associate any command to the value 0. Again this is true for all offsets and all commands and not specific to bank angle.

We can then simplify the offset definition. As example this is the offset of for bank angle 20 (4 up and 2 down):

#Bank_angle 20 - simplified - no need for comand to set 0 the value
Command 0x9452 UINT8 0 1 laminar/B738/autopilot/bank_angle_up _
0 1 laminar/B738/autopilot/bank_angle_up _
0 1 laminar/B738/autopilot/bank_angle_up _
0 1 laminar/B738/autopilot/bank_angle_up _
0 1 laminar/B738/autopilot/bank_angle_dn _
0 1 laminar/B738/autopilot/bank_angle_dn

This is tested and works fine.


I wondered about that too, but it was working so I moved on to other items that were not yet working. I will update my code with that change. Theoretically it should execute faster this way also. Thanks for the feedback. I think this method will work for the EFIS range switch as well.

There is a dataref for the position of the bank angle switch but it appears to be a read only dataref. I believe it returns 0-4 corresponding to 10-30 degrees of bank respectively. That would have been far cleaner, but that isn't possible. However, if there were a way to leverage the position dataref and only send the appropriate number of up/down commands to get to the desired setting then this would probably be the best method. I am unaware of a way to do that though.

Cheers
2022-04-06 00:46
Avatar
Samhaho
Posts: 8
Supporter
iconpizman82:

Hi Guys....

THIS is a example of using "Commands". thats technical the counterpart of "EventID" in FSUIPC.
So a predefine Sequence we start by trigger it.

For sure it workes.... But let me say.... E.g. a 4 Pos Rorary is ther set "in the dark" 3 time via the Down event temporary to a fixed point ( whatever its in Pos 2,3,4 we say 3 times -1 to set it to 1 and then e.g. increment it X times up again to fit the final position )

this workes.... But this is not logical.

Question 1.....
Is there a SET event for each number.... Like
laminar/B738/autopilot/bank_angle_0 _
laminar/B738/autopilot/bank_angle_1 _
laminar/B738/autopilot/bank_angle_2 _
or so.... So we have a EVENT but this not set Down or Up.... It set to a specific Position ????

Question 2......
Is there alternate a "Value as a Dataref" that is writebale....
Like a Dataref that show Switch Position like 0,1,2,3 .... And we can also WRITE it.... Like SET Value of Datarex XXX to Value Y


*************
If these ways not exist, then your idea is correct and simply the only improvisional way we can go.
But if a alternate exist.... Then its more logical to handle this directly.
The explaned System is a impresive cool tricky solution.... But i think its not a good way if there is a better alternate !



If we had one (question 1) or the other (question 2) it would have been too easy and we would not have been talking about it:)
This technique of executing multiple commands at once has opened to me new possibilities that I could not handle before. It is the case for example of managing the landing light switches in the Toliss (3 positions) that I could finally implement. Thanks @ChrisInUT

Sam
[Last edited by Samhaho, 2022-04-06 02:50]
2022-04-06 02:33
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 5979
Supporter
No Prob.... Just a idea.
As i said.... If there is no other way, then exactly THAT workflow is what we need to do.
No mater if it sounds unpracticalbe at first.... Our target is the expected solution.... If it works, then its fine!

Just a little request to both of you..... and also to people who read this!

Please try to NOT Quote a complete posting of a outher user.....
if you awnser to somebody directly say something like @pizman or @Samhaho.
It make no sense to fully quote (copy) the whole posting of another user again..... Everybody who read this topic in the future read also the previous topic.
No need to duplicate it over and over again!

The "Quote" is used to put a single argument of a long topic into the awnser and comment it.
If you like to comment the "whole" topic just do it without quote it again by simply write your text. everybody know its based on the former topic above !
Good Luck !
2022-04-06 03:52
Avatar
Samhaho
Posts: 8
Supporter
@Pizman82 WILCO
The reason I used quote was to notify the quoted person (not really to quote). This is needed when a message is sent at later time after the last exchange.
However it looks like neither quoting or @naming is generating notification.
How to notify someone (just to make him aware of the message) ?

Sam
2022-04-06 08:58
Avatar
Samhaho
Posts: 8
Supporter
@ChrisInUT

Doing further tests showed that:
1) No need to configure "On release"
2) All commands can be grouped in one offset provided that each angle group of commands has different number

The XPUIPC config is then:

#Bank angle rotary switch
#Bank angle 1-30 degrees; 2-25 degrees; 3-20 degrees; 4-15 degrees, 5-10 degrees
Command 0x9450 UINT8 0 1 laminar/B738/autopilot/bank_angle_up _
0 1 laminar/B738/autopilot/bank_angle_up _
0 1 laminar/B738/autopilot/bank_angle_up _
0 1 laminar/B738/autopilot/bank_angle_up _
0 2 laminar/B738/autopilot/bank_angle_up _
0 2 laminar/B738/autopilot/bank_angle_up _
0 2 laminar/B738/autopilot/bank_angle_up _
0 2 laminar/B738/autopilot/bank_angle_up _
0 2 laminar/B738/autopilot/bank_angle_dn _
0 3 laminar/B738/autopilot/bank_angle_up _
0 3 laminar/B738/autopilot/bank_angle_up _
0 3 laminar/B738/autopilot/bank_angle_up _
0 3 laminar/B738/autopilot/bank_angle_up _
0 3 laminar/B738/autopilot/bank_angle_dn _
0 3 laminar/B738/autopilot/bank_angle_dn _
0 4 laminar/B738/autopilot/bank_angle_up _
0 4 laminar/B738/autopilot/bank_angle_up _
0 4 laminar/B738/autopilot/bank_angle_up _
0 4 laminar/B738/autopilot/bank_angle_up _
0 4 laminar/B738/autopilot/bank_angle_dn _
0 4 laminar/B738/autopilot/bank_angle_dn _
0 4 laminar/B738/autopilot/bank_angle_dn _
0 5 laminar/B738/autopilot/bank_angle_dn _
0 5 laminar/B738/autopilot/bank_angle_dn _
0 5 laminar/B738/autopilot/bank_angle_dn _
0 5 laminar/B738/autopilot/bank_angle_dn

And the Mobiflight config is:
On press set to 1 for switch position 30
On press set to 2 for switch position 25
On press set to 3 for switch position 20
On press set to 4 for switch position 15
On press set to 5 for switch position 10

As said before, On release is set to none

Not only this configuration is better optimized in terms of XPUIPC offset and Mobiflight config but also it works better. The misses I had before from time to time with the "old config" seems to have disappeared.

Cheers,

Sam
[Last edited by Samhaho, 2022-04-06 11:14]
2022-04-06 10:24
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 5979
Supporter
Hmmm.

At first view there is a wrong codepart....

2,3 and 4 have FOUR time "up" to bring it to 30° Whatever it is currently in 10,15,20 or 25
BUT Mode 1 only include THREE "up" .... So special case your in 10 and like to go to 30 ..... 3 Ups ends in 25°.
Pretty sure you miss a Line !

About Optimize.

One Idea...: But i not know if this also feel smooth....

iconQuote:

#Bank angle rotary switch
#Bank angle 1-30 degrees; 2-25 degrees; 3-20 degrees; 4-15 degrees, 5-10 degrees
Command 0x9450 UINT8 0 1 laminar/B738/autopilot/bank_angle_up _
0 1 laminar/B738/autopilot/bank_angle_up _
0 1 laminar/B738/autopilot/bank_angle_up _
0 1 laminar/B738/autopilot/bank_angle_up _
0 1 laminar/B738/autopilot/bank_angle_up _
0 2 laminar/B738/autopilot/bank_angle_dn _
0 3 laminar/B738/autopilot/bank_angle_dn _
0 3 laminar/B738/autopilot/bank_angle_dn _
0 4 laminar/B738/autopilot/bank_angle_dn _
0 4 laminar/B738/autopilot/bank_angle_dn _
0 4 laminar/B738/autopilot/bank_angle_dn _
0 5 laminar/B738/autopilot/bank_angle_dn _
0 5 laminar/B738/autopilot/bank_angle_dn _
0 5 laminar/B738/autopilot/bank_angle_dn _
0 5 laminar/B738/autopilot/bank_angle_dn _

And the Mobiflight config is:
On press set to 1 for switch position 30 On Release set to 1
On press set to 2 for switch position 25 On Release set to 1
On press set to 3 for switch position 20 On Release set to 1
On press set to 4 for switch position 15 On Release set to 1
On press set to 5 for switch position 10 On Release set to 1



Every time you move your switch this occure at first in a "leave" of the current position before you reach the new position.
This leaving is a Release.
In all 5 Positions we need at first 4 time UP ( And Mode 1 exactly do this already)
So if we say On release execute Mode 1 then we always "calibrate" the switch to Pos 30° and the following Press ( e.g. Pos 3 then just send the needed number of Down Commads.

This reduce just the length of Code in XPUIPC..... It not change the Logic overall.... and maybe it occure in a little dealy so you se the virtual switch shortly jump to 30° in the moment between release and press. ...... and Maybe it finally also not work in case the first command of Release is not finished and XPUIPC ignore the Press in case its occupy a.t.m.

*****

Another Idea would be a deeper MF Logic
We can Read the Current Position of the Virtual switch.... You said that. We can maybe not write it.... But Read it !
So....
Technical we KNOW what position we got in the Sim ( BY read that Dataref) and we know what Position we Move in ( in case of the Real Switch Signal)
So technical we could make a calculation do define if we send a UP or Down .
This works fine with just two values e.g. 1 or 2 and 2 Lines in XPUIPC Code .... Like

0 1 laminar/B738/autopilot/bank_angle_up _
0 2 laminar/B738/autopilot/bank_angle_up _

Problem here.... We expect a switch Moving is always only ONE Position.
So we could not fit a "sync" by itself.
So Switch must be Sync at Startup already !
Old logic.... Sim starts by default with 30° If you take care to set it before also to 30° in Cockpit the easy logic would work!


A Last Idea is using our new "Input Action in Output Configs" .
In theory we could say "Check if Real Switch position and Virtual Switch are the same" .... If Yes, do nothing.... If No then send a command for UP or DOWN whatever the Value is greater or less then 0 ( So a difference to Up or Down)
In this logic by switch in one step all is easy.... If we switch multiple steps (in case of unsync) our Config would simply make in the next loop the check again....
Its still not equal so it send the needed comand again..... Simply so often until the both switches are sync !


***********
You see. Lots of posibilitys.
Nice Brainstorming to get in a new level !
Good Luck !
2022-04-06 14:36
icon