You are on page 1of 4

Implementation of a Home Automation System through a Central FPGA Controller

Carl J. Debono and Kurt Abela


Department of Communications and Computer Engineering University of Malta Msida, Malta c.debono@ieee.org, kurt.abela@ieee.org
AbstractTechnology advancements have made possible the implementation of embedded systems within home appliances. This has added new capabilities and features, however, most of the time, the implementations are proprietary and networking is not always possible. Yet there is an increasing demand for smart homes, where appliances react automatically to changing environmental conditions and can be easily controlled through one common device. This paper presents a possible solution whereby the user controls devices by employing a central Field Programmable Gate Array (FPGA) controller to which the devices and sensors are interfaced. Control is communicated to the FPGA from a mobile phone through its Bluetooth interface. This results in a simple, cost effective, and flexible system, making it a good candidate for future smart home solutions.

II.

BACKGROUND WORK

I.

INTRODUCTION

The concept of intelligent homes has attracted the attention of a number of researchers and practitioners during the last years. Most of these recent techniques focus on exploiting wireless communications to communicate with the devices. In [2] the authors introduce the idea of using Bluetooth as a cable replacement for home automation. However, no implementation details are given. An automation system based on Bluetooth was developed in [3]. It consists of a remote and a mobile host controller that communicates with several devices representing the home appliances. A similar solution was presented in [4], where a Bluetooth multihop mesh topology was used to relay sensor node information to a mobile phone or a personal computer. A Zigbee based home automation system was integrated with a Wi-Fi network through a gateway in [5]. The gateway provides the user interface and accessibility to the system. The system was evaluated using four devices. A similar approach was taken by the authors in [6], where the design of an architecture integrating a Zigbee home network into the Open Service Gateway initiative (OSGi) framework-based home gateway is presented. Techniques that use Internet as the means for home automation have also been proposed. A system based on an embedded controller which is interfaced via an RS232 port to a personal computer web server was presented in [7]. The controller is then connected to the appliances and sensors. The Internet access allows both local and remote access to the home system. A system using the Global System for Mobile communications (GSM), Internet, and speech recognition, was proposed in [8] for real-time monitoring and remote control of the home appliances. This adds flexibility to the system, however, it increases the cost when using GSM technology. The authors in [9] try to improve the Graphical User Interface (GUI) of the home automation system by introducing a 3D visual interface. The aim is to enhance the user experience and allow faster take up of such technologies. This system also exploits Internet to allow dwellers to control and monitor the home from outside.

The requirement for a suitable technology that enhances the quality of life in homes has always been at the center of research. User needs that a home must satisfy can vary from basic requirements to external and internal aesthetics to comfort within the home. With the advancements in technology, electrical appliances are filling the homes, providing more comfort to the dwellers and improved entertainment systems. However, their proliferation and costs related to electricity consumption are increasing user demands for home automation systems. Yet, commercially available solutions are still limited and most of the time they are tailormade for a customer, resulting in high costs. This paper presents a cost-effective solution that uses a Field Programmable Gate Array (FPGA) controller at the core of the system to provide the intelligence for the home system. Moreover, the controller interfaces to a mobile device through the Bluetooth [1] communications port to allow monitoring, configuration, and switching of devices. This allows the user to set the home environment according to the personal needs. This paper is organized as follows; Section II gives some background on systems found in literature. Section III provides an overview of the system developed, while Section IV presents the implementation of a prototype. Section V gives the obtained test results, while a final conclusion is drawn in Section VI.

978-1-4673-0784-0/12/$31.00 2012 IEEE

641

III.

SYSTEM DESIGN

A block diagram of the system developed is shown in Figure 1. It consists of a mobile phone having a Bluetooth interface, a central FPGA controller that communicates via the RS-232 protocol to the Bluetooth interface, and a number of devices which are connected to the central controller. The latter links can be either wired or wireless.

C. Control and Monitoring Devices The number of control and monitoring devices attached to the FPGA depend on the number of free input/output ports available on the FPGA. Furthermore, the system can be further expanded by cascading FPGAs or by multiplexing data coming from different sensors. This makes the system scalable. The devices connected to the FPGA can use either a wired connection or a wireless one, such as Zigbee or Infrared. In this work wired solutions were used, however, the interface can be easily replaced by a wireless solution. The modules interfaced were; a temperature sensor, a motion sensor, a light sensor, a relay switch, a Light Emitting Diode (LED) and a servo. These represent typical sensors used in the home which can allow the central controller to make decisions on whether to switch on or off various devices. Moreover, the circuits tested emulate low voltage switching, high voltage control via the relay, and motor control through the servo. The latter is useful for example to control light in a room by opening or closing shutters. Thus, the system covers most of the typical interfaces found in appliances in homes. IV. IMPLEMENTATION

The central controller was implemented on a Basys2 development board [10], which uses a Xilinx Spartan-3E FPGA [11]. The hardware inside the FPGA was developed using the Very High Speed Integrated Circuit (VHSIC) Hardware Description Language (VHDL). A modular approach was taken such that the design and test phases are simplified and scalability is facilitated. Most of the modules were developed using Finite State Machines (FSM).
Figure 1. Block diagram of the system

A. Bluetooth Interface The central FPGA controller communicates with the Bluetooth module through a serial interface. This requires that a Universal Asynchronous Receiver/Transmitter (UART) is employed on the FPGA. This technology was selected over other solutions because it is available in most mobile phones, it can be implemented with low cost, it consumes low power, and provides a level of security through its use in short distances and through its pairing function. The mobile device communicates to its inbuilt Bluetooth module through an Application Programming Interface (API) simplifying the design. On the other hand, a Bluetooth module must be interfaced with the FPGA, where accurate clocking must be generated for the UART to correctly interpret the received data. B. Mobile Device The system requires a mobile device or a smartphone having a Bluetooth interface. The application running on the device must present a simple, yet user-friendly, graphical user interface to aid the user in performing the correct commands and settings, and understanding the monitored values coming from the sensors. The software developed needs to use a portable platform that is compatible with devices coming from different manufacturers. Java was used in this work.

The UART required for the Bluetooth interface was developed using a transmit unit and a receive unit. The transmit unit consists of the Tx module which does the transmission, the Data to Send module that passes the data to be sent to the Tx, and the clock divider module which determines the baud rate. The state machine for the Tx module is shown in Figure 2. The Tx module starts in the Wait for Data state where it waits for the data to become available in the Data to Send module. Once data is present, the enable bit is set and the state moves to Send. At this point data is transmitted starting from the Least Significant Bit (LSB). Eight bits of data are sent at the selected baud rate encapsulated between a start and a stop bit. When this frame is sent, the state goes back to Wait for Data to get the second frame which completes the packet to be transmitted. When the two bytes of data are sent the state goes to RST to reset the registers and send an acknowledge signal to the Data to Send module. The enable bit is then cleared and the process starts again in the Wait for Data state. The Data to Send module is responsible for acknowledgments that are sent to the mobile device to confirm that a command has been executed, relay sensor readings, and transmit the appliances status report. The module is initialized in the Waiting state where it listens for data coming from the Algorithm module. Once data is sensed, the state moves to Send which sets the enable_out bit to inform the Tx unit. When the Tx unit acknowledges the data, the state moves to RST where the Algorithm module is informed that the data has been sent. This module responds by setting the default choice to 0000 effectively resetting the

642

state to Waiting. The module also receives data from the Temperature module which interfaces with the temperature sensor. The process is the same with the exception that the temperature reading is loaded in the registers instead of the acknowledgment.

and enters the Waiting state. When a command is received by the Rx module, this must be interpreted by the Algo state which determines the action to take. This includes switching on or off an appliance or communicating with the light, temp, and servo modules. The required signaling is thus generated and an acknowledgment generated in state Ack. The go to status state reads the status of the appliances and transmits it to the mobile device.

Figure 2. The Tx Finite State Machine

The state machine for the receiver module (Rx) is shown in Figure 3. Initially the FSM is in the Wait for start bit state where it waits for the start bit. On reception of this bit, the system moves to the Receive byte state. Data is acquired during this state, where sampling is done at the middle of each data period controlled by a counter. When the stop bit is correctly sampled, the system moves to the Store byte reset state. If this is the first byte it is stored and the system returns to the initialization state to wait for the second byte. When the second byte arrives, data is sent to the Rx separator module, which stores the data and forwards it to be displayed the onboard 7-segment displays. The enable_out bit is set to signal that data has been received can be processed. The sixteen bits of data together with the Data ready signal are also sent to the Algorithm module. The system then resets the clock counter and returns to the initial state. The baud rate used for this serial transmission is 9600Hz. A clock divider had to be implemented as the on-board clock operates at 50MHz.

Figure 4. The Algorithm Finite State Machine

The temp module interfaces through the 1-Wire protocol to the MAX DS18S20 temperature sensor [12]. The stringent timings of the bi-directional bus were adhered to. The 1-Wire bus was pulled high using a 4.7k resistor in series with a 5V supply. To transmit data, the bus is pulled low by either the master (FPGA) or by the slave (sensor). A High impedance state is applied when the bus is idle. The sensor read cycle involves pulling the bus low for 6s and then sampling the bus after 15s. To verify that a sensor is connected to the bus, the FPGA pulls the bus low for 480s. It then waits for the sensor to pull the bus low for at least 40s, confirming its presence. A Parallax Inc. light-to-frequency converter [13] was used to measure light intensity by outputting a frequency which is proportional to the light intensity on its surface. The produced 50% duty cycle square waves are fed to the FPGA. To avoid switching on light when nobody is in the room, a Motion Passive Infra-Red (PIR) sensor was used in conjunction with the light sensor. This sensor measures changes in Infra-red levels emitted by surrounding objects. These changes are converted into voltage levels and amplified, setting the output pin high. This value is detected by the FPGA. The Light module uses these two sensors to make intelligent decisions on whether to switch the lights on or off, without the intervention of the user. When motion is detected in a room, the Light module checks the light intensity and if it is below the threshold light is turned on, otherwise no action is taken. The threshold is set by the user through the mobile interface. Decisions are sent to the Algorithm module, where the on and off signals are sent to the FPGA outputs connected with the LEDs and the relay circuit.

Figure 3. The Rx Finite State Machine

The Algorithm module controls all the modules implemented on the FPGA. Data from the mobile phone reaches this module through the Rx module, where it is interpreted and a decision is made accordingly. If the state of an appliance is modified, this module sends an acknowledgement to the mobile phone via the Tx module. It also allows transmission of temperature readings and the status of the devices upon request. The state diagram for the Algorithm module is shown in Figure 4. The mobile user has to first login into the system by sending the login command. If successful the Algorithm module sends an acknowledgement

643

The Servo module determines the direction of the servo mechanism by passing two bits (left and right bit) and the duration of the signals. These signals are sent to the Algorithm module which forwards the signals to the servo hardware. The software developed for the mobile device was coded in Java. It involves a user friendly GUI that is capable of sending and receiving commands over a Bluetooth interface. The NetBeans IDE 7.0 was used to develop the Java software. The Java Bluetooth API was employed to communicate with the Bluetooth hardware. On initialization of the application, a search procedure is initialized where nearby Bluetooth devices are discovered and their available services noted. Since in this case only the serial port to the central controller is needed, the program searches for a pre-defined unique address with this service. Following discovery and pairing, the application can communicate with the central controller. Thus the user can send commands and receive status reports. The user has to log out of the system before closing the application to ensure that the connection is closed correctly. Otherwise the application might not be able to communicate with the central controller the next time around because the resource would still be expecting communication from the older connection. V. RESULTS

Figure 6. The FPGA controller and interfacing circuits

VI.

CONCLUSION

