Multi-digit word variable to string


Results 1 to 40 of 44

Threaded View

  1. #19
    Join Date
    May 2013
    Location
    australia
    Posts
    2,680


    Did you find this post helpful? Yes | No

    Default Re: Multi-digit word variable to string

    Now i'm trying to figure out how to add the remainder in the command.
    i hope this is not a medical diagnostic device
    your temperature calculation is not accurate and the remainder calculation is mathematically incorrect


    Code:
    temperature  = tempir/50         ' based on the manual we need to divide by 50 or 0.02
    temperature  = temperature - 273 ' subtract 273 for Degree in C,actually is 273,15
    yields the temp in deg C to about 1 deg of resolution with an error of +- 1 degree

    Code:
    remainder    = (tempir*2)//100   ' multiply x 2 and get the remainder //100
    calculated the 100 modulus of the temp in deg kelvin

    adding them together is nonsense , trying to display a two decimal point result is from any of these results is just not right

    Name:  Screenshot 2021-12-19 163013.jpg
Views: 1934
Size:  194.2 KB

    Code:
    wtf tempir = (temp.highbyte << 8) + temp.lowbyte ;just Nooooo! its the hardest most convoluted way i have ever encountered to go 
    tempir = temp which serves no purpose anyway
    
    
    
    
    don't like this either, it pisses away too much resolution hence its not particularly accurate 
    temperature  = tempir/50         ' based on the manual we need to divide by 50 or 0.02
    temperature  = temperature - 273 ' subtract 273 for Degree in C,actually is 273,15
    remainder    = (tempir*2)//100   ' multiply x 2 and get the remainder //100
    
    
    ;this is good  although it could be even more accurate [temperature  = temp*2  - 27315 ; temp x 2 - 273.15*100 ] >==>temperature*100] if the raw value won't exceed 32768 
    
    
    temperature  = (temp  - 13657)<<1  ; (temp-[273.15*50]) x 2   <==> temperature*100; is good
    
    
    
    
    i make the assumption temperature * 100 is the value required by the slider display
    
    
    tempir and remainder are not needed
    display like this

    Code:
    '------------------------------------------------------------------------------*'                    IR  Display 1 the parameters                              *
    '------------------------------------------------------------------------------*
    display: ' IR TEMP 
    hserout2 [$73,$00,$02,$12,$00,$ff,"IR TEMP:",00]
    Hserin2  timeout,error,[wait(6)]
    hserout2 [$73,$08,$02,$12,$F8,$00,dec2 temperature/100,".",dec2 temperature//100,"*C",00] 
    Hserin2  timeout,error,[wait(6)]
     
    
    
    gosub checksum2    
    hserout [$01,$0F,$00,temperature.highbyte,temperature.lowbyte,IRCS]   
    Hserin  timeout,error,[wait(6)]
    return
    
    
    '------------------------------------------------------------------------------|
    '                               CHECKSUM IR                                    |
    '------------------------------------------------------------------------------|
    checksum2:
    IRCS = 0
    IRCS = $01 ^ $0F ^ $00 ^ temperature.highbyte ^ temperature.lowbyte 
    return

    then lets have a look at the i2c stuff , its not right either really


    ps if negative temps are possible then additional code req
    Last edited by richard; - 19th December 2021 at 09:07.
    Warning I'm not a teacher

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