Sie sind auf Seite 1von 7

Remote PLC system using GSM network with Remote

PLC system
application to home security system using GSM
network
A. Alheraish, W. Alomar, and M. Abu-Al-Ela
Department of Electrical Engineering, King Saud University, Riyadh, Saudi Arabia

Keywords Programmable logic controller, machine automation, GSM, home security, microcontroller.

Abstract 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 elec-
tronic 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. 1

Introduction
Global System for Mobile communication (GSM) has been one of the best trustable wireless com-
munication 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 machine-
to-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 func-
tion 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
purpose [Aranguren,
hardware circuit 2002]; and designing
and software stand-alone
algorithm of home human temperature
appliance and We
system. bloodfirst
pressure
shed the light on the PLC system followed by describing the major components of the we
system using microcontroller with embedded software [Al-Ali, 2003]. In line with these works,
describe in this paper simple guideline procedures to build general purpose hardware circuit and
system:
softwaremicrocontroller,
algorithm of homeadaptation circuit,
appliance system. We and power
first shed circuit.
the light on the More detailed
PLC system followed
microcontroller
by describing the operations with focus
major components on system:
of the AT commands transmission
microcontroller, is presented
adaptation circuit, andinpower
circuit. 4.More
Section detailed5, microcontroller
In Section operations
we develop prototype withsecurity
home focus onsystem
AT commands transmission is
as an application
example of the designed PLC system. Finally, Section 6 concludes the paper. an application
presented in Section 4. In Section 5, we develop prototype home security system as
example of the designed PLC system. Finally, Section 6 concludes the paper.

Figure 1. Figure 1.
Simplified Simplified
block diagram block diagram
of PLC of PLC system
system

User
Controlling Home Appliance 18th National
Circuit Computer
Conference 2006
© Saudi Computer
Society

PLC System
The GSM network provides full duplex link to support the user requirement. The user
PLC System
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 microcon-
troller 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
2 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 neces-
sary 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
switches.
4- A/D and D/A�- Input output latch circuits.
circuits
5- Input output latch circuits.

0 10 1 10 1
12V 5
GSM

Far -12V
end Level Microcontroller
User RS232 Shifter AT
Figure 2. AT Command
The block Command
diagram of
the PLC
Adaptation circuit
Figure 2. system
The block
diagram of the
PLC system

Machine

Hardware Construction
This sectionHardware
describes inConstruction
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.
This section describes in details the major hardware components in Fig. 2, namely:
The Microcontroller
microcontroller,
The microcontroller adaptationdevice
is a programmable circuit,
that and power
can be circuit.
designed Theasintegration
to work the designerof all these
want.
components will be also sketched.
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
Thecontrols the overall system then downloads this program inside the microcontroller
Microcontroller
chip. This program must be a HEX file. The program is written using assembly language and then
converted toThe
HEXmicrocontroller
file. There are several types of the microcontrollers
is a programmable available
device that can in the markets.
be designed Theas the
to work
easiest way designer
of using the microcontroller
want. is tobrain
It acts as the replace it with
of the the personal
system. computer (PC). However,
This microcontroller is designed to
such approach is not efficient and even not cost effective. The optimum way is to use a small micro-
be multi
controller instead of PC.input multi
In this paper,output
we adoptandAT89C52
generalMicrocontroller.
purposes microcontroller. To make this
microcontroller works, the programmer writes a program that controls the overall
The AT89C52 is a low-power,
system high-performance
then downloads CMOSinside
this program 8-bit microcomputer with 8Kchip.
the microcontroller bytesThis
of Flash
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.
programmable and erasable read only memory (PEROM). The device is manufactured using ATMEL Remote
high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 PLC system
and 80C52 instruction set. The on-chip Flash allows the program memory to be reprogrammed in-
system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU using GSM
with Flash on a monolithic chip, the ATML AT89C52 is a powerful microcomputer which provides network
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.
3
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 com-
mand .

d- Perform any needed tests and acquire all possible signals that confirm the execution of the
received commands.

e- Send a confirmation message to the far end mobile set and return again in waiting state for
another commands.

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 exter-
nal 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.
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
circuitisislow
circuit to completely isolate
then the output the
will berelay
220vcurrent
and thefrom thewill
switch microcontroller
be opened butcurrent.
when This
the
method
input prevents
is high the switch
then the output will
voltage from dropping
be closed. The reasonandbehind
prevents thethis
using microcontroller
type of the
circuit is to completely isolate the relay current from the microcontroller current. This
from producing a high current, which may damage the microcontroller.
method prevents the output voltage from dropping and prevents the microcontroller
5v
from producing a high current, which may damage the microcontroller.
5v

11 22 11 22 22

220v
220v 220v
Figure 3. 220v
AC

FigureAdaptation
3. Load AC
Figure 3.
1 2 1 2
1
circuit Load Relay
Adaptation
Adaptation 1 2 1 2
1
circuit circuit Relay
4. 7k

input

150k 4.7k

input

4 The Power Circuit 150k

The required power to operate the microcontroller is 5 volt (DC) but the available
voltage supply is 220 volt (AC). The system must use a circuit to covert the voltages
The to
Power Circuit
5 volt. The circuit consists of a transformer to change the voltage from 220v (AC)
The to
required
6 voltpower
(AC),to operate the microcontroller
a bridge is 5 volt (DC)
to take the absolute valuebutofthethe
available
signal,voltage supply is and
a capacitor 220 volt
a
The Power
(AC).regulator.
The system Circuit
must
Fig. 4 use a circuit
shows to covert the
the building voltages
of this to 5 volt. The circuit consists of a transformer to
circuit.
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 required powerthetobuilding
operateof this
thecircuit.
microcontroller is 5 volt (DC) but the available
voltage supply is 2205v volt (AC). The system must use a circuit to covert the voltages
output Regulator
Input ~
to 5 volt. The circuit consists of a transformer to change the voltage from 220v (AC)
Figure 4. 220v a capacitor and a +
1m
The power
Figure 4. Bridge
to 6 volt (AC), a bridge to take the absolute value - signal,
of the
AC
circuit The power
circuit regulator. Fig. 4 shows the building of this circuit.
~
5v

Integrating the above main microcontroller


1m
5v
Regulator

output
(AT89C52),
220v
Bridgeis -illustrated Regulator +
adaptationCircuit
~
circuit, 220v
and M
AC
power ~ Input
Adaptation

+ Bridge
circuit as well as level shifter (Max 232) in Fig. 5. In the figure, the
220v
AC
1m many machines (M) or home appliances.
system is constructed to control and monitor
Figure 4.
The power
~
- AC Adaptation
Circuit
220v
AC
M

circuit

7
1
2
~ Adaptation
Circuit
220v
AC
M

3
4 Adaptation 220v
5 Circuit M
AC
Serial

Integrating the above main microcontroller (AT89C52), adaptation circuit, and power
port

circuit as well as level shifter (Max 232) is illustrated in Fig. Adaptation


5. In the220v
Circuit AC
figure,
M the
Figure 5. system is constructed to control and monitor many machines (M) or home appliances.
The
integrated 1000n Adaptation 220v M
PLC circuit 1
1000n
40 Circuit AC
39 10k

1000n

Adaptation
1
2
16
15
AT89C52 2.2k 1 2
Circuit
220v M
1k AC
3 14
1000n 4 MAX 13 9
5
6 232 12
11
10
11 31
7 10 Adaptation
8 9 Circuit
1000n 350 28 5v
27
26
25 1 2 1 2 2

Figure 5.
0.47m 24
18 23 220v
19 22 220v
The integrated 20 21 AC

PLC circuit HELE M 1 2 1 2


1
11.0592MHZ
Relay
4.7k

150k

Microcontroller Operation
Integrating the above main microcontroller (AT89C52), adaptation circuit, and power circuit as well Remote
as level shifter (Max 232) is illustrated in Fig. 5. In the figure, the system is constructed to control PLC system
and monitor many machines (M) or home appliances.
using GSM
Microcontroller Operation network
AT commands (Attention commands) are commands that control the PLC system. The AT com-
mands 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 com-
monly 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. .
5
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 stor-
age. 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 tech-
nique 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 com-
pletely.

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 pass-
word 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.
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.

dc power supply

+/- 12V
5V

Level Shifter + ��ATMEL 89X52 Microcontroller


RS232C
Connector and UART
6 Cable Input Output Ports
Start

Initializing the Microcontroller

Figure 6. Power Switch drivers


Initializing &
the mobile Key Lock Intrusion
Block [AT+CMGF=1], [AT+CSDH=1], [AT+CSMP=17, 167, 0, 0],
Status[AT+CPMS="ME",
signals "ME", "ME"] Control Detector
diagram of 1- bit 1-bit
Figure 6. Home
Is there a thief? Yes Sent SMS to the user"
Block diagram
security there is a thief"
of Home system No

security
Lighting System and Home Key Lock Infrared
system Is there a new
appliances Solenoid Sensor
No AT+CMGS
Message?

Fig. 7 shows software implementation of the home security system operation. Two implementa-
Yes

Save and read the message


tion scenarios are considered: controlling the alarm (from user’s remote mobile to the machine) and
Figure
alarm7. notification (from machine to user’s remote mobile) For the first scenario, the user sends SMS
flow Fig.
Themessage 7 shows software implementation of the home security system operation. Two
to the microcontroller. The microcontroller
Is the password correct? will then check for any new message. If there
the implementation scenarios are considered: controlling the alarm (from user's remote
No
chart
is of
a new message, the microcontroller sends AT Command that is specified for reading the message.
home mobile theto the machine) and alarm notification (from machineThen,to user's remote will
mobile)
Consequently,
security
microcontroller will save the
Yes message in its memory. the message be
compared
system with other messages that are stored previously. Based
For the first scenario, the user sends SMS message to the microcontroller. The
Decode the message on this comparison, the microcon-
troller will decide whichwill
microcontroller output
then pins checkhavefor to beanylow newandmessage.
which output pinsishave
If there a newto be high. The
message, the
high signal will go to the adaptation circuit
Control the output and opens the switch causing the machine to work. The
of the Microcontroller
microcontroller sends AT Command that is specified
received message will be automatically deleted. For the second scenario, the microcontroller input isfor reading the message.
connected Consequently, theswitch
to a switch. The microcontroller
is fixed
Delete in the
the message will
door. save
Whenthethemessage in its memory.
door is opened, the switch Then, the
is closed
and there will be an
message input
will be voltage
compared to[AT+CMGD=1}
thewith microcontroller.
other messages The microcontroller
that are storedwill check its input
previously. Based andon
sends alarm message to the
this comparison, theuser as the designerwill
microcontroller hasdecide
programmed. Fig. 8 shows
which output a snapshot
pins have of the
to be low and
complete PLC system.
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
Figure 8.
will check its input and sends alarm message to the user as the designer has
Snapshot of programmed. Fig. 8 shows a snapshot of the complete PLC system.
the PLC
system

Figure 8.
Snapshot
of the PLC
system
Remote
Start
PLC system
Initializing the Microcontroller using GSM
network
Initializing the mobile
[AT+CMGF=1], [AT+CSDH=1], [AT+CSMP=17, 167, 0, 0],
[AT+CPMS="ME", "ME", "ME"]

Is there a thief? Yes Sent SMS to the user"


there is a thief"

No

7
No Is there a new AT+CMGS

Figure 7. Message?
The flow
chart of the Yes

home Save and read the message


security
system
No Is the password correct?

Yes

Figure 7.
Decode the message
The flow
chart of the
Control the output of the Microcontroller home security
system

Delete the message


[AT+CMGD=1}

Figure 8.
Snapshot ofConclusions
the PLC
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
system
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.

References
Woodward, B. Istepamian, H. and Richards, C. (2001) “Design of a Telemedicine system using a mobile telephone”, IEEE Transaction
on Information Technology in Biomedicine, Vol 5, No 1, March .
Kugean, S. Krishnan, S. Chutatape, O. Swaminthan, S. Srinivasan, Wang, N. (2002) “Design of a mobile telemedicine system with wire-
less LAN”, International Conference on Circuits and Systems, APCCAS’02, Asia-Pacific, Oct.
Conclusions
Sang, H. Lin, C. Youn, Z. (2004) “A wireless Internet-based measurement architecture for air quality monitoring”, IEEE Conference
Instrumentation and Measurement Technology, IMTC 04, May.
In this paper, we have developed an integrated PLC system. The system is intended
Aranguren, G. Nozal, L. Blazquez, A. and Arias, J. (2002)“Remote control of sensors and actuators by GSM”, IEEE 2002 28th Annual
to beConference
used inof themany applications where the user can monitor and control target
Industrial Electronics Society IECON 02, Vol. 3, Nov.
machine remotely using GSM network. The designed PLC system is based on
Al-Ali, A. Al-Rousan, M. and Al-Shaikh, M. (2003) “Embedded system-Based Mobile Patient Monitoring Device”, The 16th IEEE
Symposium on Computer-based Medical Systems, CBMS’03, May.

Das könnte Ihnen auch gefallen