Thursday 25 September 2008

Zedomax Alarm System - Make an alarm system in 3 minutes!

Parts List:

1 Magnetic Contact Switch
1 12VDC Piezzo Buzzer
1 2N3904 Transistor

Available at RadioShack

1 CB280 Start Kit
1 CLCD420-B
1 4x4 Keypad
1 Keypad Controller

Available at Comfile

Okay, today I was thinking that I needed an alarm system for my dog, so I decided to make a doggy door alarm system. Since my dog sleeps w/ me, I needed to make an alarm system for the night, to protect my apartment from other intruding dogs...

Anways, you might think I am crazy making an alarm system for furry people...

Before I made the actual system, I decided to do it with a study board that has a little breadboard.

You can get a 12VDC Piezzo Buzzer from your local Radio Shack for about 10 bucks and magnetic contact switches w/ screws for about 5 bucks.

These magnetic contact switches are neat, they are the same ones used for a lot of residential and commercial door sensors.

They are simply magnetic switches. If door is closed, the contact is open and if door is open, the contact is closed.

You can screw them into door and the wall using the holes on the switch ends.

Yes, if you got that and some CUBLOC or any type of microcontroller w/ i/o ports, you should be ready to go.

Here, we will use Comfile's CB280 embedded computer module and a 4x4 keypad and keypad controller, which will make things easier for us since we won't have to build from scratch.

(Close-up)

You will need to solder on your Keypad to the Keypad Controller first.

Then plug in black wire to GND, red wire to 5V, and rest of the pins to ports P0, P1, P2, and P3. (labeled 0, 1, 2, and 3 on the black IDC headers)

Once you are done connecting the Keypad Controller to your study board, connect the LCD to connector labeled, "CuNET".

Yes, now you have a keypad and an LCD.

Now connect the black wire of the piezo to GND and red wire to the left side of the 3904 transistor.

Connect 5V to the right side of the 3904 transistor.

Connect the middle pin of the transistor to P5 of the CUBLOC Study Board (labeled "5").

Now why are we using a transistor?
Because the piezo takes about 150mA and each I/O of CB280 CUBLOC module only can take so much (<50ma).>

So when the I/O port goes on, the transistor will simply connect power from 5V pin to the red wire of the piezo.

Okay, now we have 1 more item, yes, that's right, we can put the magnetic contact switch.

Connect one end of the Contact switch to 5V pin and the other end to port P20, labeled "20" on the study board.

Now connect a wire from P20 to an LED on the study board.

This is to do a pull-down and we should be able to check the status of the contact switch using the LED.

All right, now you are done, you should have something like this:

Now download this source file diy100.zip and uncompress it.

You will find HomeAutomation001.cul and HomeAutomation001.cub.

Open HomeAutomation001.cul file in your CublocStudio.

Download the program to CB280 module.

When you move the bottom part of the magnetic contact switch, you should see the LCD displaying "open" and "close" while the piezo beeps.

Now enter "1234" as password on the keypad controller.

If you mess up, you can press "CNCL" button, which will clear the password.

You should see the Alarm Status on the LCD go ON.

Now when the door is open, you will hear the alarm go off.

Video of Alarm System in 3 minutes:

[Source Code]

Const Device = CB280

#define MyPass 1234

Set Pad 0,1,5

Const Byte KEY_TABLE=(0,0,14,16,0,15,0,0,0,0,13,9,8,7,0,0,0,0,12,6,5,4,0,0,0,0,11,3,2,1)

'Key table if Keypad inserted backwards to the Keypad Controller

'Const Byte KEY_TABLE=(0,0,1,4,7,10,0,0,0,0,2,5,8,11,0,0,0,0,3,6,9,12,0,0,0,0,13,14,15,16)

Dim X As Byte

'Status of Alarm

Dim AlarmON As Byte

'Status of Door

Dim Door As Byte

Dim Password As Long

Door=0

Password=0

AlarmON=0

'Set port P5 to output

Output 5

'Set Magnetic Switch to input

Input 20

On INT0 Gosub GETINT

Set int0 2

On Pad Gosub PAD_RTN

Set Ladder Off

Set Display 2,0,0,128

Cls

Delay 100

Csroff

Locate 0,0

Print "Zedomax Alarm System"

Locate 0,2

Print "Door is: "

If In(20)=1 Then

Print "open"

Else

Print "closed"

End If

If AlarmON=1 Then

Locate 0,3

Print "Alarm Status is ON"

Else

Locate 0,3

Print "Alarm Status is OFF"

End If

Do

If AlarmON=1 And Door=1 Then

Alarm

End If

Loop

GETINT:

Door=In(20)

Debug "Door: ",Dec Door,Cr

Alarm

If Door=0 Then

Locate 9,2

Print "closed "

Debug "door closed",Cr

Else

Locate 9,2

Print "open "

Debug "door open",Cr

End If

Delay 500

Return

PAD_RTN:

Peep

X=Getpad(1)

If X>29 Then Return

X=KEY_TABLE(X)

Debug "Key Pressed: ", Dec X,Cr

If X <>

Password=Password*10+X

If Password > 9999 Then Password=X

Debug "Password: ", Dec Password,Cr

If Password = MyPass Then

AlarmON=AlarmON Xor 1

If AlarmON=1 Then

Locate 0,3

Print "Alarm Status is ON "

Else

Locate 0,3

Print "Alarm Status is OFF"

End If

End If

'If ENTR pressed

Elseif X=11 Then

'If CNCL pressed

Elseif X=15 Then

Password=0

End If

Return

End

Sub Alarm()

Out 5,1

Delay 100

Out 5,0

Delay 100

End Sub

Sub Peep()

Out 5,1

Delay 5

Out 5,0

Delay 5

End Sub

Taking it Further...

You can modify the source code to change the alarm times, scheduling,
menus, etc...etc...

The CB280 module supports up to 49 I/Os, so you can add up to 49
door sensors or you can add temperature chip to monitor temperature
at the same time.

The CB220 and CB220 Proto Board can be substituted for cheaper
alternative.

The CLCD420B can be substituted for smaller LCD such as the CLCD216G
OR you can also add a graphic LCD, such as the GHLCD for expanding
your alarm system...

I will try to update w/ a touch screen alarm system for more high
tech alarm system in the future w/ CuTOUCH.

No comments: