Assignment title: Information


Home Alarm System 1. Introduction to alarm systems A home alarm system is constructed from various separate parts, which all connect to a central control unit. Your task is to implement a basic control unit and the functionality behind its user interface. To complete this task you must first understand the specification of the external parts provided and the required behaviour of the overall system. A conventional alarm system normally contains:  Central control unit  Keypad entry point / user interface  Sounder unit  Sensors such as: magnetic contacts (reed switches), pressure mats, movement sensors like passive infrared sensors (PIRs). In the case of the sensors, they all contain switches that are “closed” circuit under normal circumstances. This type of switch is known as a Normally Closed (NC) switch, the converse is known as Normally Open (NO). Magnetic contacts are used to detect when doors and windows are opened. When a door is opened a magnet is moved away from the reed switch which causes the switch contacts to open. Likewise when a movement sensor is triggered or a pressure mat depressed the circuit is broken (the switch is opened), see Figure 1. The opening of a contact can be detected by using one of the microcontroller's parallel port inputs, connected to the top of the switch whose lower end is connected to GND. The top of the switch is also connected through a resistor to 3.3v (V+). When the switch is closed the port input is connected to 0v (GND), and it will be pulled-up to 3.3v (V+) by the resistor when the sensor's switch opens. Therefore the microcontroller input is logic low (0v) when a door is closed / there is no movement, and logic high (3.3v) when the sensor is activated. The alarm controller must detect these events and respond as specified later in this document. In this assignment the sensors are emulated using normally closed push to break switches. Figure 1: Alarm sensors Normal home alarm systems include multiple sensors located in various locations, each location can have its own circuit which allows identification of the triggered switch, i.e. it lets the user know where the break-in occurred. Each sensor circuit is known as a zone, and zones can have different behaviour.2. Functional Specification - Zone Behaviour In this assignment there are two types of zone: one Entry / Exit zone, and one full set zones. Each zone has a corresponding LED to indicate its state. This alarm has SIX states of operation set, unset, entry, exit, alarm, and report. Initially it is in the unset state.  In the unset state, activation of any of the sensors should not cause the sounder unit to sound. Entry of the correct four-digit code in the user interface (described later) followed by “B” should cause the system to change to the exit state. If the user enters an invalid code three times, the alarm should change to the alarm state. Whilst in the unset state, the unset LED should be on.  When in the exit state, the user has a time interval called the exit period (1 minutes) in which to vacate their home. In the exit state, activation of any sensors in a full set zone should cause the alarm to enter the alarm state. Whilst in the exit state the sounder unit should sound for approximately 250ms every 250ms. If the user enters their four digit code followed by “B” within the period, the alarm should change to the unset state. If an invalid code is entered three times, the alarm should change to the alarm state. If all the zones are inactive when the exit period (1 minutes) expires, the alarm should enter the set state. Whilst in the exit state, the exit LED should be on.  In the set state, activation of any sensors in a full set zone should cause the alarm to enter the alarm state. Activation of the entry / exit zone should change the state to entry state. Whilst in the set state, the set LED should be on.  The purpose of the entry state is to allow the user a period of time to gain access to their home so that they can unset the alarm, this duration is known as the entry period (2 minutes). Whilst in the entry state, the sounder unit should sound for approximately 250ms every 250ms, i.e. switch on, then off at 250ms intervals. If the user enters their four-digit code followed by “B” within the period, the alarm should change to the unset state. If the user fails to enter their correct code within the entry period, the alarm should change to the alarm state. In the entry state, activation of any sensors in a full set zone should cause the alarm to enter the alarm state. Whilst in the entry state, the entry LED should be on.  When in the alarm state, the sounder unit should be enabled all the time. The alarm LED should be switched on. After 2 minutes, the sounder unit should be disabled. If the user enters the correct code followed by “B”, the alarm should change to the report state, otherwise stay in the alarm state.  When in the report state, the LCD should show the zone numbers or code error information in the first line. In the second line it should show “C key to clear”. When an “C” is entered, the alarm should change to the unset state.3. Functional Specification - User Interface The user interface consists of:  a 4x4 keypad;  a 16 character by 2 line LCD display;  6 LEDs for 6 states; (external led 8, 7, 6, 5, 4, 3 represent unset, exits, set, entry, alarm, report, respectively)  2 LEDs for 2 zones; (external led 1 for entry/exit zone, external led 2 for full set zone)  a sounder unit (replaced with LED1);  2 sensors for 2 zones (replaced with 2 switches, switch 1 for entry/exit zone, switch 2 for full set zone) There is an LED for each of the alarm's zones. When a sensor in a zone is active (circuit broken), the corresponding LED should be illuminated. When the alarm leaves the alarm state, the corresponding LED should be off. The LCD should display the state of the alarm panel left aligned on the first line of the LCD display. Normally the remainder of the display should be blank.  When the user enters the first digit of their code in the unset state, the second line of the display should additionally show left aligned “Code: *___” with the “_” characters being replaced with each successive digit entered.  If the user presses the “C” key, then the last entered character should be deleted and replaced with “_” unless there are no characters left, in which case the display should only display the state, i.e. be the same as when none of the code had been entered.  When all four digits of the code have been entered, the second line of the display should display “Press B to set”.  Any other key should cause the code entry procedure to abort without checking the user code. 4. Functional Specification - Programming Mode Following the steps in the unset state, when all four digits of the code have been entered, the second line of the display should display “Press B to set”. If a “D” key is pressed instead of “B”, the alarm should enter the programming mode and display “Prog mode” on the first line. When in the programming mode the user has four options that can be cycled through by pressing the “D” key.  The first option is to change the entry period. The LCD shows “Entry: 10s” where 10 seconds is the default entry period. If the user presses a numeric key the “1” should be replaced, a second key press should replace the “0”. The entry period should only be values in the range of 10 to 60 seconds inclusive, and key presses that would lead to invalid times should be ignored. Pressing the “D” key at any time should change the programming mode to the next programming option.  The second option is to change the exit period, and is comparable with the entry period option. The display should show “Exit: 10s”.  The third option is to change the user code, this is similar to the first two options except that the code has four numeric digits (0 to 9) and the LCD should show “Change code ____”, with the “_” characters being replaced by “*” as digits are entered. If the code has not been entered fully when the “B” key is pressed, the alarm should not change the code and should display option four. When the fourth digit hasbeen entered the display should show “Confirm: ____” and the user must re-enter the code. The “D” key should still abort the change at this stage.  Option four is “Press D to Exit”, pressing “D” should cause the programming mode to end, and the display should show the state “Unset”. The report: The report should include: 1. Requirement form 2. UML graphical representation of the system  A class diagram  A state machine diagram  A sequence diagram When necessary, you should provide brief explanation. 3. Source code Assessment criteria: Class diagram 10% State machine diagram 10% Sequence diagram 10% Correctness of program 50% Quality of program 10% Clarity of program and comments 10%