1. Trang chủ
  2. » Luận Văn - Báo Cáo

REMOTE CONTROL AND MONITORING SYSTEM VIA SMS AND INTERNET

35 440 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Remote control and monitoring system via sms and internet
Tác giả Le Phuc Hoang, Phan Tuan Duong
Người hướng dẫn PhD. Hoang Dinh Chien
Trường học Ho Chi Minh City University of Technology
Chuyên ngành Electrical - Electronics Engineering
Thể loại Luận văn tốt nghiệp
Năm xuất bản 2009
Thành phố HCM
Định dạng
Số trang 35
Dung lượng 0,93 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

REMOTE CONTROL AND MONITORING SYSTEM VIA SMS AND INTERNET

Trang 1

HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY

FACULTY OF ELECTICAL – ELECTRONICS ENGINEERING

Trang 2

Abstract

This thesis consists of five parts In the first part, we present block diagram of control circuits and models connection to connect these circuits with computer at the

processing center through infrastructure mobile network or internet network

Programming algorithms for the microcontrollers in these circuits will be presented in Part II The most important part, communicating with the phone (PC vs Phone,

Microcontroller vs Phone), to access reality through infrastructure

telecommunications network is presented in part III Part IV will present more details about connection in the system as in UART connection, RF connection, internet

connection (using Yahoo server or TCP socket) Chapter five will present results and discussion

I Circuit block and model connection

1.1 Main circuit block diagram

[1]Microcontroller PIC16F877A

[7]

RS232

[2] LCD Display

[6] Switch block

[9] PC [10] Extension circuit

Main circuit

[11]

Phone

Trang 3

- The most important block in this circuit is [1] Microcontroller PIC16F877A (PIC),

