problem with LCD large Numbers


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,695


    Did you find this post helpful? Yes | No

    Default Re: problem with LCD large Numbers

    I can't quite see why the pgm misbehaves like you mention ,. but I will make these comments


    I used POKECODE to store the number patterns in code space, making the overall program quite efficient.

    peek/poke is the least efficient way to use progmem, it only stores 1 byte per every word of flash it uses
    readcode is faster and better and on a pic18 can use the entire progmem word

    there is no need to store the row/col data in the font ,the "display" routine can calculate that information along with the column offset

    the font can be compressed to this [blank added]

    Code:
    asm
    db  0,4,4,1,      7,32,32,7,   7,32,32,7,    3,5,5,2      ;0
     db  32,8,7,32,    32,32,7,32,  32,32,7,32,   32,32,7,32   ;1
     db  0,4,4,1,      32,32,5,4,   5,4,32,32,    7,5,5,5      ;2
     db  2,4,4,1,      32,32,32,7,  32,4,4,7,     1,5,5,2      ;3 
     db  7,32,32,7,    7,5,5,7,32,  32,32,7,      32,32,32,7   ;4
     db  7,4,4,3,      7,5,5,32,    32,32,32,1,   5,5,5,2      ;5
     db  0,4,4,1,      7,32,32,32,  7,4,4,1,      3,5,5,2      ;6
     db  4,4,4,1,      32,32,32,7,  32,32,7,32,   32,7,32,32   ;7
     db  0,4,4,1,      3,5,5,2,0,   32,32,1,      3,5,5,2      ;8
     db  0,4,4,1,      3,5,5,7,     32,32,32,7,   32,5,5,2     ;9
     db  32,32,32,32,  32,32,32,32, 32,32,32,32,  32,32,32,32  ;blank
    endasm
    fully defining the font and adding a blank make leading zero suppression/ field justification far easier


    my take for a pic18f26k22 [pbp3]

    Code:
    #CONFIG
      CONFIG  FOSC = INTIO67
      CONFIG  PLLCFG = ON
      CONFIG  PRICLKEN = OFF
      CONFIG  FCMEN = OFF
      CONFIG  IESO = OFF
      CONFIG  PWRTEN = OFF
      CONFIG  BOREN = SBORDIS
      CONFIG  BORV = 190
      CONFIG  WDTEN = ON
      CONFIG  WDTPS = 32768
      CONFIG  CCP2MX = PORTC1
      CONFIG  PBADEN = OFF
      CONFIG  CCP3MX = PORTB5
      CONFIG  HFOFST = ON
      CONFIG  T3CMX = PORTC0
      CONFIG  P2BMX = PORTB5
      CONFIG  MCLRE = EXTMCLR
      CONFIG  STVREN = ON
      CONFIG  LVP = OFF
      CONFIG  XINST = OFF
      CONFIG  DEBUG = OFF
      CONFIG  CP0 = OFF
      CONFIG  CP1 = OFF
      CONFIG  CP2 = OFF
      CONFIG  CP3 = OFF
      CONFIG  CPB = OFF
      CONFIG  CPD = OFF
      CONFIG  WRT0 = OFF
      CONFIG  WRT1 = OFF
      CONFIG  WRT2 = OFF
      CONFIG  WRT3 = OFF
      CONFIG  WRTC = OFF
      CONFIG  WRTB = OFF
      CONFIG  WRTD = OFF
      CONFIG  EBTR0 = OFF
      CONFIG  EBTR1 = OFF
      CONFIG  EBTR2 = OFF
      CONFIG  EBTR3 = OFF
      CONFIG  EBTRB = OFF
    #ENDCONFIG
    DEFINE OSC 64
    OSCCON = %01110000           
    ANSELb = 0
    ANSELA = 0
    ANSELC = 0
    OSCTUNE.6=1 
    goto overasm
    asm
    bigfont         ;pic18 only  must be in 1st 64k block
     db  0,4,4,1,      7,32,32,7,   7,32,32,7,    3,5,5,2      ;0
     db  32,8,7,32,    32,32,7,32,  32,32,7,32,   32,32,7,32   ;1
     db  0,4,4,1,      32,32,5,4,   5,4,32,32,    7,5,5,5      ;2
     db  2,4,4,1,      32,32,32,7,  32,4,4,7,     1,5,5,2      ;3 
     db  7,32,32,7,    7,5,5,7,32,  32,32,7,      32,32,32,7   ;4
     db  7,4,4,3,      7,5,5,32,    32,32,32,1,   5,5,5,2      ;5
     db  0,4,4,1,      7,32,32,32,  7,4,4,1,      3,5,5,2      ;6
     db  4,4,4,1,      32,32,32,7,  32,32,7,32,   32,7,32,32   ;7
     db  0,4,4,1,      3,5,5,2,0,   32,32,1,      3,5,5,2      ;8
     db  0,4,4,1,      3,5,5,7,     32,32,32,7,   32,5,5,2     ;9
     db  32,32,32,32,  32,32,32,32, 32,32,32,32,  32,32,32,32  ;blank
    
    ft1=_rowbuff          ;shortcut to read data into rowbuffer   0:1
    ft2=_rowbuff+2        ;shortcut to read data into rowbuffer   2:3
    GLetAddress macro Label, Wout
        CHK?RP Wout
        movlw low Label          ; get low byte
        movwf Wout
        movlw High Label         ; get high byte
        movwf Wout + 1  
        BANKSEL 0
        endm 
    endasm       
     
     
    overasm: 
    DEFINE LCD_DREG PORTB 
    DEFINE LCD_DBIT 0 
    DEFINE LCD_EREG PORTB 
    DEFINE LCD_EBIT 5 
    DEFINE LCD_RSREG PORTB 
    DEFINE LCD_RSBIT 4 
    Define LCD_Bits 4
    DEFINE LCD_LINES 4 
    Define LCD_Commandus 2000
    Define LCD_DATAUS 50    
     
    
     ROW VAR BYTE '4 X 20 ROW NUMBER - 0 TO 3
     COL VAR BYTE '4 X 20 COLUMN NUMBER - 0 TO 4
     slz var bit
     rows var byte[4]       ;lcd page  start addresses
     rowbuff var byte[4]    ;a row of data for lcd
     ctemp var word
     ft1  var word ext    ;shortcut to read data into rowbuffer   0:1
     ft2  var word ext    ;shortcut to read data into rowbuffer   2:3
     parsedig var byte
     
     NUMBER VAR WORD
     TEMP VAR WORD
     COL_OFFSET VAR BYTE ' USED TO POSITION font
     font var word       ;address of data
     
     
     NUMBER = 0 
     
     lcdout 254,$01 ' CLEAR THE DISPLAY
     pause 500
     arraywrite rows,[128,192,148,212] ;pbp3 for earlier rows[0]=128:rows[0]=192: etc.........
     pause 100
    @ GLetAddress bigfont ,_font     ;get font address
    
     ''' FIRST WRITE THE CHARACTER PATTERNS TO LCD RAM FOR A PATTERN DISPLAY
     
        ' 0 Left-right UP-ramp (TOP) 
        lcdout 254,$40,$00,$01,$03,$07,$0F,$1F,$1F,$1F
        lcdout 254,rows[0], 0 
        PAUSE 1 
        ' 1 Right-left DOWN-ramp (TOP) 
        lcdout 254,$48,$00,$10,$18,$1C,$1E,$1F,$1F,$1F
        lcdout 254,rows[0]+2, 1 
        PAUSE 1 
        ' 2 Left-right UP-ramp. (BOTTOM)
        lcdout 254,$50,$1F,$1F,$1F,$1E,$1C,$18,$10,$00
        lcdout 254,rows[0]+4, 2 
        PAUSE 1 
        ' 3 Right-left DOWN-ramp (BOTTOM)
        lcdout 254,$58,$1F,$1F,$1F,$0F,$07,$03,$01,$00
        lcdout 254,rows[0]+6, 3 
        pause 1 
        ' 4 UPPER block.
        lcdout 254,$60,$1F,$1F,$1F,$1F,$00,$00,$00,$00
        lcdout 254,rows[0]+8, 4 
        PAUSE 1 
        ' 5 LOWER block.
        lcdout 254,$68,$00,$00,$00,$00,$1F,$1F,$1F,$1F
        lcdout 254,rows[0]+10, 5 
        PAUSE 1 
        '6 SMALL UP-RAMP
        lcdout 254,$70,$01,$03,$07,$0F,$1F,$00,$00,$00 '6
        lcdout 254,rows[0]+12, 6 
        PAUSE 1 
        ' '7 FULL BLOCK 
        lcdout 254,$78,$1F,$1F,$1F,$1F,$1F,$1F,$1F,$1F '7 
        lcdout 254,rows[0]+14, 7
     PAUSE 2000 ' SHORT DELAY TO DISPLAY THE SPECIAL CHARACTERS
     lcdout 254,$01 ' CLEAR THE DISPLAY
     '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''' 
    
    START:     ;display 4 digits right justified with noleading zeros
        parsedig = 4       
        slz = 1    ;suppress leading zeros  on
        col = 0
        while  parsedig
            parsedig = parsedig - 1
            TEMP = NUMBER DIG parsedig
            if slz  then
                if temp then      ;if temp > 0 then display it and cancel zero suppression
                    GOSUB DISPLAY
                    slz = 0   ;suppress zeros  cancelled
                else
                    if parsedig then temp = 10;blank   suppress all zeros except for dig 0
                    GOSUB DISPLAY
                endif
            else
                GOSUB DISPLAY
            endif
            col = col + 1
        wend 
        pause 10
        NUMBER = number + 1
        if number>9999 then number=0
    GOTO START
     
    
     ;pic18 only  font must be in 1st 64k block for readcode to function
    DISPLAY:      ;disp big digit in TEMP var @ column COL       digits 0-9 and blank 
        COL_OFFSET = (col*5)
        ctemp =  font + (temp*16); 16 bytes per chr
        for row = 0 to 3          ;read data as words to reduce code and more speed
            readcode ctemp,ft1      ;shortcut to read data into rowbuffer   0:1
            ctemp = ctemp + 2            ;next word
            readcode ctemp,ft2      ;shortcut to read data into rowbuffer   2:3
            ctemp = ctemp + 2            ;next row
            lcdout 254,(COL_OFFSET + rows[row]),str rowbuff\4;for early versions pbp  might need   rowbuff[0],rowbuff[1],rowbuff[2],rowbuff[3]   
        next
    RETURN     
      
      
     
     END
    Warning I'm not a teacher

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: problem with LCD large Numbers

    Richard:

    Thanks for your response. I modified your program to use with a 18F14K22, and since I have a serial LCD backpack, I changed the LCD stuff to SEROUT2. Also, no PB3 here, still on 2.6, but the program works great. Got 4 Warnings regarding the assembly stuff, I will try to figure that out, but the program runs just fine.

    My intent in developing this program was to have a routine to add to my programs that use LCD's with some numeric display requirements.

    I still plan on spending some (a little) time on my original program, to try to figure out the problem - hate to have an error like that that I do not understand.

    once again THANKS

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


    Did you find this post helpful? Yes | No

    Default Re: problem with LCD large Numbers

    ozarkshermit, Attached is a program I wrote quite a few years ago to test the theory of using BIG numbers on a 4 x 20 LCD display. Enjoy...
    Attached Files Attached Files
    Dave Purola,
    N8NTA
    EN82fn

  4. #4
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: problem with LCD large Numbers

    Your Z loop increments Z by 6 for each iteration.
    You increment Z by 5 manually within the loop, and the NEXT Z used to close the loop iterates another 1.

    If you take the difference between your start and end indexes for each digit A and B,
    the difference between A and B for digit zero is the only set that is evenly divisible by 6.
    The other digits overshoot the loop index by 2.

  5. #5
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: problem with LCD large Numbers

    You might also check this thread...

    http://www.picbasic.co.uk/forum/showthread.php?t=17707

    good luck
    Dwight
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

Similar Threads

  1. Math problem with PBP 2.6 and 18F4550, large numbers
    By wdmagic in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd January 2013, 05:41
  2. handling Large Numbers
    By Peter1960 in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 26th April 2007, 03:33
  3. Multiplying large numbers
    By jhonea1 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 14th April 2006, 18:41
  4. How to display large numbers
    By Peter1960 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 27th March 2006, 00:17
  5. math problems - large numbers
    By Tomasm in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th February 2004, 08:48

Members who have read this thread : 2

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

Tags for this Thread

Posting Permissions

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