PDA

View Full Version : 4 x 20 LCD display with PB3 - Pin 5 High or Low?



xpa999
- 14th March 2014, 18:08
Hi, I've searched the forum and the documentation for PB3 and the displays, but I'm still confused.

Page 171 of the PB3 manual shows pin 5 of the LCD module tied to ground and page 172 shows the pin tied high. Which is correct?

I tried a simple program to clear the display and show 'READY'. The program then goes on to repeatedly flash an LED. If I comment out the Lcdout lines, the LED flashes. With the Lcdout line in place, the program hangs and the LED doesn't flash.

Can someone suggest a place for further research?

Thanks.

Darrel Taylor
- 14th March 2014, 18:14
The R/W pin should be tied to ground for writing to the display.

The schematic that shows it tied to VDD was my fault. :o
It has already been corrected for future manuals.

xpa999
- 14th March 2014, 18:19
Thanks Darryl,

Silly question: Is there feedback from the display to the Lcdout routine (I'm thinking of the 4 bit communication) or is the pic blindly sending data to the LCD and relying on timing for the LCD to grab data?

Thanks again.

Darrel Taylor
- 14th March 2014, 20:09
No, there is no feedback to the LCDOUT routines.

If the program stops or the chip resets when trying to display things, it could be that you have LVP enabled in the configs, and the LCD uses the PGM pin.

xpa999
- 29th March 2014, 19:21
leThanks for all the help, but I'm still stuck. I wired the LCD as shown on page 172 of the PB3 manual.

After giving up with my code, I tried the example supplied with the compiler. The display still remains blank. I've adjusted the contrast, I proved that the display works by connecting it to a Midibox 8-bit core. I've tried RT(AT)FM (AT=All The) many times and the display remains as blank as my feeble brain.

Here's the last code I compiled and burned. I've turned off the watchdog timer, set the oscillator to INTOSCIO. The 887 manual says the internal oscillator defaults to 4MHz, but the example assumes an 4MHz external crystal, so that should work, shouldn't it?

The only differences I can see are 1) that Page 172 shows r/w on the LCD tied low, and the example seems to indicate that the R/W line is tied to port E.2 and is set low in the program. 2) I'm using the internal oscillator, 3) I'm using a 4x20 display rather than a 4-line display, but ignoring the extra two lines for now. 4) I'm using a breadboard, not the Lab-X1 board.

I don't know what else to try.

Help!


The code:
-------------------------------------------------------------
' Name : LCDX.pbp
' Compiler : PICBASIC PRO Compiler 3.0.6.4
' Assembler : PM or MPASM
' Target PIC : 40-pin 16F887
' Hardware : LAB-X1 Experimenter Board
' Oscillator : 4MHz external crystal
' Keywords : LCDOUT
' Description : PICBASIC PRO program to display "Hello World" on
' LAB-X1 LCD.
'

' Define LCD registers and bits
Define LCD_DREG PORTD
Define LCD_DBIT 8
Define LCD_RSREG PORTE
Define LCD_RSBIT 0
Define LCD_EREG PORTE
Define LCD_EBIT 1

ANSEL = %00000000 ' Make AN0-AN7 digital
ANSELH= %00000000 ' Make AN8-AN13 digital
Low PORTE.2 ' LCD R/W line low (W)
Pause 100 ' Wait for LCD to start up

mainloop:
Lcdout $fe, 1 ' Clear screen
Pause 500 ' Wait .5 second

Lcdout "Hello" ' Display "Hello"
Pause 500 ' Wait .5 second

Lcdout $fe, $c0, "World" ' Move to line 2 and display "World"
Pause 500 ' Wait .5 second
Goto mainloop ' Do it forever

End

Darrel Taylor
- 29th March 2014, 19:30
I wired the LCD as shown on page 172 of the PB3 manual.
But your LCD DEFINEs don't match what is on page 173.

andywpg
- 30th March 2014, 22:18
Define LCD_DREG PORTD
Define LCD_DBIT 8


This is part of your problem. If you are using a 4 bit bus, this would be either 0 or 4 - the starting bit of the D4 line. If an eight bit bus, it would be 0

xpa999
- 31st March 2014, 20:07
Thanks for the help, but...

The define I actually used was

Define LCD_DREG PORTD
Define LCD_DBIT 0

The '8' appeared as an artifact of my clumsy attempt to paste the code into the message.

As far as the 'missing' defines from page 173, they are listed on page 170 of the PBP3 manual as the defaults, so they shouldn't be needed. But... I copied the defines straight from the manual, put them in my code and the result was the same - not working.

I put in some code to flash an LED on portc.3 to confirm that the program was actually running. It is. The LED is flashing at the rate I would expect from the OSC frequency and pause statements.

I've triple checked that I have the appropriate .1uf capacitors across Vss and Vdd at the pins on the 887.

I've checked that the 20k trimmer is providing 0 to 5V to pin 3 of the display. I've tried adjusting the trimmer from one end to the other. The only display is a complete line of filled boxes on the first line and nothing on the second line.

I have checked the wiring from the chip pins to the LCD pins with an ohmmeter: They are connected as expected and there appear to be no shorts or cross-connections. I've checked Vdd to be at 5.1 volts (within spec). Unfortunately, my 'scope is out for repair so I can't really check the timing. My trusty (single line) logic probe shows activity on all of the LCD data pins and the RS and E pins.

I've messed with the timing defines, tried two different LCDs of different manufacture and two different 887 chips. As I said before, both LCDs work correctly with a pic-based MIDIBox core module.

The LCDs are 4 line x 16 character. I've tried both DEFINE LCD_LINES 2 and DEFINE LCD_LINES 4. Neither worked.

Needless to say I am very frustrated. It must be something simple I am missing, but I am at a loss. Has anyone actually tried these routines in PBP V3 and gotten them to work?

7291

xpa999
- 31st March 2014, 21:16
AAAAAAAHHHHHHHHH!

Sorry guys, in my haste, I kept comparing my wiring to the diagram on Page 172, and tied the R/W pin High rather than Low per Darryl's reply. I heard the words, but my eyes saw the diagram. It's working fine now.