Driving an OLED display, using Character LCD Component

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello,

I have been working with PSoC4 for some time, driving a standard 2 line by 16 char LCD display, using the Character LCD Component which contains routines for the Hitachi 44780 interface.  This works perfectly, with no problems.

I have now bought an OLED character display from Winstar, model WEH002002ACPP5N00001, which is a 2 line by 20 char display.  This has the same pins as the LCD module, and when I hook it up and use the same code as for LCD, it ALMOST works.  It displays the output, but all on one line and with line wrapped to the wrong position.  So clearly it is not far from working properly.

In spite of much searching through the datasheet I cannot fathom how to get it to work fully.  Does anyone know of code that has been written for such OLED displays, or how the Character LCD Component code could be modified to work with this display ?

I should mention that on the web I have seen comments that the Hitachi HD44780 controller and the Winstar OLED Controller are VERY close.  Also, I have come across comments about various jumpers on the module board that can be moved to set it up for different operation modes, but am reluctant to start experimenting with these without knowing what I'm doing.

If anyone can offer advice I will be very grateful.

0 Likes
19 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I cannot get a link to a datasheet for WEH002002ACPP5N00001, canyou provide one,please.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hi Bob,

   

My apologies; I should have included this in the previous post.
Here is a link via the supplier:

http://www.rapidonline.com/electronic-components/20x2-oled-display-yellow-57-2300

Go to the above, and click on the Technical Specification PDF Icon.
 

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

The 2nd line is off set by 40hex, So add a 40 hex offset to each character you send.  Also do not over write the registers or you will get strange displays do not write more that 20 characters to any line as this will cause an unknowned response.

0 Likes
Anonymous
Not applicable

Hi,

Thank you for reply, but I still have problems.

For example, here is the piece of code that is pertinent to display:

    LCD_Start();
    while(1u)  // Loops forever
       LCD_ClearDisplay();
       LCD_PrintString("String");
       CyDelay(20u);
      
This prints to first line of display:
 
     StringStringStringString....    continuously scrolling
    
This suggests that the API commands   LCD_ClearDisplay  and/or  LCD_Start
  are not correct for the OLED.
 
To print on the second line, You suggest adding 40 hex (0x40) to each character.
How would I do that in the above example?

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

 
     StringStringStringString....    continuously scrolling

   

 

   

You have to reposition cursor when you do a write using API.

   

 

   

If you write 'String" to location  0 then the cursor now becomes

   

= 6, so the next write occurs there. Repositioning the cursor

   

to column 0 will cause the looping writes to overwrite the last

   

write. Which in this case is correct approach.

   

 

   

Regards, Dana.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

We have seen here some timing issues with some of the LCD-controllers that are compatible to the Hitachi modell. So please check that when things are not working.

   

There is an option in the component to suppress re-generating the c-code, switch it on to avoid overwriting of your changes made.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hi,

Thank you for reply, but I still have problems.

I have done as you suggest Dana, so my code is now:

    LCD_Start();
    while(1u)  // Loops forever
       LCD_ClearDisplay();
       LCD_Position(0, 0);
       LCD_PrintString("String");
       CyDelay(20u);
      
Result is as before:
 
     StringStringStringString....    continuously scrolling
    
Regarding timing, I have edited the LCD.c file to greatly increase every CyDelay value.
I have compiled the file, and then run Build again.

Result is unchanged, as above.

So, something is still not right.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Is the display controller Hitachi/Renesas 44780 compatible ? Datasheet

   

does not indicate that.

   

 

   

The clear display command takes 6.2 mS to execute, maybe give a wait

   

to that, also a wait after you start the module, experiment with this.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

As far as I can gather, the OLED controller is NEARLY 447880 compatible.
But that is part of my problem -- I don't know where the differences are,
and where I do find differences, I don't know if they matter, and I don't know
how to edit the LCD.c file to allow for differences.

I guess I was hoping that someone might have been down this route already, and
would be able to say what code changes are required, or might even have written
API code for OLEDs.  I'm afraid my own C skills are rudimentary.

I have tried inserting waits as you suggest, but result is same as before.

Regards, Ken.
 

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Lets see your program so we can look at it and also include the data sheet for your LCD device.

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Also move your Display routine out side of the for loop.  The way it is written now you are banging it to the LCD over and over again that is why is prints String String and STring over and over again.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

@bobgoar, one should be able to write repeatedly to the

   

same location a string, by repositioning cursor each time

   

before the write.

   

 

   

So something is is still very wacky at a basic level.

   

 

   

Maybe try a delay after cursor positioning, but simply ploping in delays does not

   

make a designer feel secure that he actually understands the problem cause at

   

hand.

   

 

   

