• AVR Freaks

Hot!Noob looking for turn-key 2004 LCD Display Hello World C Code

Author
t1d
Senior Member
  • Total Posts : 138
  • Reward points : 0
  • Joined: 2015/01/26 15:49:24
  • Location: 0
  • Status: offline
2019/09/18 23:34:32 (permalink)
0

Noob looking for turn-key 2004 LCD Display Hello World C Code

Particularly for a clone 2004 LCD Display with an assumed HD44780 IC using 8-pin configuration on a 18F4550.
 
I have done my homework and searched the web for example programs. I have worked with at least eight C code programs and I have yet to find one that is plug and play. These displays are known to be finicky about delays for startup and initialization procedure.
 
I know enough about the hardware side of things to be confident that all of my hardware setup is correct... Pins confirmed. Continuity confirmed. Traffic seen on my oscilloscope. Etc. I have tried various displays; I have several... both 2004 and 1602.
 
Please do not tell me that there are plenty of good programs, if I just will give it a google. I have used Student Companion, Electric Wings, Microchip Forum, PIC Forum, and others, all to no avail.
 
I have had intermittent success, with the full circuit working and displaying everything correctly - once... I turned it off and back on and its back to not initializing.
 
This type of behavior is known for these displays, when having initialization problems. Initialization procedure, timing, oscillator settings and voltage can all cause picky problems.
 
At this point I am frustrated and just want to see a code that works. And, I do not want to go I2C, because I want to learn what is wrong with what I have. For me, learning by seeing is best.
 
I am past trying to work through the problems. So much as I don't even want to adjust code working for some other series of PIC. Sorry to whine, but I am fed up.
 
So, I am hopeful that there is a generous sole that knows they have good code and is willing to share it.
 
Thank for your help. My apologies for any ranting.

 
#1

