Changing LCD display refresh rate


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    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.

  2. #2
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    704


    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

  3. #3


    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

  4. #4
    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 20: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 " !!!
    *****************************************

  5. #5
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    704


    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

  6. #6
    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 01:08.
    Charles Linquist

  7. #7


    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 10:51.

  8. #8


    Did you find this post helpful? Yes | No

    Default Re: Changing LCD display refresh rate

    Note : I use a 40MHz xtal, and my LCD desired refresh rate is about 0.5s.

  9. #9
    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

    The ISR is not written in PBP. It is in assembly. The only INT_RETURN you need is at the end of the interrupt service routine - just before the ENDASM.

    For 40Mhz -
    Lines you need to change

    DEFINE OSC 40
    T0CON = %10000011 ; Turn timer on, divide by 16 prescaler

    movlw 0x0B ; 100 mSec @ 40MHz
    movwf TMR0H
    movlw 0xDC
    movwf TMR0L


    If MasterClock >= 5 then ; 5 X .1 sec = .5 seconds


    And no, it will not affect anything else you have running.
    Charles Linquist

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