- 12V Akku mit 280 Ah bauen         
Seite 3 von 6 ErsteErste 12345 ... LetzteLetzte
Ergebnis 21 bis 30 von 55

Thema: DS1621 auslesen

  1. #21
    Erfahrener Benutzer Robotik Einstein
    Registriert seit
    22.05.2005
    Ort
    12°29´ O, 48°38´ N
    Beiträge
    2.731
    Anzeige

    LiFePo4 Akku selber bauen - Video
    Im Programm schreibst Du bei SCL/SDA PortC und hier grad PortB, welcher ist es denn ?

  2. #22
    Erfahrener Benutzer Roboter Genie
    Registriert seit
    09.07.2005
    Ort
    127.0.0.1
    Alter
    32
    Beiträge
    824
    Hallo

    Ohh, ich meinte natürlich Port.c.
    SCL/SDA ist mit Port.c. verbunden, wahr ein tipp fehler.

    mfg Luca
    Sollte ein Bild von mir nicht angezeigt werden, einfach eine PM schicken!

  3. #23
    Neuer Benutzer Öfters hier
    Registriert seit
    16.10.2006
    Ort
    Essen
    Beiträge
    26
    Hallo zusammen,

    ich versuche auch schon seit Tagen mit der RNControl und einem DS1621 eine Temperatur anzuzeigen.
    Ich bin recht enttäuscht, dass eine so simple Aufgabe fast unlösbar ist. Ich bin davon ausgegangen, dass soetwas schon 1000fach probiert wurde und hätte schon ein paar perfekte Lösungen erwartet.

    Aber ich habe aus Euren Vorschlägen ein PRG ableiten können, das bei mir auf dem LCD und auf der RS232 die Temperatur formatiert anzeigt.

    Hier ist es:

    $regfile = "M32def.dat" ' chip
    $crystal = 16000000 ' frequenz
    $baud = 9600 ' baud rate

    Config Scl = Portc.0 ' we need to provide the SCL pin name
    Config Sda = Portc.1 ' we need to provide the SDA pin name

    Config Lcdpin = Pin , Db4 = Portb.0 , Db5 = Portb.1 , Db6 = Portb.2 , Db7 = Portb.3 , E = Portb.5 , Rs = Portb.4
    Config Lcd = 16 * 2
    Config Portb = Output
    Config Lcdbus = 4

    Dim ___lcdno As Bit
    Dim Lowtemp As Byte
    Dim Hightemp As Byte
    Dim Value As Word
    Declare Sub Convertvalue_komma1()
    Dim Convert_strg As String * 10 '!!!!!!!
    I2cinit
    Cls

    Do

    I2cstart
    I2cwbyte 144
    I2cwbyte &HEE 'Temperaturmessung anstoßen
    I2cstop

    I2cstart
    I2cwbyte 144
    I2cwbyte &HAA 'Temperaturmessung Lesekommando
    I2cstop

    I2cstart
    I2cwbyte 145
    I2crbyte Lowtemp , Ack 'LSB holen
    I2crbyte Hightemp , Nack 'MSB holen

    I2cstop

    Value = Lowtemp * 10
    If Hightemp = 128 Then
    Value = Value + 5
    End If


    Call Convertvalue_komma1()
    Print Convert_strg ; " C"


    Locate 1 , 1
    Lcd Convert_strg ; " C"

    Waitms 1000 'kurze Pause
    Loop


    End

    '-------------------------------------------------------------------------------
    'Convertvalue_komma1 wandelt Value in einen String mit einer Nachkommastelle.
    'Es wird gezeigt wie ein Zahlenwert in ein String gewandelt wird und dieser
    'formatiert werden kann.
    'Alternativ kann natürlich auch die "/10, Mod 10 Methode" angewandt werden.

    Sub Convertvalue_komma1()

    Convert_strg = Str(value)
    Convert_strg = Format(convert_strg , " 0.0")

    End Sub
    '---------------------------------


    Gruß aus Essen, Peter

  4. #24
    Benutzer Stammmitglied
    Registriert seit
    28.08.2006
    Beiträge
    48
    Hello,
    I translated a CCBasic program I wrote into a Bascom 8051 program.
    The CCBasic version works pervectly, I have not been able to test the Bascom 8051 version yet.
    I think with a few modifications the Bascom 8051 program should work on a AVR.
    Greetings,
    Windt H.J.

    Code:
    '***************************************'
    '* WINDT SYSTEMS                       *'
    '* DS1621 v1.0 for 89S8252 Flash Board *'
    '* 2006 / H.J. WINDT                   *'
    '***************************************'
    '----------------------------------------------------------------------------------------------------'
    'This software for the 89S8252 will read the DS1621 9 bit Temperature'
    '-55°C to +125°C in 0.5°C increments and display the data on a terminal program as T = xxx,x°C.'
    'The temperature is read as -550 to 1250, the last digit is actually the digit behind the comma,'
    'example 1: temp_c = -15 is actually -1,5°C'
    'example 2: temp_c = 250 is actually 25,0°C.'
    'Communication with the DS1621 is via the I2C bus.'
    'Feel free to use and share this software!'
    'DS1621 -->> DALLAS SEMICONDUCTOR Digital Thermometer and Thermostat'
    '----------------------------------------------------------------------------------------------------'
    '********************************* PORTS *********************************'
    Config Sda = P1.0
    Config Scl = P1.1
    '*************************************************************************'
    '******************************* VARIABLES *******************************'
    Dim I2c_byte As Byte
    Dim Loops1 As Byte
    Dim Temp1 As Integer
    Dim Temp2 As Integer
    Dim Temp_c As Integer
    '*************************************************************************'
    '******************************* CONSTANTS *******************************'
    Const Ds1621_i2c_address = &H0
    Const Ds1621_i2c_r_address = &H1
    '*************************************************************************'
    '********************************* SETUP *********************************'
    Config I2cdelay = 800
    '*************************************************************************'
    '******************************** PROGRAM ********************************'
    Temp_c_loop:
    Gosub Get_ds1621_temperature
    
    Temp1 = Temp_c / 10                                           'calculate hundreds tens ones from temp_c'
    Temp1 = Abs(temp1)
    
    Temp2 = Temp_c / 10                                           'calculate 1/10th from temp_c'
    Temp2 = Temp2 * 10
    Temp2 = Temp_c - Temp2
    Temp2 = Abs(temp2)
    
    Print "T = ";                                                 'display T = '
    If Temp_c < 0 Then Print "-";                                 'display "-" if temp_c < 0'
    Print Temp1 ; "," ; Temp2 ; "°C"                              'display temperature as xxx,x°C'
    
    Goto Temp_c_loop
    '*************************************************************************'
    '****************************** SUBROUTINES ******************************'
    Get_ds1621_temperature:
    
    For Loops1 = 1 To 2
    Ds1621_start_convert:
    I2cstart
    I2cwbyte Ds1621_i2c_address
    I2cwbyte &HEE
    I2cstop
    
    Ds1621_check_conversion_done:
    I2cstart
    I2cwbyte Ds1621_i2c_address
    I2cwbyte &HAC
    I2cstop
    I2cstart
    I2cwbyte Ds1621_i2c_r_address
    I2crbyte I2c_byte , Nack
    I2cstop
    Temp1 = I2c_byte And 1
    Temp2 = I2c_byte And 128
    If Temp1 = 1 Then If Temp2 = 128 Then Goto Ds1621_check_conversion_done
    
    Ds1621_read_temp:
    I2cstart
    I2cwbyte Ds1621_i2c_address
    I2cwbyte &HAA
    I2cstop
    I2cstart
    I2cwbyte Ds1621_i2c_r_address
    
    I2crbyte I2c_byte , Ack
    If I2c_byte > 127 Then Temp_c = &HFF00 + I2c_byte Else Temp_c = I2c_byte
    Temp_c = Temp_c * 10
    
    I2crbyte I2c_byte , Nack
    Temp1 = I2c_byte And 128
    If Temp1 = 128 Then Temp_c = Temp_c + 5
    
    I2cstop
    Next
    Return
    '*************************************************************************'
    '********************************* DATA **********************************'
    
    '*************************************************************************'

  5. #25
    Neuer Benutzer Öfters hier
    Registriert seit
    16.10.2006
    Ort
    Essen
    Beiträge
    26
    Hallo Windt H.J. ,

    thank you, the program works like mine. I only must change a few things.
    I test it with ATMEGA32.
    Do you have a version, with shows the temperature more exactly?
    (not only 0,5 degrees steps)

    Here the source:

    '***************************************'
    '* WINDT SYSTEMS *'
    '* DS1621 v1.0 for 89S8252 Flash Board *'
    '* 2006 / H.J. WINDT *'
    '***************************************'
    '----------------------------------------------------------------------------------------------------'
    'This software for the 89S8252 will read the DS1621 9 bit Temperature'
    '-55°C to +125°C in 0.5°C increments and display the data on a terminal program as T = xxx,x°C.'
    'The temperature is read as -550 to 1250, the last digit is actually the digit behind the comma,'
    'example 1: temp_c = -15 is actually -1,5°C'
    'example 2: temp_c = 250 is actually 25,0°C.'
    'Communication with the DS1621 is via the I2C bus.'
    'Feel free to use and share this software!'
    'DS1621 -->> DALLAS SEMICONDUCTOR Digital Thermometer and Thermostat'
    '----------------------------------------------------------------------------------------------------'
    '********************************* PORTS *********************************'
    $regfile = "M32def.dat" ' chip
    $crystal = 16000000 ' frequenz
    $baud = 9600 ' baud rate

    Config Scl = Portc.0 ' we need to provide the SCL pin name
    Config Sda = Portc.1 ' we need to provide the SDA pin name

    Config Lcdpin = Pin , Db4 = Portb.0 , Db5 = Portb.1 , Db6 = Portb.2 , Db7 = Portb.3 , E = Portb.5 , Rs = Portb.4
    Config Lcd = 16 * 2
    Config Portb = Output
    Config Lcdbus = 4
    '************************************************* ************************'
    '******************************* VARIABLES *******************************'
    Dim I2c_byte As Byte
    Dim Loops1 As Byte
    Dim Temp1 As Integer
    Dim Temp2 As Integer
    Dim Temp_c As Integer
    '************************************************* ************************'
    '******************************* CONSTANTS *******************************'
    Const Ds1621_i2c_address = 144
    Const Ds1621_i2c_r_address = 145
    '************************************************* ************************'
    '********************************* SETUP *********************************'
    Config I2cdelay = 800
    '************************************************* ************************'
    '******************************** PROGRAM ********************************'
    Temp_c_loop:
    Gosub Get_ds1621_temperature

    Temp1 = Temp_c / 10 'calculate hundreds tens ones from temp_c'
    Temp1 = Abs(temp1)

    Temp2 = Temp_c / 10 'calculate 1/10th from temp_c'
    Temp2 = Temp2 * 10
    Temp2 = Temp_c - Temp2
    Temp2 = Abs(temp2)

    Print "T = "; 'display T = '
    If Temp_c < 0 Then Print "-"; 'display "-" if temp_c < 0'
    Print Temp1 ; "," ; Temp2 ; "°C" 'display temperature as xxx,x°C'

    Goto Temp_c_loop
    '************************************************* ************************'
    '****************************** SUBROUTINES ******************************'
    Get_ds1621_temperature:

    For Loops1 = 1 To 2
    Ds1621_start_convert:
    I2cstart
    I2cwbyte Ds1621_i2c_address
    I2cwbyte &HEE
    I2cstop

    Ds1621_check_conversion_done:
    I2cstart
    I2cwbyte Ds1621_i2c_address
    I2cwbyte &HAC
    I2cstop
    I2cstart
    I2cwbyte Ds1621_i2c_r_address
    I2crbyte I2c_byte , Nack
    I2cstop
    Temp1 = I2c_byte And 1
    Temp2 = I2c_byte And 128
    If Temp1 = 1 Then If Temp2 = 128 Then Goto Ds1621_check_conversion_done

    Ds1621_read_temp:
    I2cstart
    I2cwbyte Ds1621_i2c_address
    I2cwbyte &HAA
    I2cstop
    I2cstart
    I2cwbyte Ds1621_i2c_r_address

    I2crbyte I2c_byte , Ack
    If I2c_byte > 127 Then Temp_c = &HFF00 + I2c_byte Else Temp_c = I2c_byte
    Temp_c = Temp_c * 10

    I2crbyte I2c_byte , Nack
    Temp1 = I2c_byte And 128
    If Temp1 = 128 Then Temp_c = Temp_c + 5

    I2cstop
    Next
    Return
    '************************************************* ************************'
    '********************************* DATA **********************************'

  6. #26
    Erfahrener Benutzer Roboter-Spezialist
    Registriert seit
    14.04.2006
    Ort
    Stuttgart
    Alter
    44
    Beiträge
    321
    I thought the minimum increment of the ds1621 is 0.5°... How should one be able to get more precision if the sensor doesn't support it? Maybe you could get an average over several values but that wouldn't be more precise... There is no point in trying to get a better resolution if the sensor can't supply better values. You could probably calculate a moving average over several values and "cheat" another decimal place this way
    Zitat Zitat von datasheet
    Measures temperatures from –55°C to +125°C in
    0.5°C increments.

  7. #27
    Benutzer Stammmitglied
    Registriert seit
    28.08.2006
    Beiträge
    48
    Hello,
    The DS1621 is capable of higher resolutions.
    By reading out the 8 bit temperature (not the 9 bit), counter and slope of the DS1621 and performing a calculation you can get a higher resolution (this can also be read in the datasheet).

    I’m still working on the calculation using signed integers and I hope to test it tomorrow.
    Using pen and paper the calculation seems to work.
    Greetings,
    Windt H.J.

  8. #28
    Erfahrener Benutzer Roboter-Spezialist
    Registriert seit
    14.04.2006
    Ort
    Stuttgart
    Alter
    44
    Beiträge
    321
    Oh, ok... Then I retract my statement.

  9. #29
    Benutzer Stammmitglied
    Registriert seit
    28.08.2006
    Beiträge
    48
    Zitat Zitat von peter02
    Do you have a version, with shows the temperature more exactly?
    (not only 0,5 degrees steps)
    Hello,
    I have had success writing new software (CCBasic C-Control) that reads and shows the temperature in smaller increments. \/

    I translated it into Bascom 8051 but I’m not able to compile and test it (demo version of Bascom 8051).

    With A few modifications it should work on an AVR.
    Let me know how it works out.
    Greetings,
    Windt H.J.


    Code:
    '***************************************'
    '* WINDT SYSTEMS                       *'
    '* DS1621 v1.1 for 89S8252 Flash Board *'
    '* 2006 / H.J. WINDT                   *'
    '***************************************'
    '----------------------------------------------------------------------------------------------------'
    'This software for the 89S8252 will read the DS1621 8 bit Temperature, Counter And Slope and'
    'display the data on a terminal as T = xxx , xx°C'
    'The temperature is read as -5500 to 12500, the last 2 digits are actually the digits behind the comma,'
    'example 1: temp_c = -150 is actually -1,50°C'
    'example 2: temp_c = 2500 is actually 25,00°C.
    'Communication with the DS1621 is via the I2C bus.'
    'Feel free to use and share this software!'
    'DS1621 -->> DALLAS SEMICONDUCTOR Digital Thermometer and Thermostat'
    '----------------------------------------------------------------------------------------------------'
    '********************************* PORTS *********************************'
    Config Sda = P1.0
    Config Scl = P1.1
    '*************************************************************************'
    '******************************* VARIABLES *******************************'
    Dim I2c_byte As Byte
    Dim Loops1 As Byte
    Dim Count As Byte
    Dim Slope As Byte
    Dim Temp1 As Integer
    Dim Temp2 As Integer
    Dim Temp_c As Integer
    '*************************************************************************'
    '******************************* CONSTANTS *******************************'
    Const Ds1621_i2c_address = &H0
    Const Ds1621_i2c_r_address = &H1
    '*************************************************************************'
    '********************************* SETUP *********************************'
    Config I2cdelay = 800
    '*************************************************************************'
    '******************************** PROGRAM ********************************'
    Temp_c_loop:
    Gosub Get_ds1621_temperature
    
    Temp1 = Temp_c / 100
    Temp1 = Abs(temp1)
    
    Temp2 = Temp_c / 100
    Temp2 = Temp2 * 100
    Temp2 = Temp_c - Temp2
    Temp2 = Abs(temp2)
    
    Print "T = ";
    If Temp_c < 0 Then Print "-";
    Print Temp1 ; "," ;
    If Temp2 < 10 Then Print "0";
    Print Temp2 ; "°C"
    
    Goto Temp_c_loop
    '*************************************************************************'
    '****************************** SUBROUTINES ******************************'
    Get_ds1621_temperature:
    
    For Loops1 = 1 To 2
    Ds1621_start_convert:
    I2cstart
    I2cwbyte Ds1621_i2c_address
    I2cwbyte &HEE
    I2cstop
    
    Ds1621_check_conversion_done:
    I2cstart
    I2cwbyte Ds1621_i2c_address
    I2cwbyte &HAC
    I2cstop
    I2cstart
    I2cwbyte Ds1621_i2c_r_address
    I2crbyte I2c_byte , Nack
    I2cstop
    Temp1 = I2c_byte And 1
    Temp2 = I2c_byte And 128
    If Temp1 = 1 Then If Temp2 = 128 Then Goto Ds1621_check_conversion_done
    
    Ds1621_read_temp:
    I2cstart
    I2cwbyte Ds1621_i2c_address
    I2cwbyte &HAA
    I2cstop
    I2cstart
    I2cwbyte Ds1621_i2c_r_address
    
    I2crbyte Temp_c , Nack
    If Temp_c > 127 Then Temp_c = Temp_c + &HFF00
    Temp_c = Temp_c * 100
    
    Ds1621_read_count:
    I2cstart
    I2cwbyte Ds1621_i2c_address
    I2cwbyte &HA8
    I2cstop
    I2cstart
    I2cwbyte Ds1621_i2c_r_address
    I2crbyte Count , Nack
    I2cstop
    
    Ds1621_read_slope:
    I2cstart
    I2cwbyte Ds1621_i2c_address
    I2cwbyte &HA9
    I2cstop
    I2cstart
    I2cwbyte Ds1621_i2c_r_address
    I2crbyte Slope , Nack
    I2cstop
    
    Temp1 = Count * 100
    Temp2 = Slope * 100
    
    Temp2 = Temp2 - Temp1
    Temp1 = Temp2 / Slope
    
    Temp_c = Temp_c - 25
    Temp_c = Temp_c + Temp1
    
    I2cstop
    Next
    Return
    '*************************************************************************'
    '********************************* DATA **********************************'
    
    '*************************************************************************'

  10. #30
    Neuer Benutzer Öfters hier
    Registriert seit
    31.03.2005
    Beiträge
    10
    Schonmal an die Pullup widerstände gedacht ??
    Bei mi geht ohne gar nix auch wenn alles ander in Ordnung ist !!

Seite 3 von 6 ErsteErste 12345 ... LetzteLetzte

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

Solar Speicher und Akkus Tests