Weird contrast on NHD-0216HZ-FSW-FBW-33V3C?

Comments

5 comments

  • Ted M.
    NHD Staff

    Please confirm the voltage for VDD is 3.3v.  If the LED backlight is also connected to the same 3.3v source, please check the current drawn by the LED.
    In order to provide a constant current source of 15mA to the LED backlight from the 3.3v supply, a 20 ohm resistor must be in series with the LED.
    Otherwise, excessive current draw from the LED could have an effect on VDD and possibly be causing this issue.

    Best Regards,

    0
  • LCD_DUDE

    Thanks for the swift reply!

    The voltage for VDD is 3.3V in my circuit. The microcontroller also operates on 3.3V so all communications are at the same voltage too.

    The backlight is on the same supply. I'm using a 50 ohm current limiting resistor as I didn't need the back light too bright.

    I probed the supply rail with an oscilliscope before and after the problem started - Before, the voltage was clean and steady. After, VCC is pulled down by ~.3V almost everytime commands/messages are clocked onto the datalines. I saw this behavior even with the ISP connected which has a very significant power source available (i think it can supply something like 1A?) 

    Cheers,

    0
  • Ted M.
    NHD Staff

    Please review this 4-bit mode code for a 2x16 character display, and try it to see if it produces the same results.

    / This code is written for the Arduino Uno R3.
    / Newhaven Display invests time and resources providing this open source code,
    / Please support Newhaven Display by purchasing products from Newhaven Display!
    /*****************************************************************************
    * Copyright (c) 2018, Newhaven Display International
    *
    * This code is provided as an example only and is not guaranteed by Newhaven Display.
    * Newhaven Display accepts no responsibility for any issues resulting from its use.
    * The developer of the final application incorporating any parts of this
    * sample code is responsible for ensuring its safe and correct operation
    * and for any consequences resulting from its use.
    *****************************************************************************/


    /******** INITIAL DEFINITIONS***************/

    #define E_Pin 10
    #define R_W    9
    #define R_S    8
    /************************ CHAR STRING**********/

    char const text1[] = ("Newhaven Display");
    char const text2[] = (" 4-Bit LCD Test ");
    char const text3[] = (" 2x16 Character ");
    char const text4[] = ("  LCD  Display  ");

    /************ Functions************/
    void latch(){                           // command to latch E
      digitalWrite(E_Pin, HIGH);            // Latch
      delay(1);
      digitalWrite(E_Pin, LOW);
      delay(20);
    }
    void command(char i){
      PORTD = i;
      digitalWrite(R_S, LOW);               // Command
      digitalWrite(R_W, LOW);               // Write
      latch();                              // take upper 4 bits
      i = i<<4;                             // shift 4 bits
      PORTD = i;                            // Take lower 4 bits
      latch();
    }
    void data(char i){
      PORTD = i;
      digitalWrite(R_S, HIGH);              // Data
      digitalWrite(R_W, LOW);               // Write
      latch();                              // take upper 4 bits
      i = i<<4;                             // shift 4 bits
      PORTD = i;                            // Take lower 4 bits
      latch();
    }
    /***********INITIALIZE DISPLAY************************/

    void init1(){
    digitalWrite(E_Pin, LOW);
     delay(100);                            //Wait >15 msec after power is applied
     PORTD=0x30  ;                         // Put 30 on port D
     delay(30);                             //must wait 5ms, busy flag not available
     latch();                              //command 0x30 = Wake up
     delay(10);                             //must wait 160us, busy flag not available
     latch();                              //command 0x30 = Wake up #2
     delay(10);                             //must wait 160us, busy flag not available
     latch();                              //command 0x30 = Wake up #3
     delay(10);                             //can check busy flag now instead of delay
     PORTD = 0x20;                           //put 0x20 on the output port
     latch();                               //Function set: 4-bit interface
     command(0x28);
     command(0x28);                         //Function set: 4-bit/2-line
     //command(0x10);                         //Set cursor
     command(0x0F);                         //Display ON; Blinking cursor
     command(0x06);                         //Entry Mode set
    }


    void clear_screen(){                    // clear display
     command(0x01);
    }
    void ret_home(){                        // Return to home position
     command(0x02);
    }
    void disp1(){                            // DISPLAY TEXT
      clear_screen();
      ret_home();
      for( int i = 0; i< 16; i++){
        data(text1[i]);
      }
      command(0xc0);                              // Second Line
      for (int i = 0; i<16; i++){
        data(text2[i]);
      }
      //ret_home();
    }
    void disp2(){                            // DISPLAY TEXT
      clear_screen();
      ret_home();
      for( int i = 0; i< 16; i++){
        data(text3[i]);
      }
      command(0xc0);                              // Second Line
      for (int i = 0; i<16; i++){
        data(text4[i]);
      }
      //ret_home();
    }
    void setup() {
     
      DDRD = 0xFF; // First 4 pins of PORT D as output
      DDRB = 0xFF; // Port B first 3 pins as output
      digitalWrite(11, HIGH);
      digitalWrite(12, LOW);
      init1();
      delay(100);
    }

    void loop() {
     
      disp1();
      delay(2500);
      disp2();
      delay(2500);
    }

    Regards,

    0
  • LCD_DUDE
    Ok, so I had to pull the microcontroller and LCD into a new setup to match the wiring of your code.

    The code compiled/loaded up just fine and to my surprise, the contrast returned! 😊

    After things were back working again I decided to test my code+setup to see if it’s the culprit -  I transferred both the LCD and Microcontroller back onto my original setup and re-flashed with my old code. The contrast was perfect there too!

    Now I’m left wondering - why?

    Might it have been something about the ISP programmer being disconnected that messed up some register on the LCD so that it misbehaved from that point forward?

    Maybe a partial message during power interruption left the unit in a weird state? could it have been toggling the “busy” flag from the last power cycle, but my code kept pushing data?

    Perhaps your code initializes the LCD differently than the Library(details below) I’m using to run the LCD ? Such that it more-effectively reset the issue I was seeing?

    Did I do some ESD to the device?

    Here is some more info on the setup, in case you’ve got any other ideas:
    1. I’m using an Arduino Pro Mini as my 3.3V Microcontroller
    2. Pinout on the LCD/Microcontroller is:
         LCD-1 = GND
         LCD-2 = +3.3v
         LCD-3 = NC
         LCD-4 = ARDUINO 7/PD7
         LCD-5 = GND
         LCD-6 = ARDUINO 6/PD6
         LCD-7 = NC
         LCD-8 = NC
         LCD-9 = NC
         LCD-10 = NC
         LCD-11 = ARDUINO 2/PD2
         LCD-12 = ARDUINO 3/PD3
         LCD-13 = ARDUINO 4/PD4
         LCD-14 = ARDUINO 5/PD5
         LCD-15 = +3.3V
         LCD-16 = 50 ohm resistor to ARDUINO 8/PB0, toggled low in software (MCU sinks backlight current)
    3. Using Arduino’s “LiquidCrystal” library with the following initialization:
         “LiquidCrystal lcd(7, 6, 2, 3, 4, 5);”
    0
  • Ted M.
    NHD Staff

    I am uncertain as to what may have been causing this issue, but it's great to hear you have it working!
    Murphy's law always finds a way to keep us scratching our heads.

    Best Regards,

    0

Please sign in to leave a comment.