Code that worked with WINDSTAR LCD doesn't work with Newhaven LCD?


Closed Thread
Results 1 to 37 of 37

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Default Code that worked with WINDSTAR LCD doesn't work with Newhaven LCD?

    I just transitioned a new product design from a WINDSTAR 2x16 LCD to a NEWHAVEN 2x8 LCD to save a few bucks parts cost and some panel space on the product front panel, plus the NEWHAVEN operates without a backlight. I had the PBPro code working fine with the WINDSTAR while using it as a 4-bit interface display. I notice that the WINDSTAR LCD uses a ST7006U controller while the NEWHAVEN uses a SPLC780D, but the Command/Instruction tables are identical for both LCDs. I presumed that since the NEWHAVEN LCD is also a 4-bit interface display, has exactly the same electrical interface, and the Instruction Table is the same, that all I would have to do is change those lines of code that placed the characters on each line so that they fit inside of the 8 available characters per line. In fact, I can't get any characters to appear on the screen of the NEWHAVEN display. The Newhaven data sheet includes example initialization routines in C, but I don't understand C so can't replicate in PBPro. I am attaching my PBPro initialization routine for the WINDSTAR and the C code routines for the NEWHAVEN. Can anyone advise me how to change my PBPro code to match this C code??
    Code:
    InitializeDisplay:  ' Subroutine to initialize 2X16 LCD display      
    '=================
      '-----SETUP FOR USING 2x16 LCD THAT IS INSTALLED IN EASYPIC6--------
         ' Blink LED_GRN twice to indicate entered IntializeDisplay
               For i = 0 to 1
                   HIGH LED_GRN
                   Pause 500
                   LOW LED_GRN
                   PAUSE 500
               Next
                 
         ' LCD DEFINES FOR USING 2x16 LCD with PortA in EASYPIC6
               DEFINE LCD_DREG PORTA    ' Use PORTA for LCD Data
               DEFINE LCD_DBIT 0        ' Use lower(4) 4 bits of PORTA
                                          ' PORTA.0 thru PORTA.3 connect to
                                          ' LCD DB4 thru LCD DB-7 respectively
               DEFINE LCD_RSREG PORTA   ' PORTA for RegisterSelect (RS) bit
               DEFINE LCD_RSBIT 4       ' PORTA.4 pin for LCD's RS line
               DEFINE LCD_RWREG PORTC   ' LCD read/write port
               DEFINE LCD_RWBIT 2       ' LCD read/write bit
               DEFINE LCD_EREG PORTA    ' PORTA for Enable (E) bit
               DEFINE LCD_EBIT 5        ' PORTA.5 pin for LCD's E line
               DEFINE LCD_BITS 4        ' Using 4-bit bus
               DEFINE LCD_LINES 2       ' Using 2 line Display
               DEFINE LCD_COMMANDUS 1500' Command Delay (uS)
               DEFINE LCD_DATAUS 44     ' Data Delay (uS)
           
        ' DEFINE LCD Control Constants  
               Line1   CON 128          ' Point to beginning of line 1 ($80) 
               Line2   CON 192          ' Point to beginning of line 2 ($C0)
        
        ' Test the LCD during initialization
               LCDOut $fe,1:FLAGS=0:Pause 250      ' Clear Display
               LCDOut $fe,Line1+3," LCD TEST "     ' Display on 1st line
               Pause 500
               LCDOut $fe,Line2+2,"..Power On..!!" ' Display on 2nd line
               PAUSE 1000
    Return
    Here is the C code routines that came with the NEWHAVEN:

    Code:
    4-bit Initialization:
    /**********************************************************/
    void command(char i)
    {
    P1 = i; //put data on output Port
    D_I =0; //D/I=LOW : send instruction
    R_W =0; //R/W=LOW : Write
    Nybble(); //Send lower 4 bits
    i = i<<4; //Shift over by 4 bits
    P1 = i; //put data on output Port
    Nybble(); //Send upper 4 bits
    }
    /**********************************************************/
    void write(char i)
    {
    P1 = i; //put data on output Port
    D_I =1; //D/I=HIGH : send data
    R_W =0; //R/W=LOW : Write
    Nybble(); //Clock lower 4 bits
    i = i<<4; //Shift over by 4 bits
    P1 = i; //put data on output Port
    Nybble(); //Clock upper 4 bits
    }
    /**********************************************************/
    void Nybble()
    {
    E = 1;
    Delay(1); //enable pulse width >= 300ns
    E = 0; //Clock enable: falling edge
    }
    /**********************************************************/
    void init()
    {
    P1 = 0;
    P3 = 0;
    Delay(100); //Wait >15 msec after power is applied
    P1 = 0x30; //put 0x30 on the output port
    Delay(30); //must wait 5ms, busy flag not available
    Nybble(); //command 0x30 = Wake up
    Delay(10); //must wait 160us, busy flag not available
    Nybble(); //command 0x30 = Wake up #2
    Delay(10); //must wait 160us, busy flag not available
    Nybble(); //command 0x30 = Wake up #3
    Delay(10); //can check busy flag now instead of delay
    P1= 0x20; //put 0x20 on the output port
    Nybble(); //Function set: 4-bit interface
    command(0x28); //Function set: 4-bit/2-line
    command(0x10); //Set cursor
    command(0x0F); //Display ON; Blinking cursor
    command(0x06); //Entry Mode set
    }
    /**********************************************************/

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Try bumping up the LCD_COMMANDUS value.

    1500 is just Under the minimum for that display (according to the datasheet).

    1600 should work, but try 2000.
    <br>
    DT

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Wink 2 votes ...

    Hi,

    I confirm ... LCD Commandus = 2000 !

    I do not know why, but ALL the 2x8 LCDs I have used so far always look a bit " lazy " ...and they only work with Lcd_Commandus set to 2000 !!!


    I just made the test with a 2x16 LCD, SPLC780D controller display ... no difference with either 1500 or 2000 ... so, where's the truth ???

    Experiece told ... 2000 works @ each time !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default Difference in Clear Display commands make a difference?

    Quote Originally Posted by Acetronics View Post
    I confirm ... LCD Commandus = 2000 !
    Darrel/Alain,
    I tried 2000 and also 3000 and the LCD module still doesn't display any characters, but I still know it is alive by rotating the contrast potentiometer near 0 ohms and the block letters appear on line 1 of the display. But no characters when transmitted,no matter what contrast setting.

    I noticed one very suttle difference in the Command table between the two devices for the "Clear Display" command that I am wondering if it makes a difference...and if so how I would modify my PBP code to make the change in the command. The two command tables are attached as images.
    Attached Images Attached Images   

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Jellis,

    I think the problem is your Line 1 and 2 start address. "$80 $C0"
    Try $00 - Line 1 and $40 Line 2

    Hope this helps

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Code:
         ' LCD DEFINES FOR USING 2x16 LCD with PortA in EASYPIC6
               DEFINE LCD_DREG PORTA    ' Use PORTA for LCD Data
               DEFINE LCD_DBIT 0        ' Use lower(4) 4 bits of PORTA
                                          ' PORTA.0 thru PORTA.3 connect to
                                          ' LCD DB4 thru LCD DB-7 respectively
               DEFINE LCD_RSREG PORTA   ' PORTA for RegisterSelect (RS) bit
               DEFINE LCD_RSBIT 4       ' PORTA.4 pin for LCD's RS line
               DEFINE LCD_RWREG PORTC   ' LCD read/write port
               DEFINE LCD_RWBIT 2       ' LCD read/write bit
               DEFINE LCD_EREG PORTA    ' PORTA for Enable (E) bit
               DEFINE LCD_EBIT 5        ' PORTA.5 pin for LCD's E line
    Are you doing something different?

    The EASYPIC6 schematic says the LCD is on PORTB.
    <br>
    DT

  7. #7
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default Tried it...didn't work.

    Quote Originally Posted by mark_s View Post
    I think the problem is your Line 1 and 2 start address. "$80 $C0"
    Try $00 - Line 1 and $40 Line 2
    I tried that, Mark, and it didn't make any difference.
    Where did you get the info of start of line 1 at $00 and start of line 2 at $40 for the NEWHAVEN LCD? I went through the data sheet for the NEWHAVEN display very throroughly and couldn't find anywhere that it specifies the 1st character address in Line 1 or Line 2. For that matter, I also went through the data sheet for the WINSTAR LCD and it doesn't show $80 or $C0 either.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts