Convert 3-byte hex to dec to display on LCD


Closed Thread
Results 1 to 5 of 5
  1. #1
    lab310's Avatar
    lab310 Guest

    Default Convert 3-byte hex to dec to display on LCD

    I'm doing some fp calculus and result is stored in 3 byte's. How to display this value on LCD in decimal presentation?
    For example, a1= 3f, a2=12, a3= 34
    h 3f1234 = 4133428, and this is a value to display on LCD (or serial port).

  2. #2
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382


    Did you find this post helpful? Yes | No

    Default

    My suggestion would be to mathematically combine the digits into a single value then:

    LCDout $FE,$C0,[dec calculatedvalue]

  3. #3
    lab310's Avatar
    lab310 Guest


    Did you find this post helpful? Yes | No

    Default

    Can't do that since PBP doesn't handle >16bit variables, and I have 24bit.

  4. #4
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382


    Did you find this post helpful? Yes | No

    Default

    How about:

    LCDout $FE,$C0,[dec a1,dec a2,dec a3]

  5. #5
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Code:
    Hi!
    
    Just do an addition like you would do on paper without a calculator.
    
    The multipliers used below are the single HEX digits.
    (Multipliers for your example: 3=3, F=15, 1=1, 2=2, 3=3, 4=4).
    
    See also the PicBasic "DIG" instruction.
    
    HEX
    ======
    3F1234
    
    DEC
    =======
    1048576
    1048576
    1048576
      65536
      65536
      65536
      65536
      65536
      65536
      65536
      65536
      65536
      65536
      65536
      65536
      65536
      65536
      65536
       4096
        256
        256
         16
         16
         16
          1
          1
          1
          1
    =======
    4133428
    
    
    
    (3*6)+(15*6)+(1*6)+(2*6)+(3*6)+(4*1)= 148 (write 8)
    14+(3*7)+(15*3)+(1*9)+(2*5)+(3*1)= 102 (write 2)
    10+(3*5)+(15*5)+(1*0)+(2*2)= 104 (write 4)
    10+(3*8)+(15*5)+(1*4)= 113 (write 3)
    11+(3*4)+(15*6)= 113 (write 3) 
    11+(3*0)= 11 (write 1)
    1+(3*1)= 4 (write 4)
    ==============================================
    
    Have fun!
    
    Luciano
    Last edited by Luciano; - 10th June 2005 at 20:53.

Similar Threads

  1. LCD freeze
    By harryweb in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 5th October 2009, 09:01
  2. Migrating from PIC16F690 to PIC18F4525 and having LCD issues
    By jblackann in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 6th June 2008, 21:05
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 18:27
  4. 3 HPWM channels
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th April 2006, 03:43
  5. 16F877 RAM Question
    By Art in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 6th August 2005, 12:47

Members who have read this thread : 1

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