Output to 4X20 LCD display (I2C)

I'm driving a stepper motor (variable speed with pot) with Arduino uno. I display RPM and Revolutions on the LCD at maybe .5 second interval. Every time I display there is a noticeable delay in the stepper motor. I have also tried this with the Arduino Due, same thing. Appears that the write to the LCD is very slow.

Any ideas? Any faster displays?

Thanks in advance for any help, Dale Winburn, An Arduino newbie

Please post your problem code using code tags when you do

Read this before posting a programming question

dwinburn: Any ideas? Any faster displays?

It really isn't so much about the speed of the display but rather how the display is updated, how the library communicates with it, and how (or rather when) the communication overhead occurs.

Writing to the LCD can take some time, particularly with i2c. Unfortunately, the Arduino Print class is completely synchronous so once you call print() it will not return until all the characters have been handled. And for LCDs that means all of them sent to the display.

The amount of time to print characters to the LCD can vary quite a bit depending on what you are doing and how many characters you are writing to the display. Also, different libraries do things differently than can have an impact on how long it takes to update the display. For example, the hd44780 library does things very differently with respect to LCD instruction timing and how it handles the i2c bus for doing updates to the LCD As a result it can update the LCD much faster than other libraries. On an AVR at 16Mhz, the hd44780_I2Cexp i/o class can write a byte to LCD in 549us (16x2 full display update in 18.66ms) The LiquidCrystal_I2C library on the same h/w writes a byte to the LCD in 1454us (16x2 full display update in 49.44ms) That is a nearly 3x difference from just using a better library.

On a esp8266 WeMos mini the time is 486us (16x2 full display update in 16.55ms) Bump the i2c clock up to 400Khz and it reduces even further. The AVR using a 400kHZ SCK transfers a byte in 199us (16x2 full display update in 6.76ms) The esp8266 at 400kHZ SCK transfers a byte in 130us (16x2 full display update in 4.44ms)

So you can see if you use the hd4480_I2Cexp i/o class in the hd44780 library, you can speed things up more than 10x on a faster processor and by setting the i2c clock to 400kHZ.

Even on an AVR by just switching libraries you pickup 3x faster, and if you bump the clock to 400kHz you get close to 7.5x faster.

--- bill

Use a second Arduino for the display( perhaps a pro mini)...clone units are cheap enough.

Are you clearing and rewriting the display every time, or just writing the data that has changed? That makes a major difference in how long it takes.

david_2018: Are you clearing and rewriting the display every time, or just writing the data that has changed? That makes a major difference in how long it takes.

True, which is what I said earlier. But don't forget that the library used can make an even bigger difference. For example, the hd44780 library can re-draw an entire 16x2 display in less time than it takes the Adafruit_LiquidCrystal library to draw 3 characters.

--- bill

Thanks everyone for your input. Sorry I haven’t replied to anyone’s comments, I woke up yesterday with a fever and had to go for a covid-19 test, haven’t got the results back yet, but I feel a little better today.

I’m using the <LiquidCrystal_I2C.h> library, Before I posted the question, I had already changed the code to write only two bytes of data and I still had a noticeable pause in the stepper motor.

I will try other possibilities.

Other libraries (hd44780), a second arduino sound interesting, I have an arduino uno, arduino due, a mega clone and an uno clone, just have to figure out how to communicate between the two.

Thanks again every one and have a great day,
Dale

dwinburn: a second arduino sound interesting, I have an arduino uno, arduino due, a mega clone and an uno clone, just have to figure out how to communicate between the two.

If the display is for a rev counter, no communication between the two Arduinos would be needed.

Good news, I tested negative for covid-19.

I count steps of the stepper motor to calculate RPM and revolutions. I think I'll try to send the info from the master uno to the slave then let the slave display the data on the lcd.

Thanks again everyone.