HEX byte to ASCII output...


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: HEX byte to ASCII output...

    Quote Originally Posted by mackrackit View Post
    Does that help?
    Yes it does...thank you!

    John

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: HEX byte to ASCII output...

    Works great now!

    Code:
    INTERNALTEMP:
    OWOut DQI,1,[$CC,$44]        'REQUEST FOR INT TEMP AD CONVERSION
    PAUSE 750                     'WAIT FOR CONVERSION TO COMPLETE
    OWOut DQI,1,[$CC,$BE]        'REQUEST XMIT OF TEMP DATA
    OWIn DQI,0,[INTTEMP.LOWBYTE,INTTEMP.HIGHBYTE]    'REC TEMP DATA
    IF INTTEMP.HIGHBYTE = $00 THEN INTTEMPSIGN = 43  'CHECK HIGHBYTE SET SIGN +
    IF INTTEMP.HIGHBYTE = $FF THEN INTTEMPSIGN = 45  'CHECK HIGHBYTE SET SIGN -
    IF INTTEMP.HIGHBYTE = $FF THEN INTTEMP.LOWBYTE = ($FF - INTTEMP.LOWBYTE) 'INVERT LOWBYTE FOR NEG
    INTTEMP.LOWBYTE = INTTEMP.LOWBYTE / 2    'DIV BY 2 FOR DEGREES C
    INTC_TENS = INTTEMP.LOWBYTE / 10 'CALC TENS DIGIT
    INTC_ONES = INTTEMP.LOWBYTE - (INTC_TENS * 10)   'CALC ONES DIGIT
    INTTX(1) = $30 + INTC_TENS                       'CONVERT TO ASCII
    INTTX(2) = $30 + INTC_ONES                       'CONVERT TO ASCII
    GOTO INTERNALTEMP
    end

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


    Did you find this post helpful? Yes | No

    Default Re: HEX byte to ASCII output...

    John,
    The sensor has .5 degree resolution. You can store INTTEMP.LOWBYTE into a NEW VAR of length WORD then multiply the new variable by 5. In your example 49 X 5 is 245. HEX "31" actually represents +24.5 degrees C. Use "DIG" to isolate the digits of the NEW VAR WORD. WORD size is suitable because the maximum of INTTEMP.LOWBYTE is HEX "AA", 170 X 5 = 850 which represent +85.0 degrees C.

    - Martin

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: HEX byte to ASCII output...

    Hi Martin,

    Thanks for the DIG tip. That eliminates all that math.

    Yes, I know I can get the .5 resolution, but I don't need it for this simple project. But, that doesn't mean I won't incorporate it in my code sometime in the future.

    Thank again....

    John

Members who have read this thread : 0

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