8 years, 10 months ago.

Problem with Contrast of the Nokia 5110 LCD Display

Hello Folks,

i have a Nucleo F401re and a Nokia 5110 LCD display. I am running it with 3.3V but mine also seems to be able to run with 5V.

The problem is that when i am printing just one line on the display it seems that the contrast is really low...if i print more on the display the contrast gets higher.

The wiring is ok and the metal frame of the display is also fitting good.

Has anybody an idea? I thought the Display is maybe damaged, because it is just 3$ and from china.

Thank you =)

Code is below

include the mbed library with this snippet

#include "mbed.h"
#include "NOKIA_5110.h"

5110 Display
    LcdPins myPins;
    myPins.sce  = D8;
    myPins.rst  = D9;
    myPins.dc   = D10;
    myPins.mosi = D11;//SPI_MOSI;
    myPins.miso = NC;
    myPins.sclk = D13;//SPI_SCK;
    NokiaLcd myLcd( myPins );

Serial pc(SERIAL_TX, SERIAL_RX); //output for debugging
 
DigitalOut myled(LED1);
DigitalIn mybutton(USER_BUTTON);
DigitalOut ledPower(D2);

int main() {
    LcdPins myPins;
    myPins.sce  = D8;
    myPins.rst  = D9;
    myPins.dc   = D10;
    myPins.mosi = D11;//SPI_MOSI;
    myPins.miso = NC;
    myPins.sclk = D13;//SPI_SCK;
    NokiaLcd myLcd( myPins );
    
    // Start the LCD
    myLcd.InitLcd();

  while(1) { 

        myLcd.SetXY(0,0);
        myLcd.DrawString("!!!!:::AAA!!!!!::::"); 
        
  wait(1);
}
}

/media/uploads/Shadowrap411/image1.jpg /media/uploads/Shadowrap411/image2.jpg

I use this this library with much the same display and have not noticed any contrast issues:

https://developer.mbed.org/users/eencae/code/N5110/

posted by Paul Staron 11 Jul 2015

2 Answers

8 years, 10 months ago.

Check the code you are actually using. The example code shown above does not look right. It has a spurious declaration of the display. Probably meant as comment. Make sure you dont write the same text over and over to the display at maximum speed (is the 'wait' really inside the while loop). The text would look vague cause you keep erasing and rewriting it. It will look better when you write more text since it takes a bit longer before erasing the same text again.

Also check powersupply voltages on the display. Maybe it is out of spec or somehow missing completely which may lead to a 'phantom' power supply through the SPI data and clocklines: writing more text may then look like a 'better' powersupply because the pins are at high level more often.

Accepted Answer

Hey

so i wrote the programm again...and it is working better now...but i changed the contrast in the NOKIA_5110.h to a hex value of 0xCD it was 0xC8 by default. Problem now is still that the contrast is too weak with just one line...but if i raise the contrast value i get black vertical lines all over the display...

maybe its just the cheap chinese display...for 3$ it is good enough i think...just want to learn a bit to use the nucleo and some text prints on the lcd.

wanna see the code of the latest version?

Thanks for your support guys. =)

posted by Denis Schnier 11 Jul 2015

I dont have that display type myself so cant test, but please post the code so we can have a look. Did you check the powersupply voltage on the display pins.

Edit: any progress with the display? Make sure the metal frame is pressed firmly against the PCB. Is has springs to lock it in place. Perhaps one of the display's connection pads which connects to the PCB with a sort of conductive rubber (zebrastrips) is not making good contact. This is especially important for the VLCD out pin which should connect to a capacitor on the PCB. VLCD out is the output of the on-chip LCD voltage generator. The contrast will be unstable when the Cap is missing.

posted by Wim Huiskamp 11 Jul 2015

i am using the same library like i was told too.

my code i am using is

include the mbed library with this snippet

#include "mbed.h"
#include "string.h"
#include "time.h"

DigitalIn mybutton(USER_BUTTON);
DigitalOut myled(LED1);
Timer timer;

int main()
{
    int timer_value = 0;
    bool running=0;  
    
    LcdPins myPins;
    myPins.sce  = D8;
    myPins.rst  = D7;
    myPins.dc   = D10;
    myPins.mosi = D11;      //SPI_MOSI;
    myPins.miso = NC;
    myPins.sclk = D13;      //SPI_SCK;
    NokiaLcd myLcd( myPins );
    
    
    vPcStringPrint("Setting up LCD");
    myLcd.InitLcd();        // LCD init
    vPcStringPrint("LCD set up complete");
    vPcStringPrint("Entering While Loop");
    myLcd.SetXY(0,2);    
    myLcd.DrawString("Entering WhileLoop");
    wait(2);
    myled = 0;
        while(1) 
        {
            if(mybutton == 0)  // Button is pressed     
            { 
                if(running== 0)
                {   
                    myLcd.ClearLcdMem();
                    running = 1;    
                    timer.start();
                }

            }
    
            if (mybutton == 1 && running == 1)
            {
                timer.stop();                           // Zeit stoppen
                running = 0;                            // Byte auf 0 setzen
                timer_value = timer.read_ms();          // Zeit speichern
                vPcTimePrint(timer_value);              // PC-Ausgabe
                char value[timer_value];                // Char value erstellen
                sprintf(value, "%d", timer_value);
                myLcd.SetXY(0,1);                       // LCD lokalisieren
                myLcd.DrawString("Time was ");          // Text Ausgabe
                myLcd.SetXY(0,2);                       // LCD lokalisieren
                myLcd.DrawString(value);                // Wert auf LCD schreiben
                myLcd.DrawString(" ms");                // Text Ausgabe
                timer_value = 0;                        // Zeit auf 0 setzen
                timer.reset();                          // Uhr reseten
            }   
        }   
}

the time.h is just a library written by me with all declarations of functions or prototypes...dont worry about that.

the display looks perfect in this programm...but just because i am plotting more than 1 line to the lcd...if it is just 1 line its not that good.

/media/uploads/Shadowrap411/img_4851.jpg

posted by Denis Schnier 19 Jul 2015

The code above probably wont compile. The #include "NOKIA_5110.h" is missing (unless you have included that in time.h).

There is also something wrong with

char value[timer_value];  

You should not declare that array with a variable size. It must be a constant that is large enough to make sure that the integer produced by sprintf fits. Try something like

char value[32];  

In case you still get contrast problems make sure the powersupply is OK. It should be 3V3 for the display.The Nokia 5110 display uses a Philips PCD8544 LCD controller. That device is rated for 2V7..3V3 powersupply Ignore what is says on the display printed circuit board about 3V..5V. The vertical lines could be the result of overvoltage breakdown on the LCD controller. The controller has a voltage multiplier to generate the LCD driver voltage (6V..8V5) from the powersupply voltage. When the powersupply is too high the LCD voltage will also be too high and things could break.

In case none of that helps the display may just be broken.

BTW I found a Nokia 5110 cellphone + charger at a fleamarket last week (cost me 75 Eurocents). Ripped out the display and keyboard PCB, hooked up some wires to mbed and it works fine..

posted by Wim Huiskamp 19 Jul 2015
8 years, 10 months ago.

I had a similar issue. Most of these Chinese displays are used so may not be very good, try another from a different seller.

I also tried to change the contrast settings in the header-file it is this code line

  1. define CMD_VOP_7V38 0xCC (By default it is 0xC8 Decimal 200)

but if you change it to a higher hex value it gets worse really fast...the first line is ok but the next ones create vertical lines on the display...

i will wait for more answers and check the wiring again...then i will buy a new one.

Thanks so far =)

posted by Denis Schnier 08 Jul 2015