Alarm unit

From uCtrl.net

(Redirected from ALU)
Jump to: navigation, search
Symbols-Delete-256x256.png
Rack fullsize plan.png
The Rack box project is being discontinued!
I am moving to a new location, and therefor terminating the Rack box project, my plan is to build an even bigger system based on slot-in cards in a full size rack. I'll keep you posted. Feel tree to leave a comment if you have any question.
ALU installed in the Rack box

ALU, driven by AVR ATTiny2313.

Contents

Information

ALU is a alarm central unit with two modes, see below. They can be activated with a key switch on the status panel, when the key is turned green and red LED will toggle. If the key is turned again on green LED mode 1 is activated, and on red LED mode 2. Both modes can also be activated and deactivated from the User panel for alarm.

Mode 1

Away mode, this has no alarm function. When active the status panel is turned off, system mute is active and lights in the apartment is turned off (via. LCU and MPM1). If it's dark in the light will turn on automatically if there is movement in the hall (via. LCU).

Mode 2

When activated the system counts down 6o seconds for you to leave the area. During this countdown the alarm LED and the green LED is flashing, short bursts from the buzzer. If a alarm or tamper input is active the alarm can not be turned on. If tamper should be activated during the countdown the buzzer will give long signals. When the countdown is complete the alarm is armed, the status panel turns off, system mute is activated and the apartment lights is turned off (via. LCU).

When the alarm is triggered you have 30 seconds to deactivate, or the siren will sound. The alarm LED and red LED flash fast, long signals from the buzzer. If the tamper circuit is broken the siren will sound instantly. If it's dark in the light will turn on automatically if there is movement in the hall (via. LCU). If the alarm has been tripped the alarm LED will stay on until the alarm is activated again.

I/O

Inputs

  1. PD0 Key switch N.O
  2. PD1 Key switch N.C
  3. PD2 Alarm trigger N.C
  4. PD3 Buzzer trigger
  5. PD4 Trigger mode 1
  6. PD5 Trigger mode 2
  7. PD6 Tamper N.C

Outputs

  1. PB0 Alarm LED
  2. PB1 Green LED
  3. PB2 Red LED
  4. PB3 Buzzer in status panel
  5. PB4 Siren
  6. PB5 Lights out to LCU
  7. PB6 Away mode relay
  8. PB7 Lifesignal (to MSMU2)

D-Sub 9 pin

Connector 1

  1. 5V
  2. 0V
  3. In 1 (Key switch N.O)
  4. In 2 (Key switch N.C)
  5. In 3 (Alarm trigger N.C)
  6. In 4 (Buzzer trigger)
  7. In 5 (Trigger mode 1)
  8. In 6 (Trigger mode 2)
  9. +12V Status LED

Connector 2

  1. In 7 (Tamper N.C)
  2. Out 1 (Alarm LED)
  3. Out 2 (Green LED)
  4. Out 3 (Red LED)
  5. Out 4 (Buzzer in status panel)
  6. Out 5 (Siren)
  7. Out 6 (Lights out to LCU)
  8. Out 7 (Away mode relay)
  9. Out 8 (Lifesignal)

Parts list

Quantity Supplier Part number Description
1 Elfa 73-646-56 AVR-RISC, ATtiny2313-20PI
1 Elfa 50-197-32 Plastic Enclosure (1591 FL), 120x65x40mm fixed install.
2 Elfa 44-055-51 D-Sub soldering cups, 9 pin male
1 Elfa 44-055-02 D-Sub soldering cups, 9 pin female
1 Elfa 48-161-53 DIL socket, 20-pin, 7,62mm
2 Elfa 48-884-18 Unthreaded round spacer, 3mm, Ø6mm
1 Elfa 67-008-01 Aluminium electrolytic capacitor, 10uF 25V
1 Elfa 65-851-94 Ceramic Disc Capacitor, 1 nF 100V
1 Elfa 48-326-06 Laboratory card, 100x160mm (1/5)
1 Elfa 75-034-44 LED 5mm coloured clear, Green, 2.1V, 20mA, 30mcd, 10°
2 Elfa 75-007-13 LED 5mm, Red/Green, 2.0 2.1V, 10mA, 100 63mcd, 30°
3 LED1.de 805082 LED holder 5mm, Black plastic
1 Elfa 33-711-35 LED lamp 5mm, red, Ø8.0mm, 12V, 20mA, 15mcd
7 Elfa 60-106-15 Carbon film resistor 5% 1/4W, 10 K
10 Elfa 60-104-33 Carbon film resistor 5% 1/4W, 330 Ohm
9 Elfa 60-105-73 Carbon film resistor 5% 1/4W, 4,7 K
21 Elfa 43-708-05 Socket connector 2,54, 1×36, female
23 Elfa 43-702-19 Straight pin header 2,54, 1×36, PCB
1 Elfa 33-167-18 Fuse 5x20 mm, 400 mA, quick-acting
1 Elfa 33-150-17 Open fuse holder, PCB, 5x20mm
1 Elfa 33-150-25 Open fuse holder, PCB, Protective cover
8 Elfa 71-027-59 Transistor BC547B, NPN, 45V 0.1A 0.625W

