Ein Adapter für SerialCominstruments 4

    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!

    • Ein Adapter für SerialCominstruments 4

      Hab mal ein bisschen mit SerialCominstruments 4 rum gespielt und eine Testschaltung mit 6 AD Eingängen(bis 100 VDC), 2 Digitalausgängen(LED zum testen) sowie 1 DAC Ausgang (PWM) aufgebaut. Ich wollte nur mal sehen, wie die Kommunikation mit dem Programm funktioniert, und zwar in beide Richtungen. Da es ein gutes Manual dazu gibt, war es gar nicht so schwierig. Vielleicht kann ja jemand etwas davon gebrauchen. Man kann damit Mess-oder Zählwerte visualisieren und auch den ATMega mit Schaltern und Schiebereglern fernsteuern. Diese Funktionen kann man dem Code entnehmen und für seine Bedürfnisse anpassen(und sicherlich auch noch verbessern). Viel Spass damit.

      Gruß Thomas

      Screenshot (5).png20180606_183217.jpg

      Quellcode

      1. $regfile = "m8def.dat"
      2. $crystal = 8000000
      3. $hwstack=40
      4. $swstack=16
      5. $framesize=32
      6. $baud = 115200
      7. '----------------------------------------------------------------------------------------------------------------------
      8. 'AD-Wandler einschalten
      9. Config Adc = Single , Prescaler = Auto , Reference = Internal
      10. Start Adc
      11. '----------------------------------------------------------------------------------------------------------------------
      12. 'INT UART-Empfang Int nach jedem empfangenen Byte
      13. Enable Urxc
      14. On Urxc Uart0 'ISR
      15. Enable Interrupts 'generell Interrupts einschalten
      16. '----------------------------------------------------------------------------------------------------------------------
      17. Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up , Prescale = 64
      18. '----------------------------------------------------------------------------------------------------------------------
      19. Config Portd.7 = Output
      20. Config Portb.0 = Output
      21. Led1 Alias Portd.7
      22. Led2 Alias Portb.0
      23. '----------------------------------------------------------------------------------------------------------------------
      24. Dim I1 As Single
      25. Dim I2 As Single
      26. Dim I3 As Single
      27. Dim I4 As Single
      28. Dim I5 As Single
      29. Dim I6 As Single
      30. Dim Z As Byte
      31. Dim N As Byte
      32. Dim U As Word
      33. Dim Tabelle1(50) As Word
      34. Dim Tabelle2(50) As Word
      35. Dim Tabelle3(50) As Word
      36. Dim Tabelle4(50) As Word
      37. Dim Tabelle5(50) As Word
      38. Dim Tabelle6(50) As Word
      39. Dim Index As Byte
      40. Dim Median As Word
      41. Dim S As String * 13
      42. Dim Dat As Byte
      43. Dim Byte_wert As Byte
      44. Dim Pwm_wert As Byte
      45. Dim Stellwert As String * 3
      46. Dim Status As String * 1
      47. Dim Aktor As String * 2
      48. Pwm1b = 0
      49. Led1 = 1
      50. Waitms 200
      51. Led2 = 1
      52. Waitms 200
      53. Led1 = 0
      54. Led2 = 0
      55. Do
      56. If Dat = 10 Then 'ENDE-Zeichen von UART auswerten
      57. Print S 'String zurück schicken zu Kontrolle im Terminal
      58. Gosub Ausführen
      59. S = "" 'String löschen
      60. Dat = 0 'zuletzt empfangenes Byte löschen
      61. End If
      62. Index = Index + 1
      63. U = Getadc(0)
      64. Waitus 300
      65. Tabelle1(index) = U
      66. U = Getadc(1)
      67. Waitus 300
      68. Tabelle2(index) = U
      69. U = Getadc(2)
      70. Waitus 300
      71. Tabelle3(index) = U
      72. U = Getadc(3)
      73. Waitus 300
      74. Tabelle4(index) = U
      75. U = Getadc(4)
      76. Waitus 300
      77. Tabelle5(index) = U
      78. U = Getadc(5)
      79. Waitus 300
      80. Tabelle6(index) = U
      81. If Index = 50 Then
      82. Gosub Median50
      83. Print "#1M" ; Str(i1) ; "<" ; "#2M" ; Str(i2) ; "<" ; "#3M" ; Str(i3) ; "<" ; "#4M" ; Str(i4) ; "<" ; "#5M" ; Str(i5) ; "<" ; "#6M" ; Str(i6) ; "<"
      84. End If
      85. Loop
      86. Ausführen:
      87. Aktor = Mid(s , 2 , 2) 'Aktoren(DAC und Schalter) müssen 2-Stellige Kanalnummern haben
      88. Status = Mid(s , 5 , 1)
      89. If Aktor = "20" Then 'Schalter
      90. If Status = "0" Then 'Aus
      91. Led1 = 0
      92. Elseif Status = "1" Then 'Ein
      93. Led1 = 1
      94. End If
      95. Elseif Aktor = "21" Then 'Schalter
      96. If Status = "0" Then 'Aus
      97. Led2 = 0
      98. Elseif Status = "1" Then 'Ein
      99. Led2 = 1
      100. End If
      101. Elseif Aktor = "10" Then 'DAC Kanal 10 auf Format"000" stellen, damit immer 3-stellig
      102. Stellwert = Mid(s , 5 , 1)
      103. Pwm_wert = Stellwert - 48 'wegen ASCII im String
      104. Pwm_wert = Pwm_wert * 100 ' Hunderter
      105. Stellwert = Mid(s , 6 , 1)
      106. Byte_wert = Stellwert - 48
      107. Byte_wert = Byte_wert * 10 'Zehner
      108. Pwm_wert = Pwm_wert + Byte_wert
      109. Stellwert = Mid(s , 7 , 1)
      110. Byte_wert = Stellwert - 48 'Einer
      111. Pwm_wert = Pwm_wert + Byte_wert
      112. Print "#7M" ; Str(pwm_wert) ; "<" 'für eine Kontroll-Anzeige (Kanal 7)
      113. Pwm1b = Pwm_wert
      114. End If
      115. Return
      116. '---------------------------------------------------------------------------------------
      117. Median50:
      118. For N = 1 To 24 '24mal kleinsten Wert in Tabelle suchen und auf 65000 setzen
      119. Min(tabelle1(1) , Median , Index)
      120. Tabelle1(index) = 65000
      121. Next
      122. Min(tabelle1(1) , Median , Index) 'der 25. minwert ist der Median
      123. I1 = Median / 10
      124. For N = 1 To 24
      125. Min(tabelle2(1) , Median , Index)
      126. Tabelle2(index) = 65000
      127. Next
      128. Min(tabelle2(1) , Median , Index)
      129. I2 = Median / 10
      130. For N = 1 To 24
      131. Min(tabelle3(1) , Median , Index)
      132. Tabelle3(index) = 65000
      133. Next
      134. Min(tabelle3(1) , Median , Index)
      135. I3 = Median / 10
      136. For N = 1 To 24
      137. Min(tabelle4(1) , Median , Index)
      138. Tabelle4(index) = 65000
      139. Next
      140. Min(tabelle4(1) , Median , Index)
      141. I4 = Median / 10
      142. For N = 1 To 24
      143. Min(tabelle5(1) , Median , Index)
      144. Tabelle5(index) = 65000
      145. Next
      146. Min(tabelle5(1) , Median , Index)
      147. I5 = Median / 10
      148. For N = 1 To 24
      149. Min(tabelle6(1) , Median , Index)
      150. Tabelle6(index) = 65000
      151. Next
      152. Min(tabelle6(1) , Median , Index)
      153. I6 = Median / 10
      154. Index = 0
      155. Return
      156. Uart0:
      157. Dat = Inkey() 'empfangenes Byte einlesen
      158. S = S + Chr(dat) 'zum String dazu fügen
      159. Return
      Alles anzeigen
    • Limo schrieb:

      Hab mal ein bisschen mit SerialCominstruments 4
      hast du einen link zu dieser sw?
      Bei dem 'Spannungsplot', ist das Rauschen, oder hast du an der Spannungshöhe gespielt?
      Raum für Notizen

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

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