rapidograf
Posts: 270
Joined: Sat Mar 22, 2014 11:03 am
Location: very near from here

how read temperature from DS1624

Tue Sep 30, 2014 9:17 am

i already broken head , maybe somebody know how recalculate raw data from DS1624 to positive and negative temperature/
all samples which i can found perfectly work wit positive temperature but with negtive show full garbage.
datasheet olso not gave ideas. :?: :arrow: :!:
bigest and hugest same as tiny and micro

User avatar
joan
Posts: 13655
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: how read temperature from DS1624

Tue Sep 30, 2014 9:53 am

Perhaps you read the wrong datasheet. Page 6 seems quite clear.

http://datasheets.maximintegrated.com/en/ds/DS1624.pdf

rapidograf
Posts: 270
Joined: Sat Mar 22, 2014 11:03 am
Location: very near from here

Re: how read temperature from DS1624

Tue Sep 30, 2014 10:41 am

joan wrote:Perhaps you read the wrong datasheet. Page 6 seems quite clear.

http://datasheets.maximintegrated.com/en/ds/DS1624.pdf

unfortunately i already read it many times , and even did recalculating on the paper by pen , but for negative temperature it doesnot working/
may be you are know working programm ? :!: :arrow: :idea: :arrow: :?:
bigest and hugest same as tiny and micro

User avatar
joan
Posts: 13655
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: how read temperature from DS1624

Tue Sep 30, 2014 11:22 am

The simplest thing to do is

Code: Select all

if temperature >= 128.0:
   temperature = temperature - 256.0

rapidograf
Posts: 270
Joined: Sat Mar 22, 2014 11:03 am
Location: very near from here

Re: how read temperature from DS1624

Tue Sep 30, 2014 12:56 pm

joan wrote:The simplest thing to do is

Code: Select all

if temperature >= 128.0:
   temperature = temperature - 256.0
it is enought bravest.
DS1624 use two registers for data of temperature. for integer anf for flot parts.
all samples that i seen use shifts for bits/

and how you can interprete the temperature E6F0 (hex) page #6 of datasheet ? and all negative temperature date will me more more bigger than 128 ......
bigest and hugest same as tiny and micro

User avatar
joan
Posts: 13655
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: how read temperature from DS1624

Tue Sep 30, 2014 1:21 pm

I'm not sure if you have solved your problem or not.

If you haven't it's time to post the code you are using.

rapidograf
Posts: 270
Joined: Sat Mar 22, 2014 11:03 am
Location: very near from here

Re: how read temperature from DS1624

Tue Sep 30, 2014 3:46 pm

joan wrote:I'm not sure if you have solved your problem or not.

If you haven't it's time to post the code you are using.
OK/ Lets see it , i found it by the google . :idea: :arrow: :!:

Code: Select all

import smbus
import time
DS1624A0_ADDR = 0x48
DS1624_READ_TEMP = 0xAA
DS1624_START = 0xEE
DS1624_STOP = 0x22
bus = smbus.SMBus(0)
address = DS1624A0_ADDR
def start():
bus.write_byte(address, DS1624_START);
def stop():
bus.write_byte(address, DS1624_STOP);
def read():
temp1 = bus.read_word_data(address, DS1624_READ_TEMP);
temp_l = (temp1 & 0xFF00) >> 8;
temp_h = temp1 & 0x00FF;
temp_l = temp_l >> 3;
if (temp_h & 0x80) == 0x80:
temp_l = (~temp_l) + 1;
return temp_h + ( 0.03125 * temp_l);
start();
time.sleep(1);
temperature = read();
print "%02.02f" % temperature; 
bigest and hugest same as tiny and micro

User avatar
joan
Posts: 13655
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: how read temperature from DS1624

Tue Sep 30, 2014 4:47 pm

Try

Code: Select all

   val = bus.read_word_data(address, DS1624_READ_TEMP)

   # t = val
   # val = ((t & 0x00FF) << 8) | ((t & 0xFF00) >> 8)

   temperature = val / 256.0
   if temperature > 128.0:
      temperature -= 256.0

   return temperature
Uncomment the byte swap lines if the I2C call is byte swapped.

rapidograf
Posts: 270
Joined: Sat Mar 22, 2014 11:03 am
Location: very near from here

Re: how read temperature from DS1624

