AM2320 fällt aus

    Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

    Aufgrund technischer Veränderungen ist der Mailverkehr innerhalb des Forums (Private Nachrichten) nur noch eingeschränkt möglich. Die Einschränkung ist notwendig, um zusätzliche Betriebskosten für das Forum zu vermeiden. Näheres zu den Hintergründen im Thread "Aktuelles zum Forum".Wir bitten um Verständnis.

    Hinweis kann nach Kenntnisnahme deaktiviert werden!

    • AM2320 fällt aus

      Hallo,
      hat jemand von Euch eine AM2320 zuverlässig im Einsatz? Meiner läuft bis zu 20 Stumden und dann antwortet er nicht mehr. Allein Spannungsfrei machen hilft dann bis zum nächsten Ausfall. a_28_2c02f089 . Als Notlösung dachte ich vielleicht sein VCC über eine Pin zu versorgen?
      Ursprünglich hielt ich es für einen Wackelkontakt aber mitlerweile ist er eingelötet. Auch die Idee das er durch Uart-ints aus dem Konzept gebracht wurde war unbegründet . Er sendet immer alle 8 Byte fehlerlos und bei nächster Abfrage ist er einfach "nicht mehr da"

      BASCOM-Quellcode: i2c-AM2320_M8_02

      1. $regfile = "m8def.dat"
      2. $crystal = 1000000
      3. $hwstack=32
      4. $swstack = 32
      5. $framesize = 32
      6. $baud = 9600
      7. $eepleave ' eep Datei nicht ändern
      8. '$sim
      9. Config Base = 0
      10. Ddrb = 0
      11. Portb = $ff '0=res Out, 1=res In, 2=nc,3=MO/DCF,4=Mi, 5=Scl, 6=WwAnf, 7=Übertemp
      12. Ddrc = $40
      13. Portc = $40 '0fist, 1 tist, 2fsoll,3tsoll,4 sda ,5scl,6/R
      14. Ddrd = $fe '0-RX, 1-TX, 2Feuchte ,3Heizung
      15. Portd = $f1
      16. '---------------------- I2C config
      17. $lib "i2c_twi.lbx" 'Use Hardware I2C
      18. #if _sim = 0
      19. $lib "YwRobot_Lcd_i2c.lib" 'YwRobot Treiber für LCD
      20. #endif
      21. Config Scl = Portc.5 'Platne außen: Gnd,Vdd, SDA,SCL
      22. Config Sda = Portc.4
      23. Config Twi = 50000 'Normal 100000=100kHz
      24. Const Pcf8574_lcd = &H7E 'Adresse des I2C-LCDs
      25. Const Am3220w = &HB8 '1=Vdd(3,1-5,5V), 2=SDA, 3=Gnd, 4=SCL
      26. Const Am3220r = &HB9
      27. Dim I2cbuf(8) As Byte
      28. Config Lcd = 16 * 2
      29. Dim Lcd_backlight As Byte
      30. I2cinit
      31. #if _sim = 1
      32. Config Lcdpin = Pin , Db4 = Portb.0 , Db5 = Portb.1 , Db6 = Portb.2 , Db7 = Portb.3 , E = Portb.4 , Rs = Portb.5
      33. Config Lcd = 16 * 2
      34. #endif
      35. Initlcd
      36. Config Timer1 = Timer , Prescale = 1024
      37. Config Timer0 = Timer , Prescale = 1024
      38. Config Adc = Single , Prescaler = Auto , Reference = Avcc '2,72V bei 5V
      39. Dim A As Byte , V As Byte , Z As Byte 'a=Schleifenzähler,V=länge,Z=EEpromaddresse
      40. Dim Tist As Integer , Talt As Byte , Tsoll As Byte , Thy As Byte , T_h As Byte , T_l As Byte
      41. Dim Fist As integer , Falt As Byte , Fsoll As Byte , Fhy As Byte , F_h As Byte , F_l As Byte
      42. Dim Ti As Byte , Fi As Byte , Tand As Byte , Fand As Byte
      43. Dim C_h As Byte , C_l As Byte , Ch As Word
      44. Dim Temp As Byte , Tempw As Word , Tempi As Integer , Tempstr As String * 6
      45. Thy = 2
      46. Fhy = 2
      47. Waitms 50 'wegen Lcdinit
      48. Deflcdchar 1 , 14 , 31 , 31 , 31 , 31 , 31 , 31 , 14
      49. Cls
      50. Do '###################################################
      51. Incr Z
      52. Tempw = Getadc(3) 'Tempsoll
      53. Shift Tempw , Right , 5
      54. Tsoll = Tempw + 20
      55. If Tsoll <> Talt Then Tand = 10
      56. Talt = Tsoll
      57. Tempw = Getadc(2) 'Feuchtsoll
      58. Shift Tempw , Right , 2
      59. Tempw = Tempw / 5
      60. Fsoll = Tempw + 48
      61. If Fsoll <> Falt Then Fand = 10
      62. Falt = Fsoll
      63. Gosub Lese_am
      64. If I2cbuf(0) = 3 Then
      65. Tempw = I2cbuf(2) * 256
      66. 'Shift Tempw , Left , 8
      67. Tempw = Tempw + I2cbuf(3)
      68. Fist = Tempw / 10
      69. Tempi = I2cbuf(4) * 256
      70. 'Shift Tempi , Left , 8
      71. Tempi = Tempi + I2cbuf(5)
      72. 'Tempi = Tempi + 5
      73. 'Tempi = Tempi / 10
      74. Tist = Tempi / 10
      75. If Fist >= Fsoll Then
      76. Reset Portd.3
      77. Fi = 79
      78. End If
      79. If Tist >= Tsoll Then
      80. Reset Portd.2
      81. Ti = 79
      82. End If
      83. Temp = Tist + Thy
      84. If Temp <= Tsoll Then
      85. Set Portd.2
      86. Ti = 1
      87. End If
      88. Temp = Fist + Fhy
      89. If Temp <= Fsoll Then
      90. Set Portd.3
      91. Fi = 1
      92. End If
      93. Else
      94. Fi = $2d
      95. Ti = $2d
      96. End If
      97. Locate 1 , 1
      98. If Fand > 0 Then
      99. Lcd "Feu.Soll: " ; Fsoll
      100. Decr Fand
      101. Else
      102. Lcd "Feuchte : " ; Fist
      103. End If
      104. Lcd "%r "
      105. Lcd Chr(fi)
      106. Locate 2 , 1
      107. If Tand > 0 Then
      108. Lcd "Raumsoll: " ; Tsoll
      109. Decr Tand
      110. Else
      111. Tempi = Tempi Mod 10
      112. Lcd "Raum : " ; Tist ; "," ; Tempi
      113. End If
      114. Lcd Chr(223)
      115. Lcd "C "
      116. Lcd Chr(ti)
      117. #if _sim = 1
      118. Timer0 = 250
      119. #endif
      120. Do
      121. If Neu = 1 Then Antwort
      122. Loop Until Tifr.0 = 1
      123. Reset Tifr.0
      124. If Tifr.2 = 1 Then
      125. Initlcd
      126. Tifr.2 = 0
      127. Waitms 80
      128. Deflcdchar 1 , 14 , 31 , 31 , 31 , 31 , 31 , 31 , 14
      129. Cls
      130. End If
      131. Loop
      132. End
      133. '(###############################################################################
      134. ')
      135. Lese_am:
      136. #if _sim = 0
      137. I2cstart
      138. I2cwbyte Am3220w 'Schreibadresse
      139. I2cwbyte 3 'Registerlesen
      140. I2cwbyte 0 'beginne Bei Reg 0
      141. I2cwbyte 4 'lese 4 Register
      142. I2cstop
      143. I2cstart
      144. I2cwbyte Am3220r
      145. I2crbyte F_h , Ack
      146. I2crbyte F_l , Ack
      147. I2crbyte T_h , Ack
      148. I2crbyte T_l , Ack
      149. I2crbyte C_h , Ack
      150. I2crbyte C_l , Nack
      151. I2cstop
      152. #else
      153. Tempw = Getadc(1)
      154. F_l = Tempw
      155. Shift Tempw , Right , 8
      156. F_h = Tempw
      157. Tempw = Getadc(0)
      158. T_l = Tempw
      159. Shift Tempw , Right , 8
      160. T_h = Tempw
      161. #endif
      162. Return
      Alles anzeigen
    • Hallo für den Fall das mal jemand damit arbeiten möchte.
      Mit diesem Code läuft er jetzt eine Woche ununterbrochen;
      allerdings erst nachdem er alleine an den I2C hängt,
      das LCD hat ihn wohl abgeschossen?


      Quellcode: AM2320_1.txt

      1. Lese_am: 'aufruf alle 256ms
      2. I2cstart
      3. I2cwbyte Am3220w 'Schreibadresse
      4. Waitms 1
      5. I2cstop
      6. I2cstart
      7. I2cwbyte Am3220w 'Schreibadresse 184 ($B8)
      8. I2cwbyte 3 'Registerlesen
      9. I2cwbyte 0 'beginne Bei Reg 0
      10. I2cwbyte 4 'lese 4 Register
      11. I2cstop
      12. Waitms 2 'min 1,5ms lt Datenblatt
      13. I2cstart
      14. I2cwbyte Am3220r 'Leseadresse 185 ($B9)
      15. Waitus 50 'min 30µs lt Datenblatt
      16. For A = 0 To 6 '0=funktion code(3), 1=Registeranzahl(4)
      17. I2crbyte I2cbuf(a) , Ack '2-3=Feuchte*10 (LB,HB)
      18. Next '4-5=Temperatur*10 (LB,HB)
      19. I2crbyte I2cbuf(7) , Nack '6-7=CRC
      20. I2cstop
      21. Return
      Alles anzeigen
    • Ich finde es bedenklich, _sim als Auswahlkonstante für I2C oder LCD zu benutzen. Sim kürzt alle waits weg, auch die wichtigen, die bei LCD-Ansteuerung gebraucht werden.

      Deine Leseroutinen sind nicht I2C konform, um eine Leseoperation einzuleiten, darf nach der Übertragung kein I2Cstop stehen, sondern ein repeated start.

      Stackwerte würde ich auch noch ein paar mehr spendieren.
    • Die Sim sind für den Simulator er kann das i2c LCD (eigendich das ganze i2c) nicht simulieren.
      Bei auskommentiertem $Sim sollte davon nichts mehr im Code übrigbleiben?

      Michael schrieb:

      Deine Leseroutinen sind nicht I2C konform, um eine Leseoperation einzuleiten, darf nach der Übertragung kein I2Cstop stehen, sondern ein repeated start.
      So stehts im Datenblatt. Das erste Stop-Start könnte ein repeated Start sein. Das wiederum ist nur zum wecken. Beim zweiten scheint es Sinn zu machen aber wo muss dann das waitms2 hin? Vor oder nach dem repeated Start?
    • Leider weiß ich nicht mehr wo's her kam. Hier ein Ausschnitt. Wenn ich irgendwann einmal wieder richtiges DSL habe könnte ich es auch komplett hochladen; im Moment über eine Blututh Tethering mit schlechtem Netz würde das nichts.

      Step one: Wake Sensor
      In order to reduce the humidity sensor errors caused by self-heating, the sensor in a
      non-working state, dormant, so to read the sensor must wake sensor to transmit commands to read
      and write, otherwise the sensor will not respond. It should be noted that, in the wake sensor, I2C
      address is sent, the sensor does not respond to ACK, but the host must send back an ACK clock
      verify that the ninth SCL clock signal. Wake sensor operation is following instructions:
      After the host sends a start signal is applied to the starting address, wait for sometime (waiting
      time of at least 800 μs, the maximum 3ms; such as host hardware I2C, you do not need to wait for
      the hardware I2C will automatically wait), and then sends a stop signal.
      Namely: the starting signal +0 xB8 + wait (> 800us) + stop signal timing diagram shown in
      Figure 15.
      Zwischenablage01.gif
      Figure 15: Wake Sensor
      Step two : Send the read command or send written instructions
      After the wake AM2320 sensors, can be fully in accordance with the standard read and write
      timing I2C, and the maximum speed supported 100Kb / s. Read the temperature and humidity of
      example, as shown in Figure 16.
      The host sends commands to: START +0 xB8 (SLA) +0 x03 (function code) +0 x00 (starting
      address) +0 x04 (register length) + STOP
      Zwischenablage02.gif
      Figure 16: sending a read command example temperature and humidity
      Steps three : To return the data read or confirmation signal
      Send read / write command, the host is required to wait at least 1.5ms, and then sends a read
      timing, reads return data example shown in Figure 17; must be noted that, when you read the data,
      issued after the completion of I2C address, wait at least 30μs and then sent over the next serial
      clock, reading data, or communication error occurs.