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
Peau
Posts: 44
Hello !
I've done a lot on Mobiflight lately and have two Arduino Mega's working well.
Tried to use a third Mega with some lcd;s to have as "cabin" lights and a couple of Led's.
Here is the problem; The Lcd's are always on, independebly of variables used. One way to bring them off is to use "Test" in the display tab. They are on even if Mobiflight and MSFS is shut down. I think I have done exactly the same as with my other lcd*s on my first two Maga boards. I've also tried to change to another Mega ( I have two extras ) but with the same result. Though I have two 7segment Led connected to the third board and they are working perfect and the input/output values seems to be right in Mobiflight. Confused, something buggy going on in my Mega's or in my brain. Somebody having an idea ?

Cheer, Peter

MSFS 2020
Mobiflight 9.2
Win 10
2022-01-11 19:43
Avatar
Peau
Posts: 44
Some things mixed up Lcd means Led and when I write Led I mean Lcd :)

/P
2022-01-11 20:04
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Hi

I not fully understand.... Also not the "mixup" with LCD and LED.

Basically..... A LED show the Status of the Config that controlled it..... OFF if "0" and ON if 1or Greater.

If you disable a Config then the LED remain in the last status..... Means you can not set a LED to OFF by a Precondition itself.... There must be a Config that clearly say " LED change to OFF" .

If you STOP MF then all LED should be OFF!
If this not happen pretty sure a electrical issue is the problem !
Good Luck !
2022-01-12 00:13
Avatar
Peau
Posts: 44
Conclusion of some hours of testing. On the rows 2-13 ( have the useful Pwm ) it seem impossible to get an reaction from, independently of Light vars from SimConnect. I want to turn my lights on via PANEL LIGHT var. I get the same results on both my older Mega and my newly bought. On both Mega's the 7segments displays works as expected and shows choosen vars as wind, temperatur, year, trim settings aso. They are connected to pin 22-24-26. When I connect my led's to 26-28... I got it to work but in a reverse way. When sitting in C152 and turn panel light on the led goes out and when panel light in C152 turn out the Led's goes on. Tested with other light vars with the same result. On my two other Mega's I didn't have this issue. What am I doing wrong or what is wrong ? Simupdate ?
Cheers, Peter
2022-01-12 10:25
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Ok....

Lets split this up.....

1. Simconnection and Basic MF Functions....
Here all is fine !
iconPeau:

On both Mega's the 7segments displays works as expected and shows choosen vars as wind, temperatur, year, trim settings aso.


So we definitly know you have a working Interface to the Sim, The Mega is working, and MF also is working correctly ! thats nice ! :thumbup:

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

2. PWM Support.
For Outputs (LED) with PWM enabled you need to work with the correct Values !!!!

A regulary LED -Output ( Whatever on a PWM Pin or a Normal Pin ) NOT use the PWM Option ( Checkmark empty)
Those LED have simply logic.... IF Value in Config is "0" then LED is OFF ( Pin =GRD) ..... IF Value is NOT "0" .... (e.g. 1 , 5 , 999999 or everthing else) the LED is ON ( Pin on 5v)

A LED you like to controll with the PWM Logic is different..... For sure it must be on a PWM Pin at first ... You already know !
NOW a PWM LED expect a Value of "0-255 " in the Config....
0 means OFF (0 V) and 255 means "Full Bright", same like the regulary LED.
If your Config still use a SimVar that is e.g. "0" for OFF and "1" for ON .....
Then your LED will light just in a Bright state of 1/255 So less then 0,5% of Brightness..... Pretty sure it looks already like OFF cause this is to less to see a lightning !

Soluition:
With PWM you need to adjust the Value..... E.g. using a Var for Brightness if you got one....
Or you say something like IF Value =1 then show 128 ELSE show "0" ..... In the Compare Tab.
Then you send a 128 to the LED if it should be ON ..... And 128 represent in PWM a nearly 50% Bright setting !

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

3. Inverted Behavour !

This sounds like a electrical issue in your Setup/Wirework!
A LED have a direction..... You can not change the 2 Pins by swapp the direction.... Anode to +5V and Cathode to GRD .... Otherwise it will not light !
Additional the Usage in Mobiflight must be correct !

Normaly we say : Anode Side of LED is wired to the used PIN of the Mega ..... Cathode side is wired to GRD Pin of that Mega !
Then Logic is "normal" .... Pin is HIGH if Value is 1 .... Means Power to LED and it light.

By mistake may you "reverse" the Logic !

If you set a Line from 5V Pin on Mega to Anode of LED .... And Cathode of LED to the PIN on the Mega where you create the Device....
THEN its inverted..... Now the LED get always 5V from the Mega.... But need now a GRD to light up....
The Pin still say " If Value "0" then GRD .... If Value "1" then 5V.
Means NOW your LED will light if Value in Sim is "0" and is OFF if Value is "1".

AND .... This also explane the Bahavour that LED are ON while MF is not running......
Without a Running MF all Pins are set to GRD.
And as i explane.... Your reversed LED will now light all the time.... Cause it need GRD on the Pin !


Solution: Reverse your wirework ! Always get sure.... A LED "NEVER" is connected to a 5V Pin on the Mega !
Good Luck !
2022-01-12 18:31
Avatar
Peau
Posts: 44
The "weird" in the headline is me ! Indeed very poor wiring. Anyway, now it's working. My goal was to have some led's in my desktop cockpit operated from the same switch on my Saitek Tpm where I have the instrument light in MSFS. The lights should only turn on when master battery is on and should have white light daytime and red light dusk-dawn-night
with different Led's. How I did it ;

Transform in white ( day ) light ; if($=1%%M=1&&T=1,60,0)
Placeholders;
$ = LIGHT PANEL var Simconnect
M = Master Battery var FSUIPC 0x281C
T= TIME OF DAY var SimConnect, represented by 0 1 2 3, where 1 is day.
The "60" is the PWM number, higher for brighter light.

Transform in red ( night ) light ; if($=1%%M=1&&T!=1,60,0)
The only difference is the "!", indicating it's not day (1)
Thanks for your help! Mission acccomplished !

Cheers, Peter
2022-01-13 08:52
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Syntax issue ??


if($=1%%M=1&&T=1,60,0)

A Double Modulo make no sense to me here.....

You say IF Light Panel is 1 AND Battery is 1 AND Daytime is "day-1" THEN 60 ELSE 0

So logical formula would be if($=1&&M=1&&T=1,60,0)

By the way.... Those Formulas can be written in lots of different ways....
I personaly like it to prevent me from using the AND if possible....

In that case for WHITE....
if(T=1,60*M*$,0)
If Daytime is 1 (Day) THEN Take "60" and multiply it by the Battery switch and again multiply it by the Light Panel Status. ( For sure only work if Battery and Panel Switch are Bool)
If Both are "1" then 60*1*1=60 ...... If Both are "0" then 60*0*0=0 ..... If only one is on .... 60*1*0=0 or 60*0*1=0.

You see.... Lots of posibilitys..... Non is the only true... aslong it work for you, you can do whatever you like !
Good Luck !
2022-01-13 16:38
Avatar
Peau
Posts: 44
Sorry for the typo. Of course no modulo. just plain &&.:D

DS
2022-01-13 17:58
icon