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 Attachment(s)
Difference in Clear Display commands make a difference?
Quote:
Originally Posted by
Acetronics
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.
LCD interface is PortA and DEFINES the same for both LCDs.
Quote:
Originally Posted by
Darrel Taylor
Are you doing something different?
The EASYPIC6 schematic says the LCD is on PORTB.
<br>
Yes, Darrel, I have the LCD hooked up to PortA in my development setup on the EasyPic6 via a Port expander with a ProtoBoard.
I also have the prototype PCB board laid out so that the LCD is connected to PortA in the same way as I have it working on the EasyPic. So my LCD DEFINES are correct (at least for the WINSTAR) and work on the EasyPic configuration with the WINSTAR LCD, but they don't on the prototype PCB with the NEWHAVEN display. Hope this makes it more clear.
NEWHAVEN tech support told me that as long as I saw the character dot matrix blocks on Line 1 of the display whenever it is powered up but with contrast to a minimum, it means the module is alive. That is my situation, but still can't get characters to display. I have sent this posting to NEWHAVEN to see if they can tell me why my PBP initialization isn't working, but doubt they will since their examples for their module are all in C.
Here is URl to the LCD spec
Quote:
Originally Posted by
Byte_Butcher
Well that's a tough nut to crack...
Did I miss it or is there link to the Data Sheet for your newhaven display somewhere?
You can get the spec on this display I am using at this URL:
http://www.newhavendisplay.com/index...roducts_id=258
Re: Code that worked with WINDSTAR LCD doesn't work with Newhaven LCD?
Bumping this old thread as I'm about to use a Newhaven display for the first time. I have a NHD-0216K1Z-NSRGB-FBW 16x2 5.0V display. http://www.newhavendisplay.com/specs...-NSRGB-FBW.pdf I'll be using a 18F2550 for the first time. The LCD will be on portB and in 4 bit mode.
Looking at the above working code, is that really a 10000us delay? What does the FLAGS=0 mean?
Re: Code that worked with WINDSTAR LCD doesn't work with Newhaven LCD?
Quote:
Originally Posted by
jmgelba
Looking at the above working code, is that really a 10000us delay?
Yes, it was, but this code was a very early version of my attempts to make it work. I just looked up in my latest code and I am now using the following statements that work with the display I am using, the NHD-0208AZ-RN-YBW:
DEFINE LCD_COMMANDUS 1500 ' Command Delay (uS)
DEFINE LCD_DATAUS 44 ' Data Delay (uS)
You may have to play with these values for your particular display module. Also don't be afraid to call Newhaven tech support...they are outstanding and helped me a great deal.
Quote:
What does the FLAGS=0 mean?
Go to the page in the PicBasic Pro Compiler manual (it is also online if you can't find your manual) and look up the page that describes the use of the command LCDOUT. It explains what FLAGS=0 is used for. It is used to reset an internal flag to tell the program to initialize it the next time it uses LCDOUT after having been powered down and then powered back up. Very important if you are shutting off power to the LCD during the program when it is not being used to save battery power. That is why I used it.
I hope all of this helps.
BTW, one of the ongoing problems many people have had who use the NEWHAVEN LCD display modules is how to get a clean looking mounting, which normally requires a bezel. Bezels are hard to come by for these displays. I found a company that has a good set, one which worked with mine. Go to http://www.rmfproducts.com to see what they offer. Prices are also reasonable....their Model 140-1 for my LCD display size only costs $2.15 each in quantities of 1-99, and $2.00 each for 100 or more.
I hope all this helps you.
/s/ John Ellis
Re: Code that worked with WINDSTAR LCD doesn't work with Newhaven LCD?
Thank you for that wealth of information.
This display will be mounted in a custom cast aluminum enclosure with a graphical overlay over the top. This will also contain the push buttons, the bezel info is good to know. The project is a control and monitor for a 400W LED driver.
Which PIC did you end up using?
Re: Code that worked with WINDSTAR LCD doesn't work with Newhaven LCD?
Quote:
Originally Posted by
jmgelba
Which PIC did you end up using?
Because most of my applications have a USB interface, I have favored using either the 18F2550 or 18F4550. If you don't need a USB interface these are probably over kill, but they are so low in price and have so many IO pins, they are a good choice even if you don't need the USB. I use the 18F2550 whenever I can because it is a 20 pin IC and a lot smaller than the 4550 for board layout. I published an article in the recent Forum Competition that you can see by going to that location on the Home page. Mine is the Ultrasonic Ranger application and all of my code is posted there, including the routines that intialize and use the NEWHAVEN display.
Re: Code that worked with WINDSTAR LCD doesn't work with Newhaven LCD?
Nice. I'm also using a 18F2550 - for the first time. I've started browsing through the datasheet and am currently finishing up the schematic and about to start on the layout.
This project calls for several analog in's, the LCD, the USB, 4 switch inputs, and control of a digital pot. Oh and a couple of indicator LED's.
Nothing like jumping in with both feet!
Re: Code that worked with WINDSTAR LCD doesn't work with Newhaven LCD?
So it soounds like you are still building schematic/layout and haven't started coding yet??
When you get into the coding of the USB interface you will probably run into problems. I did, and got a lot of help from Darrell Taylor and the Forum. When you get to that stage and need help, let me know and I may be able to refer you to some well hidden postings that will help you with the USB.
Re: Code that worked with WINDSTAR LCD doesn't work with Newhaven LCD?
Correct.
I've done a little searching and found the keep alive requirements and DT's keep alive program. Other than that, and the requirement for a 0.47uF cap on the USB supply pin, I havent gotten too far in to it. I'm concentrating on hardware as the first rev pcb has to work first time. I need to send out a somewhat functioning proto next week.
:eek::eek:
Re: Code that worked with WINDSTAR LCD doesn't work with Newhaven LCD?
Are you using your display in 4 bit or 8 bit and if its 4 bit, have you tied the unused data pins to ground?
Re: Code that worked with WINDSTAR LCD doesn't work with Newhaven LCD?
Quote:
Originally Posted by
jmgelba
Are you using your display in 4 bit or 8 bit and if its 4 bit, have you tied the unused data pins to ground?
I am using it in 4-bit and yes the unused data pins have to be grounded.
Re: Code that worked with WINDSTAR LCD doesn't work with Newhaven LCD?
Thanks. Incidentally, the datasheet from Digikey for the part number I'm using is incorrect. It didnt show how to connect the RGB backilighting correctly. Good job I double checked by calling New Haven tech support. The pin out was wrong - missing 2 pins and swapping the backlight A and K. Yikes Digikey!!
Re: Code that worked with WINDSTAR LCD doesn't work with Newhaven LCD?
Quote:
Originally Posted by
jmgelba
Thanks. Incidentally, the datasheet from Digikey for the part number I'm using is incorrect. It didnt show how to connect the RGB backilighting correctly. Good job I double checked by calling New Haven tech support. The pin out was wrong - missing 2 pins and swapping the backlight A and K. Yikes Digikey!!
Which LCD model of theirs are you using?
Did Newhaven warn you about incorrect data sheets on any other LCDs of theirs that are sold at DigiKey?
JE
Re: Code that worked with WINDSTAR LCD doesn't work with Newhaven LCD?
NHD-0216K1Z-NSRGB-FBW
New Haven did not warn me of any other issues with data sheets. It looks like Digikey has an early version of the correct datasheet that contains errors, as the part number of the device and the datasheet do match. However the data sheet downloaded directly from New Haven is definitely different.
Take a look at page 3 of this link: http://www.newhavendisplay.com/specs...B_FBW-REV1.pdf
And take a look at pages 3 and 4 of this link: http://www.newhavendisplay.com/specs...-NSRGB-FBW.pdf
The second link is from Digikey and pages 3 and 4 clearly show 16 pins, not 18 per the actual device. The correct pinout is pins 16, 17 and 18 are the anodes for red, green and blue respectively. Pin 15 is the cathode pin.
The digikey link shows pin 15 as anode and pin 16 as cathode.