Thu Oct 02, 2014 7:02 pm

joan wrote:Try

Code: Select all

   val = bus.read_word_data(address, DS1624_READ_TEMP)

   # t = val
   # val = ((t & 0x00FF) << 8) | ((t & 0xFF00) >> 8)

   temperature = val / 256.0
   if temperature > 128.0:
      temperature -= 256.0

   return temperature
Uncomment the byte swap lines if the I2C call is byte swapped.

i did it . only error.
i do not know how attach here picture but on string temperature = val / 256.0
bigest and hugest same as tiny and micro

User avatar
joan
Posts: 13655
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: how read temperature from DS1624

Thu Oct 02, 2014 7:09 pm

You are going to have to find a way of showing the error. I'm not going to guess.

rapidograf
Posts: 270
Joined: Sat Mar 22, 2014 11:03 am
Location: very near from here

Re: how read temperature from DS1624

Thu Oct 02, 2014 7:38 pm

joan wrote:You are going to have to find a way of showing the error. I'm not going to guess.
close this topic. nobody know as right use DS1624 .
bigest and hugest same as tiny and micro

User avatar
DougieLawson
Posts: 34380
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: how read temperature from DS1624

Thu Oct 02, 2014 8:10 pm

rapidograf wrote:
and how you can interprete the temperature E6F0 (hex) page #6 of datasheet ? and all negative temperature date will me more more bigger than 128 ......
It's a twelve bit number with the sign bit in bit 15. The top 7 bits after the sign are the integer value, the bottom 8 bits are the fractional part. Bits 0,1,2 & 3 are always zero.

Starting with 0xE6F0 == 0b1110011011110000
bit 15 is set so it's a negative value.
Take the two's complement to get 0b0001100100010000 == 0x1910
Then divide by 256 to get a floating point decimal temp value.

The easy way to do that using decimal numbers is

Code: Select all

if val > 32768:
  temp = (65536 - float(val))/256
else:
  temp = float(val)/256
Note:Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

rapidograf
Posts: 270
Joined: Sat Mar 22, 2014 11:03 am
Location: very near from here

Re: how read temperature from DS1624

Sun Oct 05, 2014 8:53 am

DougieLawson wrote:
rapidograf wrote:
and how you can interprete the temperature E6F0 (hex) page #6 of datasheet ? and all negative temperature date will me more more bigger than 128 ......
It's a twelve bit number with the sign bit in bit 15. The top 7 bits after the sign are the integer value, the bottom 8 bits are the fractional part. Bits 0,1,2 & 3 are always zero.

Starting with 0xE6F0 == 0b1110011011110000
bit 15 is set so it's a negative value.
Take the two's complement to get 0b0001100100010000 == 0x1910
Then divide by 256 to get a floating point decimal temp value.

The easy way to do that using decimal numbers is

Code: Select all

if val > 32768:
  temp = (65536 - float(val))/256
else:
  temp = float(val)/256

Mr. DougieLawson

thank you for kick my brain , i found solution by the another way , more easy for me , but maybe not so brilliant as for programmer ;) :idea: :arrow: :?: :arrow: :!:

P/S my first computer was speccy ;) i did it by meselve with board and dump of chips :D
bigest and hugest same as tiny and micro

User avatar
joan
Posts: 13655
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: how read temperature from DS1624

Sun Oct 05, 2014 9:41 am

If you post or link to the working code others could use it to read from the DS1624.

User avatar
DougieLawson
Posts: 34380
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: how read temperature from DS1624

Sun Oct 05, 2014 9:54 pm

joan wrote:If you post or link to the working code others could use it to read from the DS1624.
+1
Note:Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

rapidograf
Posts: 270
Joined: Sat Mar 22, 2014 11:03 am
Location: very near from here

Re: how read temperature from DS1624

Mon Oct 06, 2014 3:46 am

DougieLawson wrote:
joan wrote:If you post or link to the working code others could use it to read from the DS1624.
+1
OK . wait .
is here blogs or personal pages on this site ? write is forum - will lost to anytime
bigest and hugest same as tiny and micro

User avatar
joan
Posts: 13655
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: how read temperature from DS1624

Mon Oct 06, 2014 7:53 am

If you just post the code it will be found with a normal Google search, i.e. it will be found by anyone searching for "raspberry pi ds1624".

