News:

Let's find out together what makes a PIC Tick!

Main Menu

LCD 4x20 Doesn't Working (Text Doesn't Appears On LCD)

Started by swsalun, Sep 23, 2021, 04:44 AM

Previous topic - Next topic

swsalun

Hi All member here,
I have a problem with LCD 4x20, I using this to test my project, once I compiled everything is fine but once I debug/flash  also look good (success), but when I test it on real hardware doesn't working, no text is appears on a LCD.

This my wiring :
 RS to RB3
 E  to RB4
 RW to Ground
 
 D0-D1-D2-D3 to All Ground

 D4  to RD4
 D5  to RD5
 D6  to RD6
 D7  to RD7

 The rest pin all is connected as standard.

These are my code :
  ;-------------------------------------------------------------------------------
;**** Added by Fuse Configurator ****
; Use the Fuse Configurator plug-in to change these settings

Device = 16F877A
Declare Xtal 4
Config FOSC_XT, WDTE_ON, PWRTE_OFF, BOREN_ON, LVP_ON, CPD_OFF, WRT_OFF, DEBUG_OFF, CP_OFF

;**** End of Fuse Configurator Settings ****
;-------------------------------------------------------------------------------

All_Digital =true

Declare LCD_Type 0                 'text type
Declare LCD_DTPin PORTD.4          'assigns data lines to D4..7
Declare LCD_ENPin PORTB.4          'enable pin
Declare LCD_RSPin PORTB.3          'RS line pin
Declare LCD_Interface 4            '4 or 8 line interface
Declare LCD_Lines 4                'lines in the display
Declare Float_Rounding = On
Declare Float_Display_Type = LARGE

Declare Adin_Res = 10           '10-bit result required
Declare Adin_Tad = FRC          'RC OSC chosen
Declare Adin_Delay = 50         'Allow 50us sample time
 
ADCON1  = %10001101
ADCON0  = %11000001             'enable A/D  internal oscillator

TRISA = %00111111               
TRISB = %11100000               
TRISC = %00000000
TRISD = %00000000
'TRISE = %00000100
'------------------------------------- Prepare Comparator CMCON -----------------------------------------------
CMCON = 7                       
'-------------------------------------Variable For Temeperature------------------------------------------------
Dim ADC_Value   As Word     ; Variable que contendrá el valor leído por el ADC
Dim Temperatur  As Float   
Dim Volt As Word
'-------------------------------------End Temperature-----------------------------------------------------------
 
Print At 1,3, "Temperature Control  "        'Show in Line 1
Print At 2,2, "Test LCD  "                   'Show in Line 2
DelayMS  1000                 

Print At 1,1, "Temperature Room "
Print At 2,1, "Data : "
Print At 3,1,"Temp: "
Print At 4,1, "TPS:"
End

I use an external crystal with 4 mhz.
So as well my code above what is wrong, please help.


Regards,
Salun


Craig

Hi Shaun

What I would first do is setup an LED on one of the port pins and see if it Blinks On and Off when you power up See Example Blinky code below.
Loop:
 High portc.1
 Delayms 500
 Low Portc.1
 Delayms 500
Goto Loop

When the LED is working then check the following for the LCD:
See If You are Getting Little Black Block across the screen when you power up and run your code then once you see these try setting
your 10K POT For the Contrast and you should see your code running, You MUST Connect Contrast Pin. This is for the Hitachi type display.

Regards
Craig
   

Giuseppe

Try setting these declarations

Declare LCD_Interface 4
Declare LCD_ENPin PORTB.4 '
Declare LCD_RSPin PORTB.3 '
Declare LCD_Lines 4
Declare LCD_Data4_Pin PORTD.4 '
Declare LCD_Data5_Pin PORTD.5 '
Declare LCD_Data6_Pin PORTD.6 '
Declare LCD_Data7_Pin PORTD.7 '
Declare LCD_CommandUs 2000
Declare LCD_DataUs 100 '


RGV250

Hi,
When you say you have debugged it, what exactly have you done. I have just tried you code in the VSM and it works.I had to change the CPU to 16F877 and comment out CMCON, also RSPin = E.0 and ENPin = E.1
If you do not know how to use the VSM let me know and I or someone else will try to give details on its use.

Regards,
Bob

Stephen Moss