VHDL testbenches were designed to test all the developed VHDL code both at block level and at top level before downloading the synthesized code on the FPGA. The waveforms were checked to verify correct operation, both states and timings, of the hardware. The devices connected to the FPGA were also tested by forcing outputs and inputs and checking the functionality. All interfaced circuits functioned as expected. The communications channel had to be tested as well. A serial port monitoring program installed on a PC was used for this. A Bluetooth dongle was connected to the PC and the communication between mobile phone and the PC, and the PC and the FPGA controller were tested. This was done by sending Bluetooth commands and monitoring the replies. Once the controller and the Bluetooth connection were tested, the whole system was tested exhaustively by sending commands and reading and noting the results. Photos of the mobile phone screen are shown in Figure 5, while a photo of the system which involves the central FPGA controller and the interface circuits is shown in Figure 6.

An implementation of a home automation system using an FPGA central controller was presented. The FPGA was selected as, compared to microcontrollers, it provides a larger number of input/output ports and the parallel implementation of hardware results in faster algorithm execution. The user interface on the mobile phone communicates with the FPGA using the Bluetooth interface. This leads to a low cost system that can be easily scaled up. Furthermore, pairing allows some level of security to avoid network intrusion. REFERENCES
[1] [2] Bluetooth SIG, Inc. (2010). The official Bluetooth technology info site. [Online]. Available: http://www.bluetooth.com R. Shepherd, Bluetooth wireless tehnology in the home, Journal of Electronics and Communication Engineering, vol. 13, no. 5, pp. 195 203, Oct. 2001. N. Sriskanthan, F. Tan, and A. Karande, Bluetooth based home automation system. Microprocessors and Microsystems, no. 26, pp. 281 289, 2002. G. Song, Z. Wei, W. Zhang and A. Song, Design of a networked monitoring system for home automation, IEEE Trans. on Consumer Electronics, vol. 53, no. 3, pp. 933 937, Aug. 2007. K. Gill, S. H. Yang, F. Yao and X. Lu, A ZigBee-based home automation system, IEEE Trans. on Consumer Electronics, vol. 55, no. 2, pp. 422 430, May 2009. Y. G. Ha, Dynamic integration of Zigbee home networks into home gateways using OSGi service registry, IEEE Trans. on Consumer Electronics, vol. 55, no. 2, pp. 470 476, May 2009. X. Zhang, J. Sun and L. Zhou, Development of an Internet home automation system using Java and dynamic DNS service, in Proc. of the 6th Int. Conf. on Parrallel and Distributed Computing, Applications and Technologies, pp. 537 539, Dec. 2005. B. Yuksekkaya, A. A. Kayalar, M. B. Tosun, M. K. Ozcan and A. Z. Alkar, A GSM, Internet and speech controlled wireless interactive home automation system, IEEE Trans. on Consumer Electronics, vol. 52, no. 3, pp. 837 843, Aug. 2006. J. Han, J. Yun, J. Jang and K. R. Park, User-friendly home automation based on 3D virtual world, IEEE Trans. on Consumer Electronics, vol. 56, no. 3, pp. 1843 1847, Oct. 2010. Digilent Inc. (2010). Basys2. [Online]. Available: http://www.digilentinc.com/Products/Detail.cfm?Prod=BASYS2 Xilinx. (2010). [Online]. Available: http://www.xilinx.com Maxim (2010). DS18B20 programmable resolution 1-Wire digital thermometer, Datasheet. [Online]. Available: datasheets.maximic.com/en/ds/DS18B20.pdf Parallax (2010), TSL230R light-to-frequency converter, Datasheet. [Online]. Available: http://www.parallax.com/Portals/0/Downloads /docs/prod/audiovis/27924-TSL230R-v1.0.pdf

[3]

[4]

[5]

[6]

[7]

[8]

[9]

[10] [11] [12]

(a)

(b)

(c)

Figure 5. Mobile phone application showing (a) login page, (b) switching command, and (c) status report

[13]

644