Leistungsmessung mit Atiny85 und kleines OLED

    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!

    • Leistungsmessung mit Atiny85 und kleines OLED

      Hab hier mal ein kleines Projekt mit OLED
      Für meine 12V LED Beleuchtung hab ich eine kleine Strom, Spannung und Leistungsmessung gebaut.
      Auswertung läuft über einen Atiny85. Versorgt aus der 12V mit 78L05.
      Spannung mit Spannugsteiler von 12k zu 1k
      Strom mit einem Shunt von 10mOhm
      Interne Referenz = 1,1V
      Schaltplan gibt es keinen.
      Hab im Programm noch Justageanpassungen gemacht für Spannung und für Strom.

      BASCOM-Quellcode

      1. ' Insanity
      2. ' Test mit OLED
      3. $Regfile="attiny85.dat"
      4. $Crystal=8000000
      5. $hwstack=64
      6. $swstack=64
      7. $framesize=64
      8. ' Spannungsteiler mit 12K zu 1K
      9. ' Bei 12V = 859 Digits
      10. Const Spannung_Faktor = 12/885
      11. ' Shunt mit 0.01 Ohm
      12. ' Bei 15A = 140 Digits
      13. Const Strom_Faktor = 15/120
      14. 'I2C Config
      15. Config Scl = PortB.2
      16. Config Sda = PortB.0
      17. 'Display Config
      18. $lib "glcdSSD1306-I2C.lib" ' SSD1306 LIB einbinden
      19. Config I2cdelay = 1
      20. I2cinit
      21. Waitms 10
      22. Config Graphlcd = Custom , Cols = 128 , Rows = 64 , Lcdname = "SSD1306" 'SSD1106 oder SSD1306
      23. Cls
      24. ' Anlogfunktionen
      25. Declare Function Analog(byval Kanal As Byte , Byval Anzahl As Word ) As Word
      26. Config Adc = single , Prescaler = Auto , Reference = INTERNAL_1.1
      27. Start Adc
      28. Config Single = Scientific , Digits = 1
      29. Wait 1
      30. Dim Wert_U as Integer
      31. Dim Wert_I as Integer
      32. Dim Ergebnis As Single
      33. Dim Ergebnis_U As Single
      34. Dim Ergebnis_I As Single
      35. Dim Dummy as String * 8
      36. Setfont font12x16
      37. Cls
      38. Lcdat 1 , 1 , "Volt"
      39. Lcdat 4 , 1 , "Amp."
      40. Lcdat 7 , 1 , "Watt"
      41. Lcdat 1 , 117 , "V"
      42. Lcdat 4 , 117 , "A"
      43. Lcdat 7 , 117 , "W"
      44. Setfont Digital11x16
      45. Do
      46. Wert_U = Analog(3,1000)
      47. Wert_I = Analog(2,1000)
      48. Ergebnis_U = Wert_U * Spannung_Faktor
      49. Dummy = Str(Ergebnis_U,1)
      50. Ergebnis_U = Val(Dummy)
      51. Dummy = " " + Dummy
      52. Dummy = Right(Dummy,4)
      53. Lcdat 1 , 70 , Dummy
      54. Ergebnis_I = Wert_I * Strom_Faktor
      55. Dummy = Str(Ergebnis_I,1)
      56. Ergebnis_I = Val(Dummy)
      57. Dummy = " " + Dummy
      58. Dummy = Right(Dummy,4)
      59. Lcdat 4 , 70 , Dummy
      60. Ergebnis = Ergebnis_I * Ergebnis_U
      61. Dummy = Str(Ergebnis,1)
      62. Dummy = " " + Dummy
      63. Dummy = Right(Dummy,5)
      64. Lcdat 7 , 59 , Dummy
      65. Loop
      66. ' Analog messen
      67. Function Analog(Kanal , Anzahl)
      68. Local Schleife As Word
      69. Local Analogmesswert As Word
      70. Local Analogmesswert_summe As Long
      71. Local Analog_mittel As Long
      72. If Anzahl = 0 Then Anzahl = 1
      73. Analogmesswert_summe = 0
      74. For Schleife = 1 To Anzahl
      75. Analogmesswert = Getadc(Kanal)
      76. Analogmesswert_summe = Analogmesswert_summe + Analogmesswert
      77. Next
      78. Analog_mittel = Analogmesswert_summe / Anzahl
      79. Analogmesswert = Analog_mittel
      80. Analog = Analogmesswert
      81. End Function
      82. 'LCD-Font
      83. $include "font12x16.font"
      84. $include "Digital11x16.font"
      Alles anzeigen
      Dateien