-
2 Attachment(s)
Newhaven 4x40 LCD, issues!
For the past few days Ive been working with a Newhaven 4x40 Character LCD. The Newhaven NHD-0440WH-ATMI-JT has duel ST7066U controllers. I have written an Initializing routine outlined in the datasheet but NOTHING. No cursor, no characters, NADA. I have tried PBP LCDOUT using E1 only, no luck here either. Even if that worked I am not sure how to handle E1 & E2 in the LCDOUT command. Can a port assinment DEFINE such as LCD_EBIT be changed with use of the bas. file, PORTL?
Blinky light routine works fine. Any Ideas anyone?
The datasheet reads as if the LCD is in fact two (2x40) LCDs
16F886 at 4Mhz
I tried to slow the 16F886 to 2Mhz, OSCCON=$50 but PBP didnt like it.
LCD pinout -------- 16F886 Pin#
1. DB7
..PortA.7
.9
2. DB6
..PortA.6
.10
3. DB5
..PortA.5
.7
4. DB4
..PortA.4
.6
5. DB3
..PortA.3
.5
6. DB2
..PortA.2
.4
7. DB1
..PortA.1
.3
8. DB0
..PortA.0
.2
9. E1
..PortC.0
.11
10. R/W
..PortC.3
.14
11. RS
..PortC.2
.13
12. Vo
.
.Center pin 20k pot 0.5V
13. Vss
.
GND
14. Vdd
...5v
15. E2
...PortC.1
...12
16. NC
.
.GND
17. LCD+
100 ohm to 5V
18. LCD-
.GND
Code:
;16F886
@ DEVICE MCLR_OFF,BOD_OFF,WDT_ON,LVP_OFF
define osc 4
OSCCON=$60 ;70=8MHz, 60=4MHz, 50=2MHz, 40=1MHz.
ANSEL=$00
ADCON0=$00
CM1CON0= 0
CM2CON0= 0
ANSELH=$00
PortA=0
PortB=0
PortC=0
TrisA=0
TrisB=0
TrisC=0
'Constents
Wakeup CON $30
FunctionSet CON $38 ;Function Set = 8bit mode; 2-line; 5x8
DisplayON CON $0C ;Turn on display; no cursor
DisplayOnBcursCON $0F ;display on with blinking cursor
DisplayOFF CON $08 ;Turn off display
EntryMode CON $06 ;Entry mode cursor increment
ClearDisp CON $01 ;Clear display
Home CON $02 ;cursor set to home position
'Variables
Avar var byte
Bvar var byte
Cvar var byte
Dvar var byte
LED Var PORTB.1
E1 var PORTC.0 ;top 2 lines of display
E2 var PORTC.1 ;bottom 2 lines of display
RS var PORTC.2
RW var PortC.3
'EEPROM
Data @0, " Hello World line1 " '20bites
Data @20," Hello World line2 " '20bites address C0h E1
Data @40," Hello World line3 " '20bites
Data @60," Hello World line4 " '20bites address C0h E2
Start:
goto Main
Blinky:
led =0
for Avar=1 to 4
toggle led
pause 500
toggle led
pause 500
next avar
return
;INIT_LCD_SUBS
Command1: 'command sub for upper 2 lines
PortA=Cvar
Rs=0
RW=0
E1=1
pause 5
E1=0
return
Command2: 'command sub for lower2 lines
PortA=Cvar
Rs=0
RW=0
E2=1
pause 5
E2=0
return
Writedata1: 'Write to upper 2 lines
PortA=Cvar
Rs=1
RW=0
E1=1
pause 5
E1=0
return
Writedata2: 'Write to lower 2 lines
PortA=Cvar
Rs=1
RW=0
E2=1
pause 5
E2=0
return
TestBusyFlag1: 'waits until BF is clear to return
PortA=$FF
Rs=0
RW=1
E1=1
RBF:
@nop
@ BTFSC PortA.7
goto RBF
Rs=1
RW=0
E1=0
return
INIT_LCD:
'Wakeup
Cvar = Wakeup
gosub Command1
gosub Command2
pause 2
'Wakeup
Cvar = Wakeup
gosub Command1
gosub Command2
pause 2
'Wakeup
Cvar = Wakeup
gosub Command1
gosub Command2
pause 2
;FunctionSet ;Function Set = 8bit mode; 2-line; 5x8
Cvar = FunctionSet
gosub Command1
gosub Command2
pause 2
'Display Off
cvar = DisplayOFF
gosub Command1
gosub Command2
pause 2
'Display Clear
Cvar = ClearDisp
gosub Command1
gosub Command2
pause 2
'Entry Mode Set ;Entry mode cursor increment
cvar = EntryMode
gosub Command1
gosub Command2
pause 2
'Display On
cvar = DisplayOnBcurs ;Turn on display; with blinking cusor
gosub Command1
gosub Command2
pause 2
return
Main: 'Write "Hello World"
GOSUB Blinky
GOSUB INIT_LCD
Message_line1:
Cvar=Home ;Set DDRam address for line 1
gosub Command1
avar = 0 ;starting address of EEprom first message
Bvar = Avar + 20
WHILE Avar < Bvar
read Avar, Cvar
Avar = Avar + 1
gosub Writedata1 ;write Cvar(contents of EEProm character) to LCD
pause 100
WEND
Marktime:
toggle led
pause 1000
toggle led
pause 1000
goto Marktime
end
-
Re: Newhaven 4x40 LCD, issues!
I have a display now. After making some fine adjustments to Vo, characters are writing as they should. Using both LCDOUT and hammering out the commands as in the code above. More to come!
-
Re: Newhaven 4x40 LCD, issues!
A 4x40 is really two 2x40's.
And it can be handled this way ... http://www.picbasic.co.uk/forum/show...=2388#post2388
-
Re: Newhaven 4x40 LCD, issues!
Thanks for the link Darrel, I'll check this out. It looks like it will solve my problem.
Thanks again!
Wayne
-
Re: Newhaven 4x40 LCD, issues!
Talk about timing. I just received two Newhaven OLED 4x20 LCD's in the mail today (http://www.newhavendisplay.com/specs...420DZW-AY5.pdf). A couple of questions:
I am putting this on a Microchip demo board (MCP2515) and I can't use all of Port B. Can I use any 8 pins that are free? Also, what is 4 bit operation and is it worthwhile to use it? The datasheet says that 4 lines aren't used when it's in 4 bit operation so I'm curious of using 4 less pins would be advantageous without losing any clarity on the LCD screen.
Sorry to hi-jack the thread but it seems appropriate in this case.
-
Re: Newhaven 4x40 LCD, issues!
-
Re: Newhaven 4x40 LCD, issues!
Quote:
Originally Posted by
mackrackit
Thanks for the link. Regarding my other question, is there any great benefits to using 8 bit (clarity/speed) or will 4 bit do the job? If 4 bit will do the job, just so I understand correctly, I need 7 pins from the PIC:
1. RS
2. R/W
3. E
4. Low order, bi-directional (1)
5. Low order, bi-directional (2)
6. Low order, bi-directional (3)
7. Low order, bi-directional (4)
Am I on the right track?
-
Re: Newhaven 4x40 LCD, issues!
R/W goes to VSS.
8 bit is a tad faster by the math but I do not think it is humanly noticeable. I never use 8 bit as pins get ...expensive...
-
Re: Newhaven 4x40 LCD, issues!
Are you sure the R/W pin goes to ground? DT's program and the datasheet both show that R/W gets connected to the PIC. I ask because I'm not getting anything on the screen. DT's programs seems to have complied just fine, although I'm not sure if I did everything correctly.
-
Re: Newhaven 4x40 LCD, issues!
Not sure where you saw Darrel connecting RW to the PIC, in fact he says not to in this post.
http://www.picbasic.co.uk/forum/show...=2388#post2388
The R/W pin is exactly what it says Read/Write, with 0 being Write.
Do you have the contrast pin connected to a pot as recommended? That is the most common problem. That should be pin #3 on the display. Not sure why the data sheet does not so it. Got to have contrast control.
-
1 Attachment(s)
Re: Newhaven 4x40 LCD, issues!
Sorry, it wasn't Darrell. It was NavMicroSystems in this picture. Anyhow, I literally get nothing. I can't even see the screen flicker. I've verified it has 4.8V at the power input and I've tried using a pot to adjust the contrast. I've only used serial LCD's from SEETRON in the past so this is new to me. Is there a basic way to test the screen? Like applying power to the LCD and +5 to another pin will display something?
-
Re: Newhaven 4x40 LCD, issues!
I do not know of a test.
Post your code and connections/schematic.
Maybe we will be able to see the problem.
-
Re: Newhaven 4x40 LCD, issues!
Here is what I have:
Code:
DEFINE OSC 20
@ __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
@ __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
@ __CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOR_OFF_2L & _BORV_3_2L & _VREGEN_ON_2L
@ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_32768_2H
@ __CONFIG _CONFIG3H, _CCP2MX_ON_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
@ __CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_ON_4L & _XINST_OFF_4L
loopcount var word
;----[ Change these to match your LCD ]---------------------------------------
LCD_DB4 VAR PORTE.1
LCD_DB5 VAR PORTA.3
LCD_DB6 VAR PORTA.4
LCD_DB7 VAR PORTE.2
LCD_RS VAR PORTD.3
LCD_E VAR PORTA.5
LCD_Lines CON 2 ' # of Lines on LCD, 1 or 2 (Note: use 2 for 4 lines)
LCD_DATAUS CON 50 ' Data delay time in us
LCD_COMMANDUS CON 2000 ' Command delay time in us
INCLUDE "LCD_AnyPin.pbp" ; *** Include MUST be AFTER LCD Pin assignments ****
;
;----[ Your Main program starts here ]----------------------------------------
'LoopCount VAR WORD PAUSE 500 : LCDOUT $FE,1 : PAUSE 250 ; Initialize LCD (You may not need this, ; but some displays are picky)
;
Main: LCDOUT $FE,1 ; clear screen
LCDOUT $FE,$87,"Hello,",$FE,$C8,"From DT!"
;
FOR LoopCount = 0 TO 65535
LCDOUT $FE,$80, IDEC LoopCount
LCDOUT $FE,$C0, IHEX4 LoopCount
NEXT LoopCount
GOTO Main
Pin connections are as follows:
1 VSS
2 VDD
3 10K POT
4 PORTD.3
5 VSS
6 PORTA.5
7 N/C
8 N/C
9 N/C
10 N/C
11 PORTE.1
12 PORTA.3
13 PORTA.4
14 PORTE.2
15 N/C
16 N/C
-
Re: Newhaven 4x40 LCD, issues!
Did you turn the ADC off someplace ?
-
Re: Newhaven 4x40 LCD, issues!
That's the entire code. I rechecked everything and everything looks okay. I bought two LCD's so when I get home I'll try the other one. I don't know what else I can check. I have an old Mikroelectronica board that has pins for parallel LCD's so maybe I'll use that with the standard code (all pins on the same port) to see if it's my hardware or software that's causing the issue.
-
Re: Newhaven 4x40 LCD, issues!
With those configs ... the PIC is running at 48mhz, not 20.
So change the DEFINE OSC 20 to DEFINE OSC 48.
And like Dave mentioned ... add ADCON1 = $0F before the LCD pins/include.
-
1 Attachment(s)
Re: Newhaven 4x40 LCD, issues!
Christopher, I had all my wiring correct and the code looked good but I still had no display. The problem was Vo. The contrast was a critical adjustment. Once I found the sweet spot, just above 0 VDC, all was well.
I've attatched a txt file with the code to test the LCD using E1 & E2, no other hardware needed. R/W can be tied to GND or to an output. Make the necessary VAR pin assinment changes. This code will write to all four lines without using LCDOUT command.
Wayne
Attachment 6659
-
Re: Newhaven 4x40 LCD, issues!
I've tried everything you guys suggested and still no dice.
I went back to the normal LCDOUT commands where I have everything on PORTB. I've tried my Easypic3 board and the 2X16 LCD that came with it, along with 3 other LCD displays I had laying around. I get one line of solid characters, which of course is adjustable with the contrast POT on the board. The LED blinks as intended but nothing on the LCD screen. Do I need to pull up or down any other lines? Is there anything else I can check?
I'm thinking it might be my files or programmer, but my other programs program just fine. I even reinstalled the PBP file that I modified last night for DT's program but I get the same results. Anything else I can check?
-
Re: Newhaven 4x40 LCD, issues!
Nevermind, I'm an idiot. I got the Easypic3 board working and now I'll move onto trying to make the NewHaven LCD screen work.
-
Re: Newhaven 4x40 LCD, issues!
I can confirm all LCD's work on the Easypic board but I can't get any to work on the demo board. Can someone check my modified pbppic18 file to see if it's correct? I can't tell if I have a hardware issue or a software issue.
> DT > The modifications were correct.
Copyrighted file removed.
-
Re: Newhaven 4x40 LCD, issues!
Problem solved......kinda.
I can get DT's program working on my Easypic board but not on my demo board so my issue is definitely hardware. I need a magnifying glass........
Thanks to everyone who helped, I learned a lot!
-
The problem is solved.....finally!
The issue ended up being a capacitor on the demo board. I'm assuming that the rise time for the data lines wasn't quick enough. The other thing I've learned is, this LCD does not have contrast control and therefore Vo does not exist on this screen. Seems strange but that's why pin 3 is listed as N/C.
Darrel, this program is awesome. You deserve a raise!
-
Re: The problem is solved.....finally!
Christopher, pin 3 is DB5, pin 16 is NC. If you have a 20k pot center taped to Vo you should have contrast. I can vary the contrast on my 4x40 over about a turn and a half of the pot. It goes from almost no visible characters to bright characters. Look over your Vo hardware once more.
Wayne
-
Re: The problem is solved.....finally!
Quote:
Originally Posted by
MOUNTAIN747
Christopher, pin 3 is DB5, pin 16 is NC. If you have a 20k pot center taped to Vo you should have contrast. I can vary the contrast on my 4x40 over about a turn and a half of the pot. It goes from almost no visible characters to bright characters. Look over your Vo hardware once more.
Wayne
You have an LCD screen. I have an OLED screen ( I know I put LCD above but it was a mistake). Pin 3 for me is no connection. Putting a POT on pin 3 does nothing. Again, this board does not have a Vo pin.
I suppose you could adjust the contrast by lowering the input voltage if it's really necessary.
-
Re: The problem is solved.....finally!
Wow, I totality missed that. My apologies, I was a bit too energetic to help and failed to read your first post closely. Glad you got the OLED working. It's a good looking display!
-
Re: Newhaven 4x40 LCD, issues!
No worries. I'd prefer someone be too energetic to help than not help at all.
-
Re: Newhaven 4x40 LCD, issues!
I have a Newhaven display here with the ST7066U driver. It doesnt work, nor did its replacement. I then went to an Optrex and plugged it into my connector, and it worked right away. Coincidence? Either way, could you guys confirm that a ST7066U driver works?
Thanks.
-
Re: Newhaven 4x40 LCD, issues!
Jmgelba,
Just a suggestion, try using the above Newheaven_4x40_Text Code.txt , INIT_LCD rutine and its sub’s, EEPRON, and E1 variable. This routine is for a duel ST7066U so you should only use Command1 in INIT_LCD. After initializing the LCD, all PBP commands should work. As stated in above post’s Vo adjustment must be made to find the sweet spot to display. Good luck!
Wayne