API communication slow using messageport

Support for Arduino in combination with Air Manager and Air Player

Moderators: russ, Ralph

Message
Author
Shimokuta
Posts: 113
Joined: Wed Feb 03, 2021 12:52 pm

API communication slow using messageport

#1 Post by Shimokuta »

I am using an arduino where a OLED screen is connected to display COM and NAV frequencies.
I am using the message port to interface to AM 4.0
Also a dual encoder is connected to change the frequencies.
This all is interfacing well, only it is very laggy....
When turning the encoder frequencies on the OLED screen which are transfered back from AM appear with a small delay.
Is there a way to fix this lag .
USB settings are all set to the max, and sim and am are on the same pc...for now..

JackZ
Posts: 2262
Joined: Mon Feb 22, 2016 1:02 pm

Re: API communication slow using messageport

#2 Post by JackZ »

Hi.

Your problem can well be related to the interface type of your screen
If you are using an Oled screen with an I2C interface, the refresh rate is way slower than using the same OLED but with an SPI interface.
SPI uses more pins than I2C but is generally faster.
It also can depend on which display library you are using, I found out that u8g2 is typically faster than the Adafruit library.

My 10 cents

Jacques
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

lonespace
Posts: 64
Joined: Wed Mar 25, 2020 1:58 am

Re: API communication slow using messageport

#3 Post by lonespace »

Also consider how often you’re updating the display. I found that constantly sending messages through message port will cause delays, sometimes massive ones. Consider only sending a message from your instrument and to your display only when there’s a change in what it needs to display.

Shimokuta
Posts: 113
Joined: Wed Feb 03, 2021 12:52 pm

Re: API communication slow using messageport

#4 Post by Shimokuta »

Yes i have an I2C OLED interface.
I do update the display frequently, i was thinking this would perhaps speed up the interface.
hmm...i will go and try this.

Thanks guys!

lonespace
Posts: 64
Joined: Wed Mar 25, 2020 1:58 am

Re: API communication slow using messageport

#5 Post by lonespace »

As I understand it (and maybe somebody more knowledgeable will come along and correct me), when you send a message from your instrument and your Arduino is not yet ready to read it, the message gets put in a queue/buffer until it can be read. Any further messages will get put in the buffer until it’s their turn, and as these messages stack up, you end up with latency and sometimes (in my experience) a crash of your hardware.

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: API communication slow using messageport

#6 Post by jph »

Hi Lonespace.
The very best thing to do is write an Arduino only program that simulates updates to the display in use. See how this performs. As Jacques says, the update speed of 'some' of the oleds can be pretty slow - depending on what you are doing.

BUT, if everything is great in an Arduino only situation, then you can then look at messageport, but, only after running an independent Arduino prog first - without AM. You can simulate random updates with a basic timer in Arduino (WITHOUT DELAY() !) - try to never use DELAY() with Arduino.

Let us know the results of that. Also the display model you are using.
Joe. CISSP, MSc.

Shimokuta
Posts: 113
Joined: Wed Feb 03, 2021 12:52 pm

Re: API communication slow using messageport

#7 Post by Shimokuta »

I am using a 1.54" I2C Oled display, similar to this one
https://nl.aliexpress.com/item/10050020 ... 4c4djIxXgv

I tried reducing the messageport ticks in my Arduino sketch, but this did even caused more latency!!
So i increased the messageport ticks and this did speed up the interfacing!!
I is acceptable now...but not as i would like

Maybe using the u8g2 library also will help.
I will try this too.

JackZ
Posts: 2262
Joined: Mon Feb 22, 2016 1:02 pm

Re: API communication slow using messageport

#8 Post by JackZ »

A dumb remark, but make sure that the screen is powered in 3.3V instead of 5V as this information is often lacking from the site vendor. I had a hard time trying to make my own SPI Oled screen to work properly without artifacts and errors until I powered them in 3.3V
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

Shimokuta
Posts: 113
Joined: Wed Feb 03, 2021 12:52 pm

Re: API communication slow using messageport

#9 Post by Shimokuta »

Using the u8g2 library makes a huge difference!!!
When using this library instead of the AdaFruit, responses of turning the encoders are correct now.

Shimokuta
Posts: 113
Joined: Wed Feb 03, 2021 12:52 pm

Re: API communication slow using messageport

#10 Post by Shimokuta »

i have to adjust my analysis.....
The smaller the font the smoother the interfacing runs.
When using a larger font there is lag again...also with the u8g2 library...

Post Reply