Hallo,
hier mein Code.
Bisher sehe ich nur etwas wenn ich in Terminalfenster 1200Baud einstelle.
leider nicht mein Text sonder nur wirre Zeichen
Hier mein Code
Code:$regfile = "m8def.dat" $crystal = 7372800 $baud = 9600 Config Pinc.0 = Input ' Schaltport Config Pinc.1 = Input Config Pinc.2 = Input Config Pinc.3 = Input Config Pinc.4 = Input Config Pinc.5 = Input ' N.N. Config Portb.0 = Output ' Schaltport Config Portb.1 = Output Config Portb.2 = Output Config Portd.7 = Output Config Portd.6 = Output Config Portb.5 = Output ' Kontrollport Config Portd.2 = Output ' RS485 Dim I As Byte Dim Key As Byte Dim S As String * 7 Dim A As String * 4 Dim X1 As Boolean Dim X2 As Boolean Dim X3 As Boolean Dim X4 As Boolean Dim Z As String * 1 ' **** Timer ********************************************* Dim T1 As Long Dim T2 As Long Dim T3 As Long Dim T4 As Long Dim T5 As Long Dim R1 As Bit Dim R2 As Bit Dim R3 As Bit Dim R4 As Bit Dim R5 As Bit T1 = 0 T2 = 0 T3 = 0 T4 = 0 T5 = 0 Const Keys = 5 'Schaltstelle "$O001" ' Name der Schaltstelle ' Format: $O = Output ' $I = Input ' $IO = InOut ' **** Programmstart ************************************** Do R1 = Portb.0 R2 = Portb.1 R3 = Portb.2 R4 = Portd.6 R5 = Portd.7 ' **** RS485 Aktivieren und Bus prüfen On Urxc Onrxd Enable Urxc Enable Interrupts If Len(s) > 3 Then A = S S = "" Goto Pruefung Else Disable Interrupts Disable Urxc 'Portd.2 = 1 'Print 'Portd.2 = 0 End If 'Zeitschalter (Zähler) 10.000.000 = 30 Minute If T1 > 0 Then T1 = T1 + 1 If T1 > 30000000 Then Portd.6 = 0 T1 = 0 Else End If If T2 > 0 Then T2 = T2 + 1 If T2 > 80000000 Then Portb.0 = 0 T2 = 0 Else End If If T3 > 0 Then T3 = T3 + 1 If T3 > 30000000 Then Portb.2 = 0 T3 = 0 Else End If If T4 > 0 Then T4 = T4 + 1 If T4 > 15000000 Then Portd.7 = 0 T4 = 0 Else End If If T5 > 0 Then T5 = T5 + 1 If T5 > 30000000 Then Portb.1 = 0 T5 = 0 Else End If Portb.5 = 1 For I = 1 To Keys Key = I Select Case Key Case 1 : Debounce Pinc.0 , 0 , Key_o1 , Sub 'Port 1. Case 2 : Debounce Pinc.1 , 0 , Key_o2 , Sub 'Port 2 Case 3 : Debounce Pinc.2 , 0 , Key_o3 , Sub 'Port 3 Case 4 : Debounce Pinc.3 , 0 , Key_o4 , Sub 'Port 4 Case 5 : Debounce Pinc.4 , 0 , Key_o5 , Sub 'Port 5 End Select Next Loop Key_o1: Toggle Portb.0 'Buchse 1 Gosub Zustand If T2 = 0 Then T2 = 1 Else T2 = 0 End If Return Key_o2: Toggle Portb.1 'Buchse 2 Gosub Zustand If T5 = 0 Then T5 = 1 Else T5 = 0 End If Return Key_o3: Toggle Portb.2 'Buchse 3 Gosub Zustand If T3 = 0 Then T3 = 1 Else T3 = 0 End If Return Key_o5: Toggle Portd.6 'Buchse 4 Gosub Zustand If T1 = 0 Then T1 = 1 Else T1 = 0 End If Return Key_o4: Toggle Portd.7 'Buchse 5 Gosub Zustand If T4 = 0 Then T4 = 1 Else T4 = 0 End If Return '**************************************************** Onrxd: S = S + Chr(udr) Return '**************************************************** Pruefung: Z = Mid(a , 1 , 1 ) If Z = "!" Then Goto Auswerter A = Mid(s , 1 , 6) Else S = "" End If Return '**************************************************** Zustand: Disable Interrupts Disable Urxc Waitms 100 R1 = Portb.0 R2 = Portb.1 R3 = Portb.2 R4 = Portd.6 R5 = Portd.7 Disable Interrupts Disable Urxc Waitms 5 Portd.2 = 1 Waitms 10 Print Print "$O001" ; R1 ; R2 ; R3 ; R4 ; R5 Waitms 5 Portd.2 = 0 Return '**************************************************** Auswerter: Disable Interrupts Disable Urxc Waitms 100 Portd.2 = 1 Waitms 10 Print 'Print A Print "$O001" ; R1 ; R2 ; R3 ; R4 ; R5 Waitms 100 Portd.2 = 0 Return End







Zitieren

Lesezeichen