17 Replies Related Threads

    ric
    Super Member
    • Total Posts : 24600
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Noob looking for turn-key 2004 LCD Display Hello World C Code 2019/09/18 23:46:19 (permalink)
    +1 (1)
    Why start a second topic when you just started the one at https://www.microchip.com/forums/m1112800.aspx ?
     

    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!
    #2
    t1d
    Senior Member
    • Total Posts : 138
    • Reward points : 0
    • Joined: 2015/01/26 15:49:24
    • Location: 0
    • Status: offline
    Re: Noob looking for turn-key 2004 LCD Display Hello World C Code 2019/09/18 23:50:09 (permalink)
    0
    Hi, Ric,
     
    Thanks for your help.
     
    They are two separate topics. One for the libraries and one for code. If I had put them together, somebody would have said I shouldn't have. So, what to do?
    #3
    pcbbc
    Super Member
    • Total Posts : 1381
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: Noob looking for turn-key 2004 LCD Display Hello World C Code 2019/09/19 01:08:55 (permalink)
    0
    t1dunnI have had intermittent success, with the full circuit working and displaying everything correctly - once... I turned it off and back on and its back to not initializing.

    Post that project and we can make suggestions as to what is wrong.
    Usually just adding some extra delays during initialisation gets things working. If it worked once then chances are the timing is right on the edge of what is acceptable to the display.
    #4
    t1d
    Senior Member
    • Total Posts : 138
    • Reward points : 0
    • Joined: 2015/01/26 15:49:24
    • Location: 0
    • Status: offline
    Re: Noob looking for turn-key 2004 LCD Display Hello World C Code 2019/09/19 01:54:13 (permalink)
    0
    pcbbc
    Post that project and we can make suggestions as to what is wrong.
    Usually just adding some extra delays during initialisation gets things working. If it worked once then chances are the timing is right on the edge of what is acceptable to the display.

    I very much appreciate the offer to help correct the code. I have already added the delays and still no joy.
     
    I need to leave the code alone for awhile, to get things back into perspective. That's why I asked for a complete working code. If someone doesn't contribute that, I will let you know.
     
    You a very gracious to jump in. Thank you.
    #5
    PStechPaul
    Super Member
    • Total Posts : 2441
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: offline
    Re: Noob looking for turn-key 2004 LCD Display Hello World C Code 2019/09/19 21:41:46 (permalink)
    0
    It is difficult to write a library for all character LCD displays and all PICs. But here is some code that might work for you. One of these is for a PIC18F2455 and the other is for a PIC16F883. I think both of them use an 8 bit data bus. Good luck!
     
    http://enginuitysystems.com/pix/electronics/LCD_Display_1.zip
     
    http://enginuitysystems.com/pix/electronics/LCD_Display_MikroC%20(2).zip
     
    And here is some code for I2C as used on an LCD display:
     
    http://enginuitysystems.com/pix/electronics/I2C_PES.zip
    http://enginuitysystems.com/pix/electronics/LCD_PES.zip
     

     
    #6
    t1d
    Senior Member
    • Total Posts : 138
    • Reward points : 0
    • Joined: 2015/01/26 15:49:24
    • Location: 0
    • Status: offline
    Re: Noob looking for turn-key 2004 LCD Display Hello World C Code 2019/09/20 12:10:54 (permalink)
    0
    PStechPaul
    It is difficult to write a library for all character LCD displays and all PICs. But here is some code that might work for you. One of these is for a PIC18F2455 and the other is for a PIC16F883. I think both of them use an 8 bit data bus. Good luck!
     
    http://enginuitysystems.com/pix/electronics/LCD_Display_1.zip
     
    http://enginuitysystems.com/pix/electronics/LCD_Display_MikroC%20(2).zip
     
    And here is some code for I2C as used on an LCD display:
     
    http://enginuitysystems.com/pix/electronics/I2C_PES.zip
    http://enginuitysystems.com/pix/electronics/LCD_PES.zip
     


    Thanks, Paul! You are always so gracious to help.
    One file title says it is for MikroC. Will that compile in MPLab X v5+, XC8; v2.10?
    #7
    PStechPaul
    Super Member
    • Total Posts : 2441
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: offline
    Re: Noob looking for turn-key 2004 LCD Display Hello World C Code 2019/09/20 13:18:09 (permalink)
    0
    All of these use XC8. The version fort MikroC emulates the MicroC functions that were used in the original code that I was modifying for someone.

     
    #8
    t1d
    Senior Member
    • Total Posts : 138
    • Reward points : 0
    • Joined: 2015/01/26 15:49:24
    • Location: 0
    • Status: offline
    Re: Noob looking for turn-key 2004 LCD Display Hello World C Code 2019/09/20 13:39:35 (permalink)
    0
    PStechPaul
    All of these use XC8. The version fort MikroC emulates the MicroC functions that were used in the original code that I was modifying for someone.


    Thanks for the fast answer.
    I tried LCD_Display_1. It looks like it might be for a PIC18F4455, using PortD for the data lines. I am using a 18F4550, with the data lines on PortB. Also, PI-250_PCB.h is missing. I commented it out, thinking that you did not include it, because it is not needed for the present purpose. Then, a whole bunch of other stuff becomes undefined. I tried C90 and C99. But, thank you for trying to help me.
    #9
    dan1138
    Super Member
    • Total Posts : 3289
    • Reward points : 0
    • Joined: 2007/02/21 23:04:16
    • Location: 0
    • Status: offline
    Re: Noob looking for turn-key 2004 LCD Display Hello World C Code 2019/09/20 14:14:29 (permalink)
    0
    t1dunnI tried LCD_Display_1. It looks like it might be for a PIC18F4455, using PortD for the data lines. I am using a 18F4550, with the data lines on PortB. Also, PI-250_PCB.h is missing. I commented it out, thinking that you did not include it, because it is not needed for the present purpose. Then, a whole bunch of other stuff becomes undefined. I tried C90 and C99. But, thank you for trying to help me.


    A project on git hub for the PIC18F4550 with an LCD and 3 x 4 keypad is here. It may be of some help.
    post edited by dan1138 - 2019/10/22 16:35:36
    #10
    t1d
    Senior Member
    • Total Posts : 138
    • Reward points : 0
    • Joined: 2015/01/26 15:49:24
    • Location: 0
    • Status: offline
    Re: Noob looking for turn-key 2004 LCD Display Hello World C Code 2019/09/20 15:04:46 (permalink)
    0
    dan1138
    t1dunn
    I tried LCD_Display_1. It looks like it might be for a PIC18F4455, using PortD for the data lines. I am using a 18F4550, with the data lines on PortB. Also, PI-250_PCB.h is missing. I commented it out, thinking that you did not include it, because it is not needed for the present purpose. Then, a whole bunch of other stuff becomes undefined. I tried C90 and C99. But, thank you for trying to help me.



    A project on git hub for the PIC18F4550 with an LCD and 3 x 4 keypad is here.
     
    It may be of some help.


    Thanks, Dan. Much appreciated.
    #11
    t1d
    Senior Member
    • Total Posts : 138
    • Reward points : 0
    • Joined: 2015/01/26 15:49:24
    • Location: 0
    • Status: offline
    Re: Noob looking for turn-key 2004 LCD Display Hello World C Code 2019/09/20 15:08:20 (permalink)
    +2 (2)
    @Paul...
    I have gotten the original code working. So, I am making this quick post to let you know, in hopes of saving you the effort of customizing your code to my needs. I will post my findings, when I have more time.
     
    Thanks to everyone.
    #12
    nidac
    Starting Member
    • Total Posts : 53
    • Reward points : 0
    • Joined: 2019/11/03 00:54:11
    • Location: 0
    • Status: offline
    Re: Noob looking for turn-key 2004 LCD Display Hello World C Code 2019/11/13 23:34:56 (permalink)
    0
    For: @PStechPaul,...
    I want to use this code to send strings on LCD, type PVC1602, 2X16 char.
    Although the code is compiled with HI-TECH C Compiler v. 7.86 PL3, HI-TECH PICC9.83, XC8 1.33 or 2.00, the .hex file uploaded to the PIC does not send the message "Embetr ...." to the LCD. This message must scroll from right to left.
    But if I use this code , the message "Embetr ...." is sent to the LCD with scrolling.
    The .hex file at the last code it is double in size compared to the .hex file resulting from my compilation.
    It may be a compilation problem or there are two different codes. I don't know which compiler to use.
    Thanks in advance.
    #13
    AMPS
    Super Member
    • Total Posts : 468
    • Reward points : 0
    • Status: offline
    Re: Noob looking for turn-key 2004 LCD Display Hello World C Code 2019/11/14 00:20:41 (permalink)
    0
    I would recommend to use HITech compiler  with MPLAB IDe. pic16F877A works well with hitech compiler . i found issue with mplab X IDE with XC8 compiler.
     
    XC8 compiler build program without any error . it might give some warning but code wont work properly. 
    new PIC18 Series with MCC code configuration the functions associated with them works well without any error. 
     
     

     


    Amps
    *.*.*.*.*.*.*.*.*.*.*.*.*
    #14
    nidac
    Starting Member
    • Total Posts : 53
    • Reward points : 0
    • Joined: 2019/11/03 00:54:11
    • Location: 0
    • Status: offline
    Re: Noob looking for turn-key 2004 LCD Display Hello World C Code 2019/11/14 00:41:07 (permalink)
    0
    I solved:
    with xc8 compiler and header file #include< htc.h>(no #include< xc.h>) , the hex file is OK.
     
     
    post edited by nidac - 2019/11/14 00:43:45

    Attached Image(s)

    #15
    nidac
    Starting Member
    • Total Posts : 53
    • Reward points : 0
    • Joined: 2019/11/03 00:54:11
    • Location: 0
    • Status: offline
    Re: Noob looking for turn-key 2004 LCD Display Hello World C Code 2019/11/14 00:48:46 (permalink)
    0
    @AMPS:
    Thanks for suggestions.
    In MPLAB IDE v. 5.10, I can't see my old compiler HI-TECH C Compiler v7.86 PL3.
    Have you an ideea why?
    Thanks again.
    #16
    AMPS
    Super Member
    • Total Posts : 468
    • Reward points : 0
    • Status: offline
    Re: Noob looking for turn-key 2004 LCD Display Hello World C Code 2019/11/14 01:20:39 (permalink)
    0
    I have attached compiler detailed installed in my system. kindly check below image for reference.
     
    When you using MplabXide with hitech compiler It wil build successfully but wont give proper output.
    I would recommend use older version of MPLAB ide with hitech compiler.
     
    Controller like PIC16F1938/1939 series code compiled on hitech , its easy to merge code on MPLAB X IDE.
    Some old controller like PIC16F886/887 wont support XC8 library and hitech compiler on Mplab XIDE.
     
    MPLAB x IDE will easy to program/ people looking for library functions/ working on new controller should opt MPLAB Xide with Xc8 compiler.but issue also some function while handling interrupts. Need to careful while handing interrupt here.
     
    if u selected controller based on Online example like pic16F886/877/877A Series , i wont recommend to use mplab X ide.
     
     
     
     
    post edited by AMPS - 2019/11/14 01:24:09

    Attached Image(s)


    Amps
    *.*.*.*.*.*.*.*.*.*.*.*.*
    #17
    nidac
    Starting Member
    • Total Posts : 53
    • Reward points : 0
    • Joined: 2019/11/03 00:54:11
    • Location: 0
    • Status: offline
    Re: Noob looking for turn-key 2004 LCD Display Hello World C Code 2019/11/14 01:32:02 (permalink)
    0
    @AMPS:
    Thanks.
    #18
    Jump to:
    © 2019 APG vNext Commercial Version 4.5