Przedstawiam mój zamek szyfrowy.
Pomysł zrodził się już klika miesięcy temu kiedy to wpadłem że taki zamek można zrobić na tyrystorach ale układ byłby wtedy zbyt skomplikowany.
Wiec od razu jak nauczyłem się obsługi procesorów skończyłem mój projekt.
Zamek ten otwiera np. zamek elektromagnetyczny po wpisaniu odpowiedniego 4-syfrowego kodu. Główną jednostką miał być tańszy i poostrzy Attiny2313 ale planuję w przyszłości zrobić obsługę LCD do zamka tak więc w swojej konstrukcji użyłem mikrokontroler AVR ATmega8535, który posiada więcej wyjsć/wejść i posiada 4 razy większa pamięć flash.
Układ składa się z dwóch części : manipulatora (klawiatury) i układu sterującego.
Manipulator :
Składa się z 12 przycisków od 0 do 12 + * i #. Umieściłem tam też dwukolorową diodę normalnie świecąca na czerwono a po podaniu stanu wysokiego na bazę jednego z tranzystorów zawarty w manipulatorze zmienia ona kolor na zielony.
Wszystkie przyciski zwierają do masy.
Układ sterujący :
Jak już wcześniej wspomniałem użyłem procesor Atmega8353. W układzie sterującym znajduje się także programator i zasilacz stabilizowany +5V/1,5A
W skład zasilacza wchodzi mostek kondensatory i stabilizator LM7812
Cały program napisałem w BASCOMIE.
Na razie wpisałem do niego 4 dostępne kody które otwierają zamek. Teoretycznie można wpisać dowolną liczbę.
Do pisania i kompilacji programu użyłem programu BASCOM AVR DEMO 11.8.3
W tytule napisałem, że to wersja 1.0 ponieważ będą następne, chociażby wersja rozszerzona o wyświetlacz alfanumeryczny LCD.
A koszty? Hm...
Procesor 15
podstawka 0,3
stabilizator 1
gniazda 4
obudowa 3
przyciski 8,4
kondesatory 3
rezystory 0,5
mostek 0,5
kable 3
diody 1,2
tranzystory 0,4
potencjometr 0,8
piezo 1
kwarc 0,4
RAZEM : 42,5
potem jeszcze postaram się schamt namalowac na komputerze bo narazie mam go na kartce.
Czekam na Waszeopinie!
AHA : no i jeszcze sam program :
' CODE LOCK
' Ports confuguration, konfiguracja portów
' A ports, porty A
Config Porta.0 = Input ' 1
Config Porta.1 = Input ' 2
Config Porta.2 = Input ' 3
Config Porta.3 = Input ' 4
Config Porta.4 = Input ' 5
Config Porta.5 = Input ' 6
Config Porta.6 = Input ' 7
Config Porta.7 = Input ' 8
Porta.0 = 1 ' 1
Porta.1 = 1 ' 2
Porta.2 = 1 ' 3
Porta.3 = 1 ' 4
Porta.4 = 1 ' 5
Porta.5 = 1 ' 6
Porta.6 = 1 ' 7
Porta.7 = 1 ' 8
' C ports, porty C
Config Portc.0 = Input ' 9
Config Portc.1 = Input ' *
Config Portc.2 = Input ' 0
Config Portc.3 = Input ' #
Config Portc.4 = Output ' LED output, wyjscie sterujace LED
Config Portc.5 = Output ' Speaker Output , Wyjscie Glosnikowe
Config Portc.6 = Output ' transistor output, wyjście sterujące tranzystorem
Config Portc.7 = Output ' LCD_led, podswietlenie LCD
Portc.0 = 1 ' 9
Portc.1 = 1 ' *
Portc.2 = 1 ' 0
Portc.3 = 1 ' #
Portc.4 = 0 ' LED output, wyjscie sterujace LED : wylączany / czerwony
Portc.5 = 0 ' Speaker Output , Wyjscie Glosnikowe : wylączany
Portc.6 = 0 ' transistor output, wyjście sterujące tranzystorem : wylączany
Portc.7 = 0 ' LCD_led, podswietlenie LCD : wyłączone
' Variables , zmienne
Dim A As Integer ' help variable no.1, zmienna pomocnicza nr.1
Dim B As Byte ' code digit no., numer cyfr z kodu
Dim Code1 As Integer ' code1, kod
Dim Code2 As Integer ' code2, kod
Dim Code3 As Integer ' code3, kod
Dim Code4 As Integer ' code4, kod
Dim T1 As Integer ' time 1, czas 1
Dim T2 As Integer ' opening time, czas otwarcia zamka
Dim Dur As Integer ' time 1, czas 1
Dim Fra As Integer
Begin:
A = 0
B = 0
Code1 = 1234 '
Code2 = 2345 '
Code3 = 3456 '
Code4 = 4567 '
T1 = 60 ' debounce
T2 = 1 ' seconds, sekundy
Dur = 30
Fra = 400
' Main program, glowny program
Do
If Pina.0 = 0 Then '1
If B = 0 Then A = A + 1000
If B = 1 Then A = A + 100
If B = 2 Then A = A + 10
If B = 3 Then A = A + 1
Sound Pinc.5 , Dur , Fra
P1:
Waitms T1
If Pina.0 = 0 Then Goto P1
Incr B
End If
If Pina.1 = 0 Then '2
If B = 0 Then A = A + 2000
If B = 1 Then A = A + 200
If B = 2 Then A = A + 20
If B = 3 Then A = A + 2
Sound Pinc.5 , Dur , Fra
P2:
Waitms T1
If Pina.1 = 0 Then Goto P2
Incr B
End If
If Pina.2 = 0 Then '3
If B = 0 Then A = A + 3000
If B = 1 Then A = A + 300
If B = 2 Then A = A + 30
If B = 3 Then A = A + 3
Sound Pinc.5 , Dur , Fra
P3:
Waitms T1
If Pina.2 = 0 Then Goto P3
Incr B
End If
If Pina.3 = 0 Then '4
If B = 0 Then A = A + 4000
If B = 1 Then A = A + 400
If B = 2 Then A = A + 40
If B = 3 Then A = A + 4
Sound Pinc.5 , Dur , Fra
P4:
Waitms T1
If Pina.3 = 0 Then Goto P4
Incr B
End If
If Pina.4 = 0 Then '5
If B = 0 Then A = A + 5000
If B = 1 Then A = A + 500
If B = 2 Then A = A + 50
If B = 3 Then A = A + 5
Sound Pinc.5 , Dur , Fra
P5:
Waitms T1
If Pina.4 = 0 Then Goto P5
Incr B
End If
If Pina.5 = 0 Then '6
If B = 0 Then A = A + 6000
If B = 1 Then A = A + 600
If B = 2 Then A = A + 60
If B = 3 Then A = A + 6
Sound Pinc.5 , Dur , Fra
P6:
Waitms T1
If Pina.5 = 0 Then Goto P6
Incr B
End If
If Pina.6 = 0 Then '7
If B = 0 Then A = A + 7000
If B = 1 Then A = A + 700
If B = 2 Then A = A + 70
If B = 3 Then A = A + 7
Sound Pinc.5 , Dur , Fra
P7:
Waitms T1
If Pina.6 = 0 Then Goto P7
Incr B
End If
If Pina.7 = 0 Then '8
If B = 0 Then A = A + 8000
If B = 1 Then A = A + 800
If B = 2 Then A = A + 80
If B = 3 Then A = A + 8
Sound Pinc.5 , Dur , Fra
P8:
Waitms T1
If Pina.7 = 0 Then Goto P8
Incr B
End If
If Pinc.0 = 0 Then '9
If B = 0 Then A = A + 9000
If B = 1 Then A = A + 900
If B = 2 Then A = A + 90
If B = 3 Then A = A + 9
Sound Pinc.5 , Dur , Fra
P9:
Waitms T1
If Pinc.0 = 0 Then Goto P9
Incr B
End If
If Pinc.1 = 0 Then '*
Waitms 25
Sound Pinc.5 , 200 , 500
Waitms 100
Sound Pinc.5 , 200 , 500
Goto Begin
End If
If Pinc.2 = 0 Then '0
Sound Pinc.5 , Dur , Fra
P11:
Waitms T1
If Pinc.2 = 0 Then Goto P11
Incr B
End If
If Pinc.3 = 0 Then '#
Goto Check
End If
Loop
Check:
If Code1 = A Or Code2 = A Or Code3 = A Or Code4 = A Then
Sound Pinc.5 , 100 , 300
Sound Pinc.5 , 100 , 200
P12:
Portc.4 = 1
Portc.6 = 1
Waitms T1
If Pinc.3 = 0 Then Goto P12
Wait T2
Portc.4 = 0
Portc.6 = 0
Goto Begin
End If
If Code1 <> A Then
Portc.4 = 0
Portc.6 = 0
Sound Pinc.5 , 100 , 200
Sound Pinc.5 , 100 , 300
P13:
Waitms T1
If Pinc.3 = 0 Then Goto P13
Goto Begin
End If
End ' End programprogram nie jest idealny, ma liczne błędy ale ważne, że sie nie da złamać kodu
Fajne? Ranking DIY