Difference between revisions of "F16: Seismograph"

From Embedded Systems Learning Academy
Jump to: navigation, search
m (ADC Task)
m (Bluetooth Task)
Line 140: Line 140:
  
 
==== Bluetooth Task ====
 
==== Bluetooth Task ====
The Bluetooth task is used to send an "Earthquake" message to a mobile application via UART. It utilizes a binary semaphore that gets triggered when an earthquake with a value above hex 0xB00 is detected.  
+
The Bluetooth task is used to send an "Earthquake" message to a mobile application via UART. It utilizes a binary semaphore that gets triggered when an earthquake with a value above hex 0xB00 is detected.
 +
 
 +
[[File:CMPE146 F16 T2 hc06.png|thumb|left]]
  
 
=== Implementation ===
 
=== Implementation ===

Revision as of 00:28, 21 December 2016

Project Title

Seismograph

Abstract

In recent years, news of an upcoming large scale earthquake in California has been increasing. Having a seismograph would allow us to directly see any seismic activity. In addition, by adding an LCD screen, we would be able to add plots of the data in a time series manner for any research purposes. Most importantly, the seismograph device would allow to help with search and rescue efforts. When a large scale earthquake is detected, it would allow a signal to be detected via your cellphone in order to ping your GPS location in case of a building collapse.

Objectives & Introduction

Our seismograph would help bring awareness to the realities of earthquakes in California. In addition, it has the possibility to help save lives by aiding in search and rescue efforts when a large earthquake is encountered.

  • Create a working seismograph and store data onto a microSD card
  • Write software to display data onto an LCD screen
  • Add to software to send signals to cellphone via Bluetooth
  • Write a small mobile application to receive data via Bluetooth

Team Members & Responsibilities

Both team members will be working on all areas of development with specific focuses as follows:

  • Mina Yi
    • Focus on software
      • Display data on LCD screen
      • Mobile application to recognize signal
  • Andrew Ahwal
    • Focus on hardware portion to build a working seismograph

Schedule

  • Responsibility and leadership of the task is indicated by the Assignee.
    • However, it does not mean that they will be expected to complete the tasks alone.
  • Subtasks are listed in the comments section and are numbered.
  • Subtasks will be delegated as seen fit.
  • Any deviation to the schedule due to technical issues will be covered under the Testing & Technical Challenges section.

NOTE: Documentation is not specifically listed in our project schedule. However, each task has a documentation phase before and after each task.

Task# Start Date End Date Task Assignee Status Date Completed Comments
1 10/30 11/12 Order components Both Complete 11/6
2 10/31 11/7 Read datasheets & research Both Complete 11/7
3 11/6 12/1 Interfacing Bluetooth Mina Complete 12/17 1. Set up development environment

2. Create the mobile application

3. Interface SJOne board with the application

4. Send notification via bluetooth

4 11/6 11/17 Build Seismograph circuit Andrew Complete Circuit 11/13 Expected circuit completion date: 11/14

Expected testing dates: 11/14 - 11/17

5 11/18 11/18 Progress update Both Complete 11/18 In class demo of our progress.
6 11/18 11/20 Interface seismograph circuit with SJOne board Andrew Complete 11/20
7 11/21 12/7 Integrate LCD screen with SJOne board & seismograph Mina Complete 12/17 1. Fetch data created by the seismograph

2. Display data on the LCD screen

8 12/7 12/20 Testing and tweaking finalized product Both

Parts List & Cost

Part # Part Name Purchase Location Part Specification Quantity Cost per item
1 Piezoelectric Vibration Sensor With Mass wwww.sparkfun.com Sen-09197 1 $2.95
2 MicroSD Frys Electronics 16GB 1 $9.99
3 Adafruit 1.8" Color TFT Shield w/microSD and Joystick www.Amazon.com NA 1 $34.99
4 HC-06 Bluetooth Module www.Amazon.com NA 1 $8.99
5 1 nF Capacitor HSC Electronics NA 2 $0.12
6 47 nF Capacitor HSC Electronics NA 1 $0.12
7 2.2 μF Capacitor HSC Electronics NA 1 $0.12
8 10 μF Capacitor HSC Electronics NA 1 $0.12
9 10 kΏ Resistor HSC Electronics NA 2 $0.10
10 11 kΏ Resistor HSC Electronics NA 1 $0.10
11 100 kΏ Resistor HSC Electronics NA 5 $0.10
12 221 kΏ Resistor HSC Electronics NA 2 $0.10
13 22 MΏ Resistor HSC Electronics NA 4 $0.10
14 Diode HSC Electronics NA 1 NA
15 OPAMP HSC Electronics LN324N 1 NA
16 Twin Through-hole Protoboard Fry's Electronics NA 1 $20.00
17 Wire Wrapping Wires Fry's Electronics NA NA NA
18 Female and male Jumper Wires Fry's Electronics NA NA NA
19 MC7805CT Voltage Regulator HSC Electronics NA NA NA
20 DC Input HSC Electronics NA NA NA

Design & Implementation

Hardware Design

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

