chipfc - smarthome

Upload: an-trinh

Post on 04-Jun-2018

225 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 Chipfc - SmartHome

    1/22

    i

    Table of contents

    Table of contents................................................................................................iChapter 1. Introduction...................................................................................1

    About us..................................................................................................1About the project.....................................................................................1

    Chapter 2. Hardware design............................................................................3System block diagram .............................................................................3Master unit ..............................................................................................4Slave unit ................................................................................................5

    2.3.1 Slave Control ....................................................................................82.3.2 Slave Security ...................................................................................8

    2.3.3 Slave Sensor......................................................................................9

    Chapter 3. Software design........................................................................... 11Master block..........................................................................................11Slave unit ..............................................................................................12

    3.2.1 Slave Control .................................................................................. 123.2.2 Slave Security ................................................................................. 133.2.3 Slave Sensor....................................................................................14

    Application on Android phone...............................................................15Chapter 4. Results.........................................................................................17 Chapter 5. Conclusion .................................................................................. 18Chapter 6. Appendix.....................................................................................19

    Schematic of MSP430F2618-DEV slave circuit .................................... 19Schematic of CAN interface ..................................................................20Schematic for 220VAC device driver..................................................... 20

  • 8/13/2019 Chipfc - SmartHome

    2/22

    ii

  • 8/13/2019 Chipfc - SmartHome

    3/22

    1

    Chapter 1. IntroductionAbout us

    Our teams name is ChipFC from Ho Chi Minh City University of Technology.

    Our instructor is Mr Vu Trong Thien, lecturer in Computer Science and

    Engineering, Ho Chi Minh City University of Technology.

    The team has 3 members:

    Lam Xuan Hung Pham Huu Nhan Pham Van Vinh

    About the projectOur main purpose is to implement a Smart Home system using TI

    MCUs. Smart Home is not a new concept, especially in developed countries. However,

    in Vietnam, there are not much companies related to this field and the companies do

    not really have a complete product. Our team chose this project because of its

    interesting and technical nature as well as highly applicability.

    The scenario is that there is a dedicated control system which fully meets the

    users needs, including the environmental conditions and user preferences, the ability

    to operate flexibly, even providing automatic protection and alarming whenever an

    intrusion occurs.

    In this project, we proposed and implemented a model of a simple house with

    living room, garage, toilet which contains installed electrical devices for practical

    appliances. A hierarchical system with Master and Slaves will control these devices

    according to the given scenario.

    Slave devices control the household electrical devices in the rooms, gather

    information (environmental conditions) and send them back to the Master. Meanwhile

    Master not only control and retrieve data from the Slave, but also communicate with

    the user (host) through the connection to their smart phone via Bluetooth - when the

    user is inside the house and GSM when theyre outside. This system allows users to

    control their home easily and visually without any other devices but their own

    cellphones.

  • 8/13/2019 Chipfc - SmartHome

    4/22

    2

    Besides, the Master also allows users to add their own action/scenarios which is

    referenced by Master to control devices, make the system more intelligently. These

    scenarios possibly based on daytime (day night, weekday) or on special events that

    the user specified. The users custom preference can be configured through a virtual

    home model on a computer (based on real home architecture), and transfer the

    configuration to the Master controller.

  • 8/13/2019 Chipfc - SmartHome

    5/22

    3

    Chapter 2. Hardware designSystem block diagram

    According to the scenario of the system described in Chapter 1, we design

    block diagram for the system as follows:

    The following will explain more details about the design of each block of

    Master and Slave in the system.

  • 8/13/2019 Chipfc - SmartHome

    6/22

    4

    Master unitMaster unit is an LM3S811 Eval board of TI. Board contains the ARM Cortex-

    M3 LM3S811 microcontroller, integrated USB ICD programmer, OLED LCD for

    display and some basic communications. The algorithm development become more

    easily thanks to the stable hardware system.

    One of the main tasks of the Master is to communicate with the user's mobile

    phone via Bluetooth. In order to do this, we use the Bluetooth module RN-42. This

    module is connected to the Master board via UART1.

    The Master unit will takes care of communicating with Slave via UART0 based

    on CAN protocol. The pin U0Tx/Rx of LM3S811 board is connected to a 3.3V CAN

  • 8/13/2019 Chipfc - SmartHome

    7/22

    5

    transceiver module, SN65HV230. The output signals of the CAN module are

    differential CAN_high and CAN_low.

    Slave unit

    Slave units are built on the MSP430F2618 microcontroller to take advantage of

    the powerful control ability and low-power consuming characteristic.

    To quickly develop applications with various Slave function, firstly, we

    implement a small core modules, including the MSP430F2618 microcontroller LQFP-

    64, TLV1117 - 3.3V voltage regulator, some essential components and I/O port. The

    module is designed to using USB-FET programmer.

    The following is an image of MSP430F2618-DEV module.

    Power design for MSP430F2618-DEV

  • 8/13/2019 Chipfc - SmartHome

    8/22

    6

  • 8/13/2019 Chipfc - SmartHome

    9/22

    7

    MCU design

    Slaves with various tasks use the same core modules but with different

    connections depending on their function. In the original design, the system will consist

    of 3 Slave:

    Slave Controlimplements controlling and monitoring 220VAC devices, allinformation will be controlled by the Master via CAN bus.

    Slave Security provides basic communication with the user through thekeyboard and LCD display, which acts as an alarm device, allows users to

    log in at home or lock the system when theyre away. When the system is

    locked, if an intrusion is detected, an alarm message will be sent to the

    users phone.

    Slave Sensor acts as an environment monitoring device, gatheringinformation such as lighting power, temperature, humidity, etc. to transfer

    to the Master. Depending on the type of information monitored, Slave

    Sensor can be placed inside or outside the house. If it is outside, Slave

    Sensor will be equipped with a secondary power source, self-

  • 8/13/2019 Chipfc - SmartHome

    10/22

    8

    rechargeable. It can also communicate with the Master via CAN bus or

    Wireless communication (TIs Basic RF, ZigBee, SimpliciTI)

    2.3.1Slave ControlThe main task is to monitor and control devices 220VAC. Slave Control not

    only interfaces with the CAN bus via UART, but also utilizes additional I/O. The 3.3V

    output signal is connected to the BT137 Triac module, allows controlling on/off

    220VAC devices.

    In the current model, we use RC Servo to control the doors. The RC Servo

    control signals is PWM with cycle of 20ms and high-level pulse of 1 ~ 2ms, depending

    on the angle we want to set. The TAx pin, output of TimerA, is connected to the signal

    pins of the RC Servo.Slave Control simulate the lighting management system using ultrasonic

    sensors (human detection sensor), it only turns on lights whenever theres someone

    inside, and turn off lights in the opposite, for energy saving. In order to do that, Slave

    Control uses ultrasonic sensor KS101B (via I2C) and LED for simulation lighting

    management system.

    2.3.2Slave SecuritySlave Security performs the security controls at the main entrance. When the

    system is in the locked state - the owner was not at home, if an unauthorized access

    is detected, the system will send an SMS alarm to the specified phone number.

    The monitoring task is taken care by InterCom module. Slave Intercom system

    acts as a simple communication between the system and the user to perform these

    following basic functions:

  • 8/13/2019 Chipfc - SmartHome

    11/22

    9

    User setting status log in or log out. In logged in state, cellphone control function is activated, such as

    opening/closing doors, turning on/off the lights ...

    In logged out state, the system will perform security monitoring, such aschecking illegal access, SMS alarm if necessary... The owner/user must

    enter a valid password to take full control of the system.

    Slave Intercom module includes 16x2 characters LCD display and 4x4 keypad

    for user command or password input.

    Slave Security is connected to a GSM/GPRS SIM900 module for texting,

    calling. The Slave communicates with SIM900 module via UART using AT Command

    set. The module contains the SIM900, the necessary components such as voltage

    regulator, antenna, LED signal and the communication headers.

    2.3.3Slave SensorThe Slave Sensor performs monitoring the environment conditions, information

    will be collected and sent to the Security Slave via 2.4GHz RF connection. We use the

    module CC2520 2.4GHz RF transceiver, which interfaces with MSP430 board via SPI

    and GPIO. The compact size CC2520 module with built-in antenna make it more

    easily integrated into the system.

  • 8/13/2019 Chipfc - SmartHome

    12/22

    10

    Module CC2520EM

    The Slave Sensor provides various information about the environmental

    condition, depend on how many kinds of sensor attached into it. In this project, we use

    2 types of sensor: sonar for human detection and thermometer for monitoring room

    temperature.

  • 8/13/2019 Chipfc - SmartHome

    13/22

    11

    Chapter 3. Software designMaster block

    Master operation is shown in the following diagram

    Communication with Android via Bluetooth is implemented through Amarino

    library. This is an open-source project, originally designed for the Arduino system to

    provide communication between Android phones and MCU based hardware. We have

    make Amarino source code so that it can operate on the LM3S811 evalution board.

    The operation of Amarino is described below:

  • 8/13/2019 Chipfc - SmartHome

    14/22

    12

    CAN communication implemented in this project is a half-duplex one, using

    only 2 signal pins (CAN-high and CAN-low) to connect to other devices. This type of

    connection is widely used in industry cause of its low cost and noise immunity

    compared to standard communication signal, so we used CAN in the.

    CAN communication require every device attached to CAN bus having their

    own ID. Meanwhile, every message contains the original payload and a header with

    source device ID, destination device ID, message length. For example, a message from

    Master sent to Slave Control to request the on / off a light bulb will be a byte string:

    Master ID Slave ID Length_1 Length_0 Lamp_1 ON/OFF 0xFF

    Information displayed on the LCD allows us to visually observe the operation

    of the system, and debug the system during development process. Each valid control

    commands transmitted from the Master device will be processed then transferred to the

    corresponding Slave via CAN, and displayed on LCD. LCD software library isreferenced from the LM3S811 evalution board examples.

    Slave unit3.2.1Slave Control

    Block diagram of Slave Controls operation:

  • 8/13/2019 Chipfc - SmartHome

    15/22

    13

    According to the protocol described above, the command message from the

    Master will only be received by the Slave with the corresponding ID. Then the

    message will be process to get the command.

    After determining the command, Slave will execute it. The main task of Slave

    Control is to turn on/off electrical appliances such as lights, fans, windows

    (open/close), thus we utilize Timers IO and Output compare function.

    3.2.2Slave SecurityBlock diagram of Slave Securitys operation:

    Depending on each state logged on or off, the Slave Security performs

    different tasks. In logged off state, it will monitor the main door (in this projects

    demo), through a sensor, mounted directly to the door, which continuously check the

    doors state (opened or closed). Whenever an intrusion occurs (opening the door

  • 8/13/2019 Chipfc - SmartHome

    16/22

    14

    illegally), Slave Intercom is able to detect it and reports to the Master, alarms by

    turning on buzzer and send SMS message to specified phone numbers.

    The user has to enter password in order to log in via cellphone. The Slave

    Security will scan the keypad and display some information on LCD. The password

    will be sent to Master for authentication. User may also change their password through

    the keypad.

    With a complete GSM module, Slave Intercom just send commands using AT

    Command protocol via UART. The following are some simple AT commands:

    3.2.3Slave SensorDepend on what type of sensor, Slave Sensor may use I2C, SPI or ADC to read

    the sensor data. The interface with the sonar installed in living room is I2C, the Slave

    Sensor can identify whether the user is inside the room or not in order to flexibly

    control the light. Slave Sensor uses ADC to read out the rooms temperature from the

    thermometer. All the value from sensor will be kept inside the Slave memory, updated

    and transferred to Master via RF CC2520 2.4GHz module.

    The source code for CC2520 is referenced from the "CC2520 software

    example" document of TI, using the Basic RF protocol.

  • 8/13/2019 Chipfc - SmartHome

    17/22

    15

    Application on Android phoneApplication on the Android has a GUI that simulates model of the

    house. During operation, the application automatically connects to Master module of

    the system via Bluetooth and information is displayed on the phones screen as

    follow:

    When clicking on the room, the screen will display the rooms picture, along

    with interactive buttons to input the commands. Based on the design of the home, the

    Android app will have a Living room, a Dining room and a Garage.

    The hardware button Menu of the phone also is used to provide some

    expanded feature like Help, Sync Time, Voice control

  • 8/13/2019 Chipfc - SmartHome

    18/22

    16

  • 8/13/2019 Chipfc - SmartHome

    19/22

    17

    Chapter 4. ResultsWe have designed a home model with size 75cm x 60cm, including a living

    room, a dining room, a garage and a toilet, with two doors. The simulation of electrical

    appliances such as lights, fans, doors, motors arranged in the picture below.

    Hierarchical controlling system consists of a central Master and 3 Slaves:

    Control, Security and Sensor placed within the model to be easily observed. Sub-

    modules such as CAN bus, 220VAC Triac are mounted below the floor, hidden wiring

    is also used to ensure the aesthetic of the design.

    At the moment, the system operates just as we describe above. In details, the

    user can use an Android based smart phone with Bluetooth to connect to the Master

    unit. An application on Android phone with a GUI is activated, the user controls the

    devices by pressing keys on the phones display, such as opening/closing doors,

    turning on/off lights, fans, etc. The security system allows user login, alarming by

    SMS to detect illegal intrusion.

  • 8/13/2019 Chipfc - SmartHome

    20/22

    18

    However, some features are not achieved. For example, the Masters intelligent

    controlling based on schedule, or adding some more devices for a better

    demonstration.

    Chapter 5. ConclusionSmart Home project is a fascinating one, not only for its interesting technical

    problems, but also its modernity and applicability as well as long-term development.

    During TI MCU Design Contest 2012, we have an opportunity to work with TI

    microcontrollers, components, study TI designing style. Although therere some the

    limitations, we believe in what we have achieved and look forward to continuing to

    develop this project.

    Sincerely thanks to the organizer - TI Vietnam for supporting us and other

    teams during the contest.

  • 8/13/2019 Chipfc - SmartHome

    21/22

    19

    Chapter 6. Appendix

    Schematic of MSP430F2618-DEV slave circuit

  • 8/13/2019 Chipfc - SmartHome

    22/22

    20

    Schematic of CAN interface

    Schematic for 220VAC device driver1

    2

    3

    Q?

    BTA12

    A1

    K2

    T2 4

    T1 6

    U?

    MOC3020

    R?

    18012

    P?Header 2

    1

    2

    P?

    Header 2

    F?

    FUSE12

    P?

    Header 2

    R?

    220 LED?

    VCC

    ON/OFFC?C