A little venture with electronics – LCD diagnostics and software

So wiring up the LCD and getting it to display some text should have been simple, I had all the bits, the wiring was very straight forward and the libraries for programming were all written.

But the screen was just blank….

Firstly I checked the wiring was correct and no visible shorts. I then tried different libraries settling on the ST7036 as my panel was driven by an ST7032 which should be code compatible, however a change of library did not seem to help. So I thought it was time to dig out the multimeter and check that I did not have any dry joints or shorts. Unfortunately, I could not find it.

Whilst I was thinking of where I could have left it I made a couple of other changes to the circuit. On one website I saw a recommendation to keep the reset pin high so I wired that to the 5v line with another 4K7 resistor. I also wired in the backlight on the off chance that was powering more than just the light. The backlight came on but still nothing from the display.

I’ve since been advised by Midas that the display is a “a negative type LCD” so characters can’t be seen without the backlight being enabled. They also agreed that the reset should be held high.

I searched high and low in the Workshopshed and found a rev counter but no multimeter, so I put that away in the “measuring tools” drawer. At the back of the drawer was the multimeter so dragged that out and checked my circuit again. After all that it turned out that there was nothing wrong with the circuits.

So back to the software….

I dug into the libraries and noticed that the code that initialise the LCD pretty much matched the example I was seeing on the datasheet, this was a good sign as it meant my library was a good match with the panel. However in the constructor of the ST7036 class there appeared to be a bit shift of the address, one bit to the right.

_i2cAddress = ( i2cAddr >> 1 );

I’m guessing that’s there because the last bit is the read/write flag, so the library is stripping that off to provide it’s own value.

However in the case of my datasheet that had already been factored in. So I doubled up the address (to shift it one to the left) and uploaded my new code.

  • /*
  • Hello World! for Midas LCD
  • */
  • #include “ST7036.h”
  • //set the LCD address to 0x7C,
  • //16 chars and 2 line display
  • ST7036 lcd = ST7036 ( 2, 16, 0x7C );
  •  
  • void setup() {
  • lcd.init();
  • lcd.setCursor(0, 0);
  • lcd.print(“Hello world!”);
  • }
  •  
  • void loop() {
  • }

Bingo, it worked.

So the next thing to do is to wire up my sensor, hopefully that won’t cause me so much grief.

Of course if you don’t want to go through all this hassle you could always buy a ready made shield or kit, see The Shield List.

24 thoughts on “A little venture with electronics – LCD diagnostics and software

  1. Nick says:

    got a midas lcd i2c today, followed your wiring and example and was up and working within minutes, my lcd back led A/K was other way round and had to add Wire.h include for it to compile with version of st7036 I had.
    Thank you for time and example

  2. Hi Nick, thanks for the feedback, glad it went well for you. Are you making anything interesting?
    Cheers,
    Andy

  3. Nick says:

    Hi Andy,

    only just starting to use the Arduino (came from picaxe environment), no projects in mind as of yet, purely to play and understanding the coding with different input/output devices.

  4. Something I did spot which could be really handy when working with I2C devices is this scanner code which iterates through all the possible addresses looking for devices

    I2C Scanner

  5. What perfboard have you attached the display to? I have got my 2×16 display and the pins are not the standard 0.1″ spacing.
    Thanks for the write-up on using these displays.
    Cheers

  6. Ah yes, the pins are a very close together. The board I was using is a prototype shield. The board just has little circle pads with no connections between them. You have to use wires to solder these together.

    If you look at the bottom picture for Wiring the LCD you will see that I’ve bent the pins to get them to fit with the holes. If you use something like stripboard it could be a problem as you have no space to cut the gaps between the pins.

  7. Hi Andy
    Thanks for the quick reply, and pointer to the other photo. Bending the pins explains how to fit on the 0.1″ spacing.
    Cheers
    Steve

  8. 김상훈 says:

    hi i’m a student in korea who want to run this lcd…i use 18f4550 microchip and ccsc c compiler.. this is my first time that i use i2c type lcd. so i study a lot with the datasheet but… i dont have any idea so.. plz can i see your lcd driver file ?? i cant do anything even initialize action. i need your help i wait for your coment. thank you for read my comment!

  9. The libraries came from here http://playground.arduino.cc/Code/LCDi2c you might be able to port them to that microchip device but I’d not be surprised if someone had not already written one.

  10. Martin says:

    Hi Nick,
    Don’t quite understand your comments on address? I understand that the published address is 0x7C. You then say you had to double it. This is then followed by your code which has the address as 0x7C (and not 0xF8).
    Can you explain for me.

  11. Hi Martin, the address was provided in the data sheet as per the diagram. It mentioned that the last bit was not actually part of the address but was a read write flag. I had initially compensated for that and used 3E as the address. That was not needed so hence the 7C value.
    Cheers
    Andy

  12. Martin says:

    Ok Andy, thanks for asking.
    As far as I can tell, my wiring is as you describe. I am using the MCCOG21608A6w. Not quite the same as yours but it still has the ST7032 controller (I am told by Midas). I have a backlight but no characters are visible when using your code? I was using the scanners to test if I could get an I2C acknowledgement from 0x7C (or in fact any valid I2C address).
    Some additional evidence: While using the ST7036 library that you link to in the above notes, I had to rename the lcd.h to LCD.h to compile. Do you remember that? Or is it possible that the library has changed and no longer works as it did for you?
    ~M~

  13. Hi Martin, no I don’t remember having to rename any files. Are you holding the reset line high and also powering the back light?

  14. Shilpa says:

    Hi, thank you very much for your detailed information about connecting LCD. I tried it as you have explained and it is working but I am unable to turn the back light ON. Could you please suggest how should I do? Thanks.

  15. Joseph says:

    Hi what do you mean by shifting address for my display its giving me 0x3F how would I shift it is it increasing the hex value?

Leave a Reply

Your email address will not be published. Required fields are marked *

 characters available