LED Display mit 4 Digits an Atmega48

    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!

    • LED Display mit 4 Digits an Atmega48

      Hallo,

      ich habe ein paar Probleme mit einem 3641AS 4 Digits LED Display mit gemeinsamer Kathode an meinen AtMega48.
      Und wollte mal Fragen ob der Sourcecode so stimmen könnte.
      Hab einige Atmega mit "klatsche" (defekten). Die manchmal funktionieren und manchmal nicht.
      Kann mal jemand auf den Sourcecode schauen ob das so hinhauen könnte?

      Quellcode

      1. $regfile = "m48def.dat" ' specify the used micro
      2. $crystal = 1000000 ' used crystal frequency
      3. $hwstack = 32 ' default use 32 for the hardware stack
      4. $swstack = 10 ' default use 10 for the SW stack
      5. $framesize = 40 ' default use 40 for the frame space
      6. Config Portc.5 = Output
      7. Config Portc.4 = Output
      8. Config Portc.3 = Output
      9. Config Portc.2 = Output
      10. Config Portc.1 = Output
      11. Config Portc.0 = Output
      12. Config Portb.5 = Output
      13. Config Portb.4 = Output
      14. Config Portd.2 = Output
      15. Config Portd.3 = Output
      16. Config Portd.4 = Output
      17. Config Portd.5 = Output
      18. Seg_a Alias Portc.5
      19. Seg_b Alias Portc.4
      20. Seg_c Alias Portc.3
      21. Seg_d Alias Portc.2
      22. Seg_e Alias Portc.1
      23. Seg_f Alias Portc.0
      24. Seg_g Alias Portb.5
      25. Seg_dot Alias Portb.4
      26. Gnd_digit_1 Alias Portd.2
      27. Gnd_digit_2 Alias Portd.3
      28. Gnd_digit_3 Alias Portd.4
      29. Gnd_digit_4 Alias Portb.5
      30. Dim Var_stunden As Byte
      31. Dim Var_minuten As Byte
      32. Dim Var_x As Integer
      33. Dim Var_y As Byte
      34. Dim Var_tmp_anzeige As Byte
      35. Config Watchdog = 1024
      36. Declare Function Write_digit(byval Var_key As Byte) As Byte
      37. Do
      38. Incr Var_x
      39. Incr Var_y
      40. If Var_x = 1000 Then
      41. Var_x = 0
      42. Incr Var_minuten
      43. End If
      44. If Var_minuten > 59 Then
      45. Incr Var_stunden
      46. Var_minuten = 0
      47. End If
      48. If Var_stunden > 59 Then Var_stunden = 0
      49. If Var_y = 1 Then
      50. Gnd_digit_1 = 1
      51. Gnd_digit_2 = 1
      52. Gnd_digit_3 = 1
      53. Gnd_digit_4 = 0
      54. Var_tmp_anzeige = Var_minuten Mod 10
      55. Var_tmp_anzeige = Var_tmp_anzeige + 1
      56. Var_tmp_anzeige = Write_digit(var_tmp_anzeige)
      57. Elseif Var_y = 2 Then
      58. Gnd_digit_1 = 1
      59. Gnd_digit_2 = 1
      60. Gnd_digit_3 = 1
      61. Gnd_digit_4 = 1
      62. Var_tmp_anzeige = Var_minuten / 10
      63. Var_tmp_anzeige = Var_tmp_anzeige + 1
      64. Var_tmp_anzeige = Write_digit(var_tmp_anzeige)
      65. Elseif Var_y = 3 Then
      66. Gnd_digit_1 = 1
      67. Gnd_digit_2 = 0
      68. Gnd_digit_3 = 1
      69. Gnd_digit_4 = 1
      70. Var_tmp_anzeige = Var_stunden Mod 10
      71. Var_tmp_anzeige = Var_tmp_anzeige + 1
      72. Var_tmp_anzeige = Write_digit(var_tmp_anzeige)
      73. Elseif Var_y = 4 Then
      74. Gnd_digit_1 = 0
      75. Gnd_digit_2 = 1
      76. Gnd_digit_3 = 1
      77. Gnd_digit_4 = 1
      78. Var_tmp_anzeige = Var_stunden / 10
      79. Var_tmp_anzeige = Var_tmp_anzeige + 1
      80. Var_tmp_anzeige = Write_digit(var_tmp_anzeige)
      81. Var_y = 0
      82. End If
      83. Waitms 1
      84. Reset Watchdog
      85. Loop
      86. Function Write_digit(var_key As Byte)
      87. Local Var_input_ziffer As Byte
      88. Var_input_ziffer = Var_key
      89. If Var_input_ziffer = 0 Then
      90. Seg_a = 1
      91. 'A
      92. Seg_b = 1
      93. 'B
      94. Seg_c = 1
      95. 'C
      96. Seg_d = 1
      97. 'D
      98. Seg_e = 1
      99. 'E
      100. Seg_f = 1
      101. 'F
      102. Seg_g = 0
      103. 'G
      104. Seg_dot = 0
      105. 'punkt
      106. Goto Endeif
      107. Elseif Var_input_ziffer = 1 Then
      108. Seg_a = 0
      109. 'A
      110. Seg_b = 1
      111. 'B
      112. Seg_c = 1
      113. 'C
      114. Seg_d = 0
      115. 'D
      116. Seg_e = 0
      117. 'E
      118. Seg_f = 0
      119. 'F
      120. Seg_g = 0
      121. 'G
      122. Seg_dot = 0
      123. Goto Endeif
      124. Elseif Var_input_ziffer = 2 Then
      125. Seg_a = 1
      126. 'A
      127. Seg_b = 1
      128. 'B
      129. Seg_c = 0
      130. 'C
      131. Seg_d = 1
      132. 'D
      133. Seg_e = 1
      134. 'E
      135. Seg_f = 0
      136. 'F
      137. Seg_g = 1
      138. 'G
      139. Seg_dot = 0
      140. Goto Endeif
      141. Elseif Var_input_ziffer = 3 Then
      142. Seg_a = 1
      143. 'A
      144. Seg_b = 1
      145. 'B
      146. Seg_c = 1
      147. 'C
      148. Seg_d = 1
      149. 'D
      150. Seg_e = 0
      151. 'E
      152. Seg_f = 0
      153. 'F
      154. Seg_g = 1
      155. 'G
      156. Seg_dot = 0
      157. Goto Endeif
      158. Elseif Var_input_ziffer = 4 Then
      159. Seg_a = 0
      160. 'A
      161. Seg_b = 1
      162. 'B
      163. Seg_c = 1
      164. 'C
      165. Seg_d = 0
      166. 'D
      167. Seg_e = 0
      168. 'E
      169. Seg_f = 1
      170. 'F
      171. Seg_g = 1
      172. 'G
      173. Seg_dot = 0
      174. Goto Endeif
      175. Elseif Var_input_ziffer = 5 Then
      176. Seg_a = 1
      177. 'A
      178. Seg_b = 0
      179. 'B
      180. Seg_c = 1
      181. 'C
      182. Seg_d = 1
      183. 'D
      184. Seg_e = 0
      185. 'E
      186. Seg_f = 1
      187. 'F
      188. Seg_g = 1
      189. 'G
      190. Seg_dot = 0
      191. Goto Endeif
      192. Elseif Var_input_ziffer = 6 Then
      193. Seg_a = 1
      194. 'A
      195. Seg_b = 0
      196. 'B
      197. Seg_c = 1
      198. 'C
      199. Seg_d = 1
      200. 'D
      201. Seg_e = 1
      202. 'E
      203. Seg_f = 1
      204. 'F
      205. Seg_g = 1
      206. 'G
      207. Seg_dot = 0
      208. Goto Endeif
      209. Elseif Var_input_ziffer = 7 Then
      210. Seg_a = 1
      211. 'A
      212. Seg_b = 1
      213. 'B
      214. Seg_c = 1
      215. 'C
      216. Seg_d = 0
      217. 'D
      218. Seg_e = 0
      219. 'E
      220. Seg_f = 0
      221. 'F
      222. Seg_g = 0
      223. 'G
      224. Seg_dot = 0
      225. Goto Endeif
      226. Elseif Var_input_ziffer = 8 Then
      227. Seg_a = 1
      228. 'A
      229. Seg_b = 1
      230. 'B
      231. Seg_c = 1
      232. 'C
      233. Seg_d = 0
      234. 'D
      235. Seg_e = 0
      236. 'E
      237. Seg_f = 0
      238. 'F
      239. Seg_g = 0
      240. 'G
      241. Seg_dot = 0
      242. Goto Endeif
      243. Elseif Var_input_ziffer = 9 Then
      244. Seg_a = 1
      245. 'A
      246. Seg_b = 1
      247. 'B
      248. Seg_c = 1
      249. 'C
      250. Seg_d = 1
      251. 'D
      252. Seg_e = 0
      253. 'E
      254. Seg_f = 1
      255. 'F
      256. Seg_g = 1
      257. 'G
      258. Seg_dot = 0
      259. Goto Endeif
      260. End If
      261. Endeif:
      262. Write_digit = Var_input_ziffer
      263. End Function
      264. End
      Alles anzeigen
      Hab die Funktion nur gemacht da ich keinen durchgehend freien Port hab. An PortD geht es nicht wegen der späteren $baud Anweisung und an PortB nicht wegen den Quarz.

      Vielen dank!
      Alex
    • Das sind doch keine Funktionen, sondern subs (Unterprogramme). Bei Aufruf werden doch ports gesetzt und keine Werte zurück gegeben.
      Raum für Notizen

      -----------------------------------------------------------------------------------------------------

      -----------------------------------------------------------------------------------------------------
    • Pluto25 schrieb:

      Scheint mir etwas aufwendig, Digit 3 bleibt dunkel(Zeile 73). Die 'goto endeif' sind unnötig da er nach einem wahren if ab else(if) zum End If springt. Sollte aber funktionieren. Der max Strom der D-pins wird nicht überschritten?
      Hallo,

      ich weis.
      Ich hab auf die schnelle die Reihenfolg invertiert und das übersehen.
      Ja, das goto endif ist überflüssig.

      Hab an jeder Plusleitung 1k dran. Der Gesamtverbrauch der Schaltung liegt bei 7mA

      Wenn ich diesen Code verwende sehe ich das alles leuchtet:

      Quellcode

      1. $regfile = "m48def.dat" ' specify the used micro
      2. $crystal = 1000000 ' used crystal frequency
      3. $hwstack = 32 ' default use 32 for the hardware stack
      4. $swstack = 10 ' default use 10 for the SW stack
      5. $framesize = 40 ' default use 40 for the frame space
      6. '$baud = 19200
      7. Config Portc.5 = Output
      8. Config Portc.4 = Output
      9. Config Portc.3 = Output
      10. Config Portc.2 = Output
      11. Config Portc.1 = Output
      12. Config Portc.0 = Output
      13. Config Portb.5 = Output
      14. Config Portb.4 = Output
      15. Config Portd.2 = Output
      16. Config Portd.3 = Output
      17. Config Portd.4 = Output
      18. Config Portd.5 = Output
      19. Seg_a Alias Portc.5
      20. Seg_b Alias Portc.4
      21. Seg_c Alias Portc.3
      22. Seg_d Alias Portc.2
      23. Seg_e Alias Portc.1
      24. Seg_f Alias Portc.0
      25. Seg_g Alias Portb.5
      26. Seg_dot Alias Portb.4
      27. Gnd_digit_1 Alias Portd.2
      28. Gnd_digit_2 Alias Portd.3
      29. Gnd_digit_3 Alias Portd.4
      30. Gnd_digit_4 Alias Portb.5
      31. Do
      32. Gnd_digit_1 = 0
      33. Gnd_digit_2 = 0
      34. Gnd_digit_3 = 0
      35. Gnd_digit_4 = 0
      36. Seg_a = 1
      37. 'A
      38. Seg_b = 1
      39. 'B
      40. Seg_c = 1
      41. 'C
      42. Seg_d = 1
      43. 'D
      44. Seg_e = 1
      45. 'E
      46. Seg_f = 1
      47. 'F
      48. Seg_g = 1
      49. 'G
      50. Seg_dot = 1
      51. Waitms 10
      52. Loop
      Alles anzeigen
      Leider haben meine Chips alle ein paar Probleme mit den zählen will ich eine Variable hoch zählen klappt das manchmal und machmal nicht.

      Wenn er funktioniert funktioniert er aber immer und wenn nicht dann nicht...

      Grüße
      Alex
    • @Alex_T Was ich noch nicht kapiert hab', was willst du überhaupt machen? Soll das nur ein Test sein, oder willst du eine 4-stellige Anzeige haben. Dann fehlt ja das Multiplexen der einzelnen displays.
      Raum für Notizen

      -----------------------------------------------------------------------------------------------------

      -----------------------------------------------------------------------------------------------------
    • tschoeatsch schrieb:

      @Alex_T Was ich noch nicht kapiert hab', was willst du überhaupt machen? Soll das nur ein Test sein, oder willst du eine 4-stellige Anzeige haben. Dann fehlt ja das Multiplexen der einzelnen displays.
      Ich brauch nur vier Stellen für eine Uhr.
      Allerdings haut das von hinten bis vorne nicht hin.
      Scheint am MC zu liegen. Den wenn ich nur eine Ziffer hoch zählen lassen will und dann die nächste dann kommt es zu abstrusen fehlern.
      Erst zählt eine hoch mitendrin dan zwei.

      Muss mal versuchen einen meiner drei Reichelt MCs zu finden - das sind die einzigen die ich neu gekauft habe. Dank dem das der druck auf allen MCs schon verwaschen ist - ist das eine echte herausforderung.

      Vielleicht kann mal schnell jemand über meinen "Testcode" schauen vielleicht ist mir nur ein flüchtigkeitsfehler passiert.

      Grüße
      Alex

      Quellcode

      1. '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      2. $regfile = "m48def.dat" ' specify the used micro
      3. $crystal = 1000000 ' used crystal frequency
      4. $hwstack = 32 ' default use 32 for the hardware stack
      5. $swstack = 10 ' default use 10 for the SW stack
      6. $framesize = 40 ' default use 40 for the frame space
      7. Config Portc.5 = Output
      8. Config Portc.4 = Output
      9. Config Portc.3 = Output
      10. Config Portc.2 = Output
      11. Config Portc.1 = Output
      12. Config Portc.0 = Output
      13. Config Portb.5 = Output
      14. Config Portb.4 = Output
      15. Config Portd.2 = Output
      16. Config Portd.3 = Output
      17. Config Portd.4 = Output
      18. Config Portd.5 = Output
      19. Seg_a Alias Portc.5
      20. Seg_b Alias Portc.4
      21. Seg_c Alias Portc.3
      22. Seg_d Alias Portc.2
      23. Seg_e Alias Portc.1
      24. Seg_f Alias Portc.0
      25. Seg_g Alias Portb.5
      26. Seg_dot Alias Portb.4
      27. Gnd_digit_1 Alias Portd.2
      28. Gnd_digit_2 Alias Portd.3
      29. Gnd_digit_3 Alias Portd.4
      30. Gnd_digit_4 Alias Portb.5
      31. Dim Var_x As Byte
      32. Dim Var_y As Byte
      33. Dim Var_tmp_anzeige As Byte
      34. Declare Function Write_digit(byval Var_key As Byte , Byval Var_dot As Byte) As Byte
      35. Do
      36. Gnd_digit_1 = 1
      37. Gnd_digit_2 = 1
      38. Gnd_digit_3 = 1
      39. Gnd_digit_4 = 0
      40. Seg_a = 1
      41. Seg_b = 0
      42. Seg_c = 0
      43. Seg_d = 0
      44. Seg_e = 0
      45. Seg_f = 0
      46. Seg_g = 0
      47. Waitms 1000
      48. Seg_a = 0
      49. Seg_b = 1
      50. Seg_c = 0
      51. Seg_d = 0
      52. Seg_e = 0
      53. Seg_f = 0
      54. Seg_g = 0
      55. Waitms 1000
      56. Seg_a = 0
      57. Seg_b = 0
      58. Seg_c = 1
      59. Seg_d = 0
      60. Seg_e = 0
      61. Seg_f = 0
      62. Seg_g = 0
      63. Waitms 1000
      64. Seg_a = 0
      65. Seg_b = 0
      66. Seg_c = 0
      67. Seg_d = 1
      68. Seg_e = 0
      69. Seg_f = 0
      70. Seg_g = 0
      71. Waitms 1000
      72. Seg_a = 0
      73. Seg_b = 0
      74. Seg_c = 0
      75. Seg_d = 0
      76. Seg_e = 1
      77. Seg_f = 0
      78. Seg_g = 0
      79. Waitms 1000
      80. Seg_a = 0
      81. Seg_b = 0
      82. Seg_c = 0
      83. Seg_d = 0
      84. Seg_e = 0
      85. Seg_f = 1
      86. Seg_g = 0
      87. Waitms 1000
      88. Seg_a = 0
      89. Seg_b = 0
      90. Seg_c = 0
      91. Seg_d = 0
      92. Seg_e = 0
      93. Seg_f = 0
      94. Seg_g = 1
      95. Waitms 1000
      96. Gnd_digit_1 = 1
      97. Gnd_digit_2 = 1
      98. Gnd_digit_3 = 0
      99. Gnd_digit_4 = 1
      100. Seg_a = 1
      101. Seg_b = 0
      102. Seg_c = 0
      103. Seg_d = 0
      104. Seg_e = 0
      105. Seg_f = 0
      106. Seg_g = 0
      107. Waitms 1000
      108. Seg_a = 0
      109. Seg_b = 1
      110. Seg_c = 0
      111. Seg_d = 0
      112. Seg_e = 0
      113. Seg_f = 0
      114. Seg_g = 0
      115. Waitms 1000
      116. Seg_a = 0
      117. Seg_b = 0
      118. Seg_c = 1
      119. Seg_d = 0
      120. Seg_e = 0
      121. Seg_f = 0
      122. Seg_g = 0
      123. Waitms 1000
      124. Seg_a = 0
      125. Seg_b = 0
      126. Seg_c = 0
      127. Seg_d = 1
      128. Seg_e = 0
      129. Seg_f = 0
      130. Seg_g = 0
      131. Waitms 1000
      132. Seg_a = 0
      133. Seg_b = 0
      134. Seg_c = 0
      135. Seg_d = 0
      136. Seg_e = 1
      137. Seg_f = 0
      138. Seg_g = 0
      139. Waitms 1000
      140. Seg_a = 0
      141. Seg_b = 0
      142. Seg_c = 0
      143. Seg_d = 0
      144. Seg_e = 0
      145. Seg_f = 1
      146. Seg_g = 0
      147. Waitms 1000
      148. Seg_a = 0
      149. Seg_b = 0
      150. Seg_c = 0
      151. Seg_d = 0
      152. Seg_e = 0
      153. Seg_f = 0
      154. Seg_g = 1
      155. Waitms 1000
      156. Gnd_digit_1 = 1
      157. Gnd_digit_2 = 0
      158. Gnd_digit_3 = 1
      159. Gnd_digit_4 = 1
      160. Seg_a = 1
      161. Seg_b = 0
      162. Seg_c = 0
      163. Seg_d = 0
      164. Seg_e = 0
      165. Seg_f = 0
      166. Seg_g = 0
      167. Waitms 1000
      168. Seg_a = 0
      169. Seg_b = 1
      170. Seg_c = 0
      171. Seg_d = 0
      172. Seg_e = 0
      173. Seg_f = 0
      174. Seg_g = 0
      175. Waitms 1000
      176. Seg_a = 0
      177. Seg_b = 0
      178. Seg_c = 1
      179. Seg_d = 0
      180. Seg_e = 0
      181. Seg_f = 0
      182. Seg_g = 0
      183. Waitms 1000
      184. Seg_a = 0
      185. Seg_b = 0
      186. Seg_c = 0
      187. Seg_d = 1
      188. Seg_e = 0
      189. Seg_f = 0
      190. Seg_g = 0
      191. Waitms 1000
      192. Seg_a = 0
      193. Seg_b = 0
      194. Seg_c = 0
      195. Seg_d = 0
      196. Seg_e = 1
      197. Seg_f = 0
      198. Seg_g = 0
      199. Waitms 1000
      200. Seg_a = 0
      201. Seg_b = 0
      202. Seg_c = 0
      203. Seg_d = 0
      204. Seg_e = 0
      205. Seg_f = 1
      206. Seg_g = 0
      207. Waitms 1000
      208. Seg_a = 0
      209. Seg_b = 0
      210. Seg_c = 0
      211. Seg_d = 0
      212. Seg_e = 0
      213. Seg_f = 0
      214. Seg_g = 1
      215. Waitms 1000
      216. Gnd_digit_1 = 0
      217. Gnd_digit_2 = 1
      218. Gnd_digit_3 = 1
      219. Gnd_digit_4 = 1
      220. Seg_a = 1
      221. Seg_b = 0
      222. Seg_c = 0
      223. Seg_d = 0
      224. Seg_e = 0
      225. Seg_f = 0
      226. Seg_g = 0
      227. Waitms 1000
      228. Seg_a = 0
      229. Seg_b = 1
      230. Seg_c = 0
      231. Seg_d = 0
      232. Seg_e = 0
      233. Seg_f = 0
      234. Seg_g = 0
      235. Waitms 1000
      236. Seg_a = 0
      237. Seg_b = 0
      238. Seg_c = 1
      239. Seg_d = 0
      240. Seg_e = 0
      241. Seg_f = 0
      242. Seg_g = 0
      243. Waitms 1000
      244. Seg_a = 0
      245. Seg_b = 0
      246. Seg_c = 0
      247. Seg_d = 1
      248. Seg_e = 0
      249. Seg_f = 0
      250. Seg_g = 0
      251. Waitms 1000
      252. Seg_a = 0
      253. Seg_b = 0
      254. Seg_c = 0
      255. Seg_d = 0
      256. Seg_e = 1
      257. Seg_f = 0
      258. Seg_g = 0
      259. Waitms 1000
      260. Seg_a = 0
      261. Seg_b = 0
      262. Seg_c = 0
      263. Seg_d = 0
      264. Seg_e = 0
      265. Seg_f = 1
      266. Seg_g = 0
      267. Waitms 1000
      268. Seg_a = 0
      269. Seg_b = 0
      270. Seg_c = 0
      271. Seg_d = 0
      272. Seg_e = 0
      273. Seg_f = 0
      274. Seg_g = 1
      275. Waitms 1000
      276. For Var_x = 0 To 9 Step 1
      277. Gnd_digit_1 = 1
      278. Gnd_digit_2 = 1
      279. Gnd_digit_3 = 1
      280. Gnd_digit_4 = 0
      281. Var_tmp_anzeige = Write_digit(var_x , 0)
      282. Waitms 1000
      283. Next
      284. For Var_x = 0 To 9 Step 1
      285. Gnd_digit_1 = 1
      286. Gnd_digit_2 = 1
      287. Gnd_digit_3 = 0
      288. Gnd_digit_4 = 1
      289. Var_tmp_anzeige = Write_digit(var_x , 0)
      290. Waitms 1000
      291. Next
      292. For Var_x = 0 To 9 Step 1
      293. Gnd_digit_1 = 1
      294. Gnd_digit_2 = 0
      295. Gnd_digit_3 = 1
      296. Gnd_digit_4 = 1
      297. Var_tmp_anzeige = Write_digit(var_x , 0)
      298. Waitms 1000
      299. Next
      300. For Var_x = 0 To 9 Step 1
      301. Gnd_digit_1 = 0
      302. Gnd_digit_2 = 1
      303. Gnd_digit_3 = 1
      304. Gnd_digit_4 = 1
      305. Var_tmp_anzeige = Write_digit(var_x , 0)
      306. Waitms 1000
      307. Next
      308. Loop
      309. '##############################################
      310. '##############################################
      311. Function Write_digit(var_key As Byte , Var_dot As Byte)
      312. Local Var_input_ziffer As Byte
      313. Var_input_ziffer = Var_key
      314. If Var_input_ziffer = 0 Then
      315. Seg_a = 1
      316. 'A
      317. Seg_b = 1
      318. 'B
      319. Seg_c = 1
      320. 'C
      321. Seg_d = 1
      322. 'D
      323. Seg_e = 1
      324. 'E
      325. Seg_f = 1
      326. 'F
      327. Seg_g = 0
      328. 'G
      329. Seg_dot = Var_dot
      330. 'punkt
      331. Goto Endeif
      332. Elseif Var_input_ziffer = 1 Then
      333. Seg_a = 0
      334. 'A
      335. Seg_b = 1
      336. 'B
      337. Seg_c = 1
      338. 'C
      339. Seg_d = 0
      340. 'D
      341. Seg_e = 0
      342. 'E
      343. Seg_f = 0
      344. 'F
      345. Seg_g = 0
      346. 'G
      347. Seg_dot = Var_dot
      348. Goto Endeif
      349. Elseif Var_input_ziffer = 2 Then
      350. Seg_a = 1
      351. 'A
      352. Seg_b = 1
      353. 'B
      354. Seg_c = 0
      355. 'C
      356. Seg_d = 1
      357. 'D
      358. Seg_e = 1
      359. 'E
      360. Seg_f = 0
      361. 'F
      362. Seg_g = 1
      363. 'G
      364. Seg_dot = Var_dot
      365. Goto Endeif
      366. Elseif Var_input_ziffer = 3 Then
      367. Seg_a = 1
      368. 'A
      369. Seg_b = 1
      370. 'B
      371. Seg_c = 1
      372. 'C
      373. Seg_d = 1
      374. 'D
      375. Seg_e = 0
      376. 'E
      377. Seg_f = 0
      378. 'F
      379. Seg_g = 1
      380. 'G
      381. Seg_dot = Var_dot
      382. Goto Endeif
      383. Elseif Var_input_ziffer = 4 Then
      384. Seg_a = 0
      385. 'A
      386. Seg_b = 1
      387. 'B
      388. Seg_c = 1
      389. 'C
      390. Seg_d = 0
      391. 'D
      392. Seg_e = 0
      393. 'E
      394. Seg_f = 1
      395. 'F
      396. Seg_g = 1
      397. 'G
      398. Seg_dot = Var_dot
      399. Goto Endeif
      400. Elseif Var_input_ziffer = 5 Then
      401. Seg_a = 1
      402. 'A
      403. Seg_b = 0
      404. 'B
      405. Seg_c = 1
      406. 'C
      407. Seg_d = 1
      408. 'D
      409. Seg_e = 0
      410. 'E
      411. Seg_f = 1
      412. 'F
      413. Seg_g = 1
      414. 'G
      415. Seg_dot = Var_dot
      416. Goto Endeif
      417. Elseif Var_input_ziffer = 6 Then
      418. Seg_a = 1
      419. 'A
      420. Seg_b = 0
      421. 'B
      422. Seg_c = 1
      423. 'C
      424. Seg_d = 1
      425. 'D
      426. Seg_e = 1
      427. 'E
      428. Seg_f = 1
      429. 'F
      430. Seg_g = 1
      431. 'G
      432. Seg_dot = Var_dot
      433. Goto Endeif
      434. Elseif Var_input_ziffer = 7 Then
      435. Seg_a = 1
      436. 'A
      437. Seg_b = 1
      438. 'B
      439. Seg_c = 1
      440. 'C
      441. Seg_d = 0
      442. 'D
      443. Seg_e = 0
      444. 'E
      445. Seg_f = 0
      446. 'F
      447. Seg_g = 0
      448. 'G
      449. Seg_dot = Var_dot
      450. Goto Endeif
      451. Elseif Var_input_ziffer = 8 Then
      452. Seg_a = 1
      453. 'A
      454. Seg_b = 1
      455. 'B
      456. Seg_c = 1
      457. 'C
      458. Seg_d = 1
      459. 'D
      460. Seg_e = 1
      461. 'E
      462. Seg_f = 1
      463. 'F
      464. Seg_g = 1
      465. 'G
      466. Seg_dot = Var_dot
      467. Goto Endeif
      468. Elseif Var_input_ziffer = 9 Then
      469. Seg_a = 1
      470. 'A
      471. Seg_b = 1
      472. 'B
      473. Seg_c = 1
      474. 'C
      475. Seg_d = 1
      476. 'D
      477. Seg_e = 0
      478. 'E
      479. Seg_f = 1
      480. 'F
      481. Seg_g = 1
      482. 'G
      483. Seg_dot = Var_dot
      484. Goto Endeif
      485. End If
      486. Endeif:
      487. Write_digit = Var_input_ziffer
      488. End Function
      489. End
      Alles anzeigen

      Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von Alex_T ()

    • Also, jetzt verstehe ich nicht, warum du mit Funktionen arbeitest. Du möchtest doch eine Ziffer an einer Stelle anzeigen lassen. Dann mach das doch mit einer sub, der du die Ziffer und die Stelle übergibst/mitteilst. Der code dazu ist ja sehr ähnlich, aber insgesamt wird es übersichtlicher. Und wenn man nur port setzt, dann braucht man keine Funktion.
      Raum für Notizen

      -----------------------------------------------------------------------------------------------------

      -----------------------------------------------------------------------------------------------------
    • Vielleicht gibt's bei dir auch noch ein Missverständnis. Mit deiner Verschaltung kannst du nur eine Stelle mit einer Ziffer beschreiben. Würdest du eine weitere Stelle dazu schalten, dann zeigt diese dieselbe Ziffer. Wenn du an jeder Stelle eine eigene Ziffer anzeigen lassen willst, was bei einer Uhr zwingend wäre, musst du ständig die Stellen umschalten und die Ziffer zur passenden Stelle anzeigen lassen. Das meinte ich weiter oben mit dem Fehlen des Multiplexens.
      Raum für Notizen

      -----------------------------------------------------------------------------------------------------

      -----------------------------------------------------------------------------------------------------
    • Multiplexen bedeutet ja, dass immer eine Stelle nach der anderen ansteuert wird.
      Also zu erst wird Stelle 1 angesteuert (der Rest bleibt dunkel), dann Stelle 2 (Rest bleibt dunkel), usw. bis zur letzten Stelle.
      Dann geht das wieder von vorne los.

      Das sollte regelmäßig und schnell genug von Statten gehen, damit es nicht flackert.

      Aber anstelle einer Sub, die mit Angabe der Stelle und des Werts, der auszugeben ist, aufzurufen, würde ich die Ausgabe in eine Interrupt-Routine legen.
      Die ISR-Routine wählt die Stelle selbstständig und die Daten automatisch aus und steuert die Pins der Segmentanzeige.
      Eine ISR-Aufruf-Frequenz von 200Hz sollte gut und flackerfrei funktionieren. (50 Hz Wiederholrate für 4 Digits).

      Das hat den Vorteil, dass man sich im Hauptprogramm nicht um das Timing der Ausgabe kümmern muss. Dort kann man dann einfach die Variablen setzen,
      die zur Ausgabe der Uhrzeit oder sowas benötigt werden. Später wenn noch die Serielle Schnittstelle dazu kommt, kann es rucken und das sieht auf dem Display nicht schön aus.

      Und ich denke nicht, dass dein Problem mit dem Controller zu tun hat. Das liegt i.d.R. am Programm und damit am Programmierer.
      Der Controller macht immer genau das, was im Code steht. Der vertut sich bestimmt nicht.
      Seiteneffekte z.B. wegen zu geringem Frame mal außen vor.

      Übrigen ist dein SWStack mit 10 Byte recht knapp bemessen. Hier könnten Seiteneffekte auftreten. Dein Controller hat ausreichend Reserve,
      Den Wert kannst du bis auf Weiteres auf 40 setzen.

      In deiner Funktion übergibst du Werte (ByValue), damit sind dies schon Kopien der originalen Variable.
      Bedeutet, dass du davon in der Funktion nicht nochmal eine Kopie machen musst.

      Du kannst in der Abfrage also auch beruhigt "var_key" nehmen.
    • Pluto25 schrieb:

      Zeile 37 sollte d.5 nicht b.5 heißen.
      Vielen herzlichsten Dank!

      Genau das war der Fehler.

      Ich hab jetzt meine Platine wieder und wieder gereinigt - da ich dachte es wäre irgendeine "Brücke".
      Aber jetzt war es doch nur ein Flüchtigkeitsfehler. Schon überraschend wie man sowas bei 60 bis 70 mal durchlesen übersieht ;)

      Grüße
      Alex