#4
@swsalun, try setting the LVP Configuration fuse to Off (LVP_Off).
The datasheet shows the PORTB.3 is shared with this function (RB3/PGM) and that with LVP_ON PortB.3 will act as the LVP pin input pin and not as a general I/O pin. Therefore it is doubtful that there is any activity occurring on the RS pin.

If something is not working and the applicable pins have multiple uses, i.e. standard I/O or connected to a peripheral it is a good idea to check that the other pin function is set so that it does not interfere with the function you wanted.

top204

Stephen has probably hit upon the problem, with the LVP fuse setting.

On the early devices, the LVP (Low Voltage Programming) mechanism was a mess, and it dedicated, yet another, pin for programming only. So if the LVP fuse setting is on, the PGM pin, usually PORTB.5, will screw things up.

The newer devices do not use a PGM pin, but I still do not trust the Low Voltage Programming mechanism, but one day I will try it and see if it has been improved or made worse. :-) From day one, the devices should have used a low voltage programming on the oscillator pins, so it did not tie up 2 valuable pins and require 13 Volts on the VPP line.

swsalun

Quote from: Craig on Sep 23, 2021, 06:30 AMHi Shaun

What I would first do is setup an LED on one of the port pins and see if it Blinks On and Off when you power up See Example Blinky code below.
Loop:
 High portc.1
 Delayms 500
 Low Portc.1
 Delayms 500
Goto Loop

When the LED is working then check the following for the LCD:
See If You are Getting Little Black Block across the screen when you power up and run your code then once you see these try setting
your 10K POT For the Contrast and you should see your code running, You MUST Connect Contrast Pin. This is for the Hitachi type display.

Regards
Craig
   
Hi Craig,
Actually I did this with 2x16 LCD is no have a problem, but I use a PIC16F88 or PIC16F628A, so I am not do that way, because I think everything will working normal.

swsalun

Quote from: Giuseppe on Sep 23, 2021, 07:02 AMTry setting these declarations

Declare LCD_Interface 4
Declare LCD_ENPin PORTB.4 '
Declare LCD_RSPin PORTB.3 '
Declare LCD_Lines 4
Declare LCD_Data4_Pin PORTD.4 '
Declare LCD_Data5_Pin PORTD.5 '
Declare LCD_Data6_Pin PORTD.6 '
Declare LCD_Data7_Pin PORTD.7 '
Declare LCD_CommandUs 2000
Declare LCD_DataUs 100 '


Hi Giuseppe,
I trying to changes with your code above, but it doesn't working too, still same appears no see text on LCD, I already adjust a voltage for contrast pin #3 LCD.

swsalun

Quote from: RGV250 on Sep 23, 2021, 07:51 AMHi,
When you say you have debugged it, what exactly have you done. I have just tried you code in the VSM and it works.I had to change the CPU to 16F877 and comment out CMCON, also RSPin = E.0 and ENPin = E.1
If you do not know how to use the VSM let me know and I or someone else will try to give details on its use.

Regards,
Bob
Hi RGV250,
I did this my code to VSM before I come here to help to your guys here.
All is fine when I did with VSM, I think you need to know, not every project is working well after your test on the VSM, some will working but sometime it doesn't work, I have tested already before, working fine on VSM but doesn't working on real hardware, I remove already CMCON but still doesn't working

swsalun

Quote from: Stephen Moss on Sep 23, 2021, 08:17 AM@swsalun, try setting the LVP Configuration fuse to Off (LVP_Off).
The datasheet shows the PORTB.3 is shared with this function (RB3/PGM) and that with LVP_ON PortB.3 will act as the LVP pin input pin and not as a general I/O pin. Therefore it is doubtful that there is any activity occurring on the RS pin.

If something is not working and the applicable pins have multiple uses, i.e. standard I/O or connected to a peripheral it is a good idea to check that the other pin function is set so that it does not interfere with the function you wanted.
Hi Stephen Moss,
I re-compiled refer to your suggestion, bring LVP to off but still same.
I recheck all the connection from PIC pin to LCD pin, all is connected good and correct.
I trying to change my debugger from the XGPRO TL866II Plus to K150 Programmer or K125 mikrobrn (Kitsrus), but it still same no text appears on LCD.
Then Trying to change the PORT PIN, RS and EN Pin to PORTE = PORTE.1 = EN PORTE.0 = RS and RW is Ground, all Pin D0-D1-D2-D3 to ground, the other Pin to PORTD.4 - PORTD.7, after compiled it still same.

