Bibliothek für DS1621

OP Persönliche Seite #1843690
Lesenswert?

Hallo,

Kann mir jemand helfen, ich suche eine Bibliothek in C zum auswerten des 
Temperatursensores DS1621 von Maxim.
Weiß jemand wo ich einige Hilfen zur Auswertung des Sensors finde?

Ich brauch keine Hilfe zur I2C Kommunikation.
Der Sensor funktioniert und ich lese die Werte auf 0,5°C genau aus.
Aber es geht laut Datenblatt noch genauer, aber wie...

Danke martin
Gast #1843693
Lesenswert?

Hi,

eine Lib kenne ich jetzt nicht, aber auf der Seite 4 im Datenblatt
gib es doch einen Text mit der entsprechenden Formel!
1
Higher resolutions may be obtained by reading the temperature and truncating the 0.5C bit (the LSB)
2
from the read value. This value is TEMP_READ. A Read Counter command should be issued to yield the
3
COUNT_REMAIN value. The Read Slope command should then be issued to obtain the
4
COUNT_PER_C value. The higher resolution temperature may be then be calculated by the user using the following:

Das meinst du doch oder???

mfg
Stephan
OP Persönliche Seite #1843868
Lesenswert?

Mein Code sieht jetzt so aus...
1
//#########################################################################
2
int16_t get_temp_ds1621_h(uint8_t Adr_DS1621)   // (z.B. 1052^=10,52°C)
3
{
4
  addr=Adr_DS1621;
5
  int16_t temp;
6
  uint8_t temp_msb;
7
  uint8_t temp_lsb;
8

9
  ds1621_conversion();
10

11
  i2c_start_wait( addr+I2C_WRITE );      // set device address
12
  i2c_write( CMD_READ_TEMP );            // lesen
13
  i2c_stop();                     // stop
14

15
  i2c_rep_start(addr+I2C_READ);   // set device address
16
  temp_msb = i2c_read(1);         // read the first temperature byte (msb)
17
  temp_lsb = i2c_read(0);         // read and discard bit
18
  i2c_stop();
19

20
  uint8_t reg_count = ds1621_getreg(CMD_READ_COUNTER);
21
  uint8_t reg_slope = ds1621_getreg(CMD_READ_SLOPE);
22

23
  temp = (float)temp_msb*100-25+((float)reg_slope-(float)reg_count)/(float)reg_slope*100;
24

25
  return temp;
26
}

Kann mir jemand sagen, wie ich die Zeile etwas besser gestalten kann?
1
temp = (float)temp_msb*100-25+((float)reg_slope-(float)reg_count)/(float)reg_slope*

Danke martin

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren