You are on page 1of 22

Table of contents

Table of contents ................................................................................................i Chapter 1. Introduction ...................................................................................1 1.1 About us ..................................................................................................1 1.2 About the project .....................................................................................1 Chapter 2. Hardware design............................................................................3 2.1 System block diagram .............................................................................3 2.2 Master unit ..............................................................................................4 2.3 Slave unit ................................................................................................5 2.3.1 Slave Control ....................................................................................8 2.3.2 Slave Security ...................................................................................8 2.3.3 Slave Sensor......................................................................................9 Chapter 3. Software design ........................................................................... 11 3.1 Master block.......................................................................................... 11 3.2 Slave unit ..............................................................................................12 3.2.1 Slave Control ..................................................................................12 3.2.2 Slave Security .................................................................................13 3.2.3 Slave Sensor....................................................................................14 3.3 Application on Android phone ...............................................................15 Chapter 4. Results.........................................................................................17 Chapter 5. Conclusion ..................................................................................18 Chapter 6. Appendix.....................................................................................19 6.1 Schematic of MSP430F2618-DEV slave circuit ....................................19 6.2 Schematic of CAN interface ..................................................................20 6.3 Schematic for 220VAC device driver.....................................................20

ii

TI MCU DESIGN CONTEST 2012


Chapter 1.

Introduction

1.1 About 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

1.2 About the project


Our 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. 1

TI MCU DESIGN CONTEST 2012


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.

TI MCU DESIGN CONTEST 2012

Chapter 2.

Hardware design

2.1 System 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.

TI MCU DESIGN CONTEST 2012

2.2 Master unit


Master unit is an LM3S811 Eval board of TI. Board contains the ARM CortexM3 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

TI MCU DESIGN CONTEST 2012


transceiver module, SN65HV230. The output signals of the CAN module are differential CAN_high and CAN_low.

2.3 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 LQFP64, 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

TI MCU DESIGN CONTEST 2012

TI MCU DESIGN CONTEST 2012

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 Control implements controlling and monitoring 220VAC devices, all

information will be controlled by the Master via CAN bus.


Slave Security provides basic communication with the user through the

keyboard 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, gathering

information 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, self7

TI MCU DESIGN CONTEST 2012


rechargeable. It can also communicate with the Master via CAN bus or Wireless communication (TIs Basic RF, ZigBee, SimpliciTI)
2.3.1 Slave Control

The 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.2 Slave Security

Slave 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

TI MCU DESIGN CONTEST 2012


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 as

checking 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.3 Slave Sensor

The 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.

TI MCU DESIGN CONTEST 2012

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.

10

TI MCU DESIGN CONTEST 2012

Chapter 3.

Software design

3.1 Master 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:

11

TI MCU DESIGN CONTEST 2012

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 is referenced from the LM3S811 evalution board examples.

3.2 Slave unit


3.2.1 Slave Control

Block diagram of Slave Controls operation: 12

TI MCU DESIGN CONTEST 2012

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.2 Slave Security

Block 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

13

TI MCU DESIGN CONTEST 2012


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.3 Slave Sensor

Depend 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.

14

TI MCU DESIGN CONTEST 2012

3.3 Application on Android phone


Application 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 15

TI MCU DESIGN CONTEST 2012

16

TI MCU DESIGN CONTEST 2012

Chapter 4.

Results

We 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. Submodules 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.

17

TI MCU DESIGN CONTEST 2012


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.

Conclusion

Smart 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.

18

TI MCU DESIGN CONTEST 2012

Chapter 6.

Appendix

6.1 Schematic of MSP430F2618-DEV slave circuit

19

TI MCU DESIGN CONTEST 2012

6.2 Schematic of CAN interface

6.3 Schematic for 220VAC device driver


P? 1 2 Header 2 MOC3020 R? 220 LED? VCC ON/OFF 1 2 U? A K T1 T2 6 4 R? 180 1 Q? 3 2 BTA12 1 2 P? Header 2 F? FUSE C? C 1 2 P? Header 2

20

You might also like