S17: Smart security system

From Embedded Systems Learning Academy
Revision as of 07:07, 23 May 2017 by Proj user13 (talk | contribs) (Software Design)

Jump to: navigation, search

Grading Criteria

  • How well is Software & Hardware Design described?
  • How well can this report be used to reproduce this project?
  • Code Quality
  • Overall Report Quality:
    • Software Block Diagrams
    • Hardware Block Diagrams
      Schematic Quality
    • Quality of technical challenges and solutions adopted.

Smart security system

Abstract

The fact that we are often not home doesn’t have to mean our home can’t be safe. That’s why we decided to work on smart security system which will provide safety and piece of mind for users.

Main task of our project is to detect movement, turn camera towards critical area, take a picture and upload it to web where user will be able to see what was captured. Also, user will be given a possibility to control camera remotely.

It is all done by using two SJOne boards. One of them is used as remote control while the other one will be our brain which will control everything. Two motion sensors are connected to main SJOne board. If they sense the movement, controlor will send PWM signal to move motors in desired direction. Controlor will, at the same time, send signal over UART to Raspberry Pi which controls the camera and take a picture. Picture is then sent as .jpeg to web. It is received by our web application and displayed to screen where user can see what was captured. Based on what he sees user can use remote control (SJOne board) and move camera left, right, up or down.

We are taking accelerometer values from SJOne board which is used as remote control and sending them over Nordic Wireless to other board. After other board receives those values it will send PWM signal to move motors/camera in desired direction.

Objectives & Introduction

Show list of your objectives. This section includes the high level details of your project. You can write about the various sensors or peripherals you used to get your project completed.

Objectives

The objectives are as follows:

  1. To be able to detect the movement by using PIR sensors and send signals to SJOne board
  2. To be able to move motors which holds camera mount left, right, up and down by PWM signal
  3. To be able to send signal over UART from SJOne board to Raspberry Pi
  4. To be able to take a picture and upload it to web
  5. To be able to receive and show picture on the web
  6. To be able to take accelerometer values from one SJOne board and send it over Nordic Wireless to another


Team Members & Responsibilities

  • Kayalvizhi Rajagopal
  • Parth
  • Purvil
  • Miroslav Grubic
  • SHubham

Project Schedule

Sr. No. Start Date End Date Task Status Actual Completion Date
1 03/20/2017 03/26/2017
  • Research on the components required and prepare a list
  • Setup slack for team coordination
Completed 03/26/2017
2 03/27/2017 04/02/2017
  • Order the parts
  • Set up git and kanban board
Completed/In Progres
3 04/03/2017 04/09/2017
  • Study the data sheets components & prepare a high level design.
Completed
4 04/10/2017 04/16/2017
  • Design PCB layout and order it
  • Interface individual components to the controller and test their working
Completed 04/20/2017
5 04/17/2017 04/27/2017
  • Integrate sensors and motors
  • Test working of nordic wireless
Completed
6 04/28/2017 05/04/2017
  • Integrate camera with rest of the board
  • Each controller should be working individually by now. Stress test individual modules.
Completed
7 05/05/2017 05/18/2017
  • Continue with hardware/software development & integration and complete first phase of testing with the PCB
  • Test & fix basic integration bugs
In Progres
8 05/19/2017 05/23/2017
  • Final testing and Demo
Not started

Parts List & Cost

Item. No. Part Description Vendor Qty Cost
1 SG90 Micro Servo motors ebay 4 $26
2 Wireless antenna Amazon 1 $8
3 RF male to male antenna connector Anchor electronics 1 $10
4 Motion sensors Fry's electronics 2 $24
5 Camera mount ebay 1 $1.79
6 Raspberry Pi 1 $35
7 Camera 1 $25

Design & Implementation

The design section can go over your hardware and software design. Organize this section using sub-sections that go over your design and implementation.

Hardware Design

Discuss your hardware design here. Show detailed schematics, and the interface here.


Hardware Block Diagram

PIR Motion Sensor

The ST-00081 is a PIR Sensor that detects motion by sensing the change in the infrared levels of the nearby objects. Whenever any motion is detected the sensor will make the output pin high. The ST-00081 is capable to detect any motion with angle as large as 180˚.We have a potentiometer (Blue part in the back view for PIR sensor) to adjust the sensitivity for the sensor. We are using two PIR sensor to trigger the Camera and take a picture if any object is detected. We are using two PIR sensor to give the orientation for the camera depending where the motion is detected. The sensors will detect any motion (either left or right) depending which sensor detects the moving object. If both sensors detect motion at the same time, it means there is heavy motion of both sides and the camera will be facing the center(the path between two sensors) .

