Here's my simple project. For now, I'm using an old PC case to hold it, with the PC power supply (which will work quite well, supplying +12V and +5V to drive the relays, siren, and power the Webcontrol). Power consumption (according to my kill-a-watt) is 7-8 watts, including the PC power supply fan (which I plan to remove). It's a Compaq unit, ran a Pentium 133MHz (circa 1996).
I made a little circuit board with a female header to plug in to the Webcontrol, and on that PCB are screw terminals for the analogs, digitals, and screw terminals for the +12V in. The board also has a 7809 voltage regulator, so the output of the VR is jumpered down to the input of the Webcontrol.
I bought a relay board on ebay, and it works fine. I forget which one, it came from China. Relays are driven by +5DC.
I signed up for a gmx.us email address, and they have free SMTP. So I can send by that (but if you have a bug in your program and try to send too many, they will cut you off for a few hours. Yes, I know this... ).
A better way to test is to use Papercut - it's an SMTP emulator, that will run on your PC and 'accept' your email, and not forward it. http://papercut.codeplex.com/
I also found Mady MTA v 2.3 - it's a SMTP relay that you can install on your PC, and act as an intermediary while you test your board. 2.3 is an older free version, they changed to a pay-for version with the newer ones. You can watch it relay from the Webcontrol, through your PC, and then on through a 'real' ISP so the email actually goes out.
The rest of the programming was pretty simple. Here it is, with comments. Let me know any way I can clean up this code. I'm not a programmer, I'm a hack. I do a little of everything, but don't try to specialize in anything.
Note that the comments are not Webcontrol friendly; I did them in Notepad after the fact. The program does work fine (though I'll probably add some to it in the future, like the garage door raise/lower).
These are my variables / inputs / outputs:
VAR1:
0=Alarm Enabled
1=Alarm Disabled
VAR2:
0=Door Email Not Sent
1=Door Email Sent
VAR3:
0=Window Email Not Sent
1=Window Email Sent
VAR4:
0=Motion Detector Email Not Sent
1=Motion Detector Email Sent
OP1: Rear Light
OP2: Front Light
OP8: Siren
OP7: Remote Enable/Disable
IP1: Back Door
IP2: Front Door
IP3: Garage Door
IP4: Window 1
IP5: Window 2
IP6: Window 3
IP7: Motion Detector
IP8: Enable / Disable
All inputs "normally high", "low" for alarm
//////////////////////////////////////////////////////////////////////////////////////
Program with comments (cannot put comments in code, so this is not copy/paste ready)
START
CALLSUB INIT_OUT ;Initialize the output contacts, set memory values to 0
LOOP:
CALLSUB CHECK_DIS ;Check the status of the disable input (it controls VAR1)
TSTEQ VAR1 0 ;See if alarm is enabled (VAR1=0)
CALLSUB CK_DOORS ;If it is, check the door status inputs (1-3)
TSTEQ VAR1 0 ;See if alarm is enabled (VAR1=0)
CALLSUB CK_WINDOW ;If it is, check the window status inputs (4-6)
TSTEQ VAR1 0 ;See if alarm is enabled (VAR1=0)
CALLSUB CK_MOTION ;If it is, check the motion status input (7)
TSTEQ VAR1 1 ;See if alarm is disabled (VAR1=1)
CALLSUB DISAB_ALM ;If it is, disable the output relays
GOTO LOOP ;Back to the start of the loop
END
INIT_OUT: ;Intialize the outputs and variables / open relays, clear all
SET OP1 0
SET OP2 0
SET OP8 0
SET OP7 0
SET VAR1 0
SET VAR2 0
SET VAR3 0
SET VAR4 0
RET
CHECK_DIS:
TSTEQ IP8 0 ;See if disable input = 'low'
DELAY 50 ;If it is, wait for 1/2 second for debounce
TSTEQ IP8 0 ;Check it again
SET VAR1 1 ;If it is still low, set VAR1=1 (disabling alarm)
TSTEQ IP8 0 ;OK, is it still low a few cycles later?
CALLSUB CLEAR_EM ;Probably is, so let's clear the flags from sending emails
TSTEQ IP8 1 ;Check to see if input = 'high'
SET VAR1 0 ;If it is, turn alarm back on (VAR1=0)
RET
CLEAR_EM: ;Clear 'email sent' flags
SET VAR2 0
SET VAR3 0
SET VAR4 0
RET
DISAB_ALM: ;Clear relay statuses / turn lights and alarm siren off
SET OP1 0
SET OP2 0
SET OP8 0
DELAY 100 ;Wait for one second to allow for debounce
RET
CK_DOORS: ;Check door statuses - if 'low', call alarm and send email 1
TSTEQ IP1 0
CALLSUB ALARM
TSTEQ IP2 0
CALLSUB ALARM
TSTEQ IP3 0
CALLSUB ALARM
TSTEQ IP1 0
CALLSUB EMAIL1
TSTEQ IP2 0
CALLSUB EMAIL1
TSTEQ IP3 0
CALLSUB EMAIL1
RET
CK_WINDOW: ;Check window statuses - if 'low', call alarm and send email 2
TSTEQ IP4 0
CALLSUB ALARM
TSTEQ IP5 0
CALLSUB ALARM
TSTEQ IP6 0
CALLSUB ALARM
TSTEQ IP4 0
CALLSUB EMAIL2
TSTEQ IP5 0
CALLSUB EMAIL2
TSTEQ IP6 0
CALLSUB EMAIL2
RET
CK_MOTION: ;Check motion status - if 'low', call alarm and send email 3
TSTEQ IP7 0
CALLSUB ALARM
TSTEQ IP7 0
CALLSUB EMAIL3
RET
ALARM: ;Energize outputs 1, 2, and 8
SET OP1 1
SET OP2 1
SET OP8 1
RET
EMAIL1:
TSTEQ VAR2 0 ;Is VAR2=0? (Email is 'unsent')
EMAIL EM1 ;If it is, send email (EM1 = Door Alarm)
SET VAR2 1 ;Set VAR2=1 (Email is now 'sent')
RET
EMAIL2:
TSTEQ VAR3 0
EMAIL EM2 ;EM2=Window Alarm
SET VAR3 1
RET
EMAIL3:
TSTEQ VAR4 0
EMAIL EM3 ;EM3=Motion Alarm
SET VAR4 1
RET
I made a little circuit board with a female header to plug in to the Webcontrol, and on that PCB are screw terminals for the analogs, digitals, and screw terminals for the +12V in. The board also has a 7809 voltage regulator, so the output of the VR is jumpered down to the input of the Webcontrol.
I bought a relay board on ebay, and it works fine. I forget which one, it came from China. Relays are driven by +5DC.
I signed up for a gmx.us email address, and they have free SMTP. So I can send by that (but if you have a bug in your program and try to send too many, they will cut you off for a few hours. Yes, I know this... ).
A better way to test is to use Papercut - it's an SMTP emulator, that will run on your PC and 'accept' your email, and not forward it. http://papercut.codeplex.com/
I also found Mady MTA v 2.3 - it's a SMTP relay that you can install on your PC, and act as an intermediary while you test your board. 2.3 is an older free version, they changed to a pay-for version with the newer ones. You can watch it relay from the Webcontrol, through your PC, and then on through a 'real' ISP so the email actually goes out.
The rest of the programming was pretty simple. Here it is, with comments. Let me know any way I can clean up this code. I'm not a programmer, I'm a hack. I do a little of everything, but don't try to specialize in anything.
Note that the comments are not Webcontrol friendly; I did them in Notepad after the fact. The program does work fine (though I'll probably add some to it in the future, like the garage door raise/lower).
These are my variables / inputs / outputs:
VAR1:
0=Alarm Enabled
1=Alarm Disabled
VAR2:
0=Door Email Not Sent
1=Door Email Sent
VAR3:
0=Window Email Not Sent
1=Window Email Sent
VAR4:
0=Motion Detector Email Not Sent
1=Motion Detector Email Sent
OP1: Rear Light
OP2: Front Light
OP8: Siren
OP7: Remote Enable/Disable
IP1: Back Door
IP2: Front Door
IP3: Garage Door
IP4: Window 1
IP5: Window 2
IP6: Window 3
IP7: Motion Detector
IP8: Enable / Disable
All inputs "normally high", "low" for alarm
//////////////////////////////////////////////////////////////////////////////////////
Program with comments (cannot put comments in code, so this is not copy/paste ready)
START
CALLSUB INIT_OUT ;Initialize the output contacts, set memory values to 0
LOOP:
CALLSUB CHECK_DIS ;Check the status of the disable input (it controls VAR1)
TSTEQ VAR1 0 ;See if alarm is enabled (VAR1=0)
CALLSUB CK_DOORS ;If it is, check the door status inputs (1-3)
TSTEQ VAR1 0 ;See if alarm is enabled (VAR1=0)
CALLSUB CK_WINDOW ;If it is, check the window status inputs (4-6)
TSTEQ VAR1 0 ;See if alarm is enabled (VAR1=0)
CALLSUB CK_MOTION ;If it is, check the motion status input (7)
TSTEQ VAR1 1 ;See if alarm is disabled (VAR1=1)
CALLSUB DISAB_ALM ;If it is, disable the output relays
GOTO LOOP ;Back to the start of the loop
END
INIT_OUT: ;Intialize the outputs and variables / open relays, clear all
SET OP1 0
SET OP2 0
SET OP8 0
SET OP7 0
SET VAR1 0
SET VAR2 0
SET VAR3 0
SET VAR4 0
RET
CHECK_DIS:
TSTEQ IP8 0 ;See if disable input = 'low'
DELAY 50 ;If it is, wait for 1/2 second for debounce
TSTEQ IP8 0 ;Check it again
SET VAR1 1 ;If it is still low, set VAR1=1 (disabling alarm)
TSTEQ IP8 0 ;OK, is it still low a few cycles later?
CALLSUB CLEAR_EM ;Probably is, so let's clear the flags from sending emails
TSTEQ IP8 1 ;Check to see if input = 'high'
SET VAR1 0 ;If it is, turn alarm back on (VAR1=0)
RET
CLEAR_EM: ;Clear 'email sent' flags
SET VAR2 0
SET VAR3 0
SET VAR4 0
RET
DISAB_ALM: ;Clear relay statuses / turn lights and alarm siren off
SET OP1 0
SET OP2 0
SET OP8 0
DELAY 100 ;Wait for one second to allow for debounce
RET
CK_DOORS: ;Check door statuses - if 'low', call alarm and send email 1
TSTEQ IP1 0
CALLSUB ALARM
TSTEQ IP2 0
CALLSUB ALARM
TSTEQ IP3 0
CALLSUB ALARM
TSTEQ IP1 0
CALLSUB EMAIL1
TSTEQ IP2 0
CALLSUB EMAIL1
TSTEQ IP3 0
CALLSUB EMAIL1
RET
CK_WINDOW: ;Check window statuses - if 'low', call alarm and send email 2
TSTEQ IP4 0
CALLSUB ALARM
TSTEQ IP5 0
CALLSUB ALARM
TSTEQ IP6 0
CALLSUB ALARM
TSTEQ IP4 0
CALLSUB EMAIL2
TSTEQ IP5 0
CALLSUB EMAIL2
TSTEQ IP6 0
CALLSUB EMAIL2
RET
CK_MOTION: ;Check motion status - if 'low', call alarm and send email 3
TSTEQ IP7 0
CALLSUB ALARM
TSTEQ IP7 0
CALLSUB EMAIL3
RET
ALARM: ;Energize outputs 1, 2, and 8
SET OP1 1
SET OP2 1
SET OP8 1
RET
EMAIL1:
TSTEQ VAR2 0 ;Is VAR2=0? (Email is 'unsent')
EMAIL EM1 ;If it is, send email (EM1 = Door Alarm)
SET VAR2 1 ;Set VAR2=1 (Email is now 'sent')
RET
EMAIL2:
TSTEQ VAR3 0
EMAIL EM2 ;EM2=Window Alarm
SET VAR3 1
RET
EMAIL3:
TSTEQ VAR4 0
EMAIL EM3 ;EM3=Motion Alarm
SET VAR4 1
RET