Assignment 10 Alarm System

27
Univ NAME : 1. N 2. S 3. D LECTURER : DATE SEE 3223 Microprocesso versity Technology Malaysia MICRO P SEE 3223 SEMESTER 2 2009/2010 ASSIGNMENT 10 “ALARM SYSTEM” Section 01 NGO CHEE WUNG (AE07 SAM XIN MIN (AE07 DAMIAN JUDE A. BUNGKONG (AE0 : MR. KAMAL kHALIL :1 ST APRIL 2010 or Alarm System 1 70273) 70359) 070061)

Transcript of Assignment 10 Alarm System

University Technology Malaysia

NAME : 1. NGO CHEE WUNG 2. SAM XIN MIN 3. DAMIAN JUDE A. BUNGKONG (AE070061)

LECTURER : MR. KAMAL kHALIL

DATE

SEE 3223 Microprocessor

University Technology Malaysia

MICRO PSEE 3223

SEMESTER 2 2009/2010

ASSIGNMENT 10

“ALARM SYSTEM”

Section 01

NGO CHEE WUNG (AE070273)2. SAM XIN MIN (AE070359)3. DAMIAN JUDE A. BUNGKONG (AE070061)

LECTURER : MR. KAMAL kHALIL

DATE :1ST APRIL 2010

SEE 3223 Microprocessor Alarm System

1

(AE070273)(AE070359)

3. DAMIAN JUDE A. BUNGKONG (AE070061)

SEE 3223 Microprocessor Alarm System

2

Table of Contents

Assignment 10 : Alarm System

page

1: Introduction 3

2: Objectives 4

3: Hardware & Software Requirements 4

4:Statement of Problem 5

5:System Design5.1: Flow Chart

5.1.1: Interrupt 85.1.2.:Exit , Entry and Protective Mode 11

5.2: IDE 68k Alarm System Design 14

6: Corresponding Peripherals in the Program 19

7: Discussions7.1: Interrupt, Exception ,Trap 217.2: IDE 68k Alarm system 22

8: Conclusion 25

9: References 26

10:Soft Copy of Simulation File 27

SEE 3223 Microprocessor Alarm System

3

1. Introduction

This assignment required students study the requirement on the

alarm system given. Students need to analyze the system requirement

and design the flow chart. Finally, students need to write the program by

using IDE 68k assembler and run the program. Interrupts, exception, trap,

subroutine ,counter and branch were used to complete the assembler

language. The output was tested by using the hardware of visual simulator

such as switch, LED and seven segment display. Finally students try to

implement the program using Flight 68k.

SEE 3223 Microprocessor Alarm System

4

2. Objectives

2.1 To analyze the requirements of a home alarm system.

2.2 To design the alarm system by using IDE68k.

2.3 To determine the output of the system by using visual

simulator.

2.4 To implement the design in Flight 68k in lab.

3. Hardware & Software Requirements

a) A PC running the Windows NT, 2000,XP,Vista or seven operating systems.

b) IDE 68K, 68k Visual Simulator, Flight 68k.

SEE 3223 Microprocessor Alarm System

5

4. Statement of Problem

In this assignment you will be using the 68000 IDE Version 2.11 and the Visual Simulator Version 1.40. You will build 68000 program, cross-assemble and assemble it using the 68000 IDE. You will run the program using the Visual Simulator. The program will use the Peripheral simulator built in the Visual Simulator for its Input/Output interface.

Base on the examples in switch.asm and VOLTMTR.asm, design and build a program which performs the function of a HOME alarm system. The following are the function of the IRQ buttons and switches panel, message denoted by LED’s panel, and requirements of the alarm system.

Function of each IRQ button.

Button IRQ# Function

I1 1I2 2I3 3I4 4I5 5 Enter push button switch to read Password from Switches panel I6 6 Arm Alarm push button switchI7 7 Disarm Alarm

Message denoted by LED

Bit #

Function

