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
jaimeleon
Posts: 13
Hello everyone,
I have two 20x4 lcd displays. I was trying to set the configuration of MFConnector to be able to change the displayed page on each of the lcd screens by pressing one single button. The objective was to change both screens at the same button press.

I set up one button as input and used FSUIPC free offset 0x66FF and setting the value "if($<2,$+1,0) to have this control variable go from 0 to 2 with each button press (three values).

I set up one output to read back the same FSUIPC offset of 0x66FF and named "lcd select".

I set up 6 sample output screens with different contents and with these preconditions:

LCD Screen 1, page 1 Precondition lcd select = 0
LCD Screen 1, page 2 Precondition lcd select = 1
LCD Screen 1, page 3 Precondition lcd select = 2
LCD Screen 2, page 2 Precondition lcd select = 0
LCD Screen 2, page 3 Precondition lcd select = 1
LCD Screen 2, page 1 Precondition lcd select = 2

So my expectation was to be able to rotate the 3 pages (1-2, 2-3, 3-1) between the two lcd screens at the same time by pressing the button. However, this did not work. What did happen was that the program rotated the three pages on LCD Screen 1 first while LCD Screen 2 remained unchanged; and then rotated the three pages on LCD Screen 2, while LCD Screen 1 remained unchanged. Weird behavior.

I cut down the configuration eliminating the preconditions to show only page 1 on LCD Screen 1 and to make the rotation on just LCD Screen 2 and now it worked without any problem. So it works for one screen, but not for two at the same time. Has anyone encountered this problem before? Is there any limitation to using the user defined offsets as preconditions for two lcd displays?

I didnt try it yet, but it just occurred to me that maybe I could set up two separate outputs to read the same offset and then use them to drive each LCD display. I will try that tomorrow.

Best regards,
Jaime
2021-03-19 03:41
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 4647
Supporter
Hi
Looks like you find a malfunction !

I must assume that all your configs are correct as you describe. So lets say you do all fine and there is no self build issue in your logic....
In "theory" this system must work.... In real i think on this point, that i can NOT work.... But i never think about a user who try this to do. !


The Readout Config have no effect here.... Building a second one makes no sense to me !
The follow are testings to confirm the master system is correct:

1. Your Button do what it should do and also the Output for indication work!
You can simply check.... Run MF.... Press your button 10-20 times and observe the FSUIPC Output collumn right of your "lcd select" Configuration.
If it swap 0,1,2,0,1,2,0,1,2,0,1,2 and so on then the basic system is OK and confirmed !

2. Your Displays work.
Testing by show 2 test pictures. One individual on each Display ( e.g COM1 on Display 1 COM2 on Display 2) If both work same time and show the correct values AND both react to a change of a Encoder or virtual input ( Inc Com1 and Com2 ).... then all is fine !

3. Your Precon Logic work for One Display at a time.
Test: Disable the three Config from Display2. RUN.... Press button 10 Times and check if Display1 correctly swap between mode 1,2,3,1,2,3,1,2,3 without any missing steps.
Then STOP Disable Display1 Configs and enable the Display2 again. Then Test ones again.
Now Display 2 should swap 1,2,3,1,2,3,1,2,3 in perfect way.

********************
Problem:

If your right, it looks the problem is the IC2 interface. A Press of the button would need to send 2 Data blocks SAME TIME via a single interface. In Normal procedure this not happen..... Lets say you got COM1 on Display1 and COM2 on Display 2..... You would never change both same time ( millisecond/loop ). So the "updated" Information is send to Display1 or 2 in a SINGLE sequence.

For OTHER direct Devices this is no problem..... For example we still build in the past 50+ LED Configs that act all in case of the same Precon and ALL swap and work correctly ! Simply in case we would send the information here via 50+ single individual Pins.... Not via a Interface and a Adress logic !

The only Fact i not fully understand is the behavour that you controll Display1 three times and behind it controll Display2 three times.
From first view it should control 1,2,1,2,1,2 OR it should control Display1 Only..... thats confusing finaly.


