Big characters on HD44780 4x20


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    You could still use an internal Timer/Counter. Let's say RA.4/T0CKI. and poll the TMR0 register value, then use Branch...
    Code:
    IF TMR0>AmountOfRoutine then TMR0=0
    BRANCH TMR0,[Routine0, Routine1,Routine....]
    The count will be done in background.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    Join Date
    Jan 2007
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    You could still use an internal Timer/Counter. Let's say RA.4/T0CKI. and poll the TMR0 register value, then use Branch...
    Code:
    IF TMR0>AmountOfRoutine then TMR0=0
    BRANCH TMR0,[Routine0, Routine1,Routine....]
    The count will be done in background.
    Could you explain me better this solution? Actually I've solved using a non-background count.

    Do you know a tutorial or a guide to help me understand Timers/Couters in PBP? TNX!
    Last edited by erpalma; - 5th January 2007 at 22:02.

  3. #3
    Join Date
    Jan 2007
    Posts
    13


    Did you find this post helpful? Yes | No

    Default Update

    Code:
    '	@ DEVICE pic16F648A, INTRC_OSC_NOCLKOUT  	   ' System Clock Options	
    	@ DEVICE pic16F648A, HS_OSC  	   ' System Clock Options	
    
        @ DEVICE pic16F648A, WDT_OFF	   ' Watchdog Timer
    	@ DEVICE pic16F648A, PWRT_ON	   ' Power-On Timer
    	@ DEVICE pic16F648A, BOD_ON       ' Brown-Out Detect
    	@ DEVICE pic16F648A, MCLR_ON	   ' Master Clear Options (Internal)
    	@ DEVICE pic16F648A, LVP_OFF	   ' Low-Voltage Programming
    	@ DEVICE pic16F648A, CPD_OFF       ' Data Memory Code Protect
    	@ DEVICE pic16F648A, PROTECT_OFF   ' Program Code Protection
    
    
    DEFINE OSC 12
    define LCD_LINES 4
    
    Clr             CON 1
    Comm            Con $FE
    LINE1           con 2
    LINE2           con $c0
    LINE3           con $94
    LINE4           con $d4
    Offset          VAR BYTE
    OffsetP         var byte
    Interi          var word
    Decimali_Temp   VAR word
    Temporaneo      var byte
    Valore          VAR byte
    i               var byte
    n               var byte
    Sign            VAR BYTE
    DQ              var portb.1
    Recorded_Temp   var word
    Dummy           var WORD
    Decimali        var BYTE
    Resto           var WORD
    Stat            var bit
    Cold_Bit        VAR Recorded_Temp.Bit11
    Real_Cold       CON 1           
    MyButton        var portb.0
    LongPress       con 50		
    RPM_Port        var portb.2
    RPM             var WORD
    ButtonPress     var word
    x               var byte : x = -1
    
        Mybutton = 1            
        CMCON=%00000111			' Comparators OFF
    	OPTION_REG.7=0			' Enable weak Pull-Ups (used for PressButton)
    
    Begin:
            Pause 500   
            LCDOUT  254,64,31,31,31,31,0,0,0,0       ' Cust Char #0  
            LCDOUT  254,72,0,0,0,0,31,31,31,31       ' Cust Char #1  
            LCDOUT  254,80,31,31,31,15,7,3,1,0       ' Cust Char #2  
            LCDOUT  254,88,31,31,31,30,28,24,16,0    ' Cust Char #3  
            LCDOUT  254,96,0,16,24,28,30,31,31,31    ' Cust Char #4  
            LCDOUT  254,104,0,1,3,7,15,31,31,31      ' Cust Char #5
            'LCDOUT  254,112,31,31,31,31,31,31,31,31  ' Cust Char #6   
            LCDOUT  254,120,0,0,0,0,12,30,30,12      ' Cust Char #7    
        
    Main:
        goto menu
    end       
    
    Elaborazione:
            IF cold_bit = real_cold then Elaborazione_Freddo
            sign = "+"
            gosub elaborazione_common
    return
    
    Elaborazione_Common:
            Dummy  = 625 * recorded_Temp
            Interi = div32 10
            Interi  = (Recorded_Temp & $0FF0) >> 4
            Decimali_Temp = ((Recorded_Temp.Lowbyte & $0F) * 625)
            Decimali = Decimali_Temp / 100
            Resto = Decimali_Temp // 100
            if (resto >= 50) then Decimali = Decimali + 1
    return
    
    Elaborazione_Freddo:
            Sign   = "-"            
            RECORDED_TEMP = ~recorded_Temp + 1
            gosub elaborazione_common
    return
    
    Visualizzazione:
            select case Interi
                case is < 10
                    GOSUB SEGNO
                    n = 0 
                    OFFSET = 5
                    Valore = Interi
                    gosub Cifre 
                    OffsetP = 5 
                    Gosub Punto
                    N = 1
                    OFFSET = 10
                    Valore = Decimali
                    GOSUB Cifre
                case is < 100
                    offset = 0
                    n = 1 
                    Valore = Interi
                    gosub Cifre
                    OffsetP = 5
                    gosub Punto
                    N = 1
                    OFFSET = 10
                    Valore = Decimali
                    GOSUB Cifre
                case is < 200
                    offset = 0
                    n = 2 
                    Valore = Interi
                    gosub Cifre
                    offsetP = 10
                    gosub Punto
                    N = 0
                    OFFSET = 15
                    decimali_temp = decimali
                    Decimali_temp = Decimali / 10
                    Resto = Decimali // 10
                    Decimali = Decimali_temp
                    if (resto >= 5) then Decimali = Decimali + 1 
                    Valore = Decimali
                    GOSUB Cifre
                case is < 1000 
                    offset = 0
                    n = 2 
                    Valore = Interi
                    gosub Cifre
                case else 
                    offset = 0
                    n = 3
                    valore = RPM
                    gosub Cifre
                end select    
    RETURN
    
    Segno:
            SELECT CASE SIGN
                 CASE "+"
                    lcdout comm, $C2, $01, $FF, $01
                    LCDOUT COMM, $96, $00, $FF, $00
                 CASE "-"
                    lcdout comm, $C2, $01, $01, $01
                    LCDOUT COMM, $96, $00, $00, $00 
            END SELECT
    RETURN
    
    Cifre:
           For I = N to 0 STEP -1
            Temporaneo = Valore dig i 
            select case Temporaneo
                case 0 
                    gosub Numero0
                case 1 
                    gosub Numero1
                case 2 
                    gosub Numero2
                case 3 
                    gosub Numero3
                case 4 
                    gosub Numero4
                case 5 
                    gosub Numero5
                case 6 
                    gosub Numero6
                case 7 
                    gosub Numero7
                case 8
                    gosub Numero8
                case 9 
                    gosub Numero9
            end select
            OFFSET = OFFSET + 5
           next I
    return 
    
    GetButton:
    	ButtonPress=0
    	While MyButton=0
    		If ButtonPress<255 then ButtonPress=ButtonPress+1
    		Pause 50 ' This is also our Debounce value
    	Wend
    	If ButtonPress>0 then
    		If ButtonPress=>LongPress then 
    			ButtonPress=2
    		else
                buttonpress = 1	
            endif
        endif
    Return
    
    Bottone:
        gosub getbutton
        if buttonpress = 1 then goto Menu
    return
    
    Temp_Wait:
        GOSUB BOTTONE
        owin dq, 4, [Stat]
            If stat = 0 then Temp_Wait
    return
    
    Menu:
        x = x + 1
        IF x > 5 then x = 0 
        branchl x,[Sommario,Oil_temp,h2o_temp,ext_temp,int_temp,rpm_window]
    return
    
    Temps_Common:
        owin dq, 2, [Recorded_Temp.LOWBYTE,Recorded_Temp.HIGHBYTE]    
        gosub Elaborazione
        gosub visualizzazione    
    return
        
    Sommario:
        gosub bottone
        gosub clrscr
        lcdout "Sommario"
        pause 100
    goto sommario
    
    RPM_Window:
        gosub bottone
        gosub clrscr
    '    gosub Rpm_Count
    '    interi = RPM
    '    gosub visualizzazione
        lcdout "RPM_Window"
        pause 100
    goto rpm_window
    
    H2O_Temp:
            Owout DQ, 1, [$55,$28,$09,$B4,$F5,$00,$00,$00,$28,$44]
            gosub temp_wait
            owout dq, 1, [$55,$28,$09,$B4,$F5,$00,$00,$00,$28,$BE]        
        gosub clrscr
        LCDOUT comm, line1, "T", COMM, LINE2, "H", COMM, LINE3, "2", COMM, LINE4, "0"
        gosub temps_common
    goto h2o_temp
    
    Int_Temp:
        gosub bottone
        gosub clrscr
        sign = "+"
        Interi = 4
        decimali = 73
        gosub visualizzazione
        pause 100
    goto int_temp
    
    Ext_Temp:
        gosub bottone
        gosub clrscr
        Sign = "-"
        Interi = 9
        decimali = 24
        gosub visualizzazione
        pause 100
    goto ext_temp
    
    Oil_Temp:
            Owout DQ, 1, [$55,$28,$87,$8B,$F5,$00,$00,$00,$3A,$44]
            gosub temp_wait
            owout dq, 1, [$55,$28,$87,$8B,$F5,$00,$00,$00,$3A,$BE]          
        gosub clrscr
        LCDOUT comm, line1, "T", COMM, LINE2, "O", COMM, LINE3, "I", COMM, LINE4, "L"
        gosub temps_common
    goto oil_Temp 
    
    Rpm_Count:
        COUNT RPM_PORT, 500, RPM
        RPM = RPM * 2
    RETURN 
    
    Punto:
            LCDOUT Comm, ($D9 + OFFSET), $07 : return
    Numero0:
            LCDOUT COMM, ($81 + OFFSET), $05, $FF, $FF, $04
            GOSUB COMBO1
            LCDOUT COMM, ($95 + OFFSET), $FF, COMM, ($98 + OFFSET), $FF
            LCDOUT COMM, ($D5 + OFFSET), $02, $FF, $FF, $03
            RETURN
    Numero1:
            lcdout comm, ($82 + OFFSET), $05, $FF
            lcdout comm, ($C3 + OFFSET), $FF
            lcdout comm, ($97 + OFFSET), $FF
            lcdout comm, ($D7 + OFFSET), $FF        
            RETURN
    Numero2:
            GOSUB COMBO2
            LCDOUT comm, ($C4 + OFFSET), $FF
            LCDOUT comm, ($95 + OFFSET), $05, $00, $00, $00
            LCDOUT comm, ($D5 + OFFSET), $FF, $01, $01, $01
            RETURN
    Numero3:
            GOSUB COMBO2
            LCDOUT comm, ($C2 + OFFSET), $01, $01, $FF
            LCDOUT comm, ($96 + OFFSET), $00, $00, $FF
            GOSUB COMBO3
            RETURN 
    Numero4:
            lcdout comm, ($81 + OFFSET), $FF
            GOSUB COMBO1
            GOSUB COMBO4
            GOSUB COMBO5
            return      
    Numero5:
            LCDOUT COMM, ($81 + OFFSET), $05, $00, $00, $00
            GOSUB COMBO6
            GOSUB COMBO4
            GOSUB COMBO3
            RETURN    
    Numero6:
            LCDOUT COMM, ($81 + OFFSET), $05, $00, $00
            GOSUB COMBO6
            LCDOUT COMM, ($95 + OFFSET), $FF, $00, $00, $04
            GOSUB COMBO7
            RETURN
    Numero7:
            GOSUB COMBO2
            LCDOUT COMM, ($C3 + OFFSET), $01, $FF
            LCDOUT COMM, ($97 + OFFSET), $00, $FF
            GOSUB COMBO5
            RETURN
    Numero8:
            GOSUB COMBO8
            LCDOUT COMM, ($C1 + OFFSET), $02, $01, $01, $03
            LCDOUT COMM, ($95 + OFFSET), $05, $00, $00, $04
            GOSUB COMBO7
            RETURN       
    Numero9:
            GOSUB COMBO8
            LCDOUT COMM, ($C1 + OFFSET), $02, $01, $01, $FF
            GOSUB COMBO5
            LCDOUT COMM, ($D6 + OFFSET), $01, $01, $03
            RETURN
    COMBO1:
            LCDOUT COMM, ($C1 + OFFSET), $FF, COMM, ($C4 + OFFSET), $FF
            RETURN
    COMBO2:
            LCDOUT comm, ($81 + OFFSET), $00, $00, $00, $04
            RETURN
    COMBO3:
            LCDOUT comm, ($D5 + OFFSET), $01, $01, $01, $03
            RETURN
    COMBO4:
            LCDOUT comm, ($95 + OFFSET), $00, $00, $00, $FF
            RETURN
    COMBO5:
            LCDOUT comm, ($D8 + OFFSET), $FF
            RETURN
    COMBO6:
            LCDOUT COMM, ($C1 + OFFSET), $FF
            RETURN
    COMBO7:
            LCDOUT COMM, ($D5 + OFFSET), $02, $01, $01, $03
            RETURN
    COMBO8:
            LCDOUT COMM, ($81 + OFFSET), $05, $00, $00, $04
            RETURN
    Clrscr:
        lcdout comm, clr
    return

  4. #4
    Join Date
    Jan 2007
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    I'm still far away from the final code. This is an alpha release . The code is not optimized (~2200 words). Many sections are incomplete (RPM, INT_Temp, Ext_Temp, Clock....), but day by day this little project grow up!

Similar Threads

  1. Only the first 8 characters.
    By timseven in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 22nd September 2009, 01:43
  2. Big big big memory or tiny SDs!
    By Ron Marcus in forum Off Topic
    Replies: 9
    Last Post: - 25th May 2007, 18:02
  3. Led scrolling display: How to mirror characters?
    By mahia2005 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th May 2007, 03:25
  4. LCD 16 characters inline: only first 8 work
    By Mugel in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 20th October 2006, 22:07
  5. LCD 4x20 HD44780
    By inteco in forum mel PIC BASIC
    Replies: 13
    Last Post: - 27th June 2006, 16:52

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