lcd stops after about 5 minutes and gets stuck


Closed Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Aug 2009
    Posts
    63

    Default lcd stops after about 5 minutes and gets stuck

    hi ive got a real simple lcd program, just trying to see what it does over long periods of time. however it works for a while, but everynow and then only half the word appears on an update and then after 5 minutes it just gets stuck with the same output. it works at first real smooth just as i want it to. watchdog timer doesnt reset it either...

    im using an 18f2431 and this is my simple code:

    Code:
    define OSC 20                       'define oscillator at 20mhz
    
    Define LCD_DREG PORTC               'defining portC for the databits
    define LCD_DBIT 4                   'defining bits 4-7 as the 4 data bits for lcd
    define LCD_RSREG PORTC              'defining the RS register to be on PORTC
    define LCD_RSBIT 0                  'defining bit0 of portC as the RSbit for LCD
    Define LCD_EREG PORTC               'defining the LCD enable bit to be on portC
    define LCD_EBIT 3                   'defining the lcd enable bit on portc to be bit0
    define LCD_BITS 4                   'set number of lcd data bits, 4 is standard
    define LCD_LINES 2                  'define the number of lines on LCD, 2 lines is standard
    define LCD_COMMANDUS 3000           'set command delay time in microseconds
    define LCD_DATAUS 150               'set data delay time in microseconds
    
    
    
    pause 1000                          'pause for initialization of lcd
    main:                               'start of program, where the program loops back to
    lcdout $FE,1,"hello"                'clears display and shows "hello" on first line
                                            '$FE,1 clears display
                                            '"hello" shows hello on lcd
    lcdout $FE,$C0,"world"              'goes to second line of lcd and displays "world"
                                            '$FE,$C0 = move cursor to beginning of second line  
                                            '"world" displays world
    
    pause 1000                          'pause so not to update lcd too quickly
    
    lcdout $FE,1,"EVANCE"                'clears display and shows "hello" on first line
                                            '$FE,1 clears display
                                            '"hello" shows hello on lcd
    lcdout $FE,$C0,"ISKRA"              'goes to second line of lcd and displays "world"
                                            '$FE,$C0 = move cursor to beginning of second line  
                                            '"world" displays world
    pause 1000
    
    goto main                           'end of program and looping back to start of program
    
    end
    thanks

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    robertpeach, I have found in the past some LCD's require a timeout of approx. 5 to 15 milliseconds after receiving a clear command.. Try putting a "PAUSE 15" statement just after the clear LCD command... I'm pretty sure that will take care of the problem...

    Dave Purola,
    N8NTA

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi Robert,
    this PIC has capture comparators on portC, turn them off
    CCP1CON = 0
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  4. #4
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    thanks for the help!

    made a difference, although i still had a problem. in the end i tried putting a capacitor (about 470micro ohms) across the input voltage and the ground. this made my pic work real smooth and now all my programs run completely fine over long periods of time!

    unfortunately im not an expert on schematics of electronics and it was probably quite obvious to a seasoned programmer... can anyone explain the physical reason behind why this worked? sorry im quite interested in knowing this kind of stuff.

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Properly sized caps near the PIC across VDD/VSS will help do a final clean up of the power. The power supply may have nice clean power but a lot can happen along the way to the PIC.

    Larger caps most anyplace in the circuit will help with short "brown outs" a short term battery of sorts.

    That is all the technical I feel like today . But it should give you the idea.
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Sep 2009
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    Hi
    Im new at microcontrollers and i have the same problem with pic16f877a.
    Im try to make a counter.

    DEFINE LCD_DREG PORTD
    DEFINE LCD_DBIT 4
    DEFINE LCD_BITS 4
    DEFINE LCD_RSREG PORTD
    DEFINE LCD_RSBIT 2
    DEFINE LCD_EREG PORTD
    DEFINE LCD_EBIT 3
    DEFINE LCD_LINES 2


    cnt var word
    cnt =0
    pause 1000

    mainloop:
    Lcdout $fe, 1
    Lcdout $fe, 2
    cnt = cnt +1
    Lcdout "x=",DEC cnt
    Pause 1000


    Goto mainloop


    LCD starts to count (sometimes doesnt start) and after few seconds gives me
    -<????-<????-<????-<????
    and other strange things.

    same results if i use port B or port E. The pins connections are ok because i see sometimes the counter running.
    Please give some advice, i cant sleep at night.

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    You might try adding these line to your code
    Code:
    define LCD_COMMANDUS 3000           'set command delay time in microseconds
    define LCD_DATAUS 150               'set data delay time in microseconds
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Jul 2008
    Location
    TURKIYE-KONYA
    Posts
    51


    Did you find this post helpful? Yes | No

    Exclamation Config_fuses

    I think these are all about your config settings.

    Try ; power_on_reset_enable and brown_out_reset_enable


    Code:
    @ device pwrt_on , bod_on

  9. #9
    Join Date
    Sep 2009
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    Thanks
    mehmetOzdemir

    Can someone tell me all about @........
    Do i have to use something like ?

    @ DEVICE pic16F877 ' System Device
    @ DEVICE pic16F877, WDT_ON ' Watchdog Timer
    @ DEVICE pic16F877, PWRT_ON ' Power-On Timer
    @ DEVICE pic16F877, BOD_ON ' Brown-Out Detect
    @ DEVICE pic16F877, LVP_OFF ' Low-Voltage Programming
    @ DEVICE pic16F877, CPD_OFF ' Data Memory Code Protect
    @ DEVICE pic16F877, PROTECT_OFF ' Program Code Protection
    @ DEVICE pic16F877, XT_OSC

  10. #10
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Dave
    Always wear safety glasses while programming.

  11. #11
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by robertpeach View Post
    thanks for the help!

    made a difference, although i still had a problem. in the end i tried putting a capacitor (about 470micro ohms) across the input voltage and the ground. this made my pic work real smooth and now all my programs run completely fine over long periods of time!

    unfortunately im not an expert on schematics of electronics and it was probably quite obvious to a seasoned programmer... can anyone explain the physical reason behind why this worked? sorry im quite interested in knowing this kind of stuff.
    I have found putting a .01 &micro;F capacitor on the lcd power pins helps too
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  12. #12
    Join Date
    Sep 2009
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    Thanks everyone. i put

    @ DEVICE pic16F877 ' System Device
    @ DEVICE pic16F877, WDT_ON ' Watchdog Timer
    @ DEVICE pic16F877, PWRT_ON ' Power-On Timer
    @ DEVICE pic16F877, BOD_ON ' Brown-Out Detect
    @ DEVICE pic16F877, LVP_OFF ' Low-Voltage Programming
    @ DEVICE pic16F877, CPD_OFF ' Data Memory Code Protect
    @ DEVICE pic16F877, PROTECT_OFF ' Program Code Protection
    @ DEVICE pic16F877, XT_OSC


    and all works fine.

  13. #13
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    thanks mack and joe.s

    yeah that makes total sense, i was just being a bit idiotic i think! it just stores energy almost and then when there is a fluctuation in power source, the capacitor releases the built up charge to oppose the change.

  14. #14
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by robertpeach View Post
    thanks mack and joe.s

    yeah that makes total sense, i was just being a bit idiotic i think! it just stores energy almost and then when there is a fluctuation in power source, the capacitor releases the built up charge to oppose the change.
    That was a good question. Not idiotic.

    Oppose the change. Yes, we must.
    Dave
    Always wear safety glasses while programming.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts