User panel for alarm

From uCtrl.net

Jump to: navigation, search
UPA

UPA, driven by AVR ATTiny2313.

Contents

Information

UPA is a user panel for ALU, where the user can enter his/her PIN and activate mode 1 (away mode) or 2 (intruder alarm). The module is monitored by MSMU2 and a tamper circuit, this will give instant alarm if disconnected. It's not possible to activate mode 2 (intruder alarm) if UPA is disconnected. The PIN is stored in EEPROM and saved trough a power loss.

Mode 1

To activate mode 1 enter PIN + *, a one second green light indicates approved PIN and confirms command.

Mode 2

To activate mode 2 enter PIN + #, a two seconds green light indicates approved PIN and confirms command.

Change PIN

To change PIN enter current PIN + 0, yellow light indicates programming mode. The new PIN is entered and confirmed with #, green light. Any other button will reject the new code and keep the old one, red light indicates this.

When entering wrong PIN

When the wrong PIN is entered you get a red light. If the wrong PIN is entered three times the panel will not be usable for one minute. The red light will flash during this period.

I/O

Inputs

  1. PD2 Keypad 1
  2. PD3 Keypad 2
  3. PD4 Keypad 3
  4. PD5 Keypad 4

Outputs

  1. PB0 Keypad 1
  2. PB1 Keypad 2
  3. PB2 Keypad 3
  4. PB3 Channel 1
  5. PB4 Channel 2
  6. PB5 Green LED
  7. PB6 Red LED
  8. PB7 Lifesignal (to MSMU2)

D-Sub 9-pin

Pin Color Function
1. Pink 5V
2. Grey 0V
3. Yellow Channel 1
4. Black Channel 2
5. Green Tamper N.C
6. Blue Lifesignal (to MSMU2)
7. Red Alarm LED from ALU
8. Purple Green LED from ALU
9. Brown Red LED from ALU

Keypad

Tastatur 12-knapper.jpg
  1. n/a
  2. K3
  3. K2
  4. K1
  5. R1
  6. R2
  7. R3
  8. R4

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.
1 Elfa 44-093-55 D-Sub plastic hood, 9-pin, black
1 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
1 Elfa 48-884-18 Unthreaded round spacer, 3mm, Ø6mm
1 Elfa 25-962-11 D-sub cable, pin-to-pin 1,8m, 9-pin male-female
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-016-04 LED 5mm clear, Red, 2.0V, 20mA, 140mcd, 6°
3 Elfa 75-007-13 LED 5mm, Red/Green, 2.0 2.1V, 10mA, 100 63mcd, 30°
1 Elfa 75-031-70 LED reflector 5 mm, Chrome-plated plastic
3 LED1.de 805082 LED holder 5mm, Black plastic
1 Elfa 55-721-69 Control cable 10-cores, 0,14mm2, 18x0,10mm 250 V, Ø 5,4mm
1 Elfa 60-714-68 Metal film resistor 1% 0,6W, 200 ohm
4 Elfa 60-106-15 Carbon film resistor 5% 1/4W, 10 K
8 Elfa 60-104-33 Carbon film resistor 5% 1/4W, 330 Ohm
4 Elfa 60-105-73 Carbon film resistor 5% 1/4W, 4,7 K
16 Elfa 43-708-05 Socket connector 2,54, 1×36, female
16 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-152-31 Fuse Holder, wire, 5x20 / 6,3x32mm
3 Elfa 55-141-12 Cable Tie Mounts, skrew, Max 5mm
1 Elfa 35-678-07 Keyboard 12 Buttons, AK-804
3 Elfa 71-027-59 Transistor BC547B, NPN, 45V 0.1A 0.625W

Images

Schematic drawing

Upa circuit.png

Source code

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

'--------------------------------------------------------------
'                         Thomas Jensen
'--------------------------------------------------------------
'  file: AVR_UPA_v.1.0
'  date: 17/11/2007
'--------------------------------------------------------------
$regfile = "attiny2313.dat"
$crystal = 8000000
Config Portd = Input
Config Portb = Output
Config Watchdog = 1024
 
Dim Lifesignal As Byte , Number As Byte , Row As Byte , Button As Byte
Dim Code1 As Integer , Code2 As Integer , Code3 As Byte , Code4 As Byte , Nr As Byte
Dim Redled As Byte , Greenled As Byte , Amberled As Byte , Code As Integer
Dim Code_p As Integer , Kanal1 As Byte , Kanal2 As Byte , Timeout As Byte , Feil As Integer
Dim Eeprom As Eram Integer , Program As Byte , Feil_a As Byte
 
Code_p = Eeprom                                             'Get stored code
If Code_p < 0 Then Code_p = 1234                            'If no code use default
Number = 255
 
'Boot
Portb = 0
 
Start Watchdog
 
Main:
'Read keypad
If Button = 0 And Feil = 0 And Number = 255 Then
 
