Difference between revisions of "S14: Android based Automation"

From Embedded Systems Learning Academy
Jump to: navigation, search
(Hardware Interface)
(Implementation)
Line 152: Line 152:
  
 
=== Implementation ===
 
=== Implementation ===
This section includes implementation, but again, not the details, just the high levelFor 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.
+
'''Hardware Tasks'''
 +
 
 +
'''Switching Task'''
 +
 
 +
This task is the main processing place in this entire program. The task it performs is that it analyses the data received and does the intended action. This task doesn't take any inputs it gets context switched from get_data task when it receives any data into the queue. It waits for the queue item for 300ms and in case if doesn't receive any information on which it can start the process then it send the data frame it received to the other SJ One board connected in this network. Where the other SJ One board does the remaining action. This task when it gets the signal from the get_data task it compares the signal in an if cascade. It records the previous signal and it compares it with the present signal, in case if both the signals are different then it sends a toast of appropriate action to the Android application. The follow of the function is explain in the following diagram.
 +
 +
 +
 
 +
The snippet of the task is as followed for the clear understanding.
 +
 
 +
 
 +
'''Get Data Task'''
 +
 
 +
Get data task is where the data frame is received from the Android application. By using the FreeRTOS API's we receive the data from the UART-3 receive line. The data received is in character then we convert it to the format we needed. Then the pass code is compared against the pre-defined codes, if there is a match then we proceed onto add the signal into the queue. The tasks get context switched because the switch task is with higher priority. Once the data is written into the queue then immediately the switch task starts running, where it receives the signal from the queue. The detailed data flow is as follows.
 +
 
 +
   
 +
The snippet of the task is as followed for the clear understanding.
 +
 
 +
 
 +
'''Temperature Task'''
 +
 
 +
In this task we read the temperature sensor values and send it via an SPI bus to the 7-segment display to display it. This task sends a toast to the Android application that the temperature in the place where this SJ One board is present. The code snippet is as follows for reference.
 +
 +
'''Light Sensor Task'''
 +
 
 +
This function reads the light sensor values and valuates it to our requirements. This is a Boolean function where it returns where the relay should be switched on or off based on the values presented by the sensor. The function is snippet is as follows.
 +
 +
'''SOS Task'''
 +
 
 +
This task transmits SOS i.e. Save Our Souls which is a help signal in case of emergency. It is transmitted as an alternative pattern of Dots and Dashes i.e. electronically 1's and 0's. This function switches relay alternatively by approximately half a second, then the lights all connected to this network would On and Off in a pattern.
  
 
== Testing & Technical Challenges ==
 
== Testing & Technical Challenges ==

Revision as of 00:16, 23 May 2014

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.

Project Title

ANDROID BASED AUTOMATION

Abstract

This project is to develop an Android application which can be used to switch an electrical appliance On/Off, and notify the status to the user through his mobile device. Here we connect an Android Application running device to the SJSU One board using Bluetooth protocol and make the board detect the signals coming from the Android device via a Bluetooth module. This board generates operation in according to the incoming signals.

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.

Team Members & Responsibilities

  • Bhargava Kunchanapalli
    • (Hardware Implementation)
  • Harsha
    • (Android Development)
  • Kiran Vaddey
    • (Device Drivers and FreeRTOS Programming)

Schedule

Show a simple table or figures that show your scheduled as planned before you started working on the project. Then in another table column, write down the actual schedule so that readers can see the planned vs. actual goals. The point of the schedule is for readers to assess how to pace themselves if they are doing a similar project.

Schedule

Date Task Status Notes
2/24 Project Reviewing Completed
3/6 Parts Ordered Completed
3/13 Review Data sheets & Bluetooth module interfacing Completed
3/20 Installation of Android SDK and Designing a blue print of the application Completed
3/27 Android Application development (Continued...) Completed
4/3 Interfacing the mobile application with SJ-One Board using Bluetooth module Completed
4/10 Setup the interface between the SJ-One Board and External Peripherals Completed
4/17 Improving software functionality on Unique Features Completed
4/24 Testing and Debugging Completed
5/1 Testing and Debugging Completed
5/8 Final Demo Pending

