Convert dec/binary to Hex
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2005
    Posts
    5

    Default Convert dec/binary to Hex

    I read numerous post in the forum but did not find the answer to my problem.
    In fact, i wish to find a routine to obtain the same result as "HEX2" used with "LCDOUT".
    I explain, I need to read the 64 bits registered number in the 1 wire Dallas composant but i use a LCD which not allow the command for HD44780 normally use with PBP and consequantly cannot use "LCDOUT".
    In my LCD the text is displayed with the use of "LOOKUP2" and each caracter are sent in ASCII.
    The info in the 1 Wire has to be read in HEX and i dont know how i can obtain the correspondig result allowing to display same .
    I hope i was sufficient clear and that somebody can help.

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

    Default

    Hi,

    To convert a decimal number under 256 to a two-digit hex number,
    divide the number by 16. Write the number of times 16 goes into
    the number as the left digit of the hex number (using hex notation).
    Write the remainder of the division as the right digit (using hex notation).

    For example, try the number 171. Sixteen goes into 171 ten times with a
    remainder of 11.

    10 is represented by A, and 11 is represented by B in hex notation.

    171 = AB

    Use the PicBasic LOOKUP statement to return the left and right digit of the hex number.

    LOOKUP B0,[“0123456789ABCDEF”],B1

    * * *

    See PicBasic Pro manual:

    4.17.2. Division
    (The '//' operator returns the remainder).

    5.43. LOOKUP

    Best regards,

    Luciano

  3. #3
    Join Date
    May 2005
    Posts
    5

    Default

    Thanks for the help.

    Rgds

Similar Threads

  1. How to convert a HSERIN string to a hex value?
    By ShortBus in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 22nd October 2009, 04:41
  2. How to convert HEX Value as formatted BIN String ?
    By Robson in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 19th August 2007, 02:16
  3. Convert Hex to Decimal???
    By RONKON in forum mel PIC BASIC
    Replies: 2
    Last Post: - 9th May 2006, 02:14
  4. Convert Hex to Decimal
    By RONKON in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 9th May 2006, 01:01
  5. Convert 3-byte hex to dec to display on LCD
    By lab310 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 10th June 2005, 19:20

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