Changing LCD display refresh rate


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1

    Default Changing LCD display refresh rate

    Hi everyone,

    In my program, the LCD commands are placed in a loop.

    But the refresh rate of the LCD is too fast, so in certain conditions (when reading an unstable ADC value for example), the displayed numbers are changing very quickly, so it's unreadable.

    So, it will be better if my LCD refresh displayed values every 200/500ms.

    I don't want to use a delay/wait command in my loop.

    Did the DEFINE LCD [...] commands can solve this problem?

    Thanks a lot.

  2. #2
    Join Date
    Sep 2010
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: Changing LCD display refresh rate

    Why not just add a condition that only updates the LCD if the ADC value changes by a certain amount from the last reading. That would reduce the updates and also make it less resposive to small changes in voltage.

  3. #3
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default Re: Changing LCD display refresh rate

    Well, this is just an idea. Take 10 readings, then obtain the average, and display it in the LCD. Something like this,

    Code:
    MAIN:
    
    FOR I = 0 TO 9
      ....Take ADC reading READING[I] 
    NEXT I
    
    'Next obtain the average
    AVERAGE = (READING[0] + READING[1] + ......) / 10
    
    LCDOUT $FE, 1, DEC AVERAGE
    
    GOTO MAIN
    Robert
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: Changing LCD display refresh rate

    How do that?

    Here is a sample of my loop :

    lp:

    ADCON0.1=%1
    WHILE ADCON0.1=%1:WEND

    ' Store ADC results
    isense.HIGHBYTE=ADRESH
    isense.LOWBYTE=ADRESL

    ' Security fault verifications
    IF isense**40000>imax THEN flt=1

    ' LCD
    idisp=isense**40000
    lcdout $fe,$c0,$1,$20,"1 ISENS: ",DEC idisp DIG 2,DEC idisp DIG 1,".",DEC idisp DIG 0,"A"


    goto lp

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default Re: Changing LCD display refresh rate

    Code:
    lp:
    
    ADCON0.1=%1 
    WHILE ADCON0.1=%1:WEND
    
    ' Store ADC results 
    isense.HIGHBYTE=ADRESH 
    isense.LOWBYTE=ADRESL
    
    ' Security fault verifications
    IF isense**40000>imax THEN flt=1
    
    I = I+1    ; insert @top " I var Byte " 
    IF I = 1 THEN  ; also can use IF I // 200 = 1 ... and adjust "200" to the desired rate
    
    ' LCD
    idisp=isense**40000
    lcdout $fe,$c0,$1,$20,"1 ISENS: ",DEC idisp DIG 2,DEC idisp DIG 1,".",DEC idisp DIG 0,"A"
    
    ENDIF
    
    
    goto lp
    Last edited by Acetronics2; - 3rd November 2011 at 19:46.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default Re: Changing LCD display refresh rate

    Quote Originally Posted by pxidr84 View Post
    How do that?
    Something like this,

    Code:
    lp:
    
    AVERAGE = 0
    FOR I = 0 TO 9
      ADCON0.1=%1 
       WHILE ADCON0.1=%1:WEND
    
       ' Store ADC results 
       isense.HIGHBYTE=ADRESH 
       isense.LOWBYTE=ADRESL
       
       AVERAGE = AVERAGE + isense
    NEXT I
    
    AVERAGE = AVERAGE / 10
    ISENSE = AVERAGE
    
    ' Security fault verifications
    IF isense**40000>imax THEN flt=1
    
    ' LCD
    idisp=isense**40000
    lcdout $fe,$c0,$1,$20,"1 ISENS: ",DEC idisp DIG 2,DEC idisp DIG 1,".",DEC idisp DIG 0,"A"
    
    
    goto lp
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  7. #7
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Changing LCD display refresh rate

    A slightly different method:

    Updating LCDs is really time consuming, from a PIC viewpoint. I find that a .25(once every 4 seconds) update rate is about right for most people, especially if it a two-line display.

    The code below lets your code run at full speed and updates the LCD once every 4 seconds. Of course the rate can be changed to suit the user. It uses an ASM interrupt for low overhead.
    Of course, you could read the timer directly, but I find that I always need interrupts anyway.



    Code:
          DEFINE OSC 4 
    
         MasterClock VAR WORD BANKA SYSTEM
    ;----------------Timer Setup-----------------------------------  
        T0CON = 000010 ; /1:8   prescaler, tmr0 ON
    ;
    ;-------------------------------------------------------------     
       
    INCLUDE "DT_INTS-18.bas"    '
    ;---------------------------------------------------------------
    asm
        INT_LIST  macro     
            INT_Handler    TMR0_INT,  MainTimer, ASM, yes
           endm
        INT_CREATE              
    endasm
    ''----------------- Initialization Done! -----------------------------
        Goto OverInt 
    ;----------------------- Timer INt ------------------------------------    
    ASM
    MainTimer
            movlw   0xCF         ;  100 mSec @ 4MHz
            movwf   TMR0H
            movlw   0x2C
            movwf   TMR0L
           
            btfsc   MasterClock + 1,7     ; Don't let MasterClock roll over
            bra     DontCount
            infsnz  MasterClock
            incf    MasterClock + 1          
            
          
    DontCount        
          
          bcf     INTCON,2
        INT_ENABLE TMR0_INT
        INT_RETURN
    ENDASM
    ;---------------------------------------------------------------------
    OverInt:
    
       INTCON.7 = 1  ; Main Ints
       INTCON.6 = 1  ; Peripheral ints
    
        MasterClock = 0
    @ bcf INTCON,2
    @ INT_ENABLE TMR0_INT
    TopOfLoop:
        If MasterClock >= 20 then     ; 20 X .1 sec = 2 seconds
           MasterClock = 0
             
             ; Do LCD routines here
        endif
        
            ; Your main program here
            
            goto TopOfLoop
    Last edited by Charles Linquis; - 4th November 2011 at 00:08.
    Charles Linquist

  8. #8


    Did you find this post helpful? Yes | No

    Default Re: Changing LCD display refresh rate

    There is no @ int_return at the end?
    I already use a timer1 DT interrupt, this one will not affect my program?
    Last edited by pxidr84; - 4th November 2011 at 09:51.

Members who have read this thread : 0

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