Images

Schematic drawing

Alu circuit.png

Source code

The program is written in basic, using Bascom-AVR.

'--------------------------------------------------------------
'                         Thomas Jensen
'--------------------------------------------------------------
'  file: AVR_ALU_v.1.0
'  date: 07/11/2007
'--------------------------------------------------------------
$regfile = "attiny2313.dat"
$crystal = 8000000
Config Portd = Input
Config Portb = Output
Config Watchdog = 1024
 
Dim Lifesignal As Byte , Alloff As Byte , Nokkel As Byte , Nokkel_turned As Byte
Dim Horn As Byte , Armed As Byte , Button1 As Byte , Button2 As Byte
Dim Modesel As Byte , A As Byte , Alarmled As Byte , Utlost As Byte , B As Byte
 
If Pind.0 = 0 Then Nokkel = 1
If Pind.1 = 0 Then Nokkel = 2
If Nokkel = 0 Then Portb.3 = 1
 
Do
Portb.0 = 1
Waitms 100
Gosub Doloop
Portb.0 = 0
If Nokkel_turned = 1 Then
   Nokkel_turned = 0
   Start Watchdog
   Goto Main
   End If
Waitms 100
Gosub Doloop
Loop
 
Main:
If Nokkel_turned = 1 And Armed = 0 Then                     'key NO and NC
   Nokkel_turned = 0
   Portb.0 = 0
   For A = 1 To 7
   Portb.1 = 1
   Portb.2 = 0
   For B = 1 To 15
   Waitms 100
   Gosub Doloop
   Next B
   If Nokkel_turned = 1 Then Goto Selectmode
   Portb.1 = 0
   Portb.2 = 1
   For B = 1 To 15
   Waitms 100
   Gosub Doloop
   Next B
   If Nokkel_turned = 1 Then Goto Selectmode
   Next A
   Portb.1 = 0
   Portb.2 = 0
End If
 
If Nokkel_turned = 1 And Armed = 1 Then
   Nokkel_turned = 0
   Modesel = 0
   Armed = 0
   End If
 
If Modesel = 2 And Armed = 0 Then                           'arm alarm
      If Pind.2 = 1 Or Pind.6 = 1 Then
      Horn = 10
      Modesel = 0
      Goto Main
      End If
   Utlost = 0
   For A = 1 To 60
   Portb.0 = 1
   Portb.1 = 1
   Portb.3 = 1
   Waitms 100
   Portb.3 = 0
   Gosub Doloop
   Waitms 100
   Gosub Doloop
   Waitms 100
   If Pind.6 = 1 Then Portb.3 = 1
   Gosub Doloop
   Waitms 100
   Gosub Doloop
   Waitms 100
   Gosub Doloop
   Portb.0 = 0
   Portb.1 = 0
   Waitms 100
   Gosub Doloop
   Waitms 100
   Gosub Doloop
   Waitms 100
   Portb.3 = 0
   Gosub Doloop
   Waitms 100
   Gosub Doloop
   Waitms 100
   Gosub Doloop
   If Nokkel_turned = 1 Then
      Nokkel_turned = 0
      Modesel = 0
      Goto Main
      End If
   Next A
      If Pind.2 = 1 Then
      Horn = 10
      Modesel = 0
      Goto Main
      End If
   Armed = 1
   Alloff = 5
   End If
 
If Armed = 1 Then Portb.6 = 1
 
If Armed = 1 And Modesel = 2 Then
   If Alarmled = 0 Then Alarmled = 10
   If Pind.2 = 1 Then Goto Alarm
End If
 
If Armed = 0 Then
   Portb.6 = 0
   If Utlost = 1 Then Portb.0 = 1
   If Modesel = 1 Then
      Alarmled = 10
      Armed = 1
      Alloff = 5
      End If
