Montana Tech of The University of Montana
Computer Science & Software Engineering

CSCI 255
Introduction to Embedded Systems
Fall 2011


Lab #10 - Security System

DUE: Mon Dec 5th, 5PM
You will be creating a home security system. You will learn how to interface with a common output device, the two-line LCD display. This assignment is worth 100 points instead of the normal 40 points.

Overview. When the system powers on, the system is disarmed with a default password of 1234. The user can arm and disarm the system by entering the 4-digit numeric password followed by the # key. The system has two window sensors (P2.0 and P2.1) and one door sensor (P2.2). A sensor is tripped if a low-level is detected on the sensor's pin. A single sample of a low-level is enough to cause a trigger (i.e. you do not need to debounce the window or door signals).

State machine. You should implement your security system using a state machine. For details see the lecture slides. You may want to refer to the solution to the Stop Light example we did in class. Your submission should include a paper or electronic diagram of your implemented state machine. You should show all the states of your system as well as the events that cause transitions between states. The system can be in a number of states: LCD. You can read/write data to the LCD screen in either 4-bit or 8-bit mode. The LCD powerered by pin 1, grounded to pin 2, and the screen contrast controlled by pin 3. These coorsepond to the pins 1-3 of the 8052 educational board's LCD port, see page 6. You can use pins 4-6 on the LCD port for RS, RW, and EN. Reading and writing data to the LCD can be done using either a 4-bit or 8-bit input bus. 8-bit input mode is easier but will require more input lines. For details of controlling the LCD, see these slides, chapter 19 of the book, or 8052.com. You should turn off the cursor on the LCD display (use an init command of 0x0c instead of 0x0e).

Keypad. Users interact with the system using the numbers 0-9 and #. The # key is used as an "enter" key and signals password entry is complete. You can use either the 4x4 (from the previous lab) or the 3x4 keypad. If you use the 4x4 keypad, the letter keys should have no effect on the system. Both keypads will require you implement software debounce. The 3x4 keypad needs pin 1 grounded. The 3x4 is simpler in that you don't need to do a two step decoding; a pin goes low when a button is pressed. The buttons of the 3x4 keypad are connected to the pins as shown in the table on the back of the bubble pack.

Default password. Your code should make it easy to change the system's default password by modifying a single #define or constant variable. A valid password must involve entering four keys 0-9 followed by the # key. That is 001# should be considered invalid even if the default password is 0001.

Code organization. For this program, we expect you to split up the implementation into separate .h and .c files. For example, functions and constants associated with using the LCD display should be in their own .h and .c file. Similarly, things associated from reading from the keypad should be in their own .h and .c file. You can then #include the header files from your main program .c file. You will need to add all .c files containing function implementations into your Keil project. You should avoid magic numbers in your program, using #defines or constants as needed. It should be simple to change your code to support a board with different wiring.

Extra credit. Implement a system configuration menu. The user enters the menu from the DISARMED state by typing * followed by #. The menu should allow the user to do the following:
Submission. Submit your program to the Lab #10 dropbox on Moodle. Be sure each submitted source file have the required header with your name, username, and a description of the program. Your program will be graded on functionality, readability and elegance. Present your completed board to Zach or Keith for testing.

Page last updated: August 16, 2012.  Copyright © 2011 by Keith Vertanen.