DS1620. Displaying the Floating Point with BS2
C.Moher
Posts: 35
I am using the debug command to display a binary word from a DS1620 converted into·a decimal format. Displays temperature fine but truncates the number, hacking off the tenths decimal. The DS1620 is capable of displaying to a +/-·0.5 C·resolution.·I'd like to see that displayed also. How the DS1620 works is that it sends the number X 2 to the stamp. For example if the temperature read is 22.5 degrees C, it sends the number 45 out (in binary , lsb first) to the stamp. So if you are happy with just an integer measurement, you divide the number by 2 and display it via the debug command. Eg:
degC = x / 2
DEBUG ? degC
Again you get just the integer part...in the above example 22 degrees C...How do I get the decimal part ? Thanks in advance for your help.
degC = x / 2
DEBUG ? degC
Again you get just the integer part...in the above example 22 degrees C...How do I get the decimal part ? Thanks in advance for your help.
Comments
bob
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
x VAR Byte ' General purpose variable, Byte.
degC VAR Byte ' Variable to hold degrees Celsius.
' Note: DS1620 has been preprogrammed for mode 2.
OUTS=%0000000000000000 ' Define the initial state of all pins,
'FEDCBA9876543210
DIRS=%1111111111111111 ' as low outputs.
FREQOUT 0, 1000, 2000 ' Beep to signal that it is running.
HIGH 13 ' Select the DS1620.
SHIFTOUT 15, 14, LSBFIRST, [noparse][[/noparse]238] ' Send the "start conversions" command.
LOW 13 ' Do the command.
DO ' Going to display once per second.
HIGH 13 ' Select the DS1620.
SHIFTOUT 15, 14, LSBFIRST, [noparse][[/noparse]170] ' Send the "get data" command.
SHIFTIN 15, 14, LSBPRE, [noparse][[/noparse]x] ' Get the data.
LOW 13 ' End the command.
degC = x * 5 ' this is in units of 0.1 degC, but resolution of 0.5 degC,
' e.g. x=45 --> degC=225
' and ...,210, 215, 220, 225,... units of 0.5 degC
DEBUG degC/10, ".", DEC1 degC ' displays with tenths, e.g. 21.0, 21.5, 22.0, 22.5 etc.
PAUSE 1000 ' 1 second pause.
LOOP ' Read & display temperature again.
DEBUG DEC degC/10, ".", DEC1 degC
Thanks for your help. I'll spend the rest of the week answering the ? "but why"