(I am going to write about this section once I better understand how op-amp works The seismograph is constructed using two separate circuits. The first circuit illustrated below as Seismograph Circuit is what generates the voltage. This is done by a piezoelectric sensor that generates millivolts whenever a vibration or seismic activity is detected. The piezoelectric sensor has a positive and negative terminal, which connect both terminals directly to the LM324N amplifying circuit.

At this stage the voltage varies from 2.5 volts at a steady state when no seismic activity is detected. Once a vibration happens causing the piezoelectric sensor to vibrate, the voltage will drop to approximately 0 volts.

The second circuit is a rectifying circuit which takes in the 2.5 volt output that is generated from the Seismograph Circuit. This circuits purpose is to cut off the negative voltage and create only a positive voltage. This voltage that is outputted is what we connect directly into our A2D converter which is developed in the SJONE board.

Seismograph Circuit
Stage 2 Rectifying Circuit

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

The software design consists of 3 main tasks. The LCD task, ADC task, and the Bluetooth task. The ADC task continuously samples data from the seismograph and converts the analog signal to its digital counterpart. It then writes the data received along with a running time stamp (given in ms). The data was divided to an 8 bit value to scale it down for plotting on the LCD screen. The time stamp and the ADC value make up one (x,y) plot on the screen where timestamp is our x value and our 8 bit digital value is our y value. Lastly, the Bluetooth task waits for a signal from the ADC task to send a message to a mobile application.

LCD Task

The LCD task handles all of the drawing of the seismograph data to screen. Below is a flowchart of the design used. The LCD task uses SPI protocol to send data received from the queue to be drawn onto the screen.

LCD Draw Flow Chart

ADC Task

The ADC task converts the data from the seismograph to a digital value and stores it into the SD card as well as providing the value via the freeRTOS queue to the LCD task. A mutex was necessary since both writing to the SD card and LCD screen use SSP1 for transferring data.

The data stored on the SD card is in the format

Suggestion: API for ADC is provided under adc.c and could have been used.

Bluetooth Task

The Bluetooth task is used to send an "Earthquake" message to a mobile application via UART. It utilizes a binary semaphore that gets triggered when an earthquake with a value above hex 0xB00 is detected.

CMPE146 F16 T2 hc06.png

Implementation

Our overall system implementation consists of the following steps:

  1. The seismograph sends data to the SJOne board that gets converted to a digital value
  2. The 12 bit ADC value is checked to see if it is equal or greater than 0xB00 (this value was obtained through expirementation). If it is true, it signals the bluetooth task to send out the earthquake message via UART.
  3. If the mobile application receives an earthquake message, an alert appears on the screen with the GPS coordinate information
  4. The value is sent to a shared queue
  5. The LCD task receives values from the queue and following its state machine, it draws the values to the screen

Pin Connection Table

Pin Pin Mode Direction Usage
Example Example Example Example
Example Example Example Example
Example Example Example Example

Technologies Used

Mobile Application

  • Apache Cordova

Protocols, Hardware, and Peripherals

  • UART
  • SPI
  • Bluetooth
  • 1.8" TFT LCD Screen
  • ADC

Testing & Technical Challenges

Working with the ST7735

Poor Documentation

There were problems initializing the LCD screen due to poor documentation. The only provided for the screen itself was given in Chinese so it was very difficult for us to figure out how much voltage the screen required for power on. We ended up having to read through code originally intended to work for the Arduino to understand the initialization process of the LCD screen. We also compared the pins to the Arduino to figure out the voltage requirements and found that it required both a 3.3v and 5v power source.

Setting Our Origin Point

The ST7735 appears to originally be configured to be used in portrait mode with origin located at the upper left hand corner. In order for us to use draw in landscape with the (0,0) pixel at the bottom left hand corner, we swapped the width and height values (originally 128x160). We then found that it still did not start where we expected it to but instead, the (0,0) mark was on the top left hand corner in landscape view. So, when we drew the pixels, we subtracted the y value by 127 to shift the values down.

Bus Contention Issues

Since both the LCD screen and the SD card were using SSP1 for SPI communication, we had issues where the LCD screen would suddenly turn to an all white screen. We came to the conclusion that since they were using the same lines, there was bus contention. In order to solve this problem, we utilized a mutex to ensure that only one of the tasks was utilizing the line at any given time.

Conclusion

In conclusion, we were able to successfully complete our project. We built a working seismograph and interfaced it with multiple components utilizing the different communication protocols we learned in lab. This project helped solidify our knowledge and understanding of not only how important datasheets are, but how important it is to read them and understand how to read them. We found that due to poor documentation, it made it very difficult for us to actually get things working in a timely manner. We ended up sinking a great amount of time trying to figure out how to initialize the LCD screen and what voltages it expected to even turn it on. In the end, we learned a great deal implementing our project and were able to solidify our understanding of many of the things we learned during our laboratory lectures.

Improvements

In the future, we would improve on this project by implementing a joystick that would allow us to scroll through the data history. In addition, the project could be greatly improved upon if we were able to do extra research in getting accurate readings. Essentially, how do we know what voltage corresponds to what magnitude earthquake? In this project, we had to make some estimations and testing based off trial and error to find a value that fit, but we could increase the accuracy of this design through further testing and research.

In terms of the mobile application, it currently just receives a message and prints it to screen and a pop up appears with the GPS locations. In reality, this would be useless. It would be far more useful to be able to integrate this application with another social media platform like Twitter or Facebook to allow loved ones to know where you are and for people to be able to respond whether they are safe.

Project Video

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

Project Source Code

References

Acknowledgement

A special thank you to the following individuals for their help, guidance, and answering our never-ending array of questions:

  • Preetpal Kang
  • Praveen Prabhakaran
  • Charles MacDonald
  • Dr. Ozemek

References Used

List any references used in project.

Appendix

You can list the references you used.