0 SECTOR1_LED 1 SECTOR2_LED 2 SECTOR3_LED 3 SECTOR4_LED 4 Siren On (SIREN_ON)5 Counting Down done (COUNT_ZERO)6 Alarm Armed (ARMED_LED)7 Alarm Disarmed (DISARMED_LED)

SEE 3223 Microprocessor Alarm System

6

Function of each bit of the Switches panel

Bit #

Function

0 Main door opened (MAINDOOR)1 Sensors at sector 1 (SECTOR1_SENSOR)2 Sensors at sector 2 (SECTOR2_SENSOR)3 Sensors at sector 3 (SECTOR3_SENSOR)4 Sensors at sector 4 (SECTOR4_SENSOR)5 Password bit #06 Password bit #17 Password bit #2

Requirements:

If alarm is DISARMED the system will do nothing while waiting for an Arm alarm signal.

When the Alarm is ARMED and it will go into EXITENTRYDOOR mode first before entering PROTECTIVE mode. In the EXITDOOR mode seven the segment panel begins counting down from ten to zero in lapse of approximately 1 second per count. In this mode the ARMED_LED will flicker. When the count reach zero the alarm will go into PROTECTIVE mode.

In PROTECTIVE mode, if the main door is opened the alarm will go into ENTRY mode. In the ENTRY mode seven the segment panel begins counting down from ten to zero in lapse of approximately 2 second per count. In this mode the DISARMED_LED will flicker. In this mode, unless the correct PASSWORD is entered before the count is zero; the siren will be switch ON. The password is entered by setting the switch panel then followed by pressing the I5 button

Anytime in the PROTECTION mode, if any of the sectors’ sensors are activated, the siren will be switched ON.

Assuming a condition that the owner has not exit the main door (say just woke up or accidentally trigger an ALARM), anytime in the PROTECTION mode, if a PASSWORD entry is entered and correct, the alarm will be DISARMED and the siren will be switched OFF (regardless of its current state).

When siren is ON, the alarm disarm button will not disarm the alarm unless a correct 8-bit password has been entered from the switch panel,

SEE 3223 Microprocessor Alarm System

7

Suggested Pseudo Code Solution Main ProgramBegin

Initialise Interrupt vector table to service IRQ5 with IRQ5 Interrupt Service RoutineInitialise Interrupt vector table to service IRQ6 with IRQ6 Interrupt Service RoutineInitialise Interrupt vector table to service IRQ7 with IRQ7 Interrupt Service RoutineALARM_ARM Flag 0 ;DISARM mode

Do :wait for (ALARM_ARM flag = 1) {ARMED mode) from I1 interrupt SR -Toggle DISARMED_LED bitWait 1 second

While (ALARM_ARM flag <> 1)

STANDBY bit 0COUNTDOWN 10

Do ; ARMED:EXITDOOR modeCOUNTDOWN COUNTDOWN-1Toggle ARMED_LED bitWait 1 second

While (COUNTDOWN <> 0)

COUNT_ZERO 1Repeat

If (ALARM_ARM flag= 1)If (MAINDOOR = ON)

Siren Bit 1Else

ALARM_ARM 2 ;PROTECTION modeARMED_LED 1DISARMED_LED 0

EndifEndifIf (ALARM_ARM flag= 2) ;PROTECTION mode

IF (PASSWORD_CORRECT flag = 1) ;Password correctALARM_ARM flag 0Siren LED 0 ;OFF siren

End ifEndifIf (SIREN_ON = 1)

IF (PASSWORD_CORRECT flag = 1) ;Password correctSiren LED 0 ;OFF sirenARMED_LED 0 ;DISARMED_LED 1

End ifElseif (ALARM_ARM flag = 2) ;If ARMED:PROTECTION mode

If (MAINDOOR = ON) ; COUNTDOWN 10

SEE 3223 Microprocessor Alarm System

8

Do :wait for password entry from I5 ISR ARMED:ENTRY modeCOUNTDOWN COUNTDOWN-1Toggle ARMED_LED bitWait 2 second

While (COUNTDOWN <> 0)

