Problem solved! -->ST7565R LCD going haywire with Adafruit code

This was originally posted on the Adafruit forums, where I received the following awnser: "it is not our product, sorry" Unfortunately no members of the community offered help and only the Adafruit support responded. I originally posted there, since I was using their code and thought it would be the best place to start. The link:http://forums.adafruit.com/viewtopic.php?f=25&t=24548

And here is the post: [Note: I am only concerned with the Topway LM6063AFW (ST7565) LCD - The nokia LCD has been dealt with]

Hi,

I am delving into graphic LCDs and have three different models that I am working with:

The first is the Nokia 3310 LCD (PCD8544), for a work project - working Second is a Topway LM6063AFW (ST7565) - issues with displaying data Thirs is Displaytech 32128A (ST7565) - untested, wire pitch wickedly tiny

First question, with the PCD8544 library, upon startup the Adafruit Logo pops up, since this project will be used by docters, they want their own logo displayed. How do I change this? I think during initialization this is pushed to the buffer, but how do I get my own image in there? Also, there is a desire for bigger text, is this possible? Any apps that can create code for custom characters?

Second question, I just connected the Topway display and launched the library example and this is what I am seeing: Could this be a dud?

I found a reference to this issue here: (Almost at the end there is a heading "xxx, lies and datasheets", where the person explains that the page adresses start at five(4) down to eight(7) and then one(0) to four(3). Also, the entire display is shifted three pixels to the left and overflows onto the right-hand side. -> Nothing can be deliberately displayed here, but sometimes things crop up and only way to get rid of them in this 3x64px space is to power down lcd completely. Arduino snowflakes sometimes appear here though... but I cannot draw pixels in the space. Basically, top left pixel is (3,32) -> (x,y),,, http://fabienroyer.wordpress.com/2011/09/14/driving-an-adafruit-st7565-negative-lcd-display-with-a-netduino/

Unfortunately, I am not sure how to do this mapping using the Arduino interface: http://fabienroyer.files.wordpress.com/2011/09/st7565displayrefreshcode.png

Third LCD will work once I uses scavenged connectors to solder wires onto it. I do not want to take chances with the cable burning and the LCD becoming a paperweight. The thing is TINY, Smaller than a Arduino Nano, yet with 128px horizontally. Hope ST7565 library plays nicely with it!

Any help would be appreciated. Thanks! 1089


My second post (In response to Adafruit support asking to see the wiring):

Hi, I am sorry for the late reply, but my Arduino was being used for another project and could not be spared.

I have reconnected the display, and I am still getting the same results. The topway LCD has the following pinout: 1: VSS 2: VDD 3: SID 4: SCLK 5: A0 6: /RES 7: /CS1 8: VSS for backlight

And I connected it with the appropriate pins to the 4050 and to the LCD. The requested photo of wiring: note: My LCD pins are coming from a ribbon cable and I soldered them onto a breakout board for a surfacemount chip. Thus the pins are grouped in twos from left to right: 8 7 | 6 5 | 4 3 | 2 1

The datasheet for the LCD: http://www.topwaydisplay.com/Pub/Manual/LM6063AFW-Manual-Rev0.1.pdf 4050: http://www.mantech.co.za/datasheets/products/74HC4050-NXP.pdf

I hope this is a wiring issue, although I cannot find the fault, and not a problem with the LCD or driver chip. The problem I mentioned in the previous post, with the link and c-code fix, is exactly what I am experiencing as shown in the photo.

Any help is much appreciated!!!

Thanks!!! 1089

First question, with the PCD8544 library, upon startup the Adafruit Logo pops up, since this project will be used by docters, they want their own logo displayed. How do I change this?

I once had the same problem. As far as i remember, they put their logo into the frame buffer, so that i comes up as soon as the display turns on. I think I have cleared the frame buffer during init phase. But at the end, i wrote my own library...: A beta version 0.05 is available for download here: http://code.google.com/p/u8glib/downloads/list.

Second is a Topway LM6063AFW (ST7565) - issues with displaying data

It depends on the display, how the controller (e.g. ST7565) is connected to the actual LCD. So it might happen that for one display the graphics output is correct, but for another display there is something shifted or reversed. U8glib also supports ST7565 (http://code.google.com/p/u8glib/wiki/device), so maybe you could try U8glib with the U8GLIB_DOGM128() subsystem. The DOGM128 is a different display with the same controller. If the display does not appear correctly, we could easily create a U8GLIB_LM6063 with a different setup for your display.

You might also try this lib: http://code.google.com/p/dogm128/

Oliver

Hi olikraus,

Thanks for the response, I was beginning to use the LCD as a paperwheight. My Arduino was caught up in a project today, so I will test your suggestion tomorrow.

1010

Hi again Olikraus,

I have tested my LCD with your library, but unfortunately the LCD is blank. Not sure why though. Datasheet for it can be found here: http://www.topwaydisplay.com/Pub/Manual/LM6063AFW-Manual-Rev0.1.pdf

Hi

Which lib did you use? Maybe you can provide your .pde file. How did you wire your display. Sometimes a picture would help? How did you apply the reset signal?

I will look through the init sequence.

Edit: I have created a new device for your display within u8glib. It contains a modified init sequence according to your datasheet: http://code.google.com/p/u8glib/downloads/list

Oliver

Hi, I opened up the U8GLIB example sketch "Hello World" and uncommented the line for U8GLIB_DOGM128(). Just thought I would see if it worked - will try and comparing the init sequences and the datasheet tomorrow. 1010

Hi

With version 0.06 from http://code.google.com/p/u8glib/downloads/list you can uncomment U8GLIB_LM6063, which includes the init seq from the datasheet of your display.

Oliver

Hi Oliver,

Thank you for adding the LCD! Unfortunately, I am still seeing a blank screen. I noticed that the constructor line for my LCD has no reset pin. I experimented with adding one, since I saw this "initSPI(dev, sck, mosi, cs, a0, reset);" in the U8glib.h file and thought it would just pick it up. This did not work as I had hoped. Any suggestions as to what I am doing wrong?

As for my wiring: The text on the LCD is the connections on the buffer chip.

I checked it again with the Adafruit code to see if the display is actually working, and it still displays the same as it did before - so not broken.

Ok, this means, that the adafruit code works with exactly the same hardware setup, correct?

If the adafruit code works, perhaps you could provide a link to it. The i would be able to reproduce the display init sequence from the adafruit code.

If the reset of the display is wired to the arduino, then add its pin number to the constructor. (mabye you can provide the U8GLIB constructor line)

Oliver

With the same pins plugged in and remapped in the Adafruit sketch, yes it does work, except it splits my display in half and shifts it three pixels left, oveflowing onto the right-hand side, as explained in the previous posts. [Note: I just found this line of code in their library: const uint8_t pagemap[] = { 3, 2, 1, 0, 7, 6, 5, 4 }; and changed it to const uint8_t pagemap[] = { 7, 6, 5, 4, 3, 2, 1, 0 }; which fixes the problem with the display splitting in the middle - unfortunately the pixels still flow over to the right]

I would really like to use your library, since it supports rotation and the other LCDs I have.

The constructor line used for your library: U8GLIB_LM6063 u8g(13,11,10,9,8) //(SCK,MOSI,CS,A0,Reset)

The link to the Github repository of the Adafruit code: https://github.com/adafruit/ST7565-LCD/tree/master/ST7565

It throws my contrast out quite a bit though, very white display, Not sure what a better value would be. (Currently set at 0x18)

Thanks for all the help!

Ps. If you're up for it, I have a KS0108 display that also refuses to work with the general library, but also blanks on your code. But I'll leave that till later.

The U8GLIB constructor should be fine.

I took over the init sequence from github adafruit version. It is available in download v0.07 (you need to add your reset pin for the HelloWorld example!)

My dogm128 still shows up something with the LM6063 sequence, so i assume, that the init sequence is almost correct. Hopefully, you should see something now.

KS0108: Because of the large number of wires, there might be a mistake in the interconnect. GLCD lib also contains a nice diagnosis tool.

Oliver

no1010: Ps. If you're up for it, I have a KS0108 display that also refuses to work with the general library, but also blanks on your code. But I'll leave that till later.

If you want some help with the ks0108 start another thread and I'll help you get it up and going with the glcd v3 library. Use the RC3 version from here: http://code.google.com/p/glcd-arduino/downloads/list

--- bill

Hi again Oliver!

Thank you for all the trouble so far.

I just loaded your library again, and it successfully initializes my display! I did find that if I set the contrast to 0x005 it displays properly without washing out. Also, your library does not compile in the Arduino 1.0 IDE (23) - so I added this as recommended in the release notes (http://arduino.cc/en/Main/ReleaseNotes):

if defined(ARDUINO) && ARDUINO >= 100

include "Arduino.h"

else

include "WProgram.h"

endif

So the code compiles and uploads... However, everything is mirrored! Rotation works, but obviously does not help the mirroring. The 4 (I earlier thought it was 3) pixel shift is still present for some reason - might it be that my display is defective in that regard? I have tried to set pixels into that space, but it never displays. basically lines (0;63 - 3;63) are shifted to the other side of the display. [Edit] - I rotated the display 180* - which is the default orientation according to the display's manual - the pixels that cut of are still the exact same pixels. If you look at the image below - columns 0-3 on the left. This is what I mean:

Maybe this might help - sine the LCD manual is so scarce on details: http://www.gpegint.com/files/library/files/supportpdf/ST7565R_V17_960601.pdf

Thanks!

Chris

bperrybap: If you want some help with the ks0108 start another thread and I'll help you get it up and going with the glcd v3 library. Use the RC3 version from here: http://code.google.com/p/glcd-arduino/downloads/list

--- bill

Thanks Bill,

I'm going to be running around most of the day, so I'll have a look at this later, and start a thread with my findings.

Chris

Hi

However, everything is mirrored!

Sure, i just copied the adafruit init sequence. Please do the following: 1. Locate file u8g_dev_st7565_lm6063.c (.../libraries/U8glib/utility/...) 2. Try: Replace 0x0a0 with 0x0a1 (line 81), then compile and check if you see improvements 3. Try: Replace 0x0c0 with 0x0c8 (line 82), then compile and check if you see improvements

Please let me know, if 2. or 3. or both will lead to the correct result.

You may also replace 0x0a3 in line 80 by 0x0a2, which was suggested in the lm6063 datasheet.

BTW: your display is fine. The missing 4 lines are because of the fact, that the controller has a 132x64 memory, but the LCD itself is 128x64. While mirrored, we write to the 4 invisible rows.

Oliver

Hi Oliver, below you can see the results! I only had to change, 0x0a0 to 0x0a1 (line 81) and the display was completely normal!

Thank you very much for all the help, I really appreciate the trouble! The rotation is a very nice feature, one that I might use if the time allows it. I have to point out though, the console example does not scroll as I expected it to, something wrong in the code, or can't the LCD support it?

Lastly, I've noticed different fonts being used by your examples, but I cannot find documentation that explains all the uses.

The final constructor line was as follows: I used 12 instead of 8 for reset, then the pins are spaced better on the Arduino.

U8GLIB_LM6063 u8g(13, 11, 10, 9, 8);                    // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, /RES = 8

And this is the u8g_dev_st7565_lm6063.c file.

/*

  u8g_dev_st7565_lm6063.c

  Universal 8bit Graphics Library
  
  Copyright (c) 2011, olikraus@gmail.com
  All rights reserved.

  Redistribution and use in source and binary forms, with or without modification, 
  are permitted provided that the following conditions are met:

  * Redistributions of source code must retain the above copyright notice, this list 
    of conditions and the following disclaimer.
    
  * Redistributions in binary form must reproduce the above copyright notice, this 
    list of conditions and the following disclaimer in the documentation and/or other 
    materials provided with the distribution.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
  
  
*/

#include "u8g.h"

#define WIDTH 128
#define HEIGHT 64
#define PAGE_HEIGHT 8

u8g_pgm_uint8_t OLD_u8g_dev_st7565_lm6063_init_seq[] = {
  U8G_ESC_CS(0),                 /* disable chip */
  U8G_ESC_ADR(0),             /* instruction mode */
  U8G_ESC_RST(1),             /* do reset low pulse with (1*16)+2 milliseconds */
  U8G_ESC_CS(1),                 /* enable chip */
  
  0x040,                       /* set display start line */
  0x0a1,                       /* ADC set to reverse */
  0x0c8,                       /* common output mode: set scan direction normal operation/SHL Select / 17 Jan: seems to be a bug, must be 0x0c0 */
  0x0a6,                              /* display normal, bit val 0: LCD pixel off. */
  0x0a2,                       /* LCD bias 1/9 */
  0x02f,                       /* all power  control circuits on */
  /*0x0f8,*/                       /* set booster ratio to */
  /*0x000, */                  /* 4x */
  /*0x027,*/                       /* set V0 voltage resistor ratio to large */
  0x081,                       /* set contrast */
  0x005,                       /* contrast value*/
  0x0ac,                       /* indicator */
  0x000,                       /* disable */
  0x0af,                       /* display on */

  U8G_ESC_DLY(100),             /* delay 100 ms */
  0x0a5,                       /* display all points, ST7565 */
  U8G_ESC_DLY(100),             /* delay 100 ms */
  U8G_ESC_DLY(100),             /* delay 100 ms */
  0x0a4,                       /* normal display */
  U8G_ESC_CS(0),                     /* disable chip */
  U8G_ESC_END                      /* end of sequence */
};

/*init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp*/

u8g_pgm_uint8_t u8g_dev_st7565_lm6063_init_seq[] = {

  U8G_ESC_CS(0),                     /* disable chip */
  U8G_ESC_ADR(0),                 /* instruction mode */
  U8G_ESC_CS(1),                     /* enable chip */
  U8G_ESC_RST(15),                /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/

  0x0a3,                       /* 0x0a2: LCD bias 1/9 (suggested for the LM6063), 0x0a3: Used by Adafruit */
  0x0a1,                       /* 0x0a1: ADC set to reverse (suggested for the LM6063), 0x0a0: Used by Adafruit -> normal mode */
  0x0c0,                             /* common output mode: set scan direction normal operation/SHL Select */
  0x040,                       /* set display start line */
  
  0x028 | 0x04,                    /* power control: turn on voltage converter */
  U8G_ESC_DLY(50),                 /* delay 50 ms */

  0x028 | 0x06,                    /* power control: turn on voltage regulator */
  U8G_ESC_DLY(50),                 /* delay 50 ms */
  
  0x028 | 0x07,                    /* power control: turn on voltage follower */
  U8G_ESC_DLY(50),                 /* delay 50 ms */

  0x026,                       /* set V0 voltage resistor ratio to 6 (Adafruit Value, no info from LM6063 Manual) */
  
  0x0a6,                              /* display normal, bit val 0: LCD pixel off. */
  
  0x081,                       /* set contrast */
  0x005,                       /* contrast value*/
  
  /*0x0ac,*/                       /* indicator */
  /*0x000,*/                       /* disable */
  
  0x0af,                       /* display on */

  U8G_ESC_DLY(100),             /* delay 100 ms */
  0x0a5,                       /* display all points, ST7565 */
  U8G_ESC_DLY(100),             /* delay 100 ms */
  U8G_ESC_DLY(100),             /* delay 100 ms */
  0x0a4,                       /* normal display */
  U8G_ESC_CS(0),                     /* disable chip */
  U8G_ESC_END                      /* end of sequence */
};

u8g_pgm_uint8_t u8g_dev_st7565_lm6063_data_start[] = {

  U8G_ESC_ADR(0),                 /* instruction mode */
  U8G_ESC_CS(1),                     /* enable chip */
  0x010,               /* set upper 4 bit of the col adr to 0 */
  0x000,               /* set lower 4 bit of the col adr to 0 */      
  U8G_ESC_END                      /* end of sequence */

};

uint8_t u8g_dev_st7565_lm6063_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
{
  switch(msg)
  {
    case U8G_DEV_MSG_INIT:
      u8g_InitCom(u8g, dev);
      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6063_init_seq);
      break;
    case U8G_DEV_MSG_STOP:
      break;
    case U8G_DEV_MSG_PAGE_NEXT:
      {
        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
        u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6063_data_start);    
        u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
        u8g_SetAddress(u8g, dev, 1);           /* data mode */
        if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
          return 0;
        u8g_SetChipSelect(u8g, dev, 0);
      }
      break;
  }
  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
}

U8G_PB_DEV(u8g_dev_st7565_lm6063_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_lm6063_fn, u8g_com_arduino_sw_spi_fn);
U8G_PB_DEV(u8g_dev_st7565_lm6063_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_lm6063_fn, u8g_com_arduino_hw_spi_fn);

Hi Chris

Thats all good news. I modified the code in the u8glib repository so that it matches your code.

However, I also did this:

You may also replace 0x0a3 in line 80 by 0x0a2, which was suggested in the lm6063 datasheet.

This could improve the contrast a little bit.

Font: Use the setFont member procedure to assign a font: http://code.google.com/p/u8glib/wiki/userreference#setFont

Fonts are described here: http://code.google.com/p/u8glib/wiki/fontgroup

All fonts start with "u8g_font_". For example "u8g_font_osr18" will select the "OldStandard" font with a capital A of 18 pixel height. Note, that not all pixel heights are available, but this is all documented in the wiki pages. There should be a screenshot for every font.

Console Example: Thanks for the hint and, well, all is still beta. I have created an issue tracker for that and will check it. Also thanks for the Arduino 1.0 correction.

Pin/Wiring: No issue, you can select whatever pins are suitable for you.

Oliver

If you are still able to to use the Adrafruit st7565lcd code than what you will need to change in order to get your lcd to work is pull open the arduino-1.01/libraries/st75651/st7565.h file. And then change the ... #define CMD_SET_DISP_START_LINE 0x40 // should of been 60 not 40 This is effecting the callout...................... if you make this #define CMD_SET_DISP_START_LINE 0x60 then it will start at the top of the screen. now from time to time i have a wierd shifting left to right of the pixels that i haven't figured out yet. Also I had to change the Contrst from 0x18 to 0x8 for my lcd. I am useing the LEDBL51852-W-2. And i had to create my own .BMP to .HEx converter in order to create the proper .H filke that the code would display correctly, So you can replace the splash screen with the splash screen you want by changing the Code in the Arduino 1.0.1/libraries/St75651/ST7565.cpp file and the hex written under // the memory buffer for the LCD uint8_t st7565_buffer[1024] = { Just copy and paste in your hex code to change but make sure it is exact 1024 128X64 otherwise you will get nothing but garbage. Also you can change the 16 by 16 adrafruit falling example by changeing the hex file in the ST7565 Sketch right under

// a bitmap of a 16x16 fruit icon static unsigned char attribute ((progmem)) logo16_glcd_bmp[]={

Hope this helps.