ASCII HEX Word to Decimal conversion....


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: ASCII HEX Word to Decimal conversion....

    Quote Originally Posted by spcw1234 View Post
    I wasn't sure about that statement, but the LCDOUT part works fine sending the word variable.
    Not sure what you mean by sending the word variable.

  2. #2
    Join Date
    Jul 2011
    Location
    Hawaii
    Posts
    21


    Did you find this post helpful? Yes | No

    Default Re: ASCII HEX Word to Decimal conversion....

    John,

    You need to convert from ASCII to binary value. 4 bytes become 2 bytes.

    Add the following:

    ' New variables
    x var byte
    y var byte
    i var byte

    ' ************* ASCII to Binary **************
    for i = 0 to 2 step 2
    if PRITIM[i] > $40 THEN ' Handle MSNibble.
    x = PRITIM[i] + 1
    x.3 = 1
    x = x << 4
    else
    x = PRITIM[i]
    x = PRITIM[i] << 4
    endif
    if pritim[i + 1] > $40 then ' Handle LSNibble.
    y = PRITIM[i + 1] + 1
    y.3 =1
    y = y & %00001111
    else
    y = PRITIM[i + 1]
    y = y & %00001111
    endif
    if i = 0 then
    YEAR.byte1 = x | y
    else
    YEAR.BYTE0 = x | y
    endif
    next i
    '************* END of ASCII to Binary *************
    YEAR is now ready to be sent to LCD display.

    - Martin

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: ASCII HEX Word to Decimal conversion....

    These displays are ASCII. So no need to convert. Try the line below it will send ASCII $32,$30,$31,32 =(2,0,1,2)to the lcd. You may have to reverse the order PRITIM[X]'s ? Depending on the order you receive the data.

    LCDOUT $FE, $80, "YEAR =",PRITIM[3],PRITIM[2],PRITIN[1],PRITIM[0]
    Last edited by mark_s; - 17th February 2012 at 21:40.

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