Vechicle Automation Using Android

download Vechicle Automation Using Android

of 51

Transcript of Vechicle Automation Using Android

  • 7/31/2019 Vechicle Automation Using Android

    1/51

    PROGRESS

    REPORTPHASE -1

    DATE :16 MAR 2012

  • 7/31/2019 Vechicle Automation Using Android

    2/51

    Vehicle Automation

    On

    ANDROID PhoneBYUSING BLUETOOTH

  • 7/31/2019 Vechicle Automation Using Android

    3/51

    PROJECT GUIDE :Thejaswini Theju.

    Lecturer, Dept. of ECE, JSSATE

    Project Associates :

    HARSHA RAJU.

    DILIP KUMAR.

    SANJAY KUMAR.K.

    Najib Farooq.

    http://www.facebook.com/profile.php?id=1036582813http://www.facebook.com/profile.php?id=1036582813http://www.facebook.com/profile.php?id=1036582813http://www.facebook.com/profile.php?id=1036582813
  • 7/31/2019 Vechicle Automation Using Android

    4/51

    Progress Report-1

    ANDROID SIDE APP DESIGNING HARSHA

    BLUETOOTH ANDROID APP SANJAY

    ACTUATOR SIDE TESTING NAJIB & DILIP

  • 7/31/2019 Vechicle Automation Using Android

    5/51

    ABSTRACT

    Android is a software stack for mobile devices thatincludes an operating system, middleware and key

    applications. The Android SDK provides the tools andAPIs necessary to begin developing applications on theAndroid platform using the Java programming language.Mobile phones have almost become an integral part ofus serving multiple needs of humans. This applicationmakes use of the Bluetooth features of mobile phone asa solution for vehicle automation

    http://developer.android.com/sdk/index.htmlhttp://developer.android.com/sdk/index.html
  • 7/31/2019 Vechicle Automation Using Android

    6/51

    Controllerareanetwork (CAN or CAN-bus) isa vehicle bus standard designed toallow microcontrollers and devices tocommunicate with each other within avehicle without a host computer. Inour project we are going to implement

    CAN based vehicle automation byusing Bluetooth for user security.

    http://en.wikipedia.org/wiki/Vehicle_bushttp://en.wikipedia.org/wiki/Microcontrollerhttp://en.wikipedia.org/wiki/Host_computerhttp://en.wikipedia.org/wiki/Host_computerhttp://en.wikipedia.org/wiki/Microcontrollerhttp://en.wikipedia.org/wiki/Vehicle_bus
  • 7/31/2019 Vechicle Automation Using Android

    7/51

    ANDROID ARCHITECTURE

  • 7/31/2019 Vechicle Automation Using Android

    8/51

    BLOCK DIAGRAM

    wireless

    ANDROIDMOBILEWITH

    OMAP44APROCESS

    OR

    GPS

    GSM

    ZIGBEE

    BLUETOOTHBLUETOOTH

    ARM 7BOARD

    CAN

    Actuator

  • 7/31/2019 Vechicle Automation Using Android

    9/51

    HARDWARE REQUIREMENTS

    Android mobile

    ARM 7 Board Controller Area Network (CAN)

    Bluetooth

    SOFTWARE REQUIREMENTS

    Android SDK

    Eclipse SDK

    Linux Kernel

    Keil version 3

    TECHNOLOGY USED

    Bluetooth

  • 7/31/2019 Vechicle Automation Using Android

    10/51

    Android Development

    Android is an operating system based on Linux with aJava programming interface.

    The Android Software Development Kit (Android SDK)provides all necessary tools to develop Androidapplications. This includes a compiler, debugger and adevice emulator, as well as its own virtual machine torun Android programs.

    Android is currently primarily developed by Google.

  • 7/31/2019 Vechicle Automation Using Android

    11/51

    Dalvik Virtual Machine

    The Android system uses a special virtual machine, i.e.

    the Dalvik Virtual Machine to run Java basedapplications. Dalvik uses an own bytecode format whichis different from Java bytecode.

    Therefore you cannot directly run Java class files onAndroid, they need to get converted in the Dalvik

    bytecode format.

  • 7/31/2019 Vechicle Automation Using Android

    12/51

    Installation:Eclipse:

    Eclipse is created by an Open Sourcecommunity and is used in severaldifferent areas, e.g. as a developmentenvironment for Java or Androidapplications. Eclipse roots go back to2001.

    Most people know Eclipse as an

    integrated development environment(IDE) for Java. Today it is the leadingdevelopment environment for Java witha market share of approx. 65%.

  • 7/31/2019 Vechicle Automation Using Android

    13/51

    Eclipse requires an installed Java Runtime.Recommend to useJava 7 (also known as Java 1.7) or Java 6.

    Java comes in two flavors, the Java Runtime Environment (JRE)and the Java Development Kit (JDK). The JRE contains only the

    necessary functionality to start Java programs, while the JDKcontains in addition the development tools.

    Eclipse contains its own development tools, e.g. Java compiler.

    To install Eclipse download the package "Eclipse IDE for JavaDevelopers" from the

    websitehttp://www.eclipse.org/downloads and unpack it to a localdirectory.

    http://www.eclipse.org/downloadshttp://www.eclipse.org/downloads
  • 7/31/2019 Vechicle Automation Using Android

    14/51

  • 7/31/2019 Vechicle Automation Using Android

    15/51

  • 7/31/2019 Vechicle Automation Using Android

    16/51

  • 7/31/2019 Vechicle Automation Using Android

    17/51

  • 7/31/2019 Vechicle Automation Using Android

    18/51

    How to Install a specific Android version

    The Android SDK Manager allows you to install specificversions of Android. SelectWindow Android SDK

    Manager from the Eclipse menu.

  • 7/31/2019 Vechicle Automation Using Android

    19/51

  • 7/31/2019 Vechicle Automation Using Android

    20/51

  • 7/31/2019 Vechicle Automation Using Android

    21/51

    Android virtual device - Emulator

    The Android Development Tools (ADT) includes anemulator to run an Android system. The emulator

    behaves like a real Android device and allows you to testyour application without having a real device.

    You can configure the version of the Android system youwould like to run, the size of the SD card, the screenresolution and other relevant settings. You can defineseveral of them with different configurations.

  • 7/31/2019 Vechicle Automation Using Android

    22/51

  • 7/31/2019 Vechicle Automation Using Android

    23/51

    Create an Android Virtual Device

    To define an Android Virtual Device (ADV) open the "AVDManager" via Windows AVD Manager and press "New"

  • 7/31/2019 Vechicle Automation Using Android

    24/51

  • 7/31/2019 Vechicle Automation Using Android

    25/51

    To Create Our Android App

    Select File New Other Android AndroidProject and create the Android projectharsha.android.bluetooth". Enter the following

  • 7/31/2019 Vechicle Automation Using Android

    26/51

    Select the required sdk next

  • 7/31/2019 Vechicle Automation Using Android

    27/51

    After selecting the next button thefollowing directory will be created in

    eclipse

  • 7/31/2019 Vechicle Automation Using Android

    28/51

    The Android SDK allows the developer to define certain

    artifacts, e.g. strings and UI's, in two ways: via a richeditor, and directly via XML. The following descriptiontries to use the rich UI but for validation the resultingXML is also displayed. You can switch between boththings by clicking on the tab on the lower part of thescreen.

  • 7/31/2019 Vechicle Automation Using Android

    29/51

  • 7/31/2019 Vechicle Automation Using Android

    30/51

    To create attributes

    Android allows you to create attributes for resources,

    e.g. for strings or colors. These attributes can be used inyour UI definition via XML or in your Java source code.

    Select the file "res/values/string.xml" and press "Add".Select "Color" and enter "myColor"

  • 7/31/2019 Vechicle Automation Using Android

    31/51

  • 7/31/2019 Vechicle Automation Using Android

    32/51

    Once the attributes are chosen we can start adding the UIElements. We have to select res/layout/main.xml" and open the

    Android editor via a double-click. This editor allows you to createthe UI via drag and drop or via the XML source code. You canswitch between both representations via the tabs at the bottom ofthe editor. For changing the position and grouping elements youcan use the outline view.

  • 7/31/2019 Vechicle Automation Using Android

    33/51

    The following shows a screenshot of the Palette view from which you can drag and drop

    new UI elements into your layout.

  • 7/31/2019 Vechicle Automation Using Android

    34/51

    From the Palette section Form Widgets, drag a Buttonobject onto the layout.

  • 7/31/2019 Vechicle Automation Using Android

    35/51

    BLUETOOTH

    This document describes how to use the Android Bluetooth APIs toaccomplish the four major tasks necessary to communicate usingBluetooth: setting up Bluetooth, finding devices that are either

    paired or available in the local area, connecting devices, andtransferring data between devices.

    All of the Bluetooth APIs are available inthe android.bluetooth package. Here's a summary of the classesand interfaces you will need to create Bluetooth connections:

    http://developer.android.com/reference/android/bluetooth/package-summary.htmlhttp://developer.android.com/reference/android/bluetooth/package-summary.html
  • 7/31/2019 Vechicle Automation Using Android

    36/51

    BluetoothAdapter

    Represents the local Bluetooth adapter

    (Bluetooth radio). The BluetoothAdapter is the entry-pointfor all Bluetooth interaction. Using this, you can discoverother Bluetooth devices, query a list of bonded (paired)devices, instantiate aBluetoothDevice using a known MACaddress, and create a BluetoothServerSocket to listen forcommunications from other devices.

    http://developer.android.com/reference/android/bluetooth/BluetoothAdapter.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothAdapter.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothDevice.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothDevice.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothAdapter.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothAdapter.html
  • 7/31/2019 Vechicle Automation Using Android

    37/51

    BluetoothDevice

    Represents a remote Bluetooth device. Use thisto request a connection with a remote device throughaBluetoothSocket or query information about the devicesuch as its name, address, class, and bonding state.

    http://developer.android.com/reference/android/bluetooth/BluetoothDevice.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothDevice.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.html
  • 7/31/2019 Vechicle Automation Using Android

    38/51

    BluetoothSocket

    Represents the interface for aBluetooth socket (similar to a TCP Socket).This is the connection point that allows anapplication to exchange data with anotherBluetooth device via InputStream andOutputStream.

    http://developer.android.com/reference/android/bluetooth/BluetoothSocket.htmlhttp://developer.android.com/reference/java/net/Socket.htmlhttp://developer.android.com/reference/java/net/Socket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.htmlhttp://developer.android.com/reference/java/net/Socket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.html
  • 7/31/2019 Vechicle Automation Using Android

    39/51

    BluetoothServerSocket

    Represents an open server socket that listens for incoming requests(similar to a TCP ServerSocket). In order to connect two Androiddevices, one device must open a server socket with this class. When aremote Bluetooth device makes a connection request to the thisdevice, the BluetoothServerSocket will return aconnectedBluetoothSocket when the connection is accepted.

    BluetoothClass

    Describes the general characteristics and capabilities of a Bluetoothdevice. This is a read-only set of properties that define the device'smajor and minor device classes and its services. However, this doesnot reliably describe all Bluetooth profiles and services supported bythe device, but is useful as a hint to the device type.

    BluetoothProfile

    An interface that represents a Bluetooth profile. A Bluetooth profile isa wireless interface specification for Bluetooth-based communicationbetween devices. An example is the Hands-Free profile.

    http://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.htmlhttp://developer.android.com/reference/java/net/ServerSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothClass.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothProfile.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothProfile.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothClass.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.htmlhttp://developer.android.com/reference/java/net/ServerSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.htmlhttp://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.html
  • 7/31/2019 Vechicle Automation Using Android

    40/51

    Bluetooth Permissions In order to use Bluetooth features in your application, you need to

    declare at least one of two Bluetoothpermissions:BLUETOOTH and BLUETOOTH_ADMIN.

    You must request the BLUETOOTH permission in order to performany Bluetooth communication, such as requesting a connection,accepting a connection, and transferring data.

    You must request the BLUETOOTH_ADMIN permission in order toinitiate device discovery or manipulate Bluetooth settings. Mostapplications need this permission solely for the ability to discoverlocal Bluetooth devices. The other abilities granted by this

    permission should not be used, unless the application is a "powermanager" that will modify Bluetooth settings upon userrequest. Note: If you use BLUETOOTH_ADMIN permission, thenmust also have the BLUETOOTH permission.

    http://developer.android.com/reference/android/Manifest.permission.htmlhttp://developer.android.com/reference/android/Manifest.permission.htmlhttp://developer.android.com/reference/android/Manifest.permission.htmlhttp://developer.android.com/reference/android/Manifest.permission.htmlhttp://developer.android.com/reference/android/Manifest.permission.htmlhttp://developer.android.com/reference/android/Manifest.permission.htmlhttp://developer.android.com/reference/android/Manifest.permission.htmlhttp://developer.android.com/reference/android/Manifest.permission.htmlhttp://developer.android.com/reference/android/Manifest.permission.htmlhttp://developer.android.com/reference/android/Manifest.permission.htmlhttp://developer.android.com/reference/android/Manifest.permission.htmlhttp://developer.android.com/reference/android/Manifest.permission.html
  • 7/31/2019 Vechicle Automation Using Android

    41/51

    To Declare the Bluetooth permission(s) inyour application manifest file:

    ...

  • 7/31/2019 Vechicle Automation Using Android

    42/51

    Here is a basic example of a threadthat initiates a Bluetooth connection:

    private class ConnectThread extends Thread {private final BluetoothSocket mmSocket;

    private final BluetoothDevice mmDevice;

    public ConnectThread(BluetoothDevice device) {// Use a temporary object that is later assigned to mmSocket,// because mmSocket is finalBluetoothSocket tmp = null;mmDevice = device;

    // Get a BluetoothSocket to connect with the given BluetoothDevicetry {

    // MY_UUID is the app's UUID string, also used by the server codetmp = device.createRfcommSocketToServiceRecord(MY_UUID);

    } catch (IOException e) { }mmSocket = tmp;

    }

    public void run() {// Cancel discovery because it will slow down the connectionmBluetoothAdapter.cancelDiscovery();

    try {// Connect the device through the socket. This will block// until it succeeds or throws an exceptionmmSocket.connect();

    } catch (IOException connectException) {// Unable to connect; close the socket and get outtry {

    mmSocket.close();} catch (IOException closeException) { }return;

    }

    // Do work to manage the connection (in a separate thread)

    manageConnectedSocket(mmSocket);}

    /** Will cancel an in-progress connection, and close the socket */public void cancel() {

    try {mmSocket.close();

    } catch (IOException e) { }}

    }

    Managing a Connection

  • 7/31/2019 Vechicle Automation Using Android

    43/51

    Managing a Connection

    private class ConnectedThread extends Thread {private final BluetoothSocket mmSocket;private final InputStream mmInStream;private final OutputStream mmOutStream;

    public ConnectedThread(BluetoothSocket socket) {mmSocket = socket;InputStream tmpIn = null;OutputStream tmpOut = null;

    // Get the input and output streams, using temp objects because// member streams are finaltry {

    tmpIn = socket.getInputStream();tmpOut = socket.getOutputStream();

    } catch (IOException e) { }

    mmInStream = tmpIn;mmOutStream = tmpOut;

    }

    public void run() {byte[] buffer = new byte[1024]; // buffer store for the streamint bytes; // bytes returned from read()

    // Keep listening to the InputStream until an exception occurswhile (true) {

    try {// Read from the InputStreambytes = mmInStream.read(buffer);

    // Send the obtained bytes to the UI activitymHandler.obtainMessage(MESSAGE_READ, bytes, -1, buffer)

    .sendToTarget();} catch (IOException e) {

    break;}

    }}

    /* Call this from the main activity to send data to the remote device */public void write(byte[] bytes) {

    try {mmOutStream.write(bytes);} catch (IOException e) { }

    }

    /* Call this from the main activity to shutdown the connection */public void cancel() {

    try {mmSocket.close();

    } catch (IOException e) { }}

    }

    A t t

  • 7/31/2019 Vechicle Automation Using Android

    44/51

    Actuator

  • 7/31/2019 Vechicle Automation Using Android

    45/51

    This actuator can move the metal hook shown in thisphoto to the left or right. When mounted in the car, it isvertical, so the hook can move up or down. It mimics

    your motions when you pull the knob up or push itdown.

    The power-door-lock actuator is a pretty straight forwarddevice

  • 7/31/2019 Vechicle Automation Using Android

    46/51

    Inside the Actuator

  • 7/31/2019 Vechicle Automation Using Android

    47/51

    This system is quite simple. A small electric motor turns a seriesofspur gears that serve as a gear reduction. The last gear drivesa rack-and-pinion gearset that is connected to the actuator rod.The rack converts the rotational motion of the motor into thelinear motion needed to move the lock.

    One interesting thing about this mechanism is that while themotor can turn the gears and move the latch, if you move thelatch it will not turn the motor. This is accomplished by aneat centrifugal clutch that is connected to the gear and engagedby the motor.

    http://electronics.howstuffworks.com/motor.htmhttp://auto.howstuffworks.com/gear2.htmhttp://auto.howstuffworks.com/gear-ratio.htmhttp://auto.howstuffworks.com/gear6.htmhttp://auto.howstuffworks.com/clutch.htmhttp://auto.howstuffworks.com/clutch.htmhttp://auto.howstuffworks.com/clutch.htmhttp://auto.howstuffworks.com/gear6.htmhttp://auto.howstuffworks.com/gear6.htmhttp://auto.howstuffworks.com/gear6.htmhttp://auto.howstuffworks.com/gear6.htmhttp://auto.howstuffworks.com/gear6.htmhttp://auto.howstuffworks.com/gear6.htmhttp://auto.howstuffworks.com/gear-ratio.htmhttp://auto.howstuffworks.com/gear2.htmhttp://electronics.howstuffworks.com/motor.htmhttp://electronics.howstuffworks.com/motor.htm
  • 7/31/2019 Vechicle Automation Using Android

    48/51

    http://auto.howstuffworks.com/clutch.htmhttp://auto.howstuffworks.com/clutch.htm
  • 7/31/2019 Vechicle Automation Using Android

    49/51

    Fitting of Actuator in Vehicle

  • 7/31/2019 Vechicle Automation Using Android

    50/51

    Next on list:

    PROGRAMMING OF ARM 7 PROCESSOR.

    BLUETOOTH RECIEVER CONFIGRATION.

    ANDROID APP INSTALLATION AND TESTING ON A REALDEVICE.

    TPMS SENSORS AND DISPLAY UNIT.

  • 7/31/2019 Vechicle Automation Using Android

    51/51