PDA

View Full Version : ds18s20 reads incorectly



jcleaver
- 22nd July 2008, 19:22
i have tried several programs on this and several other sites to read temperature
read a lot of posts on the subject and have been able to get most to function
however the temperature readings are all low aprox 30 deg f this is only happening when i use pbp

tried mikro and works perferct what the difference??

skimask
- 22nd July 2008, 19:28
i have tried several programs on this and several other sites to read temperature
read a lot of posts on the subject and have been able to get most to function
however the temperature readings are all low aprox 30 deg f this is only happening when i use pbp
tried mikro and works perferct what the difference??
What's the difference? Plenty...signed vs un-signed integers is a good possibility for one thing...
We might be able to help you out a bunch better if you were to post one of those 'several' programs from one of those 'several' sites...
Or a search here reveals:
http://www.picbasic.co.uk/forum/showthread.php?t=5349
http://www.picbasic.co.uk/forum/showthread.php?t=7091
just for a couple of examples...
http://www.picbasic.co.uk/forum/showthread.php?t=7079
http://www.rentron.com/PicBasic/PBP1-wire.htm

jcleaver
- 22nd July 2008, 19:54
thanks for the prompt responce
http://www.rentron.com/PicBasic/one-wire3.htm
using this program with changes made for a different type of display
noticed it used the 18d20 but cant seem to find a program that uses the 18s20
nor after looking over several posts can i come up with the correct way to read this

Acetronics2
- 22nd July 2008, 20:15
Hi,

Just look at programs for DS1820 ...

or compare the " Operation measuring temp " chapters of DS18B20 and DS18S20

You will find a correct program for DS1820 in The Parallax Stamp applications ...

Alain

jcleaver
- 22nd July 2008, 21:34
Finally Got It Working Better
Thanks For The Inputs
Notice I Said Better Still Reads 10 F Deg Low
But Better Really Dont Understand Why Mikroe Works Perfectly With The Same
Hardware Using Pbp 5.0 And Mcsp 3.0
Must Be Some Difference In The Complier No? Maybe?

manwolf
- 22nd July 2008, 21:53
I posted a program that reads DS18S20s. I have 4 of them on onewire and I read them with no problem and I use PBP.
I do not expect temps below zero so I have not made allowances for that.

http://www.picbasic.co.uk/forum/showthread.php?t=9116

Nicmus
- 22nd July 2008, 21:54
Hi jcleaver,

You might want to check Maxim forum at:

http://discuss.dalsemi.com/index.php?

They had rejects on DS1820 family showing wrong temperature and there is a fix for it.

Nick

jcleaver
- 22nd July 2008, 22:04
I Do Appreicate Your Inputs
Manwolf Your Program Looks Great But Way Beyond My Knowledge
And As For As The Ds18 Goes I Have Tried Several

Again To Ask ?
Why Does Mikro Work Where Pbp Does Not
There Has To Be Some Difference In The Compliers

Using Exactly The Same Hardware Easypic4
Could It Be The Math Conversion Using Pbp

Both Programs Use The Same Formula For C To F

manwolf
- 23rd July 2008, 00:25
How are you reading the temp form the DS18S20 in PBP?
Are you using one-wire or something else?

jcleaver
- 23rd July 2008, 00:49
i have attached the 2 programs one in pbp which reads temperature incorectly
the other mikroe which works no hardware changes are made really interested in the difference


thanks

jack

skimask
- 23rd July 2008, 02:37
i have attached the 2 programs one in pbp which reads temperature incorectly
the other mikroe which works no hardware changes are made really interested in the difference


thanks

jack

Speaking strictly about PBP....
You know, just like it says in the manual, define's have to be in CAPS.
Therefore, the
define osc 20
is ignored and the timing generated by the code is generated for an oscillator of 4mhz, but apparently you are running it at 20mhz, and therefore, probably far too fast.
Did you write this code or copy/paste it? Why not use PBP's built-in OWIN/OWOUT commands?

manwolf
- 23rd July 2008, 06:07
maybe you should check the math.
With a change to the math the program works correctly. Running on a EasyPIC5 board.

Sorry I was sleeping that day in class, so I can't explain why PBP and MBasic work differently.

Acetronics2
- 23rd July 2008, 08:41
Why not use PBP's built-in OWIN/OWOUT commands?



The solution simply is here ...

MKB reads Byte by Byte and Pbp ... as you want !

just need to program a correct reading with Pbp !



Further ... TempF = TempC *9/5 + 32 ...

Remember PbP works with UNSIGNED INTEGERS ...

Alain

PS: Ski, MKB has a built-in timing adjustment,( you check an option in the project window instead of writing a DEFINE ) and The "conversion complete" polling built-in. That surprised me a bit at first time, not to see it in the source listing ...

jcleaver
- 23rd July 2008, 14:06
the osc is correct dont know why it did not show caps
tried going with 4 still read low
? what changes in math
TEMP = ((TEMP*9/5)+32 ) is what i am using
thanks for the inputs

have not found any samples using owin with this chip

Acetronics2
- 23rd July 2008, 16:10
Hi,

Did you ever try SEARCH with the 1820 Keyword ???

Surely NO !!!

I remember having posted a while ago for the DS1820 ...

Gives ... 22 Hits !

Alain

skimask
- 23rd July 2008, 16:23
I remember having posted a while ago for the DS1820 ...
Gives ... 22 Hits !
Alain
23 Hits now!
But, he's also using the DS18S20.
I know...I know...not a lot of difference between the two that can't be handled by a simple read of the datasheet.

skimask
- 23rd July 2008, 16:39
the osc is correct dont know why it did not show caps
tried going with 4 still read low
? what changes in math
TEMP = ((TEMP*9/5)+32 ) is what i am using
thanks for the inputs

have not found any samples using owin with this chip
Ok, try this:

@ DEVICE pic16F877A, HS_OSC
@ DEVICE pic16F877A, WDT_ON
@ DEVICE pic16F877A, PWRT_ON
@ DEVICE pic16F877A, BOD_ON
@ DEVICE pic16F877A, MCLR_on
@ DEVICE pic16F877A, LVP_OFF
@ DEVICE pic16F877A, CPD_OFF
@ DEVICE pic16F877A, PROTECT_OFF
define osc 20
define loader_used 1
define lcd_dreg portd
define lcd_dbit 4
define lcd_rsreg portd
define lcd_rsbit 2
define lcd_ereg portd
define lcd_ebit 3
define lcd_lines 2
define lcd_bits 4
define lcd_commandus 2000
define lcd_dataus 50
command var byte:i var byte:temp var word:dq var porta.5:dq_dir var trisa.5
adcon1=255:porta=255:portb=0:trisa=255:trisb=0:cmc on=7
Lcdout $fe,1,"Temp in degrees C"
mainloop: Gosub init1820:command=$cc:Gosub write1820:command=$44
Gosub write1820:Pause 2000:Gosub init1820:command=$cc:Gosub write1820
Pause 2000:command=$be:Gosub write1820:Gosub read1820:TEMP=((TEMP*9/5)+32)
Lcdout $fe,1,dec(temp>>1),".",dec(temp.0*5)," degrees C":Goto mainloop
init1820: Low DQ:Pauseus 500:DQ_DIR=1:Pauseus 100
If DQ=1 Then Lcdout $fe,1,"DS1820 not present":Pause 500:Goto mainloop
Pauseus 400:Return
write1820: For i=0 to 7:low dq
If command.0[temp] = 0 Then
Pauseus 60:DQ_DIR = 1
Else
@ nop
DQ_DIR = 1:Pauseus 60
Endif
Next i:Return
read1820: For i=0 to 15:low dq
@ nop
dq_dir=1:temp.0[i]=1:if dq=0 then temp.0[i]=0
pauseus60:next i:return
End

jcleaver
- 23rd July 2008, 18:58
Tried This And Get Better Reading Only 6 Deg Low

However It Does Not Respond To Any Temperature Changes

Thanks

skimask
- 23rd July 2008, 19:06
Tried This And Get Better Reading Only 6 Deg Low
However It Does Not Respond To Any Temperature Changes
Thanks
Ok, what DOES it put out for a temperature?

What happens if you heat it up, read the temperature, shut it off, put it in the freezer for a few minutes, take it out, power it up and read the temp right away?

jcleaver
- 23rd July 2008, 19:47
Read 65.xxxx

Does Not Update Hold Sensor And Nothing Changes

Reloaded Several Programs And They Work However Still Get Low Tmp Reading

Dont Think Its A Hardware Problem Because It Works Perfectly In Mikroe

Guess I Could That But Have Better Luck With Pbp As For As Adding My Stuff

skimask
- 23rd July 2008, 20:01
Read 65.xxxx
Does Not Update Hold Sensor And Nothing Changes
Reloaded Several Programs And They Work However Still Get Low Tmp Reading
Dont Think Its A Hardware Problem Because It Works Perfectly In Mikroe
Guess I Could That But Have Better Luck With Pbp As For As Adding My Stuff
65.xxx
Hmmm....maybe 65.535? 65.535 F? 65.535 C ?
Ever think that maybe your input was all 1's? And that it might've just been coincidence that your temp's are about 30 degrees low depending on the temp of the room?

Try this, might help...
http://www.picbasic.co.uk/forum/showthread.php?t=561

AND:

Acetronics2
- 23rd July 2008, 20:53
Hi, Cleaver

I suppose you work on an easyPic 4 or 5 ...

try this with sensor connected to PORTE2 and Pullup on porta.0 and 1.

After power on, type of sensor and ID is displayed.

press RA0 Button ( active low ! ) and you turn to thermo mode ( thermostat, in fact , see RA0 and RA.1 use ... )

Alain

PS : Fully PbP Written Program...

manwolf
- 23rd July 2008, 23:08
jcleaver

Here is a couple of files for you to play with.

pbptc.txt is your program that correctly displays the temp C and changes when the temp changes. You will need to change the LCD port, I use an easypic5 and you are using a different port.

I also have a program for MikroB attached, again it is for the ep5 board.

Take a few minutes and look at how the temp is being read in both. Once you figure that out you will see where the problem is.

BTW the formula is from the DS18S20 datasheet.





In your Mikro file did you notice that the temp was calculated before it is converted?

if j2 = $FF then
tmp_sign = "-" ' temperature sign
j1= j1 or $FF ' complement of two
j1= j1 + $01
else
tmp_sign = "+"
end if
j2 = (j1 and $01) * 5 ' Get decimal value
j1 = j1 >> 1 ' Get temp value
j1 = ((j1*9/5)+32) 'Convert C to F

And in your PBP file nothing is calculated until after the conversion.

TEMP = ((TEMP*9/5)+32 )
Lcdout $fe, 1, dec (temp >> 1),".",dec(temp.0 * 5)," degrees C"

Good Luck!

Acetronics: May I play around with the thermostat program you posted?

jcleaver
- 23rd July 2008, 23:58
Want To Thank All Of You For Your Help Been Great To Work With
Will Keep You Updated

Also Would Like To Look At The Pb Code For The Thermostat Program

If Not Giving Away Something

Again Thanks

Jack

jcleaver
- 24th July 2008, 01:49
Manwolf
Worked With Your Pbp And Your Right It Is Displaying The Correct C Temperature

Its Pb Math Thats Incorect

Any Ideas How ?

Also The Formula Temp = ((temp*1.8)+32) Gives Corect Answer But Wont Compile
On Pbp

manwolf
- 24th July 2008, 03:50
Jack

As Acetronics stated:

Remember PBP works with UNSIGNED INTEGERS ...

So 9/5 = 1.8 still won't fly in PBP

How about something like this?

temp = (((temp >> 1) * 100) - 25) 'calculate degrees C

temp = (temp */ 461) + 3200 'convert degrees C to F

And before you ask, crack open the ugly green book and figure out what '*/' does.

Hint: it uses all unsigned integers.

The hardest part of writing any program is learning how to handle the math. If you can not get your head around the math none of this stuff makes any sense.

Don't be afraid to throw some output in there to see what is happening. Run Debug, output to LCD or a serial port to see what it is changing.


For a better explaination of the math go here - http://www.rentron.com/PicBasic/one-wire3.htm

Ted

Acetronics2
- 24th July 2008, 13:29
Hi, Manwolf

What do you mean by that :

" Acetronics: May I play around with the thermostat program you posted? "

Of course YOU can play with it ...

Alain

Bruce
- 24th July 2008, 14:57
Your bit-banged read & write routines use a @ NOP for a 1uS delay, but you're running
at 20MHz so these are only 200nS. You would need 5 x @ NOP for a 1uS delay.

jcleaver
- 24th July 2008, 15:36
Thanks For The Math Help
As For As Speed Goes I Have Treid 4 And 20 Does Not Make A Difference

Will Work On The Math Issue

Do You Have The Thermostat Program In Pbp Not Hex

Thanks

Acetronics2
- 24th July 2008, 16:45
Hi, Jcleaver

The thermostat program was for you to verify what you had to find ... and show you a different Bargraph view.

NOT to copy / paste it ...

You can find any parts of it on this forum, The DS18x20 subject has been widely explored during the past months.

but that need some little efforts ... is it the problem ?

Alain

skimask
- 24th July 2008, 17:07
NOT to copy / paste it ...
...............................
but that need some little efforts ... is it the problem ?

Awwwww!!!!! :(

CocaColaKid
- 24th July 2008, 18:17
This code works great and gives the correct temperature throughout the sensors range in both Fahrenheit and Celsius. The format is like this: TempC = 2250 = 22.50ºC, TempF = 7250 = 72.50ºF.



ReadDS18S20:
owout sensor,1,[$CC, $44] ' Send Start Temperature Conversion command
owout sensor,1,[$CC, $BE] ' Send Read Temperature command
owin sensor,0,[STR dq\9] ' Retrieve all 9 bytes of data
RawTemp.Byte0 = dq[0]
RawTemp.byte1 = dq[1]
if RawTemp.8 = 1 then ' Check if temperature is a negative reading
SignC = Negative
RawTemp.lowbyte = RawTemp.lowbyte ^ 255 ' Invert data
else
SignC = Positive
endif
dummy = RawTemp.0 ' Store the half degree indicator bit
TempC = ((RawTemp.lowbyte) >> 1) * 100 ' Divide raw data by 2 to give real temperature
TempC = TempC + (dummy * 50) ' Add the half degree is present
if SignC = Negative then ' Only proceed if temperature is negative
if TempC => 1770 then
SignF = Negative
TempF = (TempC + 5000) * 900
TempF = div32 500
TempF = TempF - 12200
return
else
SignF = Positive
TempF = (TempC + 5000) * 900
TempF = div32 500
TempF = 12200 - TempF
return
endif
endif
SignF = Positive
TempF = TempC * 18 / 10 + 3200
return

manwolf
- 24th July 2008, 20:13
Jack

The reason your PBP version did not work was because:

You attempted to convert C to F using the RAW temp from the DS18S20.

TEMP = ((TEMP*9/5)+32 )

Then tried to calculate the temp from the results.

Lcdout $fe, 1, dec (temp >> 1),".",dec(temp.0 * 5)," degrees C"

For the fun of it lets plug some numbers in assume 27.5 C is the temp today.

From the datasheet : The temperature sensor output has 9-bit resolution, which corresponds to 0.5°C steps.

so 27.5*2 = 55

Temp = (55*9/5) + 32 = 131
So Temp now is equal to 131.

Next we shift right 131>>1 same as temp/2 = 65.5

Hmmm 65.535 does that number ring a bell?

Wonder what would happen if you were to shift first then convert C to F like all of the other code posted does?

temp = (temp>>1*9/5) +32 = (27.5*9/5)+32 = 81.5 F

Hopefully this explains to you why it works in MikroBasic and not in PBP. The math is not broken, just the order of operation.

That is why I said check math, simple change would fix it.

Acetronic: I ask because you posted for jcleaver, would not take without asking first. :)

skimask
- 24th July 2008, 20:41
You attempted to convert C to F using the RAW temp from the DS18S20.
TEMP = ((TEMP*9/5)+32 )
Then tried to calculate the temp from the results.
Lcdout $fe, 1, dec (temp >> 1),".",dec(temp.0 * 5)," degrees C"

Nice find. I should've caught that the first time around.

manwolf
- 25th July 2008, 00:34
Beginners luck.

ecoli-557
- 9th May 2014, 16:49
I am trying to follow your code in an effort to better understand it, but I don't understand
SignC = Positive


ReadDS18S20:
owout sensor,1,[$CC, $44] ' Send Start Temperature Conversion command
owout sensor,1,[$CC, $BE] ' Send Read Temperature command
owin sensor,0,[STR dq\9] ' Retrieve all 9 bytes of data
RawTemp.Byte0 = dq[0]
RawTemp.byte1 = dq[1]
if RawTemp.8 = 1 then ' Check if temperature is a negative reading
SignC = Negative
RawTemp.lowbyte = RawTemp.lowbyte ^ 255 ' Invert data
else
SignC = Positive
endif
dummy = RawTemp.0 ' Store the half degree indicator bit
TempC = ((RawTemp.lowbyte) >> 1) * 100 ' Divide raw data by 2 to give real temperature
TempC = TempC + (dummy * 50) ' Add the half degree is present
if SignC = Negative then ' Only proceed if temperature is negative
if TempC => 1770 then
SignF = Negative
TempF = (TempC + 5000) * 900
TempF = div32 500
TempF = TempF - 12200
return
else
SignF = Positive
TempF = (TempC + 5000) * 900
TempF = div32 500
TempF = 12200 - TempF
return
endif
endif
SignF = Positive
TempF = TempC * 18 / 10 + 3200
return

It would help if you shared the declarations of the variables used.
sensor equates to the hardware pin connected to the sensor?
RawTemp is a word?
dq is an array of 9?
dummy is a byte?
TempC is a byte?
TempF is a byte?

I don't get SignC or SignF and how you can equate to 'Positive' or 'Negative', I couldn't find a reference in the PBP manual.
Explanation would be appreciated.
Regards,
Steve

EarlyBird2
- 22nd May 2014, 10:37
I don't get SignC or SignF and how you can equate to 'Positive' or 'Negative', I couldn't find a reference in the PBP manual.
Explanation would be appreciated

For positive temperatures the output increases from 0000h as the temperature increases from 0 deg C.
For negative temperatures the output decreases from FFFFh as the temperature falls below -0.5 deg C.

To check for negative any output bit can be checked for 1, when that bit is outside the temperature range of the sensor. The data sheet says

The sign bit (S) indicates if the value is positive or negative: for positive numbers S = 0 and for negative numbers S = 1.

In the program RawTemp.8 is chosen as the sign bit.

ecoli-557
- 22nd May 2014, 19:39
Thanks EarlyBird2, I did figure that part out. In the code that the 'Kid' supplied, I could not get it to work until I remarked the SignC=Negative portion.
The code below works, but I have not tried for negative numbers yet..... Could you explain why?
Thanks and Regards,
Steve



ReadDS18S20:' Works, mostly.....------------------------------------------------
owout Tsensor,1,[$CC, $44] 'Send Start Temperature Conversion command
owout Tsensor,1,[$CC, $BE] 'Send Read Temperature command
owin Tsensor,0,[STR dq\9] 'Retrieve all 9 bytes of data
RawTemp.Byte0 = dq[0]
RawTemp.byte1 = dq[1]
if RawTemp.8 = 1 then 'Check if temperature is a negative reading
SignC = Negative
RawTemp.lowbyte = RawTemp.lowbyte ^ 255 'Invert data
else
SignC = Positive
endif
dummy = RawTemp.0 'Store the half degree indicator bit
TempC = ((RawTemp.lowbyte) >> 1) * 100 'Divide raw data by 2 to give real temperature
TempC = TempC + (dummy * 50) 'Add the half degree is present
' if SignC = Negative then 'Only proceed if temperature is negative - doesnt work for F, fine for C
' if TempC => 1770 then
' SignF = Negative
' TempF = (TempC + 5000) * 900
' TempF = div32 500
' TempF = TempF - 12200
' return
' else
' SignF = Positive
' TempF = (TempC + 5000) * 900
' TempF = div32 500
' TempF = 12200 - TempF
' return
' endif
' endif
SignF = Positive 'Sign is +
TempF = ((TempC * 18) / 10) + 3200 'Convert from C to F
return

EarlyBird2
- 22nd May 2014, 21:43
Negative and Positive are declared variables or constants. In your code should be

Negative CON 1
Positive CON 0

Does this help?

Could be SYMBOL or ALIAS of course.

ecoli-557
- 22nd May 2014, 23:04
EarlyBird2-
Thanks! I just tried it (I did NOT have them as CONstants), compiles fine but still gives me 0.00F.
Code is below for clarification.
Regards,
Steve



Positive con 0 'Bit used for + in the DS18S20
Negative con 1 'Bit used for - in the DS18S20
rawtemp var word 'Raw temp var
tempC var word 'Temp var for degrees C
tempF var word 'Temp var for degrees F
dq var byte[9] 'String of data from DS18S20
SignC var bit 'Bit for + or - for degrees C
SignF var bit 'Bit for + or - for degrees F
dummy var bit 'Temp var

ReadDS18S20:' Works, mostly.....--Thanks 'Kid' from Forum-----------------------
owout Tsensor,1,[$CC, $44] 'Send Start Temperature Conversion command
owout Tsensor,1,[$CC, $BE] 'Send Read Temperature command
owin Tsensor,0,[STR dq\9] 'Retrieve all 9 bytes of data
RawTemp.Byte0 = dq[0]
RawTemp.byte1 = dq[1]
if RawTemp.8 = 1 then 'Check if temperature is a negative reading
SignC = Negative
RawTemp.lowbyte = RawTemp.lowbyte ^ 255 'Invert data
else
SignC = Positive
endif
dummy = RawTemp.0 'Store the half degree indicator bit
TempC = ((RawTemp.lowbyte) >> 1) * 100 'Divide raw data by 2 to give real temperature
TempC = TempC + (dummy * 50) 'Add the half degree is present
if SignC = Negative then 'Only proceed if temperature is negative - doesnt work for F, fine for C
if TempC => 1770 then
SignF = Negative
TempF = (TempC + 5000) * 900
TempF = div32 500
TempF = TempF - 12200
return
else
SignF = Positive
TempF = (TempC + 5000) * 900
TempF = div32 500
TempF = 12200 - TempF
return
endif
endif
' SignF = Positive 'Sign is +
' TempF = ((TempC * 18) / 10) + 3200 'Convert from C to F
return




This what I have that does work, just not for negatives.....



ReadDS18S20:' Works, mostly.....--Thanks 'Kid' from Forum-----------------------
owout Tsensor,1,[$CC, $44] 'Send Start Temperature Conversion command
owout Tsensor,1,[$CC, $BE] 'Send Read Temperature command
owin Tsensor,0,[STR dq\9] 'Retrieve all 9 bytes of data
RawTemp.Byte0 = dq[0]
RawTemp.byte1 = dq[1]
if RawTemp.8 = 1 then 'Check if temperature is a negative reading
SignC = Negative
RawTemp.lowbyte = RawTemp.lowbyte ^ 255 'Invert data
else
SignC = Positive
endif
dummy = RawTemp.0 'Store the half degree indicator bit
TempC = ((RawTemp.lowbyte) >> 1) * 100 'Divide raw data by 2 to give real temperature
TempC = TempC + (dummy * 50) 'Add the half degree is present
' if SignC = Negative then 'Only proceed if temperature is negative - doesnt work for F, fine for C
' if TempC => 1770 then
' SignF = Negative
' TempF = (TempC + 5000) * 900
' TempF = div32 500
' TempF = TempF - 12200
' return
' else
' SignF = Positive
' TempF = (TempC + 5000) * 900
' TempF = div32 500
' TempF = 12200 - TempF
' return
' endif
' endif
SignF = Positive 'Sign is +
TempF = ((TempC * 18) / 10) + 3200 'Convert from C to F
return



Regards,
Steve

EarlyBird2
- 23rd May 2014, 06:34
these two lines are commented out?

' SignF = Positive 'Sign is +
' TempF = ((TempC * 18) / 10) + 3200 'Convert from C to F

so I guess you will get 0 deg F

ecoli-557
- 25th May 2014, 16:47
Steve-
Dunno what I had thought I was looking at, but when I un-commented those other lines, I now get correct readings!
This is now what seems to be working:
BTW, going to be in your neck of the woods this Wednesday, 2 days in London, then take a boat out from South Hampton on a cruise through the Baltics.
Thanks for pushing me in the right track!
Regards,
Steve



ReadDS18S20:' Works, Thanks 'Kid' and Steve from the UK....from Forum-----------
owout Tsensor,1,[$CC, $44] 'Send Start Temperature Conversion command
owout Tsensor,1,[$CC, $BE] 'Send Read Temperature command
owin Tsensor,0,[STR dq\9] 'Retrieve all 9 bytes of data
RawTemp.Byte0 = dq[0]
RawTemp.byte1 = dq[1]
if RawTemp.8 = 1 then 'Check if temperature is a negative reading
SignC = Negative
RawTemp.lowbyte = RawTemp.lowbyte ^ 255 'Invert data
else
SignC = Positive
endif
dummy = RawTemp.0 'Store the half degree indicator bit
TempC = ((RawTemp.lowbyte) >> 1) * 100 'Divide raw data by 2 to give real temperature
TempC = TempC + (dummy * 50) 'Add the half degree is present
if SignC = Negative then 'Only proceed if temperature is negative - doesnt work for F, fine for C
if TempC => 1770 then
SignF = Negative
TempF = (TempC + 5000) * 900
TempF = div32 500
TempF = TempF - 12200
return
else
SignF = Positive
TempF = (TempC + 5000) * 900
TempF = div32 500
TempF = 12200 - TempF
return
endif
endif
SignF = Positive 'Sign is +
TempF = ((TempC * 18) / 10) + 3200 'Convert from C to F
return

EarlyBird2
- 28th May 2014, 19:03
It is Wednesday you are in England the weather is cold, wet and windy. I am so sorry but what do you expect in England on a summers day. :biggrin:

Have a nice cruise to the Baltic.