IF (PASSWORD_CORRECT flag = 0) ;Password incorrectSiren LED 1 ;ON siren

ElseARMED_LED 1DISARMED_LED 0

EndifEndifIF (SECTOR1_SENSOR=1)

SECTOR1_LED 1SIREN_ON 1

EndifIF (SECTOR1_SENSOR=2)

SECTOR2_LED 1SIREN_ON 1

EndifIF (SECTOR1_SENSOR=3)

SECTOR3_LED 1SIREN_ON 1

EndifIF (SECTOR1_SENSOR=4)

SECTOR4_LED 1SIREN_ON 1

EndifEndif

ForeverEnd

IRQ5 Interrupt Service RoutineBegin

If (Switch panel = password)PASSWORD_CORRECT flag 0

Endif

Return from interrupt

End

IRQ6 Interrupt Service Routine

BeginALARM_ARM flag 1Return from interrupt

End

IRQ7 Interrupt Service Routine

BeginIf (PASSWORD_CORRECT flag = 1)

ALARM_ARM flag 0EndifReturn from interrupt

End

SEE 3223 Microprocessor Alarm System

9

5. System Design

5.1 Flow chart

5.1.1: Flow chart for interrupt

Interrupt 4 Interrupt 5

INT 4INTERRUPT 4

DISPLAY GROUP MEMBERS’ NAME

EXCEPTION“DEVIDE BY ZERO”

TRAP #15

INT 5INTERRUPT 5

STORED SWITCH TO D0

DO =0?

PASSWORD = 11110000D0-11110000

ARMED LED = 0DISARMED LED = 1

SIREN LED =0SOUND =0

ARMED LED = 1DISARMED LED = 0

SIREN LED =1SOUND =1

YESPASSWORDCORRECTCO

NOPASSWORDINCORRECT

SEE 3223 Microprocessor Alarm System

10

Interrupt 6 Interrupt 7

INT 6INTERRUPT 6

INT 7INTERRUPT 7

SYSTEM ARMEDOR EXIT MODE

ARMED LED =1DISARMED LED=0

SYSTEM DISARMED(Correct password must key in. Otherwise, alarm

will be triggered. )

SEE 3223 Microprocessor Alarm System

11

5.1.2 : Flow Chart of Exit Mode, Entry Mode, Protective Mode

NO NOTHING MODE EXIT MODE

DO NOTHING

PRESS “INT 6”

ARMED LED =1DISARMED LED =0SYSTEM ARMED

DO=10

D0 =D0 -1DELAY 1S

DISPLAYED D0

DO =0?

PROTECTIVE MODE

YES

NO

P

STARTSTART

ENDSYSTEM

DISARMED

SEE 3223 Microprocessor Alarm System

12

ENTRY MODE

PROTECTION MODE

DO=10

MAINDOOR OPEN?

YES

NO

P

D0 =D0 -1DELAY 2S

DISPLAYED D0

DO =0?

YES

NO

ENTER CORRECT PASSWORD?

SYSTEM DISARMEDARMED LED = 0

DISARMED LED =1SIREN LED =0

SOUND=0

SIRENARMED LED =1SIREN LED =1

SOUND=1

YES

NO

Q

SEE 3223 Microprocessor Alarm System

13

PROTECTIVE MODE

Q

SENSOR 1=1?

SENSOR 2=1?

SENSOR 3=1?

SENSOR 4=1?

P

ARMED LED =1SIREN LED = 1

SECTOR1 LED = 1

ARMED LED =1SIREN LED = 1

SECTOR2 LED = 1

ARMED LED =1SIREN LED = 1

SECTOR3 LED = 1

ARMED LED =1SIREN LED = 1

SECTOR4 LED = 1

NO

NO

NO

NO

YES

YES

YES

YES

SEE 3223 Microprocessor Alarm System

14

5.2 IDE 68k Alarm System Design

SEE 3223 Microprocessor Alarm System

15

SEE 3223 Microprocessor Alarm System

16

SEE 3223 Microprocessor Alarm System

17

SEE 3223 Microprocessor Alarm System