Parts List & Cost

Qty Description Total Cost
1 HC - 05 Bluetooth UART Module $10.00
1 SJ One Board $160.00
1 Relay Module $10.00
1 Any Android Phone $0.00
Total Cost 180.00

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

Electrical Switching Circuitry The electrical switching is done using a circuitry which uses relays to switch the lines. The voltage we handle here is 110V and frequency 60Hz. The transistor used in here produce sufficient current that is approximately 200V with a voltage supply of 9V rather than traditional 5V supply with drives less current when used against SJSU One board and it is used to switch the operation of the relay. The 3.3V supplied by the SJSU One board from the GPIO port is not sufficient to power the relay so the relay control board is been used in this project. As seen below, the circuit consists of a transistor, an LED, and a power supply.

The LED is connected to the control signal to show whether the relay should be turn on or turn off. The transistor acts as a switch to enable and disable the relay depending on the signal received from SJ One board. When the LPC 1768 gets the data frame from the Android application it processes it for signal and pass code where signal is processed in switch_task in our program to act accordingly. The pass code is matched against the codes which are pre assigned to identify the user.


Hardware Interface

UART Bus

The UART bus is used to communicate between Bluetooth device and the microcontroller. UART pins are power on the SJ One board using UART init function API provided by the FreeRTOS. The initialized pins are driven by the UART driver to handle the communication. Each of the UART pin if logic high produce a output voltage of 3.3V and if logic low produce a 0.0V. The SJ One board has a switch between UART-2 & UART-3, to make a selection. If we want to uses both for them then we have to use them as GPIO pins.

GPIO Port

The GPIO port is used to enable or disable the transistor and the indicator LED. When the LPC1768 micro-controller recognizes a pass code that is sent from the Android, it will send 3.3V through the GPIO which is connected to the relay circuit. Above is the GPIO initialization function. We have used port-1 pins that is P0.0 and P0.1 pins to give a 3.3V voltage to the relay circuit board. First the pins need to be selected and then the direction of the pin needs to be specified. For instance an output pin would be set to a 1 while an input would be set to 0.

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.

Implementation

Hardware Tasks

Switching Task

This task is the main processing place in this entire program. The task it performs is that it analyses the data received and does the intended action. This task doesn't take any inputs it gets context switched from get_data task when it receives any data into the queue. It waits for the queue item for 300ms and in case if doesn't receive any information on which it can start the process then it send the data frame it received to the other SJ One board connected in this network. Where the other SJ One board does the remaining action. This task when it gets the signal from the get_data task it compares the signal in an if cascade. It records the previous signal and it compares it with the present signal, in case if both the signals are different then it sends a toast of appropriate action to the Android application. The follow of the function is explain in the following diagram.


The snippet of the task is as followed for the clear understanding.


Get Data Task

Get data task is where the data frame is received from the Android application. By using the FreeRTOS API's we receive the data from the UART-3 receive line. The data received is in character then we convert it to the format we needed. Then the pass code is compared against the pre-defined codes, if there is a match then we proceed onto add the signal into the queue. The tasks get context switched because the switch task is with higher priority. Once the data is written into the queue then immediately the switch task starts running, where it receives the signal from the queue. The detailed data flow is as follows.


The snippet of the task is as followed for the clear understanding.


Temperature Task

In this task we read the temperature sensor values and send it via an SPI bus to the 7-segment display to display it. This task sends a toast to the Android application that the temperature in the place where this SJ One board is present. The code snippet is as follows for reference.

Light Sensor Task

This function reads the light sensor values and valuates it to our requirements. This is a Boolean function where it returns where the relay should be switched on or off based on the values presented by the sensor. The function is snippet is as follows.

SOS Task

This task transmits SOS i.e. Save Our Souls which is a help signal in case of emergency. It is transmitted as an alternative pattern of Dots and Dashes i.e. electronically 1's and 0's. This function switches relay alternatively by approximately half a second, then the lights all connected to this network would On and Off in a pattern.

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

Send me your zipped source code and I will upload this to SourceForge and link it for you.

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.