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! 

05/03/2024 - This forum is read-only

The community support for MobiFlight has moved exclusively over to our Discord server. Register for free and enjoy more interactive functions like image and video upload, voice chat. More than 7,000 registered users around the world make it a great experience!

See you on our MobiFlight Community Discord server.

A HUGE Thank You to everyone who participated in the forum, especially obviously to Pizman and Stephan who did an outstanding job over so many years providing an incredible service to the MobiFlight community.

The forum is still providing a lot of good content, hence we keep this information accessible.

icon
Avatar
han.schouten@home.nl
From: Margraten, Netherlands
Posts: 9
I am currently developing an autopilot console. I want to use a single encoder combined with a push button to set either the desired altitude or the desired vertical speed. In order to know which of the two presets is active, I will need one LED for the altitude preset and one for the vertical speed. The idea is, to make the interpretation of the encoder signal dependent of these LED's being on or off.

I have encountered two problems that I have labeled PROBLEM 1 and PROBLEM 2 below.

I have installed the following devices on the MobiFlight Mega:

DEVICE

AP encoder
Device Type: Encoder
Left pin: 30
Right pin: 31
Name: AP encoder

AP enc toggle
Device Type: Button
Pin: 28
Name: AP enc toggle

AP led altitude preset
Device Type: LED / Output
Pin: 29
Name: AP led altitude preset

AP led vertical speed preset
Device Type: LED / Output
Pin: 33
Name: AP led vertical speed preset

The first things to get going are both LED's being toggled by the encoder button. To keep track of the status of both LED's, I abuse two unused bits of an otherwise unused FSUIPC offset. I have configured the following rules:

INPUTS


AP enc toggle altitude on
Precondition: AP led altitude preset = 0
Module: MobiFlight Mega ...
Device: AP enc toggle
On Press: FSUIPC Offset
Offset: 0x6004
Value Type: Int
Size in Bytes: 4
Value: 1
Mask value with: 0x0010 (bit 4)

AP enc toggle altitude off
Precondition: AP led altitude preset > 0
Module: MobiFlight Mega ...
Device: AP enc toggle
On Press: FSUIPC Offset
Offset: 0x6004
Value Type: Int
Size in Bytes: 4
Value: 0
Mask value with: 0x0010 (bit 4)

AP enc toggle vertical speed on
Precondition: AP led vertical speed preset = 0
Module: MobiFlight Mega ...
Device: AP enc toggle
On Press: FSUIPC Offset
Offset: 0x6004
Value Type: Int
Size in Bytes: 4
Value: 1
Mask value with: 0x0040 (bit 6)

AP enc toggle vertical speed off
Precondition: AP led vertical speed preset > 0
Module: MobiFlight Mega ...
Device: AP enc toggle
On Press: FSUIPC Offset
Offset: 0x6004
Value Type: Int
Size in Bytes: 4
Value: 0
Mask value with: 0x0040 (bit 6)

PROBLEM 1

Each of these LED's separately, the other being switched off, works perfectly. Apparently, MobiFlight does not allow to derive two different actions from a single push button event, not even with mutually exclusive preconditions. If I activate all four rules, this mechanism stops functioning. So far, I have not succeeded in triggering both actions or in cascading one action to the other. I am afraid I need some help here.

Missing one of both LEDS, we must continue with only one: the altitude preset LED. The following rules should do the job of discriminating between altitude preset and vertical speed preset:

INPUTS

AP enc altitude preset
Precondition: AP led altitude preset != 0
Module: MobiFlight Mega ...
Device: AP encoder
On Left:
Action type: Event ID
Event ID: 65893 (AP_ALT_VAR_DEC)
Param: 1
On Right:
Action type: Event ID
Event ID: 65892 (AP_ALT_VAR_INC)
Param: 1

AP enc vertical speed preset
Precondition: AP led altitude preset = 0
Module: MobiFlight Mega ...
Device: AP encoder
On Left:
Action type: Event ID
Event ID: 65895 (AP_VS_VAR_DEC)
Param: 1
On Right:
Action type: Event ID
Event ID: (AP_VS_VAR_INC)
Param: 1

PROBLEM 2

In this setup, the vertical speed preset functions correctly. The altitude preset is functioning erratically, however: every few detentes the vertical speed goes up or down, not the altitude. Either MobiFlight does not allow to address a single device with two different rules, or something is wrong with the precondition of the altitude preset rule.

Maybe, I misinterpret the purpose of preconditions entirely. The question then is: Is what I want somehow possible, or is this just a bridge too far?

I will go on, trying to find a solution. If, in the meantime, somebody could give me a hint, I would be very grateful!