Front view for PIR Sensor
Back view for PIR sensor

PCB Design

PCB design was created in Autodesk Eagle v8.1.0. But first we created a draft, on paper, with all parts and functionalities we wanted to put on our PCB. On sparkfun.com there is a great tutorial about how to create schematic in Eagle.

First decision we had to make was what parts to use. Since we didn’t know fab companies are not soldering components, or charge extra for that, we created schematic with surface-mount components. After realising how small surface-mount components are and how difficult will be to solder them we had to start all over and change all components to through-hole.

Another important step was to choose library from which components will be imported. There is many library out there but we used sparkfun, adafruit and default Eagle library.

PCB Schematics

We created a Board/Board Layout From Schematic also by following sparkfun tutorial Using EAGLE: Board Layout. One of the things that wasn’t well explained in this tutorial is how to create board with your specific dimensions. SInce our plan was to mount SJOne board above PCB it was important to make PCB with the same dimensions as SJOne board and more important, to have holes for standoffs at the same place as the one on SJOne board. Luckily there is “Dimension” tool we used for that, although it wasn’t so easy to delete the lines that are left after using that tool.

After placing components where we wanted them, routing the board was easy with Autorouter...NOT. It produced too many errors, and wires were going too close to through-holes so we have to move wires away from them and basically do the routing manualy. Advice about routing would be to try to keep wires away as much as you can from through-holes, because when we were soldering components we were afraid that iron can damage the routes.

PCB Board Layout

Checking for errors was maybe the most important part of whole process since it helped us detect and correct few errors which we didn’t see during layout. In order to check for errors tool “DRC” Design Rule Check is used. First we used sparkfun anddefault Eagle drc files to check for errors but after we decided which fab company to used, and after checking their website and guidelines we also did final check with their drc file, what is strongly recommended. Same goes with CAM file that helped us create gerber files recomended by fab houses.

Picking a PCB manufacturer was really easy after reading this analysis. We used Oshpark because of this sentence “The quality is excellent, the boards are produced domestically, and shipping is covered in your board price.” No need to say more….or actually there is...they are purple. Yes you read right, purple. It took less then 10 days to receive them from the day we submitted our request.

We already had many components we needed but the ones we didn’t have we had to buy. As the best choice, regarding the price, there is Excess Solution.

  • PCB
  • PCB with components
  • PCB & SJOne Board

Hardware Interface

In this section, you can describe how your hardware communicates, such as which BUSes used. You can discuss your driver implementation here, such that the Software Design section is isolated to talk about high level workings rather than inner working of your project.


Software Design

Show your software design. For example, if you are designing an MP3 Player, show the tasks that you are using, and what they are doing at a high level. Do not show the details of the code. For example, do not show exact code, but you may show psuedocode and fragments of code. Keep in mind that you are showing DESIGN of your software, not the inner workings of it.

Accelerometer

We are taking accelerometer values at SJOne board that is used as remote control and sending numbers that represent range which accelerometer is currently at. There is eight ranges per axis with numbers -4 to 4 representing them. First we created struct with three members, starting value of range, end value of range and number of range. Then we create and initialize array with struct as members. Inside while(1) loop we are getting accelerometer values and looping through all ranges, where we checking if read value of accelerometer belongs to range we are currently at. If the read value belongs to the current range, send the number of that range to motor task.

The below flowchart explains how this tasks works.

Accelerometer flowchart

Nordic Wireless

In this project we are using two SJOne boards. One of them will be connected to two motors which are turning camera arm in desired direction. Camera direction will be based on two events. One of them is if sensor detect movement camera will turn in direction covered by that sensor and another one is controled by client or user of this system by turning another SJOne board. Another SJOne board will serve as a joystick or remote control and it will be possible to turn camera in desired direction by turning SJOne board. Two boards, the one that serve as remote control and the main one will communicate by utilizing Nordic Wireless.