Hope you can give me some sample test code refer to my PORT pin above, then I try to compiled it.

swsalun

Quote from: top204 on Sep 23, 2021, 09:48 AMStephen has probably hit upon the problem, with the LVP fuse setting.

On the early devices, the LVP (Low Voltage Programming) mechanism was a mess, and it dedicated, yet another, pin for programming only. So if the LVP fuse setting is on, the PGM pin, usually PORTB.5, will screw things up.

The newer devices do not use a PGM pin, but I still do not trust the Low Voltage Programming mechanism, but one day I will try it and see if it has been improved or made worse. :-) From day one, the devices should have used a low voltage programming on the oscillator pins, so it did not tie up 2 valuable pins and require 13 Volts on the VPP line.
Hi Top204-Les,
I did as stephen to change LVP to off, but it doesn't working.
I try to remove a Crystal 4 Mhz and it 2pcs capacitor 33pf.
I change PORT for RS and EN pin to PORTE.0 and PORTE.1, I not use PGM pin, but it not working, I measure my voltage to supply PIC16F877A is 4.92 VDC.
I change to compiled my debugger/programmer from TL866II Plus (with upgrade firmware to XGPRO V11.30) to K150 Kitsrus K125, but it doesn't working and also I try to change my LCD 4x20 to LCD 2x16.
So I feel this is my first time I got this mystery.
I need some advice from you, what this happen, all Pin +5 Volt and ground is connected correct, and all pin/cables between PIC to LCD Pin is correct connected.

JonW

May seem a silly question but have you tested it with a 2 x 16 that worked on the earlier processor?  Maybe the display is duff

I would go back to basics and ensure the processor is running at the correct speed and the Xtal is firing up ok with loading caps.   Flash an led on each of your IO at 500ms and go from there.

Normally if the code runs in VSM then its usually a hardware issue.

swsalun

Quote from: JONW on Sep 25, 2021, 02:59 PMMay seem a silly question but have you tested it with a 2 x 16 that worked on the earlier processor?  Maybe the display is duff

I would go back to basics and ensure the processor is running at the correct speed and the Xtal is firing up ok with loading caps.   Flash an led on each of your IO at 500ms and go from there.

Normally if the code runs in VSM then its usually a hardware issue.

Hi JONW,
What I said, actually I used a PIC16F88 or PIC16F628A, I don't have a problem when I use 2x16 LCD under Proton Compiler.
But I use a PIC16F877A with 4x20 LCD refer to my previous code posting, I have a problem, I already change the Processor PIC16F877A 4 times with different processor.
That code I already test on VSM, it working fine, but once I bring it to real hardware it doesn't.
I was check it the hardware, measure all connection seem's is fine nothing problem, I used a socket pin for PIC16F877A.

JonW

have you changed the xtal or have any other function on the 877 that can indicate that the code is actually running?  Maybe a Serial output so you can debug the output.  Sometimes the most simple mistakes take the longest to find and I always have a debug port whether its JTAG, Serial or even single wire

J

RGV250

Hi,
You might have already tried this but not sure reading here. You say you used 2x16 display on 16F88 / 16F628A devices and that worked, have you tried your 4x20 display on either 16F88 or 16F628A?

Bob 

Stephen Moss

It may not make a difference but try turning off the Watchdog Timer and Brownout reset in case one of them is resetting the PIC before it has finished writing to to the display.

Also...
1) I am not sure how you are programming the device but you cannot use LVP to change the LVP configuration fuse, you have to use high voltage programming.
2) It is worth following Craig's advice in regard to trying a simple LED toggle as sometimes a simple thing like telling the compiler the wrong Xtal frequency or selecting the wrong oscillator type can stop the whole thing running so it is good to ensure that it is at least running.

Parmin

Not sure if anyone has mentioned this, but the contrast pin of the LCD is often forgotten to be set correctly.

See_Mos

OK, so I tried the original code on real hardware and it did not work.

I changed LVP_ON to LVP_Off and it works so Parmin is probably right.

I would always put a delayms 500 and a CLS before the first print to allow the LCD to stabilize and initialize correctly but my hardware does work without.

swsalun

Hi Member,
This topic is solved, I close this.
Problem : Change RS pin to another PORTD PIN, Not use RB3/PGM PIN 36.

Regards,
Salun  :)  :)