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
elral
From: near EDDL, Germany
Posts: 50
Hallo zusammen,

bisher habe ich Mobiflight ersteinmal nur mit einem Encoder und dessen Button getestet.
Mit dem Encoder wähle ich Heading über FSUIPC für den MSFS2020. Grundsätzlich funktioniert das auch., wobei ich da auch ein kleines "Problem" habe ;)
Allerdings passiert es alle 6 - 8 Mal, das sich beim schnellen drehen einmal die Richtung ändert.

Um der Ursache auf den Grund zu gehen, habe ich den Arduino mit einer seriellen Schnittstelle verbunden und mir den Output angeschaut.
Da kann man auch gut sehen, dass sich mittendrin einmal die Richtung ändert, z.Bsp:
....
6,Set Heading,1;
6,Set Heading,3;
6,Set Heading,1;
....

Dann habe ich mit die Arduino SW angeschaut, es gibt da wohl einen Überlauf in RotaryEncoder.cpp, Funktion tick():
_position += KNOBDIR[thisState | (_oldState<<2)] * _speed;
Beim schnellen drehen wird _speed recht groß, sodass bis ~2800 (*4 bei einem Encoder mit 4 Schritten, *2 bei einem mit 2 Schritten) zur Position hinzu addiert werden können. Nach <10 Mal drehen des Encoders läuft die Variable _position dann über.
Dieses sollte allerdings in MFEncoder.cpp, Funktion update() mittels:
if ( (dir > 0 && (pos + delta*2) > MF_ENC_MAX) || (dir < 0 && (pos - delta*2) < MF_ENC_MIN))
abgefangen werden. Allerdings werden dabei nicht die Impulse pro Schritt des Encoders berücksichtigt. MF_ENC_MAX/MIN müssten also mit den Schritten dividiert (nicht multipliziert wie zuerst geschrieben) werden.
Da in der FW aber ja "nur" der Delta Wert des Encoders von Interesse ist und nicht der Absolut Wert, kann auf die if Abfrage auch verzichtet werden. Nach jedem auslesen wird die absolute Position dann halt auf Null gesetzt
Ich habe das auch schon so auf den Arduino aufgespielt und bisher keinen negativen Effekt fest gestellt.

Ich hatte noch einige Debug Print Ausgaben eingebaut und aufgezeichnet, die kann ich gerne auch zur Verfügung stellen.

Es würde mich freuen, wenn das zur Verbesserung beiträgt.

Viele Grüße

Ralf

P.S.: Allerdings wundere ich mich das es bei mir zum ersten Mal auffällt...

Edit: MF_ENC_MAX/MIN müsste also mit den Schritten dividiert und nicht multipliziert werden.
[Last edited by elral, 2021-04-14 18:01]
2021-04-14 15:19
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Hi

Das es hier ein Problem gibt ist bekannt. Bisher haben wir das aber eher als "Fehlbedienung" interpretiert.
Manche USer wollen offensichtlich einen Encoder drehen wie wenn sie ne Bohrmaschine anflanschen und 1200 rpm drehen lassen.
Dreht man den Encoder in einer "angemessenen" Speed gibt es eigentlich keine Probleme.....

ABER

Das wirkliche Problem ist eigentlich das dieser Part ( Encoder 1:1, 1:2 und 1:4 Settings) NICHT von Sebastian selbst programmiert wurde sondern von einen anderen User.
Meines Wissens ist besagter USer aber schon lang nicht mehr aktiv. Folge.... Es ist ein Part in MF von dem eigentlich keiner genau weis wie er funktioniert.
Solang es keine Probleme gibt ist alles Top.... Aber jetzt darf sich Sebastian da selber rein fuchsen und muss das ändern.

Dank deiner Arbeit sollte das aber nun womöglich deutlich einfacher gehen.

Eine letzte Bitte.

Solche Dinge machen wir gerne beim "Live Scripting".
Meld dich mal bitte bei Discord an wenns geht. Hier ist Sebastian von Zeit zu zeit im Stream Channel und schreibt Code sozusagen Live.... Sprich erfahrene USer können direkt sagen was und wo es hackt und er kann direkt checken.
Sowas geht per Voicechat deutlich schnelle rund besser als per Forum

In dem Sinne DANKE und man sieht sich hoffentlich mal auf Discord !



EDIT: https://bitbucket.org/mobiflight/mobiflightfc/issues/337/missfunction-in-the-encoder-code-part
Good Luck !
2021-04-14 19:02
Avatar
tigertfly
Posts: 7
Supporter
iconpizman82:

Hi
Das es hier ein Problem gibt ist bekannt. Bisher haben wir das aber eher als "Fehlbedienung" interpretiert.
Manche USer wollen offensichtlich einen Encoder drehen wie wenn sie ne Bohrmaschine anflanschen und 1200 rpm drehen lassen.
Dreht man den Encoder in einer "angemessenen" Speed gibt es eigentlich keine Probleme.....


Hi Ralf, I noticed that too when building an autopilot panel for the Citation CJ4, I think it is particularly noticeable in the heading bug.

The problem exists for me even with a normal knob at fairly slow speeds, just normally turning a heading knob for example. And it is exaggerated by the fact that if you move fast, the backwards jump is also a FAST event in the opposite direction, thus very noticeable if you have a higher step defined for "fast" rotary encoder events.

I actually did turn the encoder with a small power screwdriver to see the events actually occurred at regular intervals when turning at a steady speed, because the speed varies if you turn the knob by hand and the did happen at regular intervals. Of course the speed was very slow (duh!), the erroneous events seemed to happen immediately when the "fast mode" kicked in. And Mobiflight connector just treats all events as "slow" if you have not defined any "fast" events, the Arduino sends slow and fast because it does not know what is configured in the connector.

Very happy to see there was a problem that could be identified!

-Tuomas
2021-04-15 10:28
Avatar
elral
From: near EDDL, Germany
Posts: 50
Hi Tuomas,

yes, you are right. It happens also if no FAST event is defined in the connector as the firmware does not difference that. And it comes faster the more steps the encoder has (1:4, 1:2, 1:1). The problem also occur if you are turning slow, after "some" steps (depending on the time between each step) you will get an overflow of the _position variable. And this overflow results in changing the sign, means the delta from one step to the next is very high and therefore sending a FAST event in the opposite direction is detected.

As I sayed, I think the soltion is easy. Just delete the if condition as mentioned above. I tested it for a 1:4 encoder, but I can do it also for 1:2 encoder on the weekend. I will try to give some more explanations in the issue on bitbucket if this would be helpfull.

@pizman82
I have installed Discord ~4 weeks ago and I am happy to get it work to communicate with my friend.
I have also now connected to Mobiflight within Discord, but I am a little bit lost :(
What do you mean with "Stream Channel" and how can I identify Sebastian?
Sorry for this "silly" question...

Regards

Ralf
2021-04-15 13:21
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
@ Ralf.... Still get in contect to you on discord ! ( Hopefully i choose correct user name)
Good Luck !
2021-04-15 19:29
icon