also ich habe das programm jetzt nochmal sehr vereinfacht, ohne Verriegelung der Relais und ohne Timer.
Code:
'--------------------------------- Chip Definiton ----------------------------
$regfile = "m8def.dat"
$crystal = 16000000
$baud = 1200
'--------------------------------- Portdefinition ----------------------------
Config Portb = Output
Config Portd = Output
Config Portc = Output
'----------------------------------------- Timer ------------------------------
Config Timer1 = Timer , Prescale = 256
Enable Interrupts
Enable Timer1
'------------------------------------------ Subs -----------------------------
Declare Sub Blinken
Declare Sub Rolloauf
Declare Sub Rolloab
'-------------------------------------- Dims --------------------------------
Dim I As Byte
Dim Temp1 As Byte
Dim Adresse As Byte
Dim Funktion As Byte
'Dim Myadress As Byte
Dim Stoppbyte As Byte
Dim X As Byte
'-------------------------------- Aliasse ------------------------------------
Auf Alias Portc.4
Ab Alias Portc.5
Rs485 Alias Portd.2
Led Alias Portb.1
'------------------------------------------ Syncbytes ------------------------
Const Sync = &B01010100
Const Myadress = &H02
'------------------------------------ Call Blinken ------------------------------
Call Blinken
Auf = 0 ' Relais Auf = 0
Ab = 0 ' Relais Ab = 0
'------------------------------------ Hauptroutine --------------------------
_start: ' RS485 Bus einlesen
Temp1 = Waitkey()
If Temp1 <> Sync Then
Goto _start
Else
Inputbin Adresse , Funktion , Stoppbyte
If Adresse <> Myadress Then Goto _start
If Funktion = &H01 Then Goto Rolloauf
If Funktion = &H02 Then Goto Rolloab
If Stoppbyte = &H7F Then Goto _start
End If
'--------------------------------------- Rolloauf -----------------------------
Rolloauf: ' Relais Auf umschalten
Led = 1
Waitms 100
Led = 0
Toggle Auf
Goto _start
'------------------------------------- Rolloab -------------------------------
Rolloab: ' Relais Ab umschalten
Led = 1
Waitms 100
Led = 0
Toggle Ab
Goto _start
'-------------------------------- Blinken --------------------------------------
Blinken:
Portb.1 = 1
Waitms 100
Portb.1 = 0
Waitms 100
Portb.1 = 1
Waitms 100
Portb.1 = 0
Waitms 100
Portb.1 = 1
Waitms 100
Portb.1 = 0
Waitms 100
Portb.1 = 1
Waitms 100
Portb.1 = 0
Waitms 100
Portb.1 = 1
Waitms 100
Portb.1 = 0
Waitms 100
Portb.1 = 1
Waitms 100
Portb.1 = 0
Waitms 100
Return
Gibt es denn eine einfache Weise, die Relais gegenseitig zu verriegeln, ohne großartig viele Hilfsvariablen ?
Lesezeichen