Difference between revisions of "F16: Door Alarm System"

From Embedded Systems Learning Academy
Jump to: navigation, search
(Software Design)
(Implementation)
Line 196: Line 196:
  
 
=== Implementation ===
 
=== Implementation ===
This section includes implementation, but again, not the details, just the high level. For example, you can list the steps it takes to communicate over a sensor, or the steps needed to write a page of memory onto SPI Flash.  You can include sub-sections for each of your component implementation.
+
The first low priority task would check for the inputs of two motion sensors (This increases the accuracy of the detection). If both sensor sensed a motion in the first task, then it would send some data into the queue to indicate that motion is been detected. The medium priority task would wake up from sleep state because the queue is not empty anymore, this task would check the value on the light sensor to see how bright the room is. If the room is too dark (brightness <20), then there may be a thief inside the house, so an alarm frequency would be sent to the speaker pin. Else, if the value of brightness is pretty bright on the light sensor, just because it's christmas, the micro controller would generate a song called "Jingle Bell" just because it's christmas.
  
 
== Testing & Technical Challenges ==
 
== Testing & Technical Challenges ==

Revision as of 20:59, 20 December 2016



Project Title: Door Alarm System

Abstract

Our project would use a motion detector and light sensor on the SJOne board to control the output of a speaker. If the someone opens the door during daytime, the speaker would output a song as a welcome. However, if the door opened at night where there’s no light, the speaker would output an alarm because there might be thieves coming in during midnight.

Objectives & Introduction

The objective of this project to create a realizable indoor anti-theft system. The system is able to detect the people's motion by using the motion sensor, and judge the current brightness by using the on-board light sensor.

In order to accomplish the objective, we need to the following things:

  • Modified the Pulse-Width Modulation(PWM) source code to allow the speaker to play a song.
  • Figure out how to amplify the sound signal.
  • Using the ADC code to receive the signal from motion sensor.


Team Members & Responsibilities

  • Bowei Zhang
    • Program the speaker.
    • Programming the ADC code.
    • Testing the software.
  • James Huang
    • Improve the playing song algorithm.
    • Design the hardware connection between MCU and external parts.
    • Programming the ADC code

Schedule

The following table is our schedule for this project.


Week# Date Task Completion Comment
week1 Oct31 - Nov4 Project Plan & ordering parts Completed Parts Ordered
week2 Nov 7 - Nov11 Circuit Design & Writing Software (part 1) Completed Finalizing the idea.
week3 Nov14- Nov18 Circuit Design & Writing Software (part 2) Incomplete Speaker with low volume. Consider ordering Amplifier.
week4 Nov21- Nov25 Finish Testing In completed Motion Senor came with damage. Ordering new one.
week5 Nov27- Dec2 Project Report Completed Working on Report. Waiting for sensor.
week6 Dec 3 - Dec9 Cont. Testing & finish project report Incomplete Waiting for Motion sensor. Consider moving to plan B.
week7 Dec12- Dec16 Cont. Testing Completed Report finished. Testing sensor.
week8 Dec17- Dec19 Finish Report & Testing Completed Done

Parts List & Cost

Part Name Quantity Cost Notes
SJone Board 1 $80 SJone Board
Speaker module 1 $2 Buzzer
SD card 1 ~$10
LEDs 4 <$1
Motion Sensor 1 $15 Detector
Signal Amplifier 1 $1 2N3904

Design & Implementation

Hardware Design

The following figure is the system level design of our project.

File:System Level Design.PNG
Figure 1. System Level Design

Hardware Interface

Pulse-Width Modulatio(PWM)

  • As the Figure 1 showed,we connected the speaker with an 2N3904 Amplifier, and then connected it to the on- board PWM Pin (pin2.0)directly. When the speaker output condition is triggered, pin 2.0 will send a PWM signal to the amplifier and it will be amplified to allow the speaker output louder.


Analog to Digital Converter(ADC)

  • In order to receive the data from motion sensor, we connected it with the on-board ADC pin (pin 2.6), the ADC pin will send a 20us trigger signal to trigger the sensor, and then the sensor will return an analog signal. By decoding the signal, we will able to know did the sensor detect something or not.


General Purpose Input/Output (GPIO)

  • The General Purpose Input/Output(GPIO)Pin is used to control the LEDs.







File:Speaker1.PNG
Figure 3. Speaker Connection
File:Sensor1.PNG
Figure 2. Sensor Connection


Sensor Connection

The left figure showed us the sensor circuit. The middle pin which is the trigger pin has been tied to the ADC, so the analog signal that send by the senor is able to transfer to the digital signal that the MCU is able to read.


Speaker Connection

The right figure showed us how to tie the Speaker. First, we use a 1k pull-up resister to prevent the current flows. Then we used the amplifier to amplify the PWM signal to make the song comes out of speaker is loud enough.


File:SM.PNG
Figure 4. State Machine




Software Design

Figure 4 showed us the state machine of the project.

In our project, we used Real Time Operating System (RTOS) for this project. The software design consist of two tasks with different priority level. The low priority task would check for inputs of the motion sensors and if motion is detected from the sensor, the lower priority task would send data to the queue. The medium priority task would then receive the signals from the queue and generate sound for the speaker based on the value of the light sensor. If the brightness is pretty high, then it the micro-controller would output a song named "Jingle Bell", else micro-controller would output an alarm to the speaker because there maybe thieves inside the house.

Implementation

The first low priority task would check for the inputs of two motion sensors (This increases the accuracy of the detection). If both sensor sensed a motion in the first task, then it would send some data into the queue to indicate that motion is been detected. The medium priority task would wake up from sleep state because the queue is not empty anymore, this task would check the value on the light sensor to see how bright the room is. If the room is too dark (brightness <20), then there may be a thief inside the house, so an alarm frequency would be sent to the speaker pin. Else, if the value of brightness is pretty bright on the light sensor, just because it's christmas, the micro controller would generate a song called "Jingle Bell" just because it's christmas.

Testing & Technical Challenges

Describe the challenges of your project. What advise would you give yourself or someone else if your project can be started from scratch again? Make a smooth transition to testing section and described what it took to test your project.


Include sub-sections that list out a problem and solution, such as:


My Issue #1

Discuss the issue and resolution.


Conclusion

Conclude your project here. You can recap your testing and problems. You should address the "so what" part here to indicate what you ultimately learnt from this project. How has this project increased your knowledge?


Project Video

Upload a video of your project and post the link here.


Project Source Code


References

Acknowledgement

Any acknowledgement that you may wish to provide can be included here.


References Used

List any references used in project.


Appendix

You can list the references you used.