I connected an HD44780 compatible LCD via a 40wire, about 50cm long IDE cable to the proto shield of a MEGA 2560.
I have problems to get the "hello world" example running.
Lots of weird characters are displayed, sometimes changing their positions. Sometimes parts of the "Hello World" text show up, too.
My major concern is that the cable is simply too long and the signals get distorted. Is there any relief? Like adding some capacitors and/or resistors as terminators? Where? Which values might be appropriate for a start? Would I need a shielded cable?
An observation that supports this assumption is that, when I tried to control the contrast via a digital/PWM output, the value on this line influenced the contents that were displayed on the LCD. (now I simply connected it to GND).
Some additional notes:
I am using digital pins 33 to 30 for data, 34 for E and 35 for RS. I noticed that in the examples, E is connected to a pin that is suitable for PWM, but that should not matter - does it?
when adding a "delay(100);" command after an lcd.* command, the display starts flashing and no characters are visible at all.
Partially solved: I forgot to connect the 5V line (but still the display LED (connected in parallel to the power supply) was on. But it seems, it was Just powered by the other pins). Drove me nuts for 2hrs, now. Seems the signal inputs have protection diodes to dissipate overvoltage to the 5V and 0V lines. Might be an explanation for the observed behavior.
Now, you may call me stupid. But, as usually, solutions come when you start to discuss the problem. Hope, I haven't damaged the display...
And (this is not solved yet): Is there any issue with maximum cable / wire length and termination?
Is there any issue with maximum cable / wire length and termination?
Yes there is a cable length where one can start to have problems, but your not likely to find a specification that will tell you a specific length restriction. I would think a foot or two would not be a problem but more then that might start to act flacky. Adding power bypass cap(s) at the display across +5vdc and ground pins can help if required. What length did you have in mind?
If anything might help at that length (in addition to the decoupling capacitors) is a resistor in series with the E (clock) signal. Like 100-220 ohms or so. And the LCD code might have to be slowed down a bit to let the data lines settle before pulsing the clock.
--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, speaker, microphone, light sensor, potentiometer, pushbuttons
I am thinking using MAX232 to boost serial lines to + - 12 V for transmission over a decent serial cable,coule be as long as 1,000 m.
Then the receiving end will use MAX232 again to lower the voltage back to 5V. You could consider sparkfun serial LCD or mine, a much more capable serial LCD
In my graduate student years, I used to pull a very long serial cable to control an apparatus and never thought about interference as much as another long cable that carried both largish power and weak signal. If you mix rapid changing power with weak signals, you are asking for trouble unless you have separate shields inside one cable bunch.
The problem with the long cable is that it causes signal reflections with fast switching signal. This translates to signal "waving", and lines like clock lines read it like several pulses.
I can't program an AVR (running at >=8MHz) with a 50cm long cable connected to my PC parallel port, and my cable already has RC filters to slow down the signal change speed as RuggedCircuits mentioned (the AVR can switch the output in 16ns, unloaded).
My suggestion is: try a 60-65cm cable; if it still works flawlessly you're ok with the 50cm one, otherwise cut it to 40cm.
What about very long firewire cables that I've used, at least 12 ft long if not double that. Signal inside that is able to support 400Mbps so maybe the receiving end is taking care of signal reflection? Or you could use low baud rate. I am just guessing that twice the cable length with half the baud rate yields comparable results. Updating LCD needs not be fast anyway. It's for human eyes.