2

I have been trying to get a HD44780 LCD display to work for multiple times. The first time was by parallel port from a computer, then multiple times using different PIC uCs. I am only able to get the display to show half of the dots (the right side of the screen) as black, and the left side as blank/white. I read from the internet that it means the display is not initializing properly.

The display is Tianma TM161A/B

    setData(0b00110000); // INIT
    strobeE();

    DelayMs(5);

    setData(0b00110000); // INIT
    strobeE();

    DelayMs(5);

    setData(0b00001111); // ON/OFF
    strobeE();

    DelayMs(5);

    setData(0b00000001); // CLEAR
    strobeE();

    DelayMs(5);

    setData(0b00000110); // ENTRY MODE
    strobeE();

void strobeE() {
    mPORTDSetBits(E);
    DelayMs(1);
    mPORTDClearBits(E);
}

I have used a logic analyzer, a logic probe and a multimeter to check if the connections between the PIC and the LCD are correct. I think they are.

A ( bad ) picture of my timings on a logic analyzer; timings from a logic analyzer

Link to the datasheet

What am I doing wrong?

varesa
  • 639
  • 1
  • 7
  • 26
  • Try increasing all delays to maybe 10 ms. Few years ago when I was trying o start such a display, I found out that the delays specified in the datasheets were usually too short for some reason. – AndrejaKo Jun 09 '12 at 16:13
  • @AndrejaKo It made no difference... – varesa Jun 09 '12 at 16:19
  • I'm pretty sure that it's a timing issue somewhere, but at the moment, I can't figure out where it could be. – AndrejaKo Jun 09 '12 at 16:48
  • 1
    Are you sure the LCD is functional or if it's your code? I was using a NorthMicro proto board and thought my code was bad when in fact the contrast was just set too low for anything to display. Found that out by using another guys LCD with my code. – Chef Flambe Jun 09 '12 at 16:54
  • @ChefFlambe Well I can't be sure about that, unless I can get my hands on display I have seen to work with some code, but I have 3 displays ( 2 Tianma, 1 Displaytech ). One of the Tianmas seems completely dead, and I assume it is broken. Other two show the black bars. Would be really bad luck to have 3 broken displays. – varesa Jun 09 '12 at 17:41
  • @AndrejaKo That's what I think too. Can the times be too long? The datasheet speaks about times like 50 us. 10 ms is 200 times bigger. It doesn't mention about max-times – varesa Jun 09 '12 at 17:44
  • @varesa Could be, but I don't think so. I've seen such displays operated by hand using push-buttons and Schmitt triggers. I also remember back when I used to drive a HD44780 type display, I used much longer delays than in the datasheet and it worked fine with them (but not short delays). I can't telly you anything else than to try experimenting with the delays. – AndrejaKo Jun 09 '12 at 17:48
  • The piece of code you posted doesn't give us enough information. Where is your initialisation code? Are you driving the RS and RW lines correctly? You could also post a wiring diagram - just in case. – Armandas Jun 09 '12 at 18:43
  • @Armandas What initialization are you talking about? PIC? LCD? Anyway I added a bit longer piece of code... – varesa Jun 09 '12 at 18:57
  • @varesa, you need to mention which port of the PIC is connected to which pin on the LCD. Also, some information on the TRIS registers of the relevant port will be helpful. – abdullah kahraman Jun 09 '12 at 19:02
  • @abdullahkahraman Well all the ports are output, which can be seen from the LA screen, that they really work. I can post the whole code if you want – varesa Jun 09 '12 at 19:05
  • @varesa it would be great that you post the whole code and the schematic. If this project includes things other than controlling the LCD, I think you should filter irrelevant things out both in the schematic and the code, before posting. – abdullah kahraman Jun 09 '12 at 19:08
  • @varesa if you do not have any schematic available, at least post a table that shows connections in-between the PIC and the LCD. For example: D0-RB0, RS-RB7 etc. – abdullah kahraman Jun 09 '12 at 19:09
  • @abdullahkahraman ... Now I made it work, but no idea how. Maybe there was a loose wire? – varesa Jun 09 '12 at 19:46
  • @varesa it is impossible for us to understand what is going on without knowing enough. Glad it has worked. – abdullah kahraman Jun 09 '12 at 20:13
  • 1
    You show the data and E lines. There are also the R/W line (which can be tied to W permanently, but you still have to do it) and the C/D line which you don't show at all. Do you handle those lines correctly? And there is the power-up-rto-first-commnd delay. – Wouter van Ooijen Jun 09 '12 at 20:51
  • @WoutervanOoijen RW and RS were ( supposed to be ) tied to ground (now the RS is driven by the uC), and the display was powered up before the uC, so no need for a addittional delay. I believe my issue was floating RS or RW (loose wire) – varesa Jun 09 '12 at 23:08

2 Answers2

2

The problem with the display not initializing was because of a loose wire. It was either RS or RW, that was left floating.

My logic analyzer showed it being in the low state, but seems the LCD's controller thought otherwise. (Different kind of input)

A tip:
Check your wirings: not connected != input driven low

A logic probe, which emits a high, or low pitch sound depending on the signal, helped me find the problem. It did not give any kind of sound at all on that pin.

varesa
  • 639
  • 1
  • 7
  • 26
  • Could you post a more accurate diagnosis of the problem? It seems quite vague to be helpful in this form. – clabacchio Jun 14 '12 at 07:26
  • @clabacchio What should I post? When nothing else worked, I checked my wiring one more time... I don't think that was the original problem, but it's hard to know now... – varesa Jun 14 '12 at 07:31
  • you should try to bring it to the previous state, and replicate the error, if possible. Otherwise, not to be rude, your answer won't be useful to anybody else – clabacchio Jun 14 '12 at 07:35
  • @clabacchio Sadly I do not have the breadboard and other stuff available, I thought of the same thing... – varesa Jun 14 '12 at 07:44
1

Check your "function set" word (0b00110000). bits 2 and 3 (N and F in datasheet) set display shape. If they are set incorrectly, part of display will not function -- try all 4 combinations.

theamk
  • 3,128
  • 11
  • 15
  • @varesa - That's great, but people are still trying to help you! It would be great if you would [answer your own question](http://blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/) so that future readers with the same problem can benefit from your solution. – Kevin Vermeer Jun 13 '12 at 21:50
  • @KevinVermeer Yeah, I thought I had accepted someone's answer, but seems I hadn't ( there weren't even any answers before this). I was too lazy to write one last night... – varesa Jun 14 '12 at 07:01