• AVR Freaks

Helpful ReplyHot!lcd doesnt diisplay_Student-Companion

Page: 12345 > Showing page 1 of 5
Author
aviator3679
Junior Member
  • Total Posts : 105
  • Reward points : 0
  • Joined: 2019/08/22 13:32:23
  • Location: 0
  • Status: offline
2020/02/21 09:27:37 (permalink)
0

lcd doesnt diisplay_Student-Companion

Hello, I am following some tutorials from a youtube channel, its called Student Companion, about interfacing a  16 x 2 lcd. The tutorial used a Hitachi lm016 lcd and pic18f2620, but i used a qapass 16x2 lcd (i think its the same but from another manufacturer) and pic18f2220 instead. The circuit is basically a pic18f2220 connected to qapass 16x2 lcd in portB,with only D4-D7 used, and for the contrast pin i used a 4.14 K potentiometer, and anode connected to 5V, and the entire circuit powered by my power supply at 4.8V. The lcd backlight is working perfectly, but no letters are displayed on the screen. I triple checked all the connections and that every pin and cable is touching my breadboard. I was also adjusting the contrast with the potentiometer and still nothing. I even took out the potentiometer and put 2K,or 5K or 10K resistors to see if the problem is the contrast, but still nothing. The code i used is the same as that Student Companion used,except that i adjusted the code to pic18f2220 (meaning that in mplabx ide I created a new project for pic18f2220 and just copied the code from the pic18f2620 project to the new one), and that i used qapass 16x2 lcd. I also used mpalb ide and xc8 v1.34 compiler. The code builds successfully and when i put the hex file on proteus for simulation the lcd works just fine. Any clue from your experience? The code for the source file is below, if you need also the header file too tell me, thank you very much!!!
 
 
#include <stdio.h>
#include <stdlib.h>
#include "lcd_test.h"
void init_XLCD(void);
void DelayFor18TCY(void);
void DelayPORXLCD(void);
void DelayXLCD(void);
void main(void){
init_XLCD();
putrsXLCD("StudentCompanion");
SetDDRamAddr(0x40);
putrsXLCD("LCD DISPLAY");
while(1){

}
}
void init_XLCD (void){
OpenXLCD(FOUR_BIT & LINES_5X7);
while(BusyXLCD());
WriteCmdXLCD(0x06);
WriteCmdXLCD(0x00);
}
void DelayFor18TCY(void){
Nop(); Nop(); Nop(); Nop();
Nop(); Nop(); Nop(); Nop();
Nop(); Nop(); Nop(); Nop();
Nop(); Nop();
return;
}
void DelayPORXLCD(void){
Delay1KTCYx(30);
}
void DelayXLCD(void){
Delay1KTCYx(10);
}
 
#1
katela
Super Member
  • Total Posts : 1815
  • Reward points : 0
  • Joined: 2013/06/11 05:25:18
  • Location: South Africa
  • Status: offline
Re: lcd doesnt diisplay_Student-Companion 2020/02/21 09:39:10 (permalink)
0
Hi,
The configuration bits is also important. Can you post your configuration bits? Are you running on internal or external oscillator? 
How are you connecting your LCD pins to the microcontroller (data lines, E, RS, R/W)?
Are you able to connect an LED on one of the free pins, and blink it at 1 second rate to make sure your PIC is running correctly?
 

Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
YouTube Tutorials: https://www.youtube.com/StudentCompanionSA
#2
aviator3679
Junior Member
  • Total Posts : 105
  • Reward points : 0
  • Joined: 2019/08/22 13:32:23
  • Location: 0
  • Status: offline
Re: lcd doesnt diisplay_Student-Companion 2020/02/21 10:19:26 (permalink)
0
Hi, 
I am running on internal oscillator.
D4 =>rb0
D5=>rb1
D6=>rb2
D7=>rb3
E=>rb4
RS=>rb5
RW=>ground
 
I didn't do the led blinking, but since the code was able to be uploaded and read,shouldnt it work fine?
 
 
#3
aviator3679
Junior Member
  • Total Posts : 105
  • Reward points : 0
  • Joined: 2019/08/22 13:32:23
  • Location: 0
  • Status: offline
Re: lcd doesnt diisplay_Student-Companion 2020/02/21 10:20:49 (permalink)
0
// CONFIG1H
#pragma config OSC = INTIO2 // Oscillator Selection bits (Internal RC oscillator, port function on RA6 and port function on RA7)
#pragma config FSCM = OFF // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
#pragma config IESO = OFF // Internal/External Switchover bit (Internal/External Switchover mode disabled)
// CONFIG2L
#pragma config PWRT = OFF // Power-up Timer enable bit (PWRT disabled)
#pragma config BOR = OFF // Brown-out Reset enable bit (Brown-out Reset disabled)
#pragma config BORV = 20 // Brown-out Reset Voltage bits (VBOR set to 2.0V)
// CONFIG2H
#pragma config WDT = OFF // Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDTEN bit))
#pragma config WDTPS = 32768 // Watchdog Timer Postscale Select bits (1:32768)
// CONFIG3H
#pragma config CCP2MX = ON // CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)
#pragma config PBAD = ANA // PORTB A/D Enable bit (PORTB<4:0> pins are configured as analog input channels on Reset)
#pragma config MCLRE = OFF // MCLR Pin Enable bit (MCLR disabled; RE3 input is enabled in 40-pin devices only (PIC18F4X20))
// CONFIG4L
#pragma config STVR = ON // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
#pragma config LVP = ON // Single-Supply ICSP Enable bit (Single-Supply ICSP enabled)
// CONFIG5L
#pragma config CP0 = OFF // Code Protection bit (Block 0 (000200-0007FFh) not code-protected)
#pragma config CP1 = OFF // Code Protection bit (Block 1 (000800-000FFFh) not code-protected)
// CONFIG5H
#pragma config CPB = OFF // Boot Block Code Protection bit (Boot block (000000-0001FFh) is not code-protected)
#pragma config CPD = OFF // Data EEPROM Code Protection bit (Data EEPROM is not code-protected)
// CONFIG6L
#pragma config WRT0 = OFF // Write Protection bit (Block 0 (000200-0007FFh) not write-protected)
#pragma config WRT1 = OFF // Write Protection bit (Block 1 (000800-000FFFh) not write-protected)
// CONFIG6H
#pragma config WRTC = OFF // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) are not write-protected)
#pragma config WRTB = OFF // Boot Block Write Protection bit (Boot block (000000-0001FFh) is not write-protected)
#pragma config WRTD = OFF // Data EEPROM Write Protection bit (Data EEPROM is not write-protected)
// CONFIG7L
#pragma config EBTR0 = OFF // Table Read Protection bit (Block 0 (000200-0007FFh) not protected from table reads executed in other blocks)
#pragma config EBTR1 = OFF // Table Read Protection bit (Block 1 (000800-000FFFh) not protected from table reads executed in other blocks)
// CONFIG7H
#pragma config EBTRB = OFF // Boot Block Table Read Protection bit (Boot block (000000-0001FFh) is not protected from table reads executed in other blocks)
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
#include <xc.h>
#define _XTAL_FREQ 8000000
#4
1and0
Access is Denied
  • Total Posts : 10914
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: lcd doesnt diisplay_Student-Companion 2020/02/21 10:32:42 (permalink)
0
aviator3679
 
#pragma config PBAD = ANA // PORTB A/D Enable bit (PORTB<4:0> pins are configured as analog input channels on Reset)

Disable the analog features here.
#5
katela
Super Member
  • Total Posts : 1815
  • Reward points : 0
  • Joined: 2013/06/11 05:25:18
  • Location: South Africa
  • Status: offline
Re: lcd doesnt diisplay_Student-Companion 2020/02/21 10:41:20 (permalink)
0
aviator3679
 
I didn't do the led blinking, but since the code was able to be uploaded and read,shouldnt it work fine?
 

No. If the code is uploaded it does not mean it will work as intended. That's why it's very important to make sure at least your PIC is running at correct frequency as intended before checking other things.

Add in your main code: OSCCON = 0x7F; // 8MHz internal oscillator or read the REGISTER 2-2: OSCCON REGISTER in the datasheet to configure it appropriately.

Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
YouTube Tutorials: https://www.youtube.com/StudentCompanionSA
#6
aviator3679
Junior Member
  • Total Posts : 105
  • Reward points : 0
  • Joined: 2019/08/22 13:32:23
  • Location: 0
  • Status: offline
Re: lcd doesnt diisplay_Student-Companion 2020/02/21 10:49:29 (permalink)
0
why to disable it? its on reset only and mclr is off. maybe i am wrong i dont know ill try this too thank you
#7
aviator3679
Junior Member
  • Total Posts : 105
  • Reward points : 0
  • Joined: 2019/08/22 13:32:23
  • Location: 0
  • Status: offline
Re: lcd doesnt diisplay_Student-Companion 2020/02/21 10:51:39 (permalink)
0
=>katela
 
thank you ill add it to the code,but since it in the bottom of the header file shouldn t it be ok?
now im also uploading the blink led code and i ll tell you whats the result,thank you
#8
aviator3679
Junior Member
  • Total Posts : 105
  • Reward points : 0
  • Joined: 2019/08/22 13:32:23
  • Location: 0
  • Status: offline
Re: lcd doesnt diisplay_Student-Companion 2020/02/21 11:20:21 (permalink)
0
=> katela
 
just checked the led, its working just fine
#9
aviator3679
Junior Member
  • Total Posts : 105
  • Reward points : 0
  • Joined: 2019/08/22 13:32:23
  • Location: 0
  • Status: offline
Re: lcd doesnt diisplay_Student-Companion 2020/02/21 11:39:57 (permalink)
0
i also increased the delays just in case,almost dubled them but nothing
#10
katela
Super Member
  • Total Posts : 1815
  • Reward points : 0
  • Joined: 2013/06/11 05:25:18
  • Location: South Africa
  • Status: offline
Re: lcd doesnt diisplay_Student-Companion 2020/02/21 12:49:07 (permalink)
0
Try to change the delay:

void DelayFor18TCY(void){
Nop(); Nop(); Nop(); Nop();
Nop(); Nop(); Nop(); Nop();
Nop(); Nop(); Nop(); Nop();
Nop(); Nop();
return;
}

To:

void DelayFor18TCY(void){
Delay10TCYx(20);
}

Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
YouTube Tutorials: https://www.youtube.com/StudentCompanionSA
#11
1and0
Access is Denied
  • Total Posts : 10914
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: lcd doesnt diisplay_Student-Companion 2020/02/21 13:07:49 (permalink)
5 (1)
katela
Try to change the delay:

I'd replace all those delays with __delay_us() and __delay_ms().
 
#12
ric
Super Member
  • Total Posts : 27716
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: lcd doesnt diisplay_Student-Companion 2020/02/21 14:13:48 (permalink)
0
aviator3679
why to disable it? its on reset only and mclr is off. maybe i am wrong i dont know ill try this too thank you

Who are you answering here?
It appears you are replying to 1and0's advice to change the PBAD setting fron "analog" to "digital".
This has nothing to do with MCLR, and everything to do with how PORTB operates.
 
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#13
aviator3679
Junior Member
  • Total Posts : 105
  • Reward points : 0
  • Joined: 2019/08/22 13:32:23
  • Location: 0
  • Status: offline
Re: lcd doesnt diisplay_Student-Companion 2020/02/21 15:05:13 (permalink)
0
yes i was answering to 1and0, i tried the delays katela proposed and didnt work,now i am trying 1and0's advice and ill tell you how it goes
#14
aviator3679
Junior Member
  • Total Posts : 105
  • Reward points : 0
  • Joined: 2019/08/22 13:32:23
  • Location: 0
  • Status: offline
Re: lcd doesnt diisplay_Student-Companion 2020/02/21 15:32:20 (permalink)
0
just tried 1and0's advice on setting #pragma config PBAD = ANA // PORTB A/D Enable bit (PORTB<4:0> pins are configured as analog input channels on Reset)  on digital but still nothing, i really dont have a clue. One possibility could be that i have one power supply at 5V and i have connected those 5V to the anode of the lcd, to the VDD and VSS of the lcd, to the VDD and VSS of the pic mcu, and to the potentiometer for the contrast pin. And i was wondering what if the power goes to everyting else except the pic (to the path with the lowest resistance), but i put my multimeter on the VDD and VSS pins of the pic and the voltage was 5V, which means the pic works fine. I even took apart the entire circuit once more to see if the problem was a misconnection, but it wasnt (this is the 3rd time). Now, the lcd backlight works fine, but is there a way to see if there is another problem with lcd so that it doesnt display the code?As far as i know,if an lcd doesnt work then if powered up only one line should be lit,and if both line are bright then its not functioning. My lcd when powered up has one line bright, which should mean it works.
#15
dan1138
Super Member
  • Total Posts : 3644
  • Reward points : 0
  • Joined: 2007/02/21 23:04:16
  • Location: 0
  • Status: offline