End If
 
Waitms 100
Gosub Doloop
Goto Main
End
 
Alarm:                                                      'alarm triggered
   For A = 1 To 30
   Portb.0 = 1
   Portb.2 = 1
   Portb.3 = 1
   Waitms 100
   Portb.0 = 0
   Gosub Doloop
   Waitms 100
   Portb.0 = 1
   Gosub Doloop
   Waitms 100
   Portb.0 = 0
   Gosub Doloop
   Waitms 100
   Portb.0 = 1
   Gosub Doloop
   Waitms 100
   Portb.0 = 0
   Portb.2 = 0
   Portb.3 = 0
   Gosub Doloop
   Waitms 100
   Gosub Doloop
   Waitms 100
   Gosub Doloop
   Gosub Doloop
   Waitms 100
   Gosub Doloop
   Waitms 100
   Gosub Doloop
   Waitms 100
   Gosub Doloop
   If Nokkel_turned = 1 Then
      Nokkel_turned = 0
      Modesel = 0
      Armed = 0
      Goto Main
      End If
   If Pind.6 = 1 Then Goto Sirene
   Next A
 
   Sirene:                                                  'siren
   For A = 1 To 60
   Utlost = 1
   Portb.0 = 1
   Portb.3 = 1
   Portb.4 = 1
   Waitms 100
   Portb.0 = 0
   Gosub Doloop
   Waitms 100
   Portb.0 = 1
   Gosub Doloop
   Waitms 100
   Portb.0 = 0
   Gosub Doloop
   Waitms 100
   Portb.0 = 1
   Gosub Doloop
   Waitms 100
   Portb.0 = 0
   Portb.3 = 0
   Waitms 100
   Gosub Doloop
   Waitms 100
   Gosub Doloop
   Waitms 100
   Gosub Doloop
   Waitms 100
   Gosub Doloop
   Waitms 100
   Gosub Doloop
   If Nokkel_turned = 1 Then
      Nokkel_turned = 0
      Portb.4 = 0
      Modesel = 0
      Armed = 0
      Goto Main
      End If
   Next A
   Portb.4 = 0
   Goto Main
 
End
 
Selectmode:                                                 'select mode
Nokkel_turned = 0
If Portb.1 = 1 Then Modesel = 1
If Portb.2 = 1 Then Modesel = 2
Portb.1 = 0
Portb.2 = 0
Goto Main
End
 
Doloop:
'Key turned
If Pind.0 = 0 And Pind.1 = 1 And Nokkel = 2 Then            '1
   Nokkel = 1
   Nokkel_turned = 1
   End If
If Pind.0 = 1 And Pind.1 = 0 And Nokkel = 1 Then            '2
   Nokkel = 2
   Nokkel_turned = 1
   End If
 
'Ext button 1
If Pind.4 = 0 And Button1 = 0 Then
   Button1 = 1
   If Modesel = 1 Then
      Nokkel_turned = 1
      Goto Endofbutton1
      End If
   If Modesel = 0 Then Modesel = 1
   Endofbutton1:
   End If
If Pind.4 = 1 Then Button1 = 0
 
'Ext button 2
If Pind.5 = 0 And Button2 = 0 Then
   Button2 = 1
   If Modesel = 2 Then
      Nokkel_turned = 1
      Goto Endofbutton2
      End If
   If Modesel = 0 Then Modesel = 2
   Endofbutton2:
   End If
If Pind.5 = 1 Then Button2 = 0
 
'Buzzer
If Pind.3 = 0 And Horn = 0 Then Horn = 10
If Horn = 10 Then Portb.3 = 1
If Horn = 7 Then Portb.3 = 0
If Horn > 0 Then Horn = Horn - 1
 
'All off
If Alloff = 5 Then Portb.5 = 1
If Alloff = 2 Then Portb.5 = 0
If Alloff > 0 Then Alloff = Alloff - 1
 
'AlarmLED
If Alarmled = 10 Then Portb.0 = 1
If Alarmled = 9 Then Portb.0 = 0
If Alarmled > 0 Then Alarmled = Alarmled - 1
 
'Lifesignal
If Lifesignal > 0 Then Lifesignal = Lifesignal - 1
If Lifesignal = 6 Then Portb.7 = 1
If Lifesignal = 1 Then Portb.7 = 0
If Lifesignal = 0 Then Lifesignal = 21
 
Reset Watchdog
Return
End
Personal tools
Namespaces
Variants
Actions
Navigation
Categories
projects
Toolbox