In order for two nodes, in Nordic Wireless, to be able to communicate they need to have same channel number. It is done by editing sys_config.h file Chanel number can be any number between 2402 and 2500

 #define WIRELESS_CHANNEL_NUM            2455   ///< 2402 - 2500 to avoid collisions among 2+ mesh networks

Beside that each node need to have unique address which can bee any number between 1 – 254

 #define WIRELESS_NODE_ADDR              110    ///< Any value from 1-254

We also changed node name, to “tx” and “rx” for testing purpose when we first wanted to ping other board and get its name.

Our NordicSend() task first creates data array with three variables. Two variables are actually X and Y axis values from accelerometer sensor and third indicates this is a manual control, since camera can be turned by sensor too, as explained above. When sending a packet it is important to include address of receiver, “rx” node, number of hops, which in our case can even be 0 since for demo purpose our two boards will be close and will communicate directly with each other, and number of variables. Then it just sends formed packet.

Receiver node, NordicReceive() just receives a packet in defined period of time which gives us three variables sent by “tx” node, representing X and Y axis values, based on which we will control motors and thus turn camera in desired direction and third variable indicating this is a manual control.

The below flowchart explains how this works.

Nordic Wireless flowchart

Servo motor

Nordic Wireless flowchart

[[File: CMPE244 S17 SSS Camera task flowchart.png|600px|thumb|center|Nordic Wireless flowchart]]

Implementation

The software flow was designed such a way that different modules work together, each with a priority assigned and a running rate. The software is divided into different task, each performing a specific task. The overall project involves two boards communicating over wireless network. On the main SJOne board which is the heart of the security system controls two motion sensors, two servos, camera, wifi and Nordic Receiver. The other board which is used for manual control by the user houses accelerometer, switches for control commands and nordic transmitter.

Below figure shows how tasks communicate to each other on a board and across boards.

Software Flow diagram - Tasks interacting with each other



As can be seen in the figure, most tasks communicate with each other via semaphores. On the transmitter side, when user enables the manual control by pressing SW1, a semaphore is given to Accelerometer task, which calculates the orientation and to the Nordic transmitter task, which transmits the orientation value and control commands over wireless mesh network.

On the Receiver side board, servo motor turns the camera based on the motion sensor values by default(left or right) or based on accelerometer orientation if the manual override is ON. Hence the servo task's response is based on 3 different modules - Motion sensor 1, Motion sensor 2 and Nordic wireless receive(which receives the manual override and accelerometer orientation values). Therefore we use 'Event groups', where the servo task wakes up if any of the three tasks set a bit in the event group. Once the task is awake, it checks the 3 bits to see which event invoke it.

Event group bits



The priority is given to manual override bit. If manual override is set, the motion sensors values are ignored and servo responds to accelerometer orientation received over wireless network. If the manula override is OFF, then servo turns left or right or center based on left sensor is triggered or right sensor is triggered or both sensors are triggered.

Whenever the motion sensors are triggered, servo orients the camera to the desired position and gives a semaphore to 'camera task'. This semaphore wakes up the camera task, which transmits command '1' over UART to the Raspberry Pi. When the command '1' is received, raspberry Pi triggers the camera to take a picture and invokes wifi task to upload the image to the webpage.

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

Interface camera with SJOne board

Problem: First issue we encountered was when we wanted to interface camera to the SJOne board. If you look at the pictures of PCB you will notice that in bottom part of PCB there is 8 through-holes that were meant to be used for the camera. They are left unused since camera we had was Arducam. It was supposed to be able to interface it with any board using I2C or SPI. It turned out that only way to interface that camera is by using Arduino boards or Raspberry Pi with Arduino library. So don’t try to do that.

Solution: Problem was solved after consulting Preet and getting permission to use Raspberry Pi just to interface camera but still to send signal to capture photo from SJOne board by UART.

My Issue #2

Male/Female connector for wireless antennas

Problem: We had an issue with antennas for Nordic Wireless. Before we ordered antennas we contacted colleague who was using antennas on SJOne board two semesters before us. With his reference we ordered same antennas, since they've been using them successfully. When antennas arrived our code was already written and ready to test. We were really looking forward to this since this was one of interesting parts of our project. The problem was that antennas we ordered had female connector same as our SJOne boards. SJOne boards manufactured a year ago had male connector so they could use this antennas.

Solution: We didn't want to order new antennas and spend additional money, so we borrowed older SJOne boards just to test our board.

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

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.