Re: lcd doesnt diisplay_Student-Companion 2020/02/21 15:44:29 (permalink)
3 (2)
The Original Poster has a lot of problems.
 
The web site for "Student Companion" says it is “www.studentcompanion.co.za is being upgraded!”
The Student Companion tutorial content I could still find on interfacing the HD44780 LCD modules using XC8 seemed primitive.
 
What I found directed the student to install the obsolete PIC18F peripheral library for XC8 v1.35 and use the XLCD functions. I know these from old and I found the implementation to be less than robust. There is a significant problem getting the delay functions used to manage the parallel interface timing to produce the correct amount of real time delay between bit sets and clears.
 
I would suggest that the OP find a tutorial hosted on a web sit that is working.
#16
katela
Super Member
  • Total Posts : 1815
  • Reward points : 0
  • Joined: 2013/06/11 05:25:18
  • Location: South Africa
  • Status: offline
Re: lcd doesnt diisplay_Student-Companion 2020/02/21 16:01:28 (permalink)
0
dan1138
 
What I found directed the student to install the obsolete PIC18F peripheral library for XC8 v1.35 and use the XLCD functions. I know these from old and I found the implementation to be less than robust. There is a significant problem getting the delay functions used to manage the parallel interface timing to produce the correct amount of real time delay between bit sets and clears.

 
The same article which was initially written 7 years ago, explains that the PIC18F peripheral library is being phased out, and it provides an alternative, an example to use the PICDEM 2 Plus LCD library for people who would prefer an alternative LCD library to this old legacy XLCD library.
This is a backup page of the same article: https://www.studentcompanion.net/en/interfacing-lcd-display-with-pic-microcontroller-xc8/
The OP decided to use the old legacy XLCD library.

Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
YouTube Tutorials: https://www.youtube.com/StudentCompanionSA
#17
aviator3679
Junior Member
  • Total Posts : 105
  • Reward points : 0
  • Joined: 2019/08/22 13:32:23
  • Location: 0
  • Status: offline
Re: lcd doesnt diisplay_Student-Companion 2020/02/21 16:04:25 (permalink)
0
guys PEACE!!!haha
#18
dan1138
Super Member
  • Total Posts : 3644
  • Reward points : 0
  • Joined: 2007/02/21 23:04:16
  • Location: 0
  • Status: offline
Re: lcd doesnt diisplay_Student-Companion 2020/02/21 16:27:03 (permalink)
0
aviator3679
guys PEACE!!!haha



Sorry, don't mean to disparage your efforts.
 
It could be a worthy learning exercise rewriting the XLCD library code into something useful.
 
I did this a few years ago and have since used it on 12-bit(baseline,PIC16C), 14-bit(midrange,PIC16F), 16-bit(PIC18), 24-bit(PIC24) and 32-bit(PIC32) instruction word controllers.
 
The code I created requires some nit-picky modifications to the the functions that generate the parallel control bus timing. That is why I cannot recommend that you use my code.
 
But you can find an example here:
 
https://github.com/dsoze1138/18F4550_LCD_3x4kp
post edited by dan1138 - 2020/02/21 16:28:17
#19
aviator3679
Junior Member
  • Total Posts : 105
  • Reward points : 0
  • Joined: 2019/08/22 13:32:23
  • Location: 0
  • Status: offline
Re: lcd doesnt diisplay_Student-Companion 2020/02/21 17:02:56 (permalink)
0
thank you very  much, but since the code builds and on proteus the simulation works,shouldnt it work in real life too? I mean its not a complex circuit that too many things can go wrong, its only an lcd connected to a pic mcu. I don`t understand why it doesn`t work
#20
Page: 12345 > Showing page 1 of 5
Jump to:
© 2020 APG vNext Commercial Version 4.5