two variables on LCD


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302

    Default two variables on LCD

    I have two variables

    Var1 var word
    Var2 var word

    The var1 is always 1 and the var2 is anything from 0 to 65535.

    var1 = 00000000 00000001
    var2 = 11111011 11010000
    var1 + var2 = 00000000 00000001 11111011 11010000
    Decimal = 130000

    I want to show on LCD as Result = 1300,00

    How to show the result on LCD;

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Cool

    Quote Originally Posted by savnik View Post
    I have two variables
    Var1 var word
    Var2 var word
    The var1 is always 1 and the var2 is anything from 0 to 65535.
    var1 = 00000000 00000001
    var2 = 11111011 11010000
    var1 + var2 = 00000000 00000001 11111011 11010000
    Decimal = 130000
    I want to show on LCD as Result = 1300,00
    How to show the result on LCD;
    Here we go again...

    1) Get the update for PBP 2.50A. Handles LONG (31 bit variables, +/- 2,000,000,000)

    2) Split the variable up the hard way...
    original var1 = $1
    original var2 = $fbd0
    Add a small subroutine in your program to make it so that each word 'handles' 4 digits, so you end up with:
    varhigh var word 'in this case it will be 0
    varmed var word 'in this case should end up with 0013
    varlow var word 'in this case should end up with 0000

    Shouldn't be THAT hard.

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    This is adapted from the thread ...

    32-bit Variables and DIV32, Hourmeter 99999.9
    http://www.picbasic.co.uk/forum/showthread.php?t=1942

    Should work, but I haven't tested the modification.
    Code:
    BigVar    VAR WORD[2]    ; 32-bit (Dword)
      Var1    VAR BigVar(1)
      Var2    Var BigVar(0)
    
    Result    Var Word
    Remainder Var Word
    
    ;----[Load a 32-bit (Dword) variable into PBP registers, Prior to DIV32]-----
    Asm
    PutMulResult?D macro Din
        MOVE?BB   Din, R2
        MOVE?BB   Din + 1 , R2 + 1
        MOVE?BB   Din + 2, R0
        MOVE?BB   Din + 3, R0 + 1
        RST?RP
      endm
    EndAsm
    
    ;====[Simple loop to test Big Numbers]=======================================
    Start:
        Var1 = 1
        Var2 = %1111101111010000
    
    MainLoop:
        LCDOUT $FE,1        ; clear screen
        Gosub ShowBigNumber
        PAUSE 1000
        Var2 = Var2 + 1
        if Var2 = 0 then Var1 = Var1 + 1
    goto MainLoop    
    ;===========================================================
    
    
    ;----[Display 32-bit value with 2 decimals using LCDOUT]---------------------
    ShowBigNumber:
    @   PutMulResult?D  _BigVar
        Result = DIV32 1000
        Remainder = R2
        LCDOUT $FE, 2            ; Home Cursor
        IF Result > 0 then
            LCDOUT Dec Result, DEC1 Remainder/100,".",DEC2 Remainder//100
        else
            LCDOUT DEC Remainder/100,".",DEC2 Remainder//100
        endif   
    return
    HTH,
     DT

  4. #4
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Smile

    Thank you Darrel.
    It's work fine.
    Only i put out the two lines
    Var2 = Var2 + 1
    if Var2 = 0 then Var1 = Var1 + 1

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik View Post
    Only i put out the two lines
    Var2 = Var2 + 1
    if Var2 = 0 then Var1 = Var1 + 1
    Exactly what you should have done.

    Thanks for the update.

    DT

Similar Threads

  1. Is this code not initialising the LCD properly?
    By Platypus in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 30th January 2010, 19:14
  2. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  3. PIC16F684 + LCD to use the 256bytes of EEPROM - HELP
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th March 2008, 14:19
  4. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07
  5. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30

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