PDA

View Full Version : DS1620. Displaying the Floating Point with BS2

C.Moher
04-20-2007, 07:39 AM
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.

Robert Kubichek
04-20-2007, 07:56 AM
Would multiplying by 10 to shift the decimal, then divide by 2, and just shifting the decimal back work?

bob

Tracy Allen
04-20-2007, 08:00 AM
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.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

C.Moher
04-20-2007, 08:01 AM
Not sure what you mean by "just shifting the decimal back" ....how ?? Dividing by 10 again ?? I'm not sure, I can try it but what I have gathered from the research I have done, its not an easy task apparently so I don't think something that simple will do it. I'll give it a try though.

C.Moher
04-20-2007, 08:12 AM
Nope sorry Tracy. That's giving a square.0 repeatedly. Here's what my code looks like now with that in it:
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, [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, [170] ' Send the "get data" command.
SHIFTIN 15, 14, LSBPRE, [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.

C.Moher
04-20-2007, 08:51 AM
ye haw... Tracy your code works fine but you were missing the "DEC' in front of the first degC....should be:

DEBUG DEC degC/10, ".", DEC1 degC

Thanks for your help. I'll spend the rest of the week answering the ? "but why"