****************
Solution:
If you be able to do.... Make a short test for me.....
Use a second Mega.... Connect your two Displays splitted.... So Display 1 to Mega 1... Display 2 to Mega 2. ( And sure create the Device on Mega 2 Correctly and DELETE the 2.nd Display device on Mega 1.
THEN just change the Device from your Display2 Configs to the "new" Display on Mega2.
Make a test.....

I will say NOW it workes..... Cause the change occure in a sending via TWO IC2 controllers.... So there should be no longer blocking !

***************
Sorry i can not test myself.... I only own 1 Display 16x2 for testings. Like most Cockpoitbuilders i not use or plan for LCD Displays.... So i can not rebuild this.
Good Luck !
2021-03-19 08:42
Avatar
jaimeleon
Posts: 13
Hello pizman82,
Ok, I made some additional tests today on the two lcd setup (20x4) connected to an arduino mega.

To confirm your comments:
1. the button is correctly configured as input and the output "lcd select" correctly displays the values 0, 1, 2, 0, 1, 2 when the button is pressed.
2. The screens are correctly connected and they both show "Mobiflight Rocks" when the mega board is plugged in. Before trying to switch pages, they both correctly displayed the 8 and 12 values, as reported by me in another post (workaround for 7 value limit).

First I tried to create a new lcd select 2 input that reads the same offset 0x66FF and changed the preconditions on the lcd2 pages to use this new variable. The result was slightly different this time. I had deleted some of the screens for lcd1, so I had to redo them. This time, on each button press 0,1, 2, 0, 1, 2, the two lcd screens alternated in showing the page appropriate to the value of the button press. Still weird, just different. It did not make a difference whether I used lcd select 1 and 2 or just lcd select 1.

Next, as you pointed out this problem may be caused by the two page change instructions being issued too fast into the one serial i2c interface, I tried separating the page switches into single event per screen. For this I extended the lcd select input to go from 0 to 5 and changed the preconditions for lcd1 pages to change on 0, 1, 2, and lcd2 pages to change on 3, 4, 5. It worked. Lcd1 now showed the three pages, followed by lcd2 showing the three pages. So my conclusion was that the screen changes can be done but in separate events.

Next, following your request, I added one pro micro board to Mobiflight (I only have one mega board). I changed Lcd1 from the mega board to the pro micro. This is actually the first time I connected two boards to the software. Mobiflight identified both boards. I then created the lcd display in the pro micro configuration and renamed it lcd3. After resetting all boards and software, they both displayed "Mobiflight Rocks". So far so good.

I then changed the lcd1 outputs to display to the new pro micro board and lcd3 was shown as the only option. However, it doesnt matter what I do on Mobiflight. Nothing gets displayed in the lcd3. When I press the Test buton, nothing happens. If I run the simulation nothing happens in the lcd3. It continues to display "Mobiflight Rocks". I do observe the led on the pro micro board show data being received when I press the button.

Althouth the lcd3 (connected to the pro micro) did not display anything, lcd2 (connected to the mega) did do the page rotation correctly. I am speculating that had lcd3 worked it would have displayed the pages correctly too. I even wiped the eeprom in the pro micro with the arduino IDE and loaded a program to test the lcd and that worked, so it is not the arduino or the lcd screen. I reloaded the Mobiflight firmware and again could not write to this lcd screen. Mobiflight Rocks is the only thing that is displayed.

Any ideas on why the pro micro does not seem to be working correctly with the lcd screen???? Could it be that the pro micro board sda and scl pins for the i2c interface (pins 2 and 3 on the pro micro) are not the same as in the mega board (pins 20 and 21)?

For reference, this is the pro micro board I bought at Amazon.com
https://www.amazon.com/gp/product/B01MTU9GOB/ref=ppx_yo_dt_b_asin_title_o04_s01?ie=UTF8&psc=1

Regards,
Jaime
[Last edited by jaimeleon, 2021-03-20 04:48]
2021-03-20 00:42
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 4647
Supporter
Hi again !

Badly we could not test what i looking for.... Whatever i agree. I still think it "would" work if you had used a MEGA for the second board.

PLEASE: If a other user who owned 2 Megas and 2 LCD Displays read this .... Please confirm that theory !!


*******

About the "strange" behavior ....
I still think the trouble is the IC2 Interface that get struggle if we send 2 commands within a verry short time periode ( technical it is not same time cause there are 2 configs.... And also on the firmware there are 2 workingsteps.... But pretty sure verry close to each other.
The differences ( You report in the 2nd testrun) i think have occured in case the sequence of the Configs change.

Lets extremly say the READ Config you use for PRecondition indication (LCD Select) is in the MF File between the Display1 and Display 2 Configs. IF you press the button then the Display1 Configs use the "old" value in the next loop, cause the moment MF detect the Change ( on the LCD Select Config) happen behind. Then the LCD 2 Configs still have the new Value ! .
May this work now, cause on the next loop some milliseconds later the LCD1 Configs also get access to the new value and change the display.... But maybe then the first IC2 operation is still finished.
I also think it make a difference how long the config is..... Lets say there are hundrets of Output Config lines..... So the loop take a little longer. Maybe this also result in a different situation !
Whatever.... This is just lucky then and not really a solve of the problem.... We jsut not see it in case we "slowdown" the system.

By the way.... A last idea here.... Change for testing the Logging Mode.... Enable it in DEBUG and make a test. Then another test with a again disabled Logging Mode !
I´m sure this extrem change of the MF working speed also occure in a verry different situation for your Swapping !


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

About Micro Pro.
I think problem here is the board !

We have so many Meetings now and i not understand why Sebastian not clearly make a statement here. He always say "it work" but i still say "it can NOT work" !!!


Check the Datasheets for the linked Micro Pro !
http://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/ATMega32U4.pdf

iconQuote:


16/32K Bytes of In-System Self-Programmable Flash (ATmega16U4/ATmega32U4
1.25/2.5K Bytes Internal SRAM (ATmega16U4/ATmega32U4)
512Bytes/1K Bytes Internal EEPROM (ATmega16U4/ATmega32U4)



And then check the Real MEGA Specs.
https://store.arduino.cc/arduino-mega-2560-rev3

iconQuote:


Flash Memory: 256 KB of which 8 KB used by bootloader
SRAM: 8 KB
EEPROM: 4 KB



I still think.... These Micros can NOT work with Mobiflight! It is like with UNO.... they will do basic things like 5 Buttons but can not handle all the fetures we will do.

The only "Micro" that garentee work is the mini version of the real Mega.....
like this... https://www.ebay.de/itm/Mini-MEGA-2560-Pro-Micro-USB-CH340G-ATMEGA2560-16AU-For-Mega-2560-R3-Arduino-NEU-/233082740772
Good Luck !
2021-03-20 08:41
Avatar
jaimeleon
Posts: 13
Hello again,
I agree with you that the pro micro is much more limited in resources than a mega board, but no reason why it shouldn't work within its limitations. Please note the only thing connected to my pro micro board was the lcd screen. Nothing else. As I noted before, this board and lcd screen were tested with another sketch, without problems. Also, I observe that it does pass the internal test by correctly displaying "Mobiflight Rocks!". This tells me that Mobiflight does see the lcd screen and can write to it. It is still a mystery why nothing else will display.

I know nothing of this, but it seems more like a bug in the Mobiflight support for lcd screens on micro boards. Maybe @DocMoebius could take a look at this?

Has anyone else successfully connected lcd screens with a pro micro or micro boards?

I have ordered a couple of mini mega boards, so I should be able to test this in about a week or two.
https://www.amazon.com/gp/product/B08KXYWNZ3/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1

Regards,
Jaime
2021-03-20 19:15
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 4647
Supporter
I finaly not know.... Cause i´m not a programmer at all....

When i see it correctly in the Bitbucket Pages, then the "FULL" MF Firmware ( we put on the Boards like a sketch) is much bigger then the memory. Work with 256k but for my understanding not possible with 32k.

I not know what parts he "cut" for the UNO or the ProMicro.... But logical it is not possible to copy a firmeware that is much bigger then 32k to a board that only have 32k.
Good Luck !
2021-03-21 14:25
Avatar
jaimeleon
Posts: 13
Hello everyone,
My new mini mega board arrived last night, so I was able to test the two lcd screens hooked up to two separate boards, as suggested in a previous post.

I am happy to report that the two screens successfully switched pages at the same time, controlled by one single button. This confirms Pizman82 suspicion that the problem might be caused by a limitation on the i2c serial interface not being able to send commands to the two screens, within a very short time span. Thanks to Pizman82 for diagnosing the problem and figuring that by using two mega boards we would be able to circumvent the problem, providing two separate i2c interfaces.

In conclusion from my testing:
  1. Using one mega board, changing pages in two lcd screens can only be done one screen at a time. Use two buttons or two separate button presses instead.
  2. Pro Micro boards (Atmega32u4) currently appear to be unable to use lcd screens in Mobiflight. Although no problem was reported and "Mobiflight Rocks!" was displayed when set up, nothing else could be displayed afterwards. This limitation or bug should maybe be documented somewhere.
  3. Using two mega boards appears to be the best solution to be able to change pages on two screens at the same time.


UPDATE 4/8/21
I have been making very many tests over the past week with two lcd screens and one or two mega boards. Here are my conclusions:

One board to control two lcd screens is STRONGLY NOT RECOMMENDED. Even though Mobiflight allows you to use up to two in one board, don't. Limit yourself to one lcd screen per each mega board. It appears that the speed to update two screens on one i2c serial interface is just too slow. I tested two screens connected to one mega board, with nothing else connected (all other inputs and outputs on another mega board). When the plane was on the ground both screens appear to be operating well. As soon as the plane starts to move on the runway, the second screen (address 0x26) becomes sluggish and freezes. The first screen (address 0x27) continued to operate normally, updating the flight information. As soon as the airplane lands and stops, both screens operate normally again.

As expected, separating the two screens to one board each results in much better results. This time, I tested one screen with all other inputs and outputs on one board, and the second screen alone on the other board. Both screens operated normally displaying the flight information and you can even switch pages on the screens, which was impossible in the previous setup with one board. For reference, about half of the 70 pins were being used for other inputs and outputs.

Best regards,
Jaime
[Last edited by jaimeleon, 2021-04-09 01:08]
2021-03-26 17:18
icon