16x2 LCD controller crashing (showing garbage characters) - Page 1
Forum section: electronics / projects

author: webgiorgio
author_rank: Regular Contributor
timestamp: June 07, 2018, 01:45:13 pm
content: Hello,I have a circuit with a micro-controller and a dot matrix LCD display, 16x2 (those you find on Ebay for 2€).Time to time the display enter a state where it is showing garbage characters. Re-initializing the display with a command from the uC does not solve the problem.This lead me to think that the problem is on the controller chip (a non brand version of HD44780U, chip on board).In fact, if I remove the power to the LCD display and put it backs On, it is still showing garbage, but ifI now call the initialization functionit goes back to normal.Has this ever happened to you? The 5V supply looks fine on the oscilloscope, and I have 100 nF capacitor quite close to the display supply pins.Would it be smart to be able to cut the power supply of the LCD display from the uC?

author: BradC
author_rank: Super Contributor
timestamp: June 07, 2018, 01:58:56 pm
content: Does your initialization function cover all the required settings, or is it relying on the display being in a freshly powered up state?ie, if something goes south, are you absolutely positive you are resetting and configuring the display correctly?

author: JS
author_rank: Frequent Contributor
timestamp: June 07, 2018, 04:05:01 pm
content: Yes, pretty common failureAre you driving with parallel data or it has a serial driver?In 4 wire (or serial, as it drives in 4 pin mode) commands are spplited in two write operation, the command which says I'You should add the initializationsending data in 4W is the only 4w and 8w compatible one, but it should be send at least 3 times to avoid confusions with previous commands.Once in 4W you should clear the display and start over.JSEnviado desde mi LG-M250 mediante Tapatalk

author: webgiorgio
author_rank: Regular Contributor
timestamp: June 07, 2018, 08:35:10 pm
content: I use 4 data lines (D4, D5, D6, D7), register select (RS) and Enable (E). The read-write (RW) is to GND.On the software side I use Arduino, with the library <LiquidCrystal.h>.https://www.arduino.cc/en/Reference/LiquidCrystalTo initialise the LCD I call:Code:lcd.begin(16, 2);lcd.clear();QuoteI don't know.QuoteNext time the display goes nuts, I will try sending the initialization commands at least 4 times.

author: JS
author_rank: Frequent Contributor
timestamp: June 07, 2018, 09:14:05 pm
content: Quote from: webgiorgio on June 07, 2018, 08:35:10 pmYou don't need to send that command 3 or 4 times, one should be enough as it's probably doing it correctly, it does more than sending the 4 pin setup instruction, but you never really know what's happening behind the scense (unless you dig, but you don't need to).If using arduino just send the lcd.begin(16,2); and lcd.clear(); once and you should be good to go.JS

author: Dubbie
author_rank: Unknown
timestamp: June 08, 2018, 05:24:16 am
content: Also check the timings. Some timings that are rock solid on some units can be dodgy on others from another manufacturer.

author: klunkerbus
author_rank: Unknown
timestamp: June 09, 2018, 01:16:44 am
content: The LCD display on my 3D printer would often go into "garbage" mode. As already suggested, using the 4-bit interface requires two commands to specify a character for the display to show. A static hit or anything else that causes a double strobe or a strobe to be missed gets the data transfers out of sync. What I eventually figured out was that the "garbage" was very predictable - I was just addressing the extended ASCII character set that is normally unused. Odds are you're doing the same.

author: webgiorgio
author_rank: Regular Contributor
timestamp: June 09, 2018, 08:16:50 pm
content: You are right, that's what is happening to my display. In fact, the "garbage" changes once a second in the second line, as supposed to.So, how to prevent or mitigate the issue before the user faces the LCD and gets scared?Turning the LCD controller off-and-on as soon as the use press any button?My idea:One pin of the uC is controlling in PWM the backlight LED. The lowest it goes is 50% PWM. I could use this signal to turn off the LCD holding the signal low for a certain time. (I mean, use the PWM to charge a capacitor trough a diode, then the voltage of the capacitor to drive a NPN with emitter to ground, and collector to the base of a PNP transistor which has the emitter to 5V and collector to the Vcc pin of the LCD).

