Serial LCD Backpack write speed

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jeffreysbrown
 
Posts: 3
Joined: Thu Sep 03, 2015 3:42 pm

Serial LCD Backpack write speed

Post by jeffreysbrown »

I have question about speeding up serial communication with the LCD Backpack.
My Arduino (Metro) sketch is controlling several relays and a stepper motor. I'm using the LCD Serial Backpack with SoftwareSerial as part of the user interface, and there is a timer that updates the display once per second -- no delays() used. I've found that this causes a slight pause in the stepper motion (using AccelStepper). Checking execution time, my main loop typically executes in 8 to 12 microseconds, with a peak of about 130 microseconds when a math function (including math.Random) is executed. So, well less than 1 millisecond. Timing the call to display 2 lines of text, I find that takes on the order of 35 milliseconds. This is just to write, not move the cursor or clear the display.
Any way to speed this up? Or, should I just use a gearmotor and a couple relays instead of a stepper? It's a low-rpm cyclical (back and forth) rotation, so that is an option, albeit a less desirable one, as I already have a few steppers, and would prefer the simple variable-speed option a stepper gives me. Code available, in full or in part. Thanks!
-Jeff B.

User avatar
jeffreysbrown
 
Posts: 3
Joined: Thu Sep 03, 2015 3:42 pm

Re: Serial LCD Backpack write speed

Post by jeffreysbrown »

One bump (and that will be all, I promise)...
No one has thoughts about this?
thx,
Jeff

User avatar
underconstrained
 
Posts: 3
Joined: Thu May 26, 2016 12:27 pm

Re: Serial LCD Backpack write speed

Post by underconstrained »

I'm in the same boat. I'm trying to do some motor stuff and occasionally write to an LCD and am playing with both and Arduino Uno and Teensy LC, 3.6 and 4.0. All tests are run using an adafruit 16x2 display and modified versions of the Teensy Benchmark example. I get the following:

Without the backpack & running on an Uno
LiquidCrystal = 386 milliseconds
LiquidCrystalFast = 213 milliseconds

With backpack via i2c on an Uno
Adafruit_LiquidCrystal = 2032 milliseconds

the following teensys were tested with bidirectional level shifters Adafruit PID 757 on RS,RW,EN,D4-D7 pins

Teensy LC
LiquidCrystal = 295 milliseconds
LiquidCrystalFast = 70 milliseconds

Teensy3.6
LiquidCrystal = 274 milliseconds
LiquidCrystalFast = around 650-750 milliseconds

Teensy 4.0
LiquidCrystal = 271 milliseconds
LiquidCrystalFast = gives me garbage characters

I'm trying to understand why the i2c version is so much slower, fewer pins I guess.
If the libraries existed, would the backpack work faster on the teensy via i2c or SPI?

Any general guidance on how to communicate more quickly with LCD screens would be greatly appreciated. are we running into the hardware limitations of the screens?

I'm posting this to the teensy forum as well, after seeing jeffreysbrown's similar line of questioning there...

User avatar
underconstrained
 
Posts: 3
Joined: Thu May 26, 2016 12:27 pm

Re: Serial LCD Backpack write speed

Post by underconstrained »

Forgot the SPI case

running the teensy benchmark code

With backpack via SPI on an Uno
Adafruit_LiquidCrystal = 2495 milliseconds

Here is modified code

Code: Select all

/*
 Demonstration sketch for Adafruit i2c/SPI LCD backpack
 using 74HC595 SPI expander
 ( http://www.ladyada.net/products/i2cspilcdbackpack/index.html )

 This sketch prints "Hello World!" to the LCD
 and shows the time.
 
  The circuit:
 * 5V to Arduino 5V pin
 * GND to Arduino GND pin
 * CLK to Digital 2
 * DAT to Digital 3
 * LAT to Digital 4
*/


// include the library code:
#include "Wire.h"
#include "Adafruit_LiquidCrystal.h"

// Connect via SPI. Data pin is #3, Clock is #2 and Latch is #4
Adafruit_LiquidCrystal lcd(3, 2, 4);


const int nRows = 2;      //number of rows on LCD
const int nColumns = 16;  //number of columns

const int length = nRows * nColumns;
char text[length+1];
char blanks[length+1];

void setup(void) {
  lcd.begin(nColumns,nRows);
  lcd.setCursor(0,0);
  char c = 'A';
  for (int i=0; i<length; i++) {
    text[i] = c++;
    blanks[i] = ' ';
    if (c > 'Z') c = 'A';
  }
  text[length] = 0;
  blanks[length] = 0;
  unsigned long startTime=millis();
  byte repetitions = 20;
  while (repetitions--) {
    lcd.setCursor(0,0);  // fill every screen pixel with text
    lcd.print(text);
    lcd.setCursor(0,0);  // then fill every pixel with blanks and repeat
    lcd.print(blanks);
  }
  unsigned long endTime = millis();
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Benchmark ");
  lcd.print(nColumns, DEC);
  lcd.write('x');
  lcd.print(nRows, DEC);
  lcd.setCursor(0,1);
  lcd.print(endTime - startTime);
  lcd.print(" millisecs.");
}

void loop() {
}

User avatar
jeffreysbrown
 
Posts: 3
Joined: Thu Sep 03, 2015 3:42 pm

Re: Serial LCD Backpack write speed

Post by jeffreysbrown »

This might help:
I installed a version of espSoftwareSerial, from https://github.com/plerup/espsoftwareserial
and, have upped my Serial (for debugging) and SoftwareSerial to 57600 baud. I found that reduced the time for a 2-line display to 13 milliseconds.
HOWEVER --- seems to be rather unstable with the Serial Backpack, which tends to revert to 9600 baud on power-cycling, and not 'pick up' the higher rate, even on a reboot of my Metro (Uno).
Adafruit mentioned that their board can be reconfigured to support up to 57600 baud, but the documentation on how to do so was not apparent to me from the tutorial docs.
* I am not an expert * But, it seems that the Serial RX/TX rate does have a large effect on write times (not really a surprise).

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”