If Row = 0 Then                                             'Keyboard row 1
   Portb.0 = 1
   If Pind.5 = 1 Then Number = 10
   If Pind.4 = 1 Then Number = 7
   If Pind.3 = 1 Then Number = 4
   If Pind.2 = 1 Then Number = 1
   Portb.0 = 0
   End If
 
If Row = 1 Then                                             'Keyboard row 2
   Portb.1 = 1
   If Pind.5 = 1 Then Number = 0
   If Pind.4 = 1 Then Number = 8
   If Pind.3 = 1 Then Number = 5
   If Pind.2 = 1 Then Number = 2
   Portb.1 = 0
   End If
 
If Row = 2 Then                                             'Keyboard row 3
   Portb.2 = 1
   If Pind.5 = 1 Then Number = 11
   If Pind.4 = 1 Then Number = 9
   If Pind.3 = 1 Then Number = 6
   If Pind.2 = 1 Then Number = 3
   Portb.2 = 0
   End If
 
Row = Row + 1                                               'Next row
If Row > 2 Then Row = 0
End If
 
'Reset button status
Portb.0 = 1
Portb.1 = 1
Portb.2 = 1
If Pind.2 = 0 And Pind.3 = 0 And Pind.4 = 0 And Pind.5 = 0 Then Button = 0
Portb.0 = 0
Portb.1 = 0
Portb.2 = 0
 
'Get code
If Number <> 255 Then
Button = 1
Select Case Nr
   Case 0                                                   'Digit 1
   Code1 = Number
   Code1 = Code1 * 1000
   Code = Code1 + Code
   Amberled = 4
   Case 1                                                   'Digit 2
   Code2 = Number
   Code2 = Code2 * 100
   Code = Code2 + Code
   Amberled = 4
   Case 2                                                   'Digit 3
   Code3 = Number
   Code3 = Code3 * 10
   Code = Code3 + Code
   Amberled = 4
   Case 3                                                   'Digit 4
   Code4 = Number
   Code = Code4 + Code
   Amberled = 4
 
   Case 4
   If Program = 1 Then                                      'Program new code
      Select Case Number
         Case 11                                            'Accept
         Code_p = Code
         Eeprom = Code_p
         Greenled = 60
         Case Else                                          'Reject
         Redled = 30
         End Select
      Number = 255
      Program = 0
      Gosub Reset_code_read
      Goto Main
      End If
   If Code = Code_p Then                                    'Code correct
   Feil_a = 0
      Select Case Number
         Case 0                                             'New code
         Program = 1
         Amberled = 40
         Case 10                                            'Channel 1
         Kanal1 = 20
         Greenled = 20
         Case 11                                            'Channel 2
         Kanal2 = 20
         Greenled = 40
         Case Else                                          'Reject
         Redled = 30
         End Select
   Else                                                     'Code failed
      Redled = 30
      Feil_a = Feil_a + 1
   End If
   Timeout = 0
   Number = 255
   Gosub Reset_code_read
   Goto Main
End Select
Nr = Nr + 1
Number = 255
End If
 
'Timeout when entering code
If Nr > 0 And Timeout = 0 Then Timeout = 201
If Timeout > 0 Then Timeout = Timeout - 1
If Timeout = 1 And Nr <> 0 Then
   Gosub Reset_code_read
   Number = 255
   Redled = 30
   End If
 
'Error handling, 3 wrong codes
If Feil_a > 3 And Feil = 0 Then
   Feil = 1200
   Feil_a = 0
   End If
If Feil > 0 And Redled = 0 Then Redled = 4
If Feil > 0 Then Feil = Feil - 1
 
'AmberLED
If Amberled > 0 Then
   Greenled = Amberled
   Redled = Amberled
   Amberled = 0
   End If
 
'GreenLED
If Greenled > 2 Then Portb.5 = 1
If Greenled = 2 Then Portb.5 = 0
If Greenled > 0 Then Greenled = Greenled - 1
 
'RedLED
If Redled > 2 Then Portb.6 = 1
If Redled = 2 Then Portb.6 = 0
If Redled > 0 Then Redled = Redled - 1
 
'Channel1
If Kanal1 = 20 Then Portb.3 = 1
If Kanal1 = 1 Then Portb.3 = 0
If Kanal1 > 0 Then Kanal1 = Kanal1 - 1
 
'Channel2
If Kanal2 = 20 Then Portb.4 = 1
If Kanal2 = 1 Then Portb.4 = 0
If Kanal2 > 0 Then Kanal2 = Kanal2 - 1
 
'Lifesignal
If Lifesignal > 0 Then Lifesignal = Lifesignal - 1
If Lifesignal = 12 Then Portb.7 = 1
If Lifesignal = 1 Then Portb.7 = 0
If Lifesignal = 0 Then Lifesignal = 41
 
Reset Watchdog
Waitms 50
Goto Main                                                   'Loop cycle
End
 
Reset_code_read:                                            'Reset code param.
   Nr = 0
   Code = 0
   Code1 = 0
   Code2 = 0
   Code3 = 0
   Code4 = 0
Return
End
Personal tools
Namespaces
Variants
Actions
Navigation
Categories
projects
Toolbox