Witam. Poniżej przedstawiam program do procesora Attiny2313 oraz schemat sterowania bramą. Układ ma działać na czterech przekaźnikach - dwa do otwierania i zamykania oraz jeden do domykania oraz jeden do wolnego otwierania w fazie początkowej. Dodatkowo układ ma zabezpieczenie do bezpiecznika przeciwprzeciążeniowego C8 oraz podłączenie do bariery optycznej. Sterowanie jest realizowane przez jeden przycisk (zasada, otwórz - stop - zamknij - stop) oraz trzy mikrowyłączniki NO - zamknięte, uchylone, otwarte. I jdenak coś nie działa. Proszę o pomoc w diagnozie.
Listing programu w BASCOMie.
A poniżej schemat:

Listing programu w BASCOMie.
$regfile = "Attiny2313.dat"
$crystal = 1000000
Config Portb = Input
Portb = &B00000000
Config Portd = Output
Portd = &B0000000
Pinb.5 = 1
Wolne_otwieranie Alias Portd.0
Otwieranie Alias Portd.1
Wolne_zamykanie Alias Portd.2
Zamykanie Alias Portd.3
Kran_close Alias Pinb.0
Kran_middle Alias Pinb.1
Kran_open Alias Pinb.2
Switch Alias Pinb.3
Bariera Alias Pinb.4
Przeciazenie Alias Pinb.5
Dim Pozycja As Integer
Dim Stan As Bit
Pozycja = 11
Stan = 0
Do
If Switch = 1 And Stan = 0 And Przeciazenie = 1 Then
Stan = 1
If Pozycja = 21 And Wolne_zamykanie = 1 Then
Wolne_zamykanie = 0
Pozycja = 11
Elseif Pozycja = 21 And Wolne_zamykanie = 0 Then
Wolne_zamykanie = 1
Cls
Elseif Pozycja = 11 And Wolne_otwieranie = 1 Then
Wolne_otwieranie = 0
Pozycja = 21
Elseif Pozycja = 11 And Wolne_otwieranie = 0 Then
Wolne_otwieranie = 1
Elseif Pozycja = 12 And Otwieranie = 1 Then
Otwieranie = 0
Pozycja = 22
Elseif Pozycja = 12 And Otwieranie = 0 Then
Otwieranie = 1
Elseif Pozycja = 22 And Zamykanie = 1 Then
Zamykanie = 0
Pozycja = 12
Elseif Pozycja = 22 And Zamykanie = 0 Then
Zamykanie = 1
End If
Elseif Kran_close = 1 And Wolne_zamykanie = 1 Then
Wolne_zamykanie = 0
Pozycja = 11
Elseif Kran_open = 1 And Otwieranie = 1 Then
Otwieranie = 0
Pozycja = 22
Elseif Pozycja = 11 And Kran_middle = 1 And Wolne_otwieranie = 1 Then
Wolne_otwieranie = 0
Waitms 500
Otwieranie = 1
Pozycja = 12
Elseif Pozycja = 22 And Kran_middle = 1 And Zamykanie = 1 Then
Zamykanie = 0
Waitms 500
Wolne_zamykanie = 1
Pozycja = 21
Elseif Bariera = 1 And Pozycja = 22 And Zamykanie = 1 Then
Zamykanie = 0
Waitms 500
Otwieranie = 1
Pozycja = 12
End If
If Switch = 0 Then
Stan = 0
End If
If Przeciazenie = 0 Then
If Pozycja = 11 And Wolne_otwieranie = 1 Then
Wolne_otwieranie = 0
Pozycja = 21
Elseif Pozycja = 12 And Otwieranie = 1 Then
Otwieranie = 0
Pozycja = 22
Elseif Pozycja = 21 And Wolne_zamykanie = 1 Then
Wolne_zamykanie = 0
Pozycja = 11
Elseif Pozycja = 22 And Zamykanie = 1 Then
Zamykanie = 0
Pozycja = 12
End If
End If
Loop
End
A poniżej schemat:
