Tool box alarm

Mark.R

Member
Hi all, it’s been a while.

I have been asked to build an alarm for a friends site tool box and immediately thought of the old PICAXE. I can do the hardware side of things but the program side still gets me, so I thought I would ask the extended family.

What it will have will be one input for the arm/disarm switch, one input for the entry door and one input for all other doors.
It will have one output for a status LED, one output an entry/exit buzzer and one for the alarm sounder or horn its self.

Now the hard bit for me, the operation.

1. Set input active
2. Exit timer starts, entry/exit buzzer start and LED flashes fast until until 5 seconds after the entry/exit door is closed.
3. Alarm now armed LED flashes slowly.
4. If input for all other doors becomes active alarm sounder operates immediately.
5. If entry/exit door is opened then entry timer starts, entry/exit buzzer starts and LED flashes fast. Entry timer 15 seconds.
6. If set input still active after the 15 second entry time then the alarm sounder will operate.

I will probably be using a PICAXE – 18 for this.
I would be grateful of any help with the program and the circuit.

Mark
 

Dippy

Moderator
How much are getting paid? Do we charge by the hour or for the contract?
Just kidding.
Someone will come along and do it all for you shortly. Code for this would take hippy about 20 minutes... @£30 per hour, sorry just kidding again.
 

hippy

Ex-Staff (retired)
The best way to approach this is by drawing the details of what state the alarm is in at any time, and what action takes it to another state. For example ...

Armed : Door opens goes to entry alert. Start 15s timer running.

Entry alert : If door closed, go back to Armed. If 15s timed out, go to Alarm.

Alarm : Electrify the shed. Wait for police to arrive ...

It's really just a more formal way of what you wrote above, but it's good for seeing the flaws in moving between sates. Handy fr debugging as well. As per ...

5. If entry/exit door is opened then entry timer starts, entry/exit buzzer starts and LED flashes fast. Entry timer 15 seconds.
6. If set input still active after the 15 second entry time then the alarm sounder will operate.


So I'm breaking into your shed, the entry alert goes off, I shut the door and hide behind a hedge. Does the alarm go off or does it cancel ? If it cancels, I'll bet good money ( I'm still owed £10 for writing its code which is why I'm stealing tools up to but not exceeding that value :} ) that I can open the door, go in shut the door ( alarm cancels ), root around, leave and close the door and no one will be any the wiser for a few days.

You might also want to include a PIR in the shed if you are going for an auto-cancel rather than always alarm on potential break in. Another thing to bear in mind is any stautory obligations to not sound an alarm for more than X minutes at a time, with a Y minute gap between.

Where the 'state diagram' helps is that from each circle which represents a state there will always be an even number of lines per event which moves it on; when the event occurs and when it doesn't, some will be loop-backs to the same state, eg 15s timeout; not timed out keep waiting, timed out ring the bell.

Once you've got that diagram it's then a reasonable simple process of converting it to PICAXE code ...

Code:
Armed:
  If DOOR IS CLOSED Then Armed
  If DOOR IS OPEN Then EntryAlert_Start

EntryAlertStart:
  timeout := 15
EntryAlert:
  Gosub UpdateTimeout
  If timeout = 0 Then RingBell
  If timeout <> 0 Then EntryAlert
etc.
 
Last edited:

Mark.R

Member
Thanks for all that hippy and you right, once the entry door has opened which starts the entry timer it latches so even if the door is closed again the only way to stop the alarm from sounding is to disarm it. There is also the need as you say for a 30sec on and 30sec off time for the alarm sounder.

Mark
 
Top