NHD-0216K1Z

Comments

4 comments

  • Saurabh_B

    Can you tell me what letter you are seeing on your display?
    Also How long are the delays in your code?

    0
  • lakin

    Hi
    Thank you for responding.  I got the unit working.
    Notice :  Write(text1) did not have the i,  corrected Write(text1);

    void DisplayInfo(){   //disp_pic
      int i;
      Home();
        for (i=0;i<8;i++){
            Write(text1); 
            y = 0;  // debug breakpoint
        }
    }

    0
  • Saurabh_B

    That's great to hear, were you able to figure out the command that helps you get to the second line?

    Instead of being a new line, this is actually the Set DDRAM address.
    You can find a datasheet for one of our displays here: http://www.newhavendisplay.com/specs/NHD-0216K1Z-FL-YBW.pdf

    On page 6 of the datasheet, we have the master table of instructions. On this we are using the Set DDRAM Address command (4th command from the bottom).
    Using this you can set the cursor to any position of the display, the addresses of the digits can be found on the bottom of page 5.

    0
  • lakin

    OK thanks.  I will be experimenting a little more and will use that method.  I'm a C programmer using a PIC.  Here is some C code if someone is interested.   To run it, header files, timers (delay) and variables need to be defined. 

    void main(void) {
        TRISC = 0x00; //  this port is set for outputs
        TRISA3 = 0; //AN3 +VREF
        TRISA5 = 1; // AN4   bit 5 set as input
        ANSELH = 0x00;
        TRISB0 = 0; // enable signal output
        TRISB1 = 0; // read/write signal
        TRISB2 = 0; // register select signal   
       
        /******************************************/
        x = 0;  // debug breakpoint
        PORTC = 0x00;  // clear screen
        WriteCtl();  //  write commands
        delay(50);
        delta=500;
        cycle=40;
        //  continous run
        while(1){
          Init();
          DisplayInfo();
          delay(10000);
        }
     
    }
     
    void DisplayInfo(){   //disp_pic
      int i;
      Home();
        for (i=0;i<16;i++){   
           Write(text1);
            delay(1000);
            y = 0;  // debug breakpoint
        }
    }
    void Write(unsigned char Dat){
         
        PORTC = Dat;
        delay(5);
        RSHI; // RB2=1
        RWLO;//RB1=0; //write
        EHI; // RB0
        delay(100);
        ELO; //RB0
        RSLO;
        y=0;  // breakpoint
    }

    void Home(){
        PORTC = 0x02;  //home
        WriteCtl();
        delay(5);
        PORTC = 0x01;  // clear screen
        WriteCtl();
        delay(5);
    }
    void NextLine(){
        PORTC = 0xC0;
        WriteCtl();
    }
    // write controls

    void WriteCtl(){   
        RSLO;
        RWLO; //RB1
        EHI; //RB0
        delay(10);
        ELO; //RB0
    }

    // AorD = 0 for address and 1 for data

    void WriteAN(int AorD) {  // wrtAdr = 0; wrtNum = 1;
        RWLO;//RB1=0; //write
        ELO; // RB0
        if (AorD == 0) {
            RSLO; //RB2  address
        } else {
            RSHI; //RB2  data
        }
        delay(10);
        EHI;    //RB0=1;//EHI; //RB0
        delay(1);
        ELO; //RB0
    }


    void WriteInt(unsigned char initNum){
        PORTC = initNum;
        RSLO; // RB2
        RWLO;  // RB1
        EHI; // RB0
        delay(100);
        ELO; // RB0
        y=0; // breakpoint
    }

    void Init(){
     ELO;
     delay(500);    //Wait >40 msec after power is applied       
     WriteInt(0x30);  //command 0x30 = Wake up       
     delay(100);      //must wait 5ms, busy flag not available       
     WriteInt(0x30);  //command 0x30 = Wake up #2       
     delay(100);      //must wait 160us, busy flag not available       
     WriteInt(0x30);  //command 0x30 = Wake up #3       
     delay(100);      //must wait 160us, busy flag not available       
     WriteInt(0x38);  //Function set: 8-bit/1-line       
     WriteInt(0x14);//Set cursor to right AC+1     
     WriteInt(0x0C);  //Display ON; Cursor ON       
     WriteInt(0x06);  //Entry mode set   cursor right DDRAM + 1
    }
    0

Please sign in to leave a comment.