Greetings, Han Schouten - Margraten - The Netherlands
[Last edited by han.schouten@home.nl, 2016-10-02 14:12]
2016-10-02 11:41
Avatar
han.schouten@home.nl
From: Margraten, Netherlands
Posts: 9
Apologies for the lousy layout of device and rule definitions above. The text I have prepared was definitely more readable!
2016-10-02 11:45
Avatar
han.schouten@home.nl
From: Margraten, Netherlands
Posts: 9
For reasons that I cannot understand, PROBLEM 1 has solved itself!

PROBLEM 2 persists, however. One tiny modification: The ON left (Fast) and On Right (Fast) events of the AP enc altitude preset INPUT had the vertical speed actions attached to themselves. This explains the "erratic behaviour" I have observed earlier.

The fact that this rule responds to the On Left (Fast and On Right (Fast) events points into the direction of some error on the On Left and on Right tabs.
2016-10-02 15:28
Avatar
han.schouten@home.nl
From: Margraten, Netherlands
Posts: 9
PROBLEMS SOLVED!

The cause of the malfunction was in pointing at the wrong device: [AP dsp altitude preset] instead of [AP led altitude preset]. Sorry, it took me a while to notice this!

For those interested in the conditional triggering of rules: I have had to add a rule [AP enc toggle init] that specifies what must be done if both LED's are off: then the [LED AP led altitude preset] must light up (i.e., the fourth bit in offset 0x6004 must be set). I have extended the preconditions in [AP enc toggle altitude on] and [AP enc toggle vertical speed on] to check whether the states of both LED's are opposite.
2016-10-02 16:27
Avatar
dymojim
Posts: 5
It seems to me that you are making matters too complex here. Is it not
possible to just use one bit position and toggle it with the push switch
on the encoder. Then if the bit is set you control altitude and if not set
you control airspeed. Then you do not have your two bits set or reset
together and need to find a solution for this.

The same applies for driving the leds, if the bit is ON then drive the
altitude led and if OFF, drive the airspeed led.

Or have I missed something here in the use of your led control bits?
2016-12-03 06:30
Avatar
pizman82
From: ETSI, Germany
Posts: 6010
Supporter
Hiho.
Interesting Setup....
I never worked with custom FSUIPC before but now i will try. This open new ways !

For youre config i think theres a much easyer way like "dimojim" suscripe.
This solution is NOT Tested cause i´m not at home this tme.... Just a idea that can work maby......

Same Hardware Setup like suscribe above.....
****

- 1.
Set a Fake Output Ofset without a LED in use.... just for preconditening in later configs.....
Name: PRE-Status Alt-VS ( for example)
Offset 0x6004 1 Byte INT (Think this a custom offset you used too Normaly 1 Byte should be enough )

- 2.
Create the Toggle Function
Input
Name: Toggle Alt-VS Button
Device : Youre Toggle Button on Pin 28
Offset: 6004 1 Byte INT
On Push : Funktion : " IF ($=1,0,1) "

Hope that function is right (cant test at the moment). Normaly that should say.... If Offset is actual 1 then set it to 0.... Else (also if offset is 0) the set it to 1.

NOTE: I Never worked with Custom Offset Before. I belive that the Offset is "0" when system start and there was no entry before. This system only workes if the Offset exist already i think .

- 3.
Create 4 Configs... Output LED Alt ; Output LED VS ; Input Encoder Alt ; Input Encoder VS
Now you have to devine by youreself witch CustomOffset Status should be ALT or VS. For example we say 0=ALT 1=VS

Now Set your ALT Encoder Config for the Encoder on Pin 30/31
Use the Offsets like you suscribe for Left and Right
Set Precondition >>> Only Work if Fake Config "PRE-Status Alt-VS" Value =0

Same way for the VS Encoder..... Use Same Encoder on Board, Use the Offsets Left/Right for the VS setting....
But now set Precondition >>> Only Work if Fake Config "PRE-Status Alt-VS" Value =1

Now the Encoder should toggle betwen the two modes ALT/VS according as the value of our Fake Config is set to 1 or 0 .


- 4.
For the LED you use the same Created Custum Offset 6004 1 Byte INT.
The VS LED works without special setup.... When Value =1 (We say above 1 =VS) the LED is lighted.... When Alt is on the value is 0 and the LED is off.

THE ALT LED need a short compare entry... If Offset Value is 0 then set value to 1 else Set to 0
So the ALT LED will be lighted now when Value is 0 (We say above 0=ALT) .... And when Offset is 1 for VS the Alt LED still off in case of this campare.


***

HOPE This Setup will work.... If yes this is much easyer like your config with lots of conditions and with bitmasking.

Good Luck !
Good Luck !
2016-12-03 14:29
icon