The focus of this paper is to present a low-cost and simple approach to designing intelligent home system using the concept of mobile-to-machine and machine-to-mobile communication. First, we develop a general purpose electronic
circuit design that can control and monitor a variety of home appliances with interface that can be plugged into GSM handset unit. The design based on PLC comprises microcontroller, adaptation circuit, power circuit, and RS232 interface. Then, we develop prototype home security system as an application example of the designed PLC system. The system is completely built and tested and showed perfect operation.
Global System for Mobile communication (GSM) has been one of the best trustable wireless communication systems that can be accessed and used very easily. It is cost effective either if we consider the price of its transceiver module (a simple cellular phone) or the subscription fees. With the trend of huge growing usage of GSM during the past decade, network services is extended beyond speech communication to so many other custom specified applications, machine automation and machineto-machine communication. This paper designs an intelligent home that can communicate with the user by using a mobile phone over GSM network. The interface and communication between home appliance the controlling circuit is the most important component in automation process. This function is implemented by using a Programmable logic controller (PLC) interfaced to a mobile phone.The user sends GSM data in the form of SMS (short message service) message to switch ON or OFF any appliance inside the home, like lamp, light, air condition, washer machine, TV, register,video â€¦etc. The appliance may also sends to the user its status and alarms. For instance, if some
body tries to get into the home, then the home will automatically send alarm message to the user mobile phone or call the police station (if required). The system can be improved to provide the user with information about the status of each appliance, for example "Is the air condition ON or OFF?" A sketch of overall design of the PLC system is shown in Fig. 1. In the literature, there are few contributions proposed in recent years in machine-to-machine ,mobile-to-machine, or machine-to-mobile communication. These include: designing prototype
integrated mobile telemedicine system interfaced with sensors to a patient's body using GSM
simulation[Woodward, 2001]; designing mobile system with wireless LAN [Kugean, 2002];
implementing measurement system to monitor the ambient air quality using GPS, GPRS modem
and advanced RISC machine [Sang,2 004]; designing remote control of sensors and actuators using GSM module [Aranguren, 2002]; and designing stand-alone human temperature and blood pressure system using microcontroller with embedded software [Al-Ali, 2003]. In line with these works, we describe in this paper simple guideline procedures to build general purpose hardware circuit and software algorithm of home appliance system. We first shed the light on the PLC system followed by describing the major components of the system: microcontroller, adaptation circuit, and power circuit. More detailed microcontroller operations with focus on AT commands transmission is presented in Section 4. In Section 5, we develop prototype home security system as an application example of the designed PLC system. Finally, Section 6 concludes the paper.purpose hardware circuit and software algorithm of home appliance system. We first shed the light on the PLC system followed by describing the major components of the system: microcontroller, adaptation circuit, and power circuit. More detailed microcontroller operations with focus on AT commands transmission is presented in Section 4. In Section 5, we develop prototype home security system as an application example of the designed PLC system. Finally, Section 6 concludes the paper.
The GSM network provides full duplex link to support the user requirement. The user can access the application remotely through SMS service where his message read and decoded by the microcontroller attached to the mobile set through a suitable interface, usually RS232 is used but also either Bluetooth or infrared links can be used. A resident assembly program on the microcontroller board allows it to transmit and receive data bytes to and from the attached GSM module under the control of the far end phone key board or upon receiving SMS from the remote mobile phone The decoded message is then processed and used to access the application using digital input /output or digital to analog converter. Adaptation circuits are also needed to provide suitable operating voltage level for the application. Examples of adaptation circuits are relay, power switch, power amplifierâ€¦etc. Fig. 2 shows the block diagram of the connection between the main components of the PLC system. In the figure, the level shifter is used to change the signal level in the serial port (12 volt for logic 0 and -12 volt for logic 1) to TTL level (5 volt for logic 1 and 0 volt for logic 0) to be compatible with the microcontroller. The used level shifter in this circuit is MAX232. The machine is the major part of the system because the overall system is built to control it. The machine can be either electrical or mechanical or any other type according to the user requirements. The machine includes all the necessary circuits and sensors needed to couple, apply input or output signals from the microcontroller to the units to be controlled. Among the circuit that may be employed in general are:
1- Different types of sensors, analog or digital, to sense temperature, pressure , speed, â€¦etc
2- Analog signal processing circuits
3- Programmable counters and timers, power switches: mechanical relays or semiconductor
4- A/D and D/A circuits
5- Input output latch circuits
BLOCK DIAGRAM OF PLC SYSTEM
This section describes in details the major hardware components in Fig. 2, namely: microcontroller, adaptation circuit, and power circuit. The integration of all these components will be also sketched. The microcontroller is a programmable device that can be designed to work as the designer want It acts as the brain of the system. This microcontroller is designed to be multi input multi output and general purposes microcontroller. To make this microcontroller works, the programmer writes a program that controls the overall system then downloads this program inside the microcontroller chip. This program must be a HEX file. The program is written using assembly language and then converted to HEX file. There are several types of the microcontrollers available in the markets. The easiest way of using the microcontroller is to replace it with the personal computer (PC). However, such approach is not efficient and even not cost effective. The optimum way is to use a small microcontroller instead of PC. In this paper, we adopt AT89C52 Microcontroller.The AT89C52 is a low-power, high-performance CMOS 8-bit microcomputer with 8K bytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using ATMEL high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 and 80C52 instruction set. The on-chip Flash allows the program memory to be reprogrammed insystem or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the ATML AT89C52 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications. The 89C52 chip contains the following sections:
1- Standard 80C51 CPU
2- Full-Duplex UART (Universal Asynchronous Receiver Transmitter).
3- 3 programmable timers.
4- 8 k byte Flash memory.
5- 4 I/O programmable ports
6- Crystal Oscillator circuit where the crystal is connected externally. The chip can also work from external clock generator while disabling the Crystal oscillator.
The functions of the microcontroller in the system are:
a- Initiate the attached GSM module and make it ready to communicate with the other phone by
sending a confirmation either through SMS or dialing the previously stored phone numbers list.
This is important to acknowledge the far end control units that the system is ready. This step is done once when system power is turned ON, and each time the power is turned ON.
b- Check the reception of any commands either in SMS or by answering a call and waiting the
commands from the far end mobile set. This also include sending a confirmation that the message is received .
c- Process the received commands and produce all signals needed to physically execute this command
.d- Perform any needed tests and acquire all possible signals that confirm the execution of the
e- Send a confirmation message to the far end mobile set and return again in waiting state for
Of course the above functions are general and the system driving software may be written to adopt a specified application.
One of the 8051's many powerful features is it's integrated UART, otherwise known as a serial port.The fact that the 8051 has an integrated serial port means that the programmer may very easily read and write values to the serial port. If it were not for the integrated serial port, writing a byte to a serial line would be a rather tedious process requiring turning on and off one of the I/O lines in rapid succession to properly "clock out" each individual bit, including start bits, stop bits, and parity bits.However, the programmer does not have to do this. Instead, he simply needs to configure the serial port's operation mode and baud rate. Once configured, all what he has to do is writing to an SFR (Special Function Register) to write a value to the serial port or read the same SFR to read a value from the serial port. The 8051 will automatically let the programmer know when it has finished sending the character he wrote and will also let him know whenever it has received a byte so that he can process it. The programmer does not have to worry about transmission at the bit level-which saves him quite a bit of coding and processing time.
The Adaptation Circuit
The microcontroller controller can accept TTL level in its input or output but most of the external
circuits work in either 220volt or 110 volt and thus the microcontroller can not operate these
circuits. To overcome this, the adaptation circuit is used to convert the input or the output voltage level between the microcontroller and the external circuit. The adaptation circuit consists mainly of relays and transistors. Fig. 3 shows the adaptation circuit suggested in this paper. When the input to the adaptation circuit is low then the output will be 220v and the switch will be opened but when the input is high then the switch will be closed. The reason behind using this type of the circuit is to completely isolate the relay current from the microcontroller current. This method prevents the output voltage from dropping and prevents the microcontroller from producing a high current, which may damage the microcontroller.
The Power Circuit
The required power to operate the microcontroller is 5 volt (DC) but the available voltage supply is 220 volt (AC). system must use a circuit to covert the voltages to 5 volt. The circuit consists of a transformer to
change the voltage from 220v (AC) to 6 volt (AC), a bridge to take the absolute value of the signal, a capacitor and a regulator. Fig. 4 shows the building of this circuit.
Integrating the above main microcontroller (AT89C52), adaptation circuit, and power circuit as well as level shifter (Max 232) is illustrated in Fig. 5. In the figure, the system is constructed to control and monitor many machines (M) or home appliances.
AT commands (Attention commands) are commands that control the PLC system. The AT commands can be considered as a representation of the signal that passes inside the PLC system. If the microcontroller is considered as the brain of the system then the AT Commands act as the nervous of the system. These commands are used to allow the connection between the data terminal equipment and the data communication equipments through any port like the serial port RS232. The most commonly used AT Commands that are related to the SMS message are the following:
1- AT+CMGF=1 /* Setting the massage format to the text mode.
2- AT+CSDH=1 /* Setting the AT command to the mode that allows sending SMS. .
3- AT+CSMP=17, 167, 0, 0 /* Setting the text mode parameter, where the second parameter specifies the period for resending, meaning that 167 specifies that the time is 24 hours. The other parameters are related to the coding protocols.
4- AT+CPMS=<mem1>, <mem2>, <mem3> /* Preferring the memory location for the message storage.
mem represents the type of memory to be used either SIM card or mobile equipment which are
indicated by SM or ME respectively.
mem1 specifies the memory from which the message will be read and deleted.
mem2 specifies the memory to which writing and sending operation are made.
mem3 specifies the memory that the received message will be stored in it
5- AT+CMGR=1 /* Reading the message, where "1" is the number of the message in the memory.
6- AT+CMGS= "the phone number" /* Sending the message.
7- AT+CMGD=1 /* Deleting the message.
Sending the AT Commands by using the microcontroller is not an easy job. This is because the
designer has to understand the communication protocols that are used by the GSM and by the mobile phone. Since sending the AT Commands will be through the serial port, the AT Command will be sent character by character. Once the mobile receives the character, it will use an error checking technique to check if the character was received correctly or there is error on it. The technique used in the mobile is the echo checking technique. In this technique, the mobile will resend the same received character again to the microcontroller to check if the transmitted character was received correctly or not. The procedure of transmitting the commands will be as follows. First, the microcontroller sends the first character of the AT Commands to the mobile. Then, the microcontroller will wait for the mobile phone to resend the same character to prevent the collision between the transmitted and received signal at the SBUF (Serial Control, Addresses 99h). The microcontroller will send the remaining characters by the same way. Once the AT Command has been sent completely, the mobile phone will send a response to the microcontroller. The number of the character response will vary from At Command to other. The microcontroller must wait until the received response finish completely.
Home Security System
A simple application of the above described system is a home security system as shown in Fig. 6. This system enables the far end user through SMS facility to monitor the state of home door and detect any illegal intrusion; select and change a certain password for key locking the door; and control the home lighting system to give impression for the outsiders that there is somebody inside. The password may be any four characters where their ASCII code is inserted in the deriving program either using the key pad or by sending a SMS message from the far end mobile. The intrusion detector is a simple LED (Light Emitting Diode) and an infrared sensors. These two elements are fixed across the door and send on/off signal in case of intrusion. The sensor will be connected to the microcontroller and acts as a switch. The sensor is read by the microcontroller that decode their reading and send it to the far end user through GSM network as SMS. Notice that the alarm of an illegal intrusion will be ignored when the program receive the correct password. The Control of the lighting system can be performed simply by using voltage controlled power switches connected shunt the usual on/ off switch of selected rooms and appliances in the house. The control signals of these switches come from port C of the microcontroller as it programmed as an output port.
BLOCK DIAGRAM OF HOME SECURITY SYSTEM
Fig. 7 shows software implementation of the home security system operation. Two implementation scenarios are considered: controlling the alarm (from user's remote mobile to the machine) and alarm notification (from machine to user's remote mobile) For the first scenario, the user sends SMS message to the microcontroller. The microcontroller will then check for any new message. If there is a new message, the microcontroller sends AT Command that is specified for reading the message. Consequently, the microcontroller will save the message in its memory. Then, the message will be compared with other messages that are stored previously. Based on this comparison, the microcontroller will decide which output pins have to be low and which output pins have to be high. The high signal will go to the adaptation circuit and opens the switch causing the machine to work. The received message will be automatically deleted. For the second scenario, the microcontroller input is connected to a switch. The switch is fixed in the door. When the door is opened, the switch is closed and there will be an input voltage to the microcontroller. The microcontroller will check its input and sends alarm message to the user as the designer has programmed. Fig. 8 shows a snapshot of the complete PLC system.
REMOTE PLC SYSTEM USING GSM NETWORK
In this paper, we have developed an integrated PLC system. The system is intended to be used in many applications where the user can monitor and control target machine remotely using GSM network. The designed PLC system is based on microcontroller and adaptation circuit connected to various home devices. The electronic circuit design of each design element was described with economical and simple layout. The system was applied to an example of home security notification to monitor and control the home door alarm. The system has been implemented in laboratory and proved to be feasible by experiments.