Ken, this is an aside for after you get display running. I have used char displays

   

in loops before and depending on write rate can get some "artifacts" appearing

   

in display that may it look low quality. A way around this is to create a display

   

buffer in ram, in your case MyDisBuff[ 2 ][ 21 ], and when you go to write do a char

   

for char comparison of the buffer with the string, and if any char has changed,

   

update buff and write that char to display, if not then do nothing. This will only write

   

changed chars to display, and virtually eliminates artifacts.

   

 

   

Regards, Dana.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hello,

I have attached the zip file for the whole design, made with Create Workspace Bundle.
I hope this is what you require.
I have set my code back to be correct for driving the LCD, and checked it works correctly.

Note that all this is a work in progress, so much of my code is far from optimal at present.
Also of course if you try to use it nothing will work without the oscillator circuit!
But the display should be OK, although displayed values will be meaningless.

The display routine is inside the main loop because the frequency and voltage displayed
can and does change at any time.  I do realise that some parts, such as the "Freq: " string
can be outside the loop -- I intend to fix this later.

I have also attached the LCD datasheet.  This is for an 8 char by 1 row display, but it is
essentially the same as for my 16 char by 2 row LCD.

Many thanks, regards,     Ken.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

It seems I can attach only one file at a time, so here is the LCD datasheet.

0 Likes
Anonymous
Not applicable

I have just clocked your latest reply Dana.
I have not noticed any unwanted artifacts with the LCD display, but
your comment about using a buffer so that I only write characters that
have changed seems like a much more efficient way of driving the display.
So I will certainly try that when I get to the "optimising phase" later
in the project.
Many thanks,  Ken.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

If you look at section 15.2 in datasheet there are delays needed.

   

You might check the code generated for the LCD module to see

   

what delays the Cypress code does.

   

 

   

Another quick check is get your hands on a 44780 declared compatible

   

LCD, just to check no gremlins exist. And check with another OLED

   

to make sure the module you have is OK.

   

 

   

This code -

   

 

   

        if (period >= 100000) {
            div_per = 1000 ;  afterpt_per = 2 ;  units_per = " mS" ;
        }
        else if (period >= 10000) {
            div_per = 1000 ;   afterpt_per = 3 ;  units_per = " mS" ;
        }  
        else if (period >= 1000) {
            div_per = 1000 ;   afterpt_per = 4 ;  units_per = " mS" ;
        }
        else if (period >= 100) {
            div_per = 1 ;   afterpt_per = 2 ;  units_per = " uS" ;
        }
        else if (period >= 10){
            div_per = 1 ;   afterpt_per = 3 ;  units_per = " uS" ;
        }
        else {
            div_per = 1 ;   afterpt_per = 4 ;  units_per = " uS" ;
        }             

.....

   

you might consider storing in a struc array the settings and use a pointer

   

in the decision  tree, just to save code space.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable
        Try to add a couple of mS delay (or upto 10ms , just to check) between each instruction to the LCD.   
0 Likes
Anonymous
Not applicable

Problem solved !

After much poking around with the code, I have managed to get my OLED display
working properly.  I have made two edits:

To clear the display, I have modified code as follows:
   LCD_ClearDisplay();   which is:   LCD_WriteControl(0x01);
       is replaced with two lines:
   LCD_WriteControl(0x00);
   LCD_WriteControl(0x01);

To write two lines on display, I have modified code as follows:
   Insert:
       LCD_WriteControl(0x28);
   This overwrites the line in LCD_init() which says:
       LCD_WriteControl(LCD_DISPLAY_2_LINES_5x10);   /* 2 Lines by 5x10 Characters */
         which is same as   LCD_WriteControl(0x2C);
    i.e. the one bit for N, number of lines, has to be flipped.
    This makes it opposite from what the datasheet says!
    I don't know if this is a mistake in the datasheet, or what?
   
Having done above, everything is now working as it should, except that there are
signs of the "artifacts" that you mentioned -- occasional flickering of random pixels.
It is very slight, but it would be nice to get rid of them -- I will investigate that.

Perhaps what I describe above, or a proper tidy version of it, could be made available
somewhwere for others who are trying to drive OLED character displays.

Thanks for comment about using a struc array for multiple decisions.
I'll give that some thought.

Many thanks for your help.  Ken.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Super, glad to have been of assistance.

   

 

   

If you have time file a CASE and report this, would be helpful to all.

   

 

   

    

   

          

   

To create a technical case at Cypress -

   

 

   

www.cypress.com

   

“Support”

   

“Technical Support”

   

“Create a Case”

   

 

   

You have to be registered on Cypress web site first.

   

   

 

   

 

   

Regards, Dana.

0 Likes