18

SEE 3223 Microprocessor Alarm System

19

6: Corresponding Peripherals of IDE 68k in this program 6.1.LED

6.2. SWITCH

DISARMED

ARMED

COUNTDONE

SIREN

SECTOR4

SECTOR2

SECTOR3

SECTOR1

PASSWORDBIT#1

1

PASSWORDBIT#2

1

PASSWORDBIT#0

1

SECTOR4SENSOR

SECTOR2SENSOR

MAINDOOR

SECTOR3SENSOR

SECTOR1SENSOR

SEE 3223 Microprocessor Alarm System

20

6.3.Seven Segment Display

SEE 3223 Microprocessor Alarm System

21

7.Discussion

7.1 Discussion on Interrupt, Exception and TrapThe program will run start from the main function at address $2000. If the interrupt button was pushed, corresponding interrupt function will be executed. After the interrupt functions ended. Program counter will point to the main program and continued.

Interrupt functionInterrupt 4First, Interrupt function 4 will start by display the name of the Group member.Start from Damian, Ngo and samOutput:

Secondly, it will intialise D0=5, D1=10. It will perform the function D1=D0/D1 continuously. It will reached a stage whereD1=0. Hence , it will perform a “divide by zero exception”. It is denoted byMOVE.B #%01010101 ,$E003.Output:

Finally, it will run Trap #9 function which will terminate the program. We need to reset the program in order to run it again.

SEE 3223 Microprocessor Alarm System

22

7.2 Discussion on IDE 68k’s Alarm System

Interrupt 5 function to armed the alarm system. It is denoted by Armed LED=1Disarmed Led=0

The system is enter the exit mode, end counter will count for 10 amd displau in seven segment display.

“out”symbolize the user is exit the house

When the counter finish count, it will go into protective mode which denoted by

“Prot”at seven segment display and armed LED=1 .

In the protective mode. If the main door open (switch0=1) the program will enter the “entry mode” counter will count 10 times with 2 second delay each time.

“in”symbolize the user is enter the house.

During the counting time, correct password need to enter to disarmed the alarmThe correct password is #%11110000

If the password correct: disarmed LED=1, seven segment display: “darm”

SEE 3223 Microprocessor Alarm System

23

If the password is incorrect or no password is key in after the counting time. The alarm will triggered. It will denoted byArmed LED=1Siren LED =1

Seven Segment display : “beeP”Sound =1

To disarmed the alarm, correct password need to be entered and press the disarmed interrupt (interrupt 7)if the password correct, the system will be disarmed and denoted byDisarmed LED=1

Seven segment display : “darm”

If the password still incorrect, the alarm is remained triggered.

SEE 3223 Microprocessor Alarm System

24

In the protective mode. If the main door not open (switch0=0) the program will

remained at the “protective mode”. which denoted by “Prot” at seven segment display and armed LED=1 .

If any sensor switch is triggered. The alarm system will be triggered as well.Example: sensor 2 is triggeredOutput: Armed LED=1

Siren LED=1 Sensor 2 LED=1 Sound =1

Seven Segment display : “beeP”

If no sensor switch is triggered. The alarm system will remained at protective mode

To disarmed the triggered alarm, user can only use the interrupt 7 (disarmed interrupt) and key in the correct password, The alarm remained triggered as long as incorrect password is keyed in.

SEE 3223 Microprocessor Alarm System

25

8.0 Conclusion

1. The requirements stated were fulfilled by comparing the output

of the program.

2. The alarm system design was functioning.

3. The output of the program were obtained through the 68k

Visual Simulator.

4. Students were trying to some part of the program by using

Flight 68k.

SEE 3223 Microprocessor Alarm System

26

9.0 References

1. Lecturer notes of SEE3223 Microprocessor by Mr Kamal Khalil

2. Microprocessor Theory and Applications with 68000/68020 and Pentium

by M. RAFIQUZZAMAN, Ph.D.

SEE 3223 Microprocessor Alarm System

27

10. Soft Copy Of Simulation file