rapidograf
Posts: 270
Joined: Sat Mar 22, 2014 11:03 am
Location: very near from here

Re: how read temperature from DS1624

Wed Oct 08, 2014 6:47 pm

DougieLawson wrote:
joan wrote:If you post or link to the working code others could use it to read from the DS1624.
+1
as i promissed , i put to here part of code where is recalculating from internal data of DS1624 to human understading date ;) in during couple days i will try use it togetje with sensor , but previously it working based on the chart of official datasheet

Code: Select all

raw_t=0xE6F0   #raw_t - it is date which was read from DS1624 , 0xE6F0  fore checking , this date = 25.0625 celsius



if (raw_t>0x8000):
	raw=raw_t>>4;
	data_t=((0x0FF8-raw)*0.0625+0.5)*-1;
else:
	raw=raw_t>>4;
	data_t=raw*0.0625;

print "T=", data_t
Print "raw_t=", raw_t
bigest and hugest same as tiny and micro

User avatar
DougieLawson
Posts: 34380
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: how read temperature from DS1624

Thu Oct 09, 2014 11:38 am

Your code is doing basically the same as my code. You're using hex numbers and overly complex maths, but it should get the same result.
Note:Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

rapidograf
Posts: 270
Joined: Sat Mar 22, 2014 11:03 am
Location: very near from here

Re: how read temperature from DS1624

Thu Oct 09, 2014 1:18 pm

DougieLawson wrote:Your code is doing basically the same as my code. You're using hex numbers and overly complex maths, but it should get the same result.
wow . i did not know that i can do work with "overly complex maths" .
my code is cyrvly , you are best professional.
bigest and hugest same as tiny and micro

rapidograf
Posts: 270
Joined: Sat Mar 22, 2014 11:03 am
Location: very near from here

Re: how read temperature from DS1624

Fri Oct 10, 2014 8:56 am

DougieLawson wrote:
rapidograf wrote:
and how you can interprete the temperature E6F0 (hex) page #6 of datasheet ? and all negative temperature date will me more more bigger than 128 ......
It's a twelve bit number with the sign bit in bit 15. The top 7 bits after the sign are the integer value, the bottom 8 bits are the fractional part. Bits 0,1,2 & 3 are always zero.

Starting with 0xE6F0 == 0b1110011011110000
bit 15 is set so it's a negative value.
Take the two's complement to get 0b0001100100010000 == 0x1910
Then divide by 256 to get a floating point decimal temp value.

The easy way to do that using decimal numbers is

Code: Select all

if val > 32768:
  temp = (65536 - float(val))/256
else:
  temp = float(val)/256
sorry i'm not clar undersant how you transform from 0xE6F0 to 0x1910 ? what operations necessary do for this woodoo doing ? ;)
bigest and hugest same as tiny and micro

User avatar
joan
Posts: 13655
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: how read temperature from DS1624

Fri Oct 10, 2014 9:12 am

I posted code which works earlier in the thread.

User avatar
DougieLawson
Posts: 34380
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: how read temperature from DS1624

Fri Oct 10, 2014 5:21 pm

rapidograf wrote: sorry i'm not clar undersant how you transform from 0xE6F0 to 0x1910 ? what operations necessary do for this woodoo doing ? ;)
Take the two's complement. Ignore the sign bit, invert every other bit (so 1 becomes 0, 0 becomes 1) then add 1.
http://en.wikipedia.org/wiki/Two%27s_complement
Note:Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

User avatar
DougieLawson
Posts: 34380
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: how read temperature from DS1624

Fri Oct 10, 2014 5:22 pm

joan wrote:I posted code which works earlier in the thread.
Me too.
Note:Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

rapidograf
Posts: 270
Joined: Sat Mar 22, 2014 11:03 am
Location: very near from here

Re: how read temperature from DS1624

Fri Oct 10, 2014 7:29 pm

DougieLawson wrote:
joan wrote:I posted code which works earlier in the thread.
Me too.
unfortunately no either gest right code. ........
i run the programm which i found bye google .

it show me .

23.75 degree , initial code (which was read from register DS1624) = 49175 , that mean 0xC017,
in bits 1100000000010111 .

what it does mean ? is datasheet wrong ? or .......... trye somewhere near
bigest and hugest same as tiny and micro

Return to “Python”