author: jbb
author_rank: Super Contributor
timestamp: June 09, 2018, 08:47:33 pm
content: OK, sounds like you have an EMI problem. (ElectroMagnetic Interference)You could re-initialise the LCD periodically (you probably don’t need to cycle the power), but that’s a band aid. What you should do is try to stop it from happening. I suspect that adding some filters to the strobe, RS and data lines might help a lot.Can you post a diagram and a photo of your setup? There may be problems with layout or wiring that we can help with.Do you have an oscilloscope?

author: klunkerbus
author_rank: Unknown
timestamp: June 09, 2018, 10:50:50 pm
content: FWIW, "standard" fixes I've heard of people trying on their printers include -a) shortening the wiring to the LCD as much as possible.b) isolating the LCD wiring from any other wiring to minimize crosstalkc) shielding the wiring to the LCDd) adding a series termination resistor like 47-ohms in at least the E pin. Some people add them in all of the lines but IMO the E signal is the most critical one. That's the one that strobes the data into the LCD controller.

author: JS
author_rank: Frequent Contributor
timestamp: June 10, 2018, 02:39:24 am
content: Some audio circuits use bootstrapping to keep common mode input impedance really high while leaving a low impedance path to the BJT input. The circuit do work and increases the CMRR when the source impedance is unbalanced, in that regard is great but you need the common mode to stay between the rails as the bootstrapping stage must drive the differential amp inputs with 99.99% of the common mode signal, multiplying the common mode input impedance by 1000. (add as much nines and zeros as you like)So, the limitation is that differential probe can't manage signals bigger than it's own rails. And tweaking the HF going to the bootstrapping circuit might be quite tricky, as impedances must be matched in many steps of the process. If LF CMRR is very important and HF CMRR not so much (depending on the application) this is a good approach, also it works fine when the CM signal isn't much greater than the normal mode one, but you want to archive high amounts of CMRR even when the source impedance is unbalanced. If you want to cancel out mains induced noise from an audio amplifier this does a good job. It's probably for good application in audio where you feed a 24 bit converter with a signal that originally had SNR=30dB. Not so much in instrumentation as you have to feed an 8 bit ADC with a signal that origginaly had SNR=-40dB.One walk around would be to tweak the CMRR on the fly, which is completely doable as long as you can sense the CM signal by it's own without having imposed the NM you are trying to measure in the first place. or the impedance unbalance of the source. Not so practical.JS

author: webgiorgio
author_rank: Regular Contributor
timestamp: June 10, 2018, 08:49:43 pm
content: See attached photo. I am starting to feel guilty on my EMC design.The ribbon cable that takes the LCD and push-buttons signals (6 button on one analog input of the uC) from the bottom to the top board is right above the switching 5V DC-DC converter, and besides mosfets and relays driving two 5A 24Vdc motors at 1 kHz (the relays only invert the polarity of the motor when the mosfet is off).This is meant for prototype, I already decided to move the Arduino on the top board in the next PCB version.So that the traces to LCD and pushbuttons are short.On this design I could shorten the ribbon cable and cover it with aluminum tape. However, the problem happens quite seldom. It can work well for 2 days with driving the motor several hundred times, without the LCD crashing. How can I force the problem to happen?I have an oscilloscope (Rigol 70 MHz).

author: jbb
author_rank: Super Contributor
timestamp: June 11, 2018, 12:31:34 am
content: OK, that’s by no means hopeless. We might be a Kentucky to improve the situation with a few resistors and capacitors.I would suggest adding some 100 R series resistors to the E, RS, RW and D lines at the Arduino end. Then add some 10nF capacitors from these lines to ground as close to the LCD as possible. This will do two things: the resistors prevent big current spikes out of the Arduino into the ribbon cable (which is capacitive) and th capacitors absorb high frequency content (e.g. noise). You should use your scope to check that the RS, RW and D lines are all stable before the E puls goes off. If the caps are too large, the signal will be impacted and it won’t work well.While you’re there, adding some capacitors to the buttons might be a good idea. They will absorb spikes when you touch the buttons (e.g. electrostatic discharge ESD) which could upset your microcontroller. A classic issue is ‘I touched the button and it reset.’To emulate interference, expensive test labs use a few methods: beaming radio waves at a device, firing small arcs I got the device and transformer fouling spikes and surges into the device. I hear that you can use the spark ignited from a BBQ to drop some sparks into a device, but I don’t know how the energy from that will line up with real world events.