coordinating activities of the remaining (control display ASCII characters on the LCD

display [1], the control switch (relay) [5], control serial communication via RS232[7],

process signals from the sensor block [4], and encode and decode for the RF link [3]

This block is similarly to the block of the main circuit, but there is no switch block

circuit We can use this circuit independently with the main circuit, and the structure

of the sensor block (*) may be changed to connect with different sensors

1.2 The most simple connection model

Microcontroller PIC16F877

Extension circuit

Phone

Trang 4

Center PC connects with a cell phone (Home Mobile) Home Mobile will send message containing commands (SMS) to Remote Mobile Remote Mobile is a cell phone connected with the board having sensors This board collects parameters from sensor, then transfers to Remote Mobile and Remote Mobile sends SMS containing these parameters to Home Mobile At home, Center PC reads SMS from Home Mobile and processes data

Mobile

Remote Mobile

Sensor Cell phone network

Trang 5

1.3 The model connection with extended circuit using transmitter and receiver RF modules or RS232

The blocks “Extended Remote Sensor1” and “Extended Remote Sensor2” are

extended blocks to enlarge the system The details of RF link and RS232 link (UART link) will be presented in Part IV

Data from sensors in the block [1], [2], [3] will be send to center by remote mobile The SMS message received at Home Mobile will be processed by PC (storage and graph)

Remote Center

Sensor [1]

Extended Remote Sensor1 [3]

PC

Remote mobile Home Mobile

Extended Remote

sensor2 [2]

RF

RS232

Trang 6

1.4 Model connection for collecting data from remote sensor using internet

Target of this model: Saving cost for region which have internet

1.5 Replaced model for remote region while don’t have internet, but covered by mobile network

Home

PC Internet

Remote PC

Remote Center Sensor

Extended Remote Sensor1

Extended Remote Sensor2 Mobile

Extended Remote Sensor1

Extended Remote Sensor2

RS232

RS232 RS232

Trang 7

This model using GPRS (2G) network for connection sensors from remote area to center

II Algorithms for programming microcontroller in the board (center board and extension board)

Save received characters to

RF buffer

Process UART buffer [a], and delete it

RF frame is completed?

-Process RF buffer[b]

And delete it

No

No

Yes Yes

Trang 8

Processing data in buffer RF (block [b]), buffer UART (block [a]).It means detach data bytes in them, and save to third Buffer After that waiting for certain time, or trigger event caused by center (such as calling signal or arrival message signal from center), to transmit data in that buffer to center by SMS

2.2 Extended circuit for main circuit

III Protocols for connecting cell phone to PC or microcontroller

We use two types of protocol in this thesis, AT command and FBUS protocol

Collecting data from sensors and save to buffer

Have trigger event?

Send data in buffer to Board center (center circuit)

Start

Yes

No

Trang 9

3.1 AT command

3.1.1 Some single AT commands used in communication with the cell phone

at+cbc? Get information about the pin status, to know when to cover the pin at+gmm? Get information about your phone model, to select the appropriate AT command set

at+cgmi? Get information about device‘s manufacturer

at+csq? Get information about the strength interference

at+cusd=1,"*101#" Get information about the amount in the account of SIM, for the should recharge the SIM

at+csca? Retrieved number message center, used to sending message process at+cpbr=1,25 Used to read the telephone directory from 1 to position 25

3.1.2 The combination of AT commands

- Combination of AT commands to read the last message in the device

at+cpms=”me” After this command we know the number of messages (X) have in the phone

at+cmgf=1 Specify the message read in text format ( at+cmgf=0, PDU format) at+cmgr=X After this command we have the last message in the device

OK

- Combination of commands to help read all messages

at+cpms="me” show out memory to read data is the device memory

(at+cpms="sm” show out memory to read data is the SIM memory)

at+cmgf=1 Specify the message read in text format

at+cmgl="all” Read all messages in the memory

- Combination of command to help read the message received from device

Trang 10

at+cnmi=2,1,0,0,0 Setting up the report when the message send to device

When a message come to device, the phone will output to COM port the following

text string

+CMTI: "ME",60

This string show that the message is saved in the position 60 in the phone (ME)

Similarly, if messages stored in SIM in position 60, the string returns form

- Combination of command to delete message in the phone

Command delete messages in the position X in the device memory or SIM

memory

at+cpms=”me” (SIM memory: at+cpms=”sm”)

at+cmgd=X

3.2 FBUS protocol

3.2.1 General about FBUS protocol

The FBUS protocol is used in communication between phone and PC We can also

use FBUS for communication between phone and microcontroller FBUS bases in

packets for error control and management

Trang 11

S: source address

D: destination address

00: pc/ microcontroller address

0c: phone address

type: command type

len: number of octet from len to sq

body: content of command

sq: sequence packet number

0? Padding, if len is odd, octet 00 is added to frame

chk: checksum,, for checking error, 2 byte

3.2.3 Command from PC to phone, request send an SMS message to

3.2.4 Structure of ACK command from phone to PC

Type: type command of command needed to ack

IV Details of the links in the system

4.1 UART connection

Circuit of conversion voltage level for connecting PC & Microcontroller

Trang 12

Programming to establish communication between the controller and the computer is important The purpose is to transmit and receive command strings from PC to microcontroller or from microcontroller to microcontroller

We use the following diagram for establish protocol communication

Detail of UART communication

Text string is transmitted to ASCII characters Start a chain of characters ‘#‘, and ended the series as characters ‘*’

To ease the process of communication between the computer-PIC, and PIC-PIC, we defined a set of commands

PIC is always in the status of pending orders from the PC When it receives the string text from PC, it will split the command based on the characters ' # 'and' * ' After separating out each command, PIC will in turn implement the commands

#ping* Use ping to check connection between circuits

UART UART

UART

Trang 13

#1r1n* Use 1r1n to enable relay1 in TERMINAL1

#1r2n* Use 1r1n to enable relay2 in TERMINAL1

#1r1f* Use 1r1f to disable relay1 in TERMINAL1

#1r2f* Use 1r2f to disable relay2 in TERMINAL1

#1the* Request terminal1 send data about temperature to CENTER

#1r1s* Request TERMINAL1 send status of relay1 to CENTER

#1r2s* Request TERMINAL1 send status of relay2 to CENTER

#2r1n* Use 2r1n to enable relay1 in TERMINAL2

#2r2n* Use 2r1n to enable relay2 in TERMINAL2

#2r1f* Use 2r1f to disable relay1 in TERMINAL2

#2r2f* Use 2r2f to disable relay2 in TERMINAL2

#2the* Request terminal1 send data about temperature to CENTER

#2r1s* Request TERMINAL2 send status of relay1 to CENTER

#2r2s* Request TERMINAL2 send status of relay2 to CENTER

Algorithm for processing string in center board, and terminal board

Trang 14

Len: length of buffer

Start=1: allowed to save characters to receive buffer

Start=0: not allowed to save characters to receive buffer

4.2 RF connectton

4.2.1 Using transmitter and receiver RF module to make RF connection

Receive character C

C=’#’

Start=1 Len=0

C=’*’

Start=0

-Buffer[len]=C -Len=len+1

-Output to lcd display -Process command in buffer

Yes

No Start

Trang 15

Figure 2 Transmitter RF module

Circuit for connecting to these modules

Figure 3 Connect to receiver module

Figure 1 Receiver RF module

Trang 16

Figure 4 Connect to transmitter module

4.2.2 Programming to communicate in RF link

Two important parts in this session are:

-Transmit one byte (8 bits)

-Transmit many bytes (Frame)

Structure of one byte

Structure of one frame

Trang 18

for(i=0;i<=7;i++){tx=(x&(1<<i))>>i;delay_ms(1);} }

Trang 19

The varible tong content data byte

Algorithm helps decoding a frame (a frame consists of many of byte data)

Trang 20

Socket set allows the communication channel that two channels are marked by two ports (port) Through this process one can receive and send data to the other

 Port number

To be able to make the communication, one process must declare number of socket you use Each port can communicate at an address specified in the system When the process is assigned a port number, it can receive data sent to this port from the other Process the remaining is also required to create a socket

Besides the port number, the two sides must also communicate the IP address of each other IP Address distinction between this computer with other computers on the network TCP / IP In the port number used to distinguish the different processes on the same computer

Trang 21

 Realization

We designed software to connect Center PC to Remote PC This software is written from Visual Basic (VB) and used socket to build a client – server system VB provide us a component, which has function as socket, is Winsock (mswinsck.ocx) After we have setup this program on 2 PC (1 center PC and 1 remote PC), we must put in program one port number (here is 1221) and IP for each PC The program on center PC is designed to send control commands (messages) to remote PC after connecting successfully The program on remote PC will receive commands and transfer it to COM port (RS232) The board connects to remote PC through COM port will receive and perform these commands The data from sensor or device will be transmitted to the board, then is sent to remote PC Remote PC continues to send this data to center PC processing

Yahoo Messenger

 Introduction

Yahoo Messenger (YM) is an application connection to exchange data between two PC through Internet This is software widely used in Vietnam Although not an open source software entirely but Yahoo Server allows you to connect directly with it

to transmit information, the data to a YM any use Port 5050 and the Host Server (cs101.msg yahoo.com, scs.msg.yahoo.com , ) that always guarantee the stability,

Trang 22

Center PC

Remote PC

Board Yahoo Server

security, and especially the speed of transfers is very high, almost real So we can completely write an application based Yahoo Server to create a connection between

PC and controls, control devices remotely

We use Yahoo server to connect Center PC to Remote PC Center PC send commands to Remote PC via Yahoo Messenger After receiving command of Center

PC, Remote PC (has a program, written by VB, control and manage device directly) send those commands to board connected to PC and transfer data to Center PC

PC (center PC and remote PC) This is important code used to connect Yahoo Server:

Private Sub sckMain_Connect()

Dim ByteArray1() As Byte

Dim ByteArray2() As Byte

Dim str As String

Trang 23

On Error GoTo ErrorRaised

Trang 24

However, this software not only be used to send/ receive data, but it is also improved to process command and connect to the board The synchronous speed is

115200 bps In addition, we only setup this program on remote PC, then we can use Yahoo Messenger program on some PC to connect to remote PC and send device control command To do that, we open a chat window from YM and send a message which contains standard control commands (ex: D01: ON#, Reload# ) to Yahoo id signed in to program put in remote PC

Website

We can use website from some PC everywhere to control devices connected with remote fix PC To realize this idea, we designed a website which is written by PHP language In addition, PHP language provides us a function to connect PC to Board though RS232 So we can send control commands directly from website to board This is important code to connect to board

<?php

include "php_serial.class.php";

// Let's start the class

$serial = new phpSerial;

// First we must specify the device This works on both linux and windows (if

Trang 25

V RESULT & DISCUSS

5.1 Some image of Data management and processing program

Figure 5 Management software system

Trang 26

Figure 6 Management with Yahoo

Figure 7 Data collection and control devices through the Yahoo

Trang 27

Figure 8 Management with SMS

Figure 9 Collect data by SMS

Trang 28

Figure 10 Some functions of the software

Figure 11 Observed data as graphs

Trang 29

Figure 12 Installation parameters for software

5.2 Some image of website for Control and monitor devices

Figure 13 Log in using the web interface

Trang 30

Figure 14 Control equipment

Figure 15 Monitoring of environmental parameters

5.3 Some images of prototype board

Trang 31

Figure 16 The board connections and mobile devices

Figure 17 Terminal Board 1

Trang 32

Figure 18 Terminal Board 2

Figure 19 Center Board

5.4 Some images of debugging software

Trang 33

Figure 20 Control interface FBUS connection

Figure 21 Control interface COM connection

Trang 34

REFERENCE

[1] RAHUL P et al (2007) A Novel Approach to Remote Sensing and Control The

6th WSEAS Int Conf on Electronics, Hardware and Optical communication, Corfu Island, Greece

[2] Sony Ericsson (2003) AT Commands Online Reference T68, T68i, T300, T310, T610, Z600, T230, T238, T226, T630

Website :

http://www.embedtronics.com/nokia/fbus.html http://www.edaboard.com/ftopic264676.html http://discussion.forum.nokia.com/forum/showthread.php?t=72056 http://www.8051projects.net/microcontroller-tutorials/

http://www.panuworld.net/nuukiaworld/hardware/cables/fbus.htm http://www.picvietnam.com/forum/showthread.php?t=2234 http://www.serasidis.gr/circuits/smscontrol/smscontroller.htm http://www.developershome.com/sms/

http://www.edaboard.com/ftopic70001.html http://www.activexperts.com/xmstoolkit/atcommands/dtmf/

http://www.edaboard.com/topic293431.html

Ngày đăng: 25/04/2013, 11:25

TỪ KHÓA LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm

w