Speed and loading issues of LCD screens

Hello,

So I am currently using arduino IDE to program the Raspberrypi Pico W. I have connected a tca9548a multiplexer to the pico W so I can control 4 independent LCDs. For your reference, I am using the LCDs from here: https://akizukidenshi.com/catalog/g/g112486/ they are 16x2 backlit LCDs.

I am now trying to display info on all 4 simultaneously. The first line in all the LCDs are just static dots. The second lines in all LCDs display different text and continuously scroll right in a loop. While building this, I tried the LCDs one by one and in the code I will share now, I combined all 4 LCDs in one code. Now all the LCDs are displaying text but the issue is that they are either too slow, or are displaying only partial text, or displaying weird alphabets. The reason I am wondering if there is a problem is that when I only have one LCD following this code, there is no lag or issues mentioned. but the more LCDs I add, the worse these problems get. I do not know what steps to take to fix this. Should I perhaps place step up resistors? or will a change in the code make it faster?

I have attached the code here:

#include <ST7032_asukiaaa.h>

#include "Wire.h"                    // For I2C
//#include "LCD.h"                     // For LCD
 // Added library*
#define TCA9548A_ADDR 0x70  
#define LCD_ADDR 0x3e
               // TCA9548A Encoder address
ST7032_asukiaaa lcd;  // Set the LCD I2C address


char text[] = " blue ";
char text2[] = " LESSGOO ";
char text3[] = "work once more!";
char text4[] = "one last";


void selectChannel(uint8_t channel) {
  if (channel > 7) return;
  Wire.beginTransmission(TCA9548A_ADDR);
  Wire.write(1 << channel);
  Wire.endTransmission();
  delay(100);

    lcd.begin(0x3e, 16, 2);
}

void setup() {
  Wire.begin();
  Serial.begin(9600);
  delay(3000);

for (uint8_t channel = 0; channel < 8; channel++) {
    selectChannel(channel);  // Select the channel
    delay(100);  // Allow time for the device to respond

  Wire.beginTransmission(LCD_ADDR);
    uint8_t error = Wire.endTransmission();
    if (error == 0) {
      Serial.print("LCD detected at channel ");
      Serial.println(channel);
    } else {
      Serial.print("No device detected at channel ");
      Serial.println(channel);
    }
  }
}


void loop(){

//DISPLAY 1
selectChannel(7);

 static int startIndex = 0;
  int textLength = strlen(text);

lcd.clear();
  // Print the text starting from the calculated index
  lcd.setCursor(0,0);
  lcd.print(".....");
  lcd.setCursor(0, 1);
  // Print the first part of the text
  for (int i = 0; i < 16; i++) {
    int currentIndex = (startIndex + i) % textLength;
    lcd.print(text[currentIndex]);
  }

  startIndex = (startIndex + 1) % textLength; // Update the start index for the next iteration
  
  delay(400); // Adjust the speed of scrolling here


//DISPLAY 2

selectChannel(2);

 static int startIndex2 = 0;
  int text2Length = strlen(text2);

lcd.clear();
  // Print the text starting from the calculated index
  lcd.setCursor(0,0);
  lcd.print(".....");
  lcd.setCursor(0, 1);
  // Print the first part of the text
  for (int i = 0; i < 16; i++) {
    int currentIndex2 = (startIndex2 + i) % text2Length;
    lcd.print(text2[currentIndex2]);
  }

  startIndex2 = (startIndex2 + 1) % text2Length; // Update the start index for the next iteration
  
  delay(300); // Adjust the speed of scrolling here
  

  //DISPLAY 3

  selectChannel(1);

 static int startIndex3 = 0;
  int text3Length = strlen(text3);

lcd.clear();
  // Print the text starting from the calculated index
  lcd.setCursor(0,0);
  lcd.print(".....");
  lcd.setCursor(0, 1);
  // Print the first part of the text
  for (int i = 0; i < 16; i++) {
    int currentIndex3 = (startIndex3 + i) % text3Length;
    lcd.print(text3[currentIndex3]);
  }

  startIndex3 = (startIndex3 + 1) % text3Length; // Update the start index for the next iteration
  
  delay(500); // Adjust the speed of scrolling here


//DISPLAY 4
   selectChannel(0);

 static int startIndex4 = 0;
  int text4Length = strlen(text4);

lcd.clear();
  // Print the text starting from the calculated index
  lcd.setCursor(0,0);
  lcd.print(".....");
  lcd.setCursor(0, 1);
  // Print the first part of the text
  for (int i = 0; i < 16; i++) {
    int currentIndex4 = (startIndex4 + i) % text4Length;
    lcd.print(text4[currentIndex4]);
  }

  startIndex4 = (startIndex4 + 1) % text4Length; // Update the start index for the next iteration
  
  delay(500); // Adjust the speed of scrolling here
  }
  

I have also attached pictures of the circuit. it is messier than it looks. The 3.3V, Ground, SDA and SCL pins of the Pico W are connected to their counterparts on the Multiplexer. From the multiplexer, the SDA and SCL pins of all the LCDs are connected to respective SDA and SCL pins 0,1,2,7. They are also connected to the ground and power. it is a very simple circuit actually. All the circuits of the LCDs are correct since I tested this configuration with different code. but if you think a change will help, I am happy to try it.





How much do you think that your delays add to your problem? I count a total of 1.7 seconds in loop().

That is a 16x2 LCD. It is using i2c, correct?
What i2c driver are you using? Most are able to change the address, eliminating the multiplexer.

void selectChannel(uint8_t channel) {
  if (channel > 7) return;
  Wire.beginTransmission(TCA9548A_ADDR);
  Wire.write(1 << channel);
  Wire.endTransmission();
  delay(100);

  lcd.begin(0x3e, 16, 2);
}

Do you really need 100mS after switching the multiplexer channel? That seems like a very long delay.

lcd.begin() should only be needed in setup(), re-initializing the displays every time you change multiplexer channels will cause extra delay and may cause noticeable blinking of the display.

Do you want the text to be repeated multiple times on the line, or do you want a single copy of the text to scroll across the entire 16-character width? The way the code is written, any text shorter than 16 characters will be repeated on the line.

I just took a look at the LCD library you are using. It allows multiple instances with different i2c addresses. Are you certain you need the multiplexer?

Ah i see, so the delays seem to all add up then. How do I ensure that they all follow the same delay. For example, for all the LCDs, the delay is only 400 or so- so all the text moves as the same speed?

What is the ideal delay after switching a multiplexer channel?

I will make that change and initialise lcd.begin() only in setup. I think you might be right about it adding extra delay and issues on the LCD. I will give it a try.

So for the text, I want it to be repeated indefinitely on the second line of the LCD. eg- "blue blue blue blue blue blue..." in an endless scroll. So thats "blue " repeated indefinitely in a scroll

Yes, most LCD boards have a way to manually change their i2c addresses by soldering something on the i2c module on the back . But the LCDs I have do not have that option, so it seems I am stuck with them all having the same i2c addresses. The easiest way to solve that was with the multiplexer.

I don't know about the multiplexer. I can get a LCD with a driver that can change the i2c address for $0.83 from AliExpress. Hard to get a multiplexer for that.
https://www.aliexpress.us/item/3256805913767190.html?spm=a2g0o.tm1000004601.d0.1.58fe53f3wetKeP&sourceType=562&pvid=bc3e943e-7272-4b16-b958-5a1a34e2bb7d&pdp_ext_f={"ship_from"%3A"CN"%2C"sku_id"%3A"12000036406595433"}&scm=1007.28480.379202.0&scm-url=1007.28480.379202.0&scm_id=1007.28480.379202.0&pdp_npi=4%40dis!USD!US%20%241.32!US%20%240.83!!!9.55!6.02!%402101e58317181482049215351e83c8!12000036406595433!gsd!US!3864521724!&channel=sd&aecmd=true&gatewayAdapt=glo2usa

I don't recall ever seeing a sketch that had any delay after switching the multiplexer channel on a TCA9548a.

Remove all delays from loop() and add a single one at the end of loop() is probably the easiest way for now. Till you also want to react on button presses, serial input etc.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.