Professional Documents
Culture Documents
Burglar Alarm Final Report 1 PDF
Burglar Alarm Final Report 1 PDF
Final Report
Submitted By:
Brandon Maciel, Linda Thompson, Bradford SavageTeam 1A
ETEE3255 Lab VII
Instructor: Barry Sherlock
Date Due: November 18th, 2010
1
Final Report
Team 1A
Abstract
The purpose of this project was to design, build, and test a burglar system. Using
simulation software and a programming code that was made to control operation of the
system via a microcontroller. A user interface was designed that will enabled the user
to manipulate several functions, such as arming/disarming the system and turning
particular sensors on or off. In order to demonstrate practical user implementation of
the burglar alarm system, the programming code was implemented with a visual
interface, a LCD display unit and a keyboard. The system was tested by triggering
various
sensors,
mostly
magnetic
switches,
which
were
connected
to
the
2
Final Report
Team 1A
3
Final Report
Team 1A
more advanced than ever before giving households everywhere the sense of safety and
security they have been yearning to attain for centuries on end.
Advanced Technology Solutions has a tech savvy, high priced alarm system for
$619.99. Their product consists of 2 x 1/3 inch SONY Super HAD CCD Cameras and 1
x 4-Channel Digital Video Recorder (DVR).
infrared sensors that serve 2 purposes: video surveillance and motion detecting.
Coupled with the DVR, this system is state of the art with an almost fool-proof
dependability scenario. Although the Advanced Technology Solutions system has one
major flaw; it is priced too high for the average consumer.
Wireless Home has a less expensive solution priced at $99.95. While the price is right
for the average consumer, this system lacks dependability as it contains only 1 infrared
sensor and 2 magnetic window sensors. This obvious lack of security is unacceptable
for most consumers, considering most home have 10 sets of windows and two doors.
4
Final Report
Team 1A
The fact that one has to buy warning signs and decals separately might lead the
consumer to the conclusion that the company has trimmed all costs to provide a great
deal. But with minimal experience in commercial sensor pricing, this product is also
drastically overpriced, although touted as a great deal.
The purpose of this project is to deliver a reasonably priced, dependable alarm system.
After analyzing the competition, the projects 14 sensor array will provide beefed-up
security than even the more expensive systems. More sensors simply equal more
security. Finding dependable sensors will be a tough task for the project, but once
reasonably priced sensors have been found, accomplishing the low-cost goal will be
within reach.
3. Experimental Method
A program was written that simulated a basic house burglary alarm system. This alarm
system was able to detect when there was an intrusion through any door, window, or
garage door. Also there was an LCD screen which displayed the alarm status along
with a 16-bit hexadecimal keypad that helped navigate through the LCD screen.
The house consisted of sensors on all windows and doors. There had to be at least six
window sensors, two garage door sensors, and two regular door sensors. In addition to
the sensors it was required that there be four either infrared motion detectors. The
5
Final Report
Team 1A
motion detectors detected motion throughout the house. The program that was written
was a link to all switches and infrared detectors to the AVR ATMEGA 128.
After the sensors and infrared detectors were set up, a user interface was created to
display on the LCD screen. The 16-bit hexadecimal keypad was used to navigate
through the LCD screen. The user interface had four different modes the user could
choose from. There were the Setup, Arm, Disarm, and Status modes to select from.
The screens looked similar to the figure below.
S Y S T E M
S T A T U S
1 0 / 2 0 / 0 9
1 0 : 3 0 A M
A L A R M
M O D E :
S T A T U S :
A R M E D
S E C U R E
6
Final Report
Team 1A
disarm the alarm with the five digit disarm code after it has been tripped. When the
alarm system was not armed there was the main screen where the user could select
between all four modes by push button.
debounced in order for them to work properly. This was done by using capacitors and
resistors between the switch and AVR connection. All equipment required is shown on
Table 1 shown below.
Requirements
Usage
Microcontroller used
6 Sensors
7
Final Report
Team 1A
4. Program Code
The program code was written piece by piece. The first important piece of the
code was to initialize the ports being used.
sensors for the windows and doors. Port D was initialized to communicate with
the Keypad. Port E was initialized to communicate with the LCD screen. Finally
Port F was used to initialize the motion sensors.
// Port A initialization
PORTA=0x00;//port for window and door sensors
DDRA=0xFF;//0-3 for windows and 4-7 for door sensors
// Port D initialization
PORTD=0x0F; //Port for the keypad
DDRD=0xF0;
//Upper 4-bits are output and lower 4-bits are
inputs
// Port E initialization
PORTE=0x00;
//Port for the LCD
DDRE=0xFC;
//Pins 2-7 are outputs for LCD
// Port E initialization
PORTF=0x00;
DDRF=0xFF;
sensors
The second piece of code that was a major portion was telling the LCD screen
what to display. The LCD screen is how the user communicates with the burglar
alarm system. So what is shown on the display screen is important so the user
can navigate through the screens without any problems. An example of this
code is displayed below in figure three.
8
Final Report
Team 1A
//Text used for Set-up Screen
unsigned char setup_screen0[21] =
("
SYSTEM SETUP
for setup
unsigned char setup_screen1[21] =
("
ARM
for Arm--45 seconds to leave and ALL sensors armed
unsigned char setup_screen2[21] =
("
DISARM
for disarm--45 seconds to enter correct 5 DIGIT code
unsigned char setup_screen3[21] =
("
STATUS
for Sensor Status Screen
");//press A
");//press B
");//press C
");//press D
9
Final Report
Team 1A
if(PINF.2==1)sensor_screen3[11]='-';else
sensor_screen3[11]='A';
The switches on the ATmega128 were simulations of the sensor for the burglar
alarm system. When the sensor was set to high then the door/window was
closed. When it was set to low the door/window was opened.
5. Experimental Results
While writing the program, there were several issues that had to be dealt with
before we got the code working. The first problem was trying to find which port to
use for the LCD screen. The LCD screen has its own slot on the ATmega 123
but it does not show what port it was. After a great deal of research it was found
that port E was needed to work the LCD screen.
Once the right port was initialized for the LCD screen there was also trouble
trying to get the screen display what was desired for it to display. The screen
would just show blocks across the entire screen. It took a lot of trial and error to
finally get the LCD displaying what it needed to display.
10
Final Report
Team 1A
Setting up the Date and Time in the system setup also took a lot longer than
planned in the original work breakdown structure.
door/window was closed, and if the switch read low then the door/window was
open.
6. Conclusion
The objective of this project was to create a model burglar alarm system that
would detect motion and the opening of all doors and windows when the system
is armed. The system should have a LCD screen that allowed you to setup, arm,
disarm, and check the status of the alarm system. A keypad was also needed to
navigate through the LCD screen. There had to be a total of six window sensors,
four door sensors (two regular doors and two garage doors), and four motion
detectors.
11
Final Report
Team 1A
The greatest challenge faced in this project was writing and debugging the code
to get it to operate correctly. There were several problems in the code that had
to be fixed before it would work correctly. A few of the main problems corrected
were assigning the right port to the LCD screen (Port E), getting the LCD screen
to display correctly, and getting the time and date to set up correctly.
Overall the parts of the objectives that were completed worked correctly as the
objectives specified. Although infrared motion detectors could not be obtained,
code was still written to include them.
7. References
Atomic Mall product Info- Wireless Home -Business Security Burglar Alarm System.
Web.< http://www.atomicmall.com/view.php?id=540587>
Dino Direct- Advanced Technology Solutions 4 Channel DVR & 2 Color Cameras
Security System. Web.< http://www.dinodirect.com/cameras-security-system-4channeldvr-sky-8204st-cam-817l/AFFID-183.html>
12
Final Report
Team 1A
http://www.top5inrealestate.com/items/view/null/8973/
13
Final Report
Team 1A
8. Appendix
Appendix 1. Project Guidelines
14
Final Report
Team 1A
15
Final Report
Team 1A
16
Final Report
Team 1A
17
Final Report
Team 1A
Chip type
: ATmega128L
Program type
: Application
AVR Core Clock frequency: 16.000000 MHz
Memory model
: Small
External RAM size
: 0
Data Stack size
: 1024
*****************************************************/
#include <mega128.h>
#include <delay.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define FIRST_ADC_INPUT 0
#define LAST_ADC_INPUT 0
unsigned char adc_data[LAST_ADC_INPUT-FIRST_ADC_INPUT+1];
#define ADC_VREF_TYPE 0xE0
#define LCD_PORT PORTE
//LCD connected to Port E
#define LCD_RS
0x04
//LCD Register Select 0=Instruction input,
1=Data input
#define LCD_EN
0x08
//LCD Enable bit
#define TRUE
0
#define FALSE
1
#define
#define
#define
#define
#define
#define
#define
#define
door1
door2
door3
door4
window_1
window_2
window_3
window_4
PORTA.0
PORTA.1
PORTA.2
PORTA.3
PORTA.4
PORTA.5
PORTA.6
PORTA.7
#define window_5
#define window_6
PORTF.0
PORTF.1
#define
#define
#define
#define
PORTF.2
PORTF.3
PORTF.4
PORTF.5
sensor_1
sensor_2
sensor_3
sensor_4
//Declared variables
void intsetup ();
void InputData1 ();
char button (char keycode);
void SensorScreen ();
void MainMenu();
void MainMenu2();
void zone_set_up();
unsigned long GetCurrentDate();
unsigned long GetCurrentTime();
void clock ();
18
Final Report
Team 1A
{
LCD_PORT
LCD_PORT
LCD_PORT
delay_ms
LCD_PORT
LCD_PORT
LCD_PORT
delay_ms
LCD_PORT
LCD_PORT
LCD_PORT
delay_ms
LCD_PORT
LCD_PORT
LCD_PORT
delay_ms
}
= LCD_EN;
= 0x30|LCD_EN;
= 0x30;
(1);
= LCD_EN;
= 0x30|LCD_EN;
= 0x30;
(1);
= LCD_EN;
= 0x30|LCD_EN;
= 0x30;
(1);
= LCD_EN;
= 0x20|LCD_EN;
= 0x20;
(1);
//Routine repeated
19
Final Report
Team 1A
void lcd_cmd (unsigned char cmd)
{
//send high bits
LCD_PORT = LCD_EN;
LCD_PORT = (cmd & 0xF0) |LCD_EN;
makes EN low
LCD_PORT = (cmd & 0xF0);
//send low bits
LCD_PORT = LCD_EN;
LCD_PORT = ((cmd << 4) & 0xF0) |LCD_EN;
LCD_PORT = ((cmd << 4) & 0xF0);
makes EN low
delay_ms (5);
process the command
}
void LCD_init() //Initializes the LCD
{
LCD_reset();
lcd_cmd (0x28);
//4-bit, 2 line, 5x7 dots
lcd_cmd (0x0C);
//Display on Cursor off
lcd_cmd (0x06);
//Entry Mode
lcd_cmd (0x01);
//Clears the Screen
lcd_cmd (0x80);
// Set Cursor at line 1
}
//Set the LCD display position x=0...39, y=0...3
void lcd_gotoxy (unsigned char x, unsigned char y)
{
lcd_cmd (base_y [y] + x);
lcd_x = x;
lcd_y = y;
}
/*void lcd_senddata (unsigned char data)
//Write one character to LCD
{
//send high bits
LCD_PORT = LCD_EN|LCD_RS;
// Allow data to be
sent to LCD
LCD_PORT = ((data & 0xF0) |LCD_EN|LCD_RS);
//Write the data to
the LCD
LCD_PORT = ((data & 0xF0) |LCD_RS);
// Put on commands
ports makes EN low
//send low bits
LCD_PORT = LCD_EN|LCD_RS;
// makes EN high
LCD_PORT = (((data << 4 ) & 0xF0) |LCD_EN|LCD_RS);
LCD_PORT = (((data << 4) & 0xF0) |LCD_RS);
//Puts data on the LCD
delay_ms (5);
//Give LCD time to
process
}
*/
void lcd_displaystring (unsigned char *var)
//Display a string on the
LCD
{
unsigned char current_char;
while (*var != 0)
{
current_char = *var++;
20
Final Report
Team 1A
//send high bits
LCD_PORT = LCD_EN|LCD_RS;
// makes EN high and RS
high to write to LCD
LCD_PORT = ((current_char & 0xF0) |LCD_EN|LCD_RS);
LCD_PORT = ((current_char & 0xF0) |LCD_RS);
// Put on commands
ports makes EN low
//send low bits
LCD_PORT = LCD_EN|LCD_RS;
// makes EN high
LCD_PORT = (((current_char << 4 ) & 0xF0) |LCD_EN|LCD_RS);
LCD_PORT = (((current_char << 4) & 0xF0) |LCD_RS);
//Puts string
on the LCD
delay_ms (5);
//Give LCD time to process
}
}
");
");
");
// system
//
time
// armed or
"); //secure or
21
Final Report
Team 1A
unsigned char sensor_screen0
status screen
unsigned char sensor_screen1
location of sensor
unsigned char sensor_screen2
unsigned char sensor_screen3
nominal
[21] = ("
SENSOR STATUS
"); // sensor
unsigned char c = 0;
unsigned char temperature_data;
int clock_hours;
int time_counter;
=
=
");//sensor #'s
");//A= tripped, N=
");//press A for
");//press B for
");//press C for
");//press D for
");//press A for
");//press B for
");//press C for
");//press D for
("
ENTER CODE
");
("ARM = 1
DISARM = 2 ");
22
Final Report
Team 1A
int
int
int
int
int
clock_seconds;
clock_minutes;
date_DD;
date_MM;
date_YY;
unsigned char ZZ = 0;
int arm;
int code_a;
int code_b;
int code_c;
int code_d;
int code_e;
int decide;
int status;
void main(void)
{
// Port A initialization
PORTA=0x00;//port for window and door sensors
DDRA=0xFF;//0-3 for windows and 4-7 for door sensors
// Port D initialization
PORTD=0x0F; //Port for the keypad
DDRD=0xF0;
//Upper 4-bits are output and lower 4-bits are inputs
// Port E initialization
PORTE=0x00;
//Port for the LCD
DDRE=0xFC;
//Pins 2-7 are outputs for LCD
// Port E initialization
23
Final Report
Team 1A
PORTF=0x00;
DDRF=0xFF;
//
//
//
//
//
Timer/Counter 0 initialization
Clock source: System Clock
Clock value: 250.000 kHz
Mode: Normal top=FFh
OC0 output: Disconnected
ASSR=0x00;
TCCR0=0x04;
TCNT0=0x06;
OCR0=0x00;
// ADC initialization
// ADC Clock frequency: 1000.000 kHz
// ADC Voltage Reference: Int., cap. on AREF
// Only the 8 most significant bits of
// the AD conversion result are used
24
Final Report
Team 1A
while (1)
{
keyData1 = PIND & 0x0F;
if ((keyData1 != 0xF) & ZZ==0)
{
delay_ms (5);
keyData2 = PIND & 0x0F;
if (keyData1 == keyData2)
{
key_select = button(keyData2);
and put in a variable
ZZ=1;
}
}
25
Final Report
Team 1A
void SatusMenu()//-----------tells what status menu displays
{
lcd_cmd (0x01);
lcd_gotoxy(0,0);
lcd_displaystring (setup_screen0);
lcd_gotoxy (0,1);
lcd_displaystring (setup_screen1);
lcd_gotoxy (0,2);
lcd_displaystring (setup_screen2);
lcd_gotoxy (0,3);
lcd_displaystring (setup_screen3);
}
void SensorMenu()//defines sensor menu
{
lcd_cmd (0x01);
lcd_gotoxy(0,0);
lcd_displaystring (system_screen0);
lcd_gotoxy (0,1);
lcd_displaystring (system_screen1);
lcd_gotoxy (0,2);
lcd_displaystring (system_screen2);
lcd_gotoxy (0,3);
lcd_displaystring (system_screen3);
}
26
Final Report
Team 1A
clock_hours += key_select;
InputData1();
clock_minutes = key_select*10;
InputData1();
clock_minutes += key_select;
InputData1();
date_MM = key_select*10;
InputData1();
date_MM += key_select;
InputData1();
date_DD = key_select*10;
InputData1();
date_DD += key_select;
InputData1();
date_YY = key_select*10;
InputData1();
date_YY += key_select;
lcd_gotoxy (0,1);
lcd_displaystring (enter_code);
digit_code();
InputData1();
code_a = key_select;
if (code_a == 1);
{
continue;
27
Final Report
Team 1A
}
InputData1();
code_b = key_select;
if (code_b == 2);
{
continue;
}
InputData1();
code_c = key_select;
if (code_c == 3);
{
continue;
}
InputData1();
code_d = key_select;
if (code_d == 4);
{
continue;
}
InputData1();
code_e = key_select;
if (code_e == 5);
{
continue;
}
lcd_gotoxy (0,2);
lcd_displaystring (arm_disarm);//---------decide if arm or disarm
InputData1();
decide = key_select;
if (decide == 1);
{
status = 1;
UpdateSensorStatus();//armed and secure
return;
}
else if (decide == 2);
{
status = 2;
UpdateSensorStatus();//disarmed and secure
return;
}
}
28
Final Report
Team 1A
29
Final Report
Team 1A
return current_date;
}
30
Final Report
Team 1A
='A';
='R';
='M';
='E';
='D';
system_screen3[10]='S';
system_screen3[11]='E';
system_screen3[12]='C';
31
Final Report
Team 1A
system_screen3[13]='U';
system_screen3[14]='R';
system_screen3[15]='E';
return;
}
='D';
='I';
='S';
='A';
='R';
='M';
='E';
='D';
system_screen3[10]='I';
system_screen3[11]='N';
system_screen3[12]='S';
system_screen3[13]='E';
system_screen3[14]='C';
system_screen3[15]='U';
system_screen3[16]='R';
system_screen3[17]='E';
return;
}
}
32
Final Report
Team 1A
33
Final Report
Team 1A
34
Final Report
Team 1A
case 0xB0: keypressed =9;
break;
case 0x70: keypressed ='C';
break;//--------------------------------}
break;
case 0x7:
PORTD = 0xF7; delay_ms(5);
keycode = (PIND & 0xF0);
switch(keycode)
{
case 0xE0: keypressed ='*';
MainMenu2 ();
break;
case 0xD0: keypressed =0;
break;
case 0xB0: keypressed ='#';
break;
case 0x70: keypressed ='D';
SensorScreen ();//-----------------------------break;
}
break;
}
DDRD = 0xF0; //rows are outputs, cols are inputs
PORTD = 0x0F; //pullup resistor for inputs, set outputs to low
return (keypressed);
}