IP ... - IEEE Xplore

0 downloads 0 Views 316KB Size Report
This device was designed with STM32 chips, receiving data or original images from ... a high accuracy, low power consumption, a good stability and supports ...
A Data/Image Transmission Device Based on TCP/IP Protocol Bo SHANG, Chengdong WU, Tingting MENG, Chengxi GAO, Yunzhou ZHANG College of Information Science and Engineering Northeastern University Shenyang 110819, China [email protected]

I.

INTRODUCTION

Ethernet technology obtained fast development because of its low price and high degree of flexibility. It is not only widely used in the business office area, but also in a dominant position of the upper network communication market in commercial computer network communications and industrial control systems. Its application in embedded devices is becoming wider and wider and its market share is getting higher and higher [1-3]. Energy monitoring for large public buildings is not only one of the social development trends, but also the future development direction of the public sector achieving modern management [4]. This paper introduces a design of data/image transmission device based on embedded TCP/IP protocol. This device can receive data from energy monitoring meter through ZigBee wireless communication, which avoids troublesome integrated wiring [5-7]. II.

SYSTEM ARCHITECTURE AND HARDWARE DESIGN

The hardware of the intelligent device designed by this paper mainly includes micro controller, ZigBee communication module, power supply circuit, function keys, SD card file system, TCP/IP protocol PHY module, etc. Its function and hardware architecture is shown in Fig. 1.

ZigBee

Power supply circuit ZigBee module

220V

Watchdog

Network interface

STM32F103RDT6

LCD display

Function keys

SD card file system

Figure 1. System function structure

A. Core processor STM32F103 is selected as core processing chip, which has a high-performance ARM® Cortex-M3 32-bit RISC core. This chip works at 72MHz and has built-in high-speed memories (flash memory as high as 128K bytes and SRAM as high as 20K bytes). The communications between the core processing chip and peripherals are realized with 2 integrated SPI ports, a UART asynchronous serial interface, etc. The resource allocation is shown in Table 1. TABLE I. if Pin is PA4-PA7 PB10, PB11 PB12-PB15 PC0-PC15

PROCESSOR RESOURCE ALLOCATION Then Functional configuration is SPI UART SPI 16 bits parallel

And Application is SD card file system ZigBee communication module TCP/IP protocol PHY module LCD display

B. Peripheral circuit design The power modules use a level transition chip AS1117-3.3 to convert a 5V power supply to a 3.3 V one which is used by the whole board. AS1117-3.3 is an efficient DC/DC converter with MOSFET and perfect protection function. The display module adopts a 2.8 inch TFT LCD screen, which has 320 * 240 pixels and displays 262K colors. This module adopts 3.3 V power supply and uses 16 parallel bus to communicate with the core processor. There are two interfaces (SD bus and SPI bus) to communicate between the core processor and the SD card file system and the SPI interface is chosen. 4 pins have been used by SPI communication. Every pin needs to be connected with a 45k pull-up resistor to ensure the communication.

Study of multidimensional information perceptual system on the disaster site based on UAV and sensor network, Numbers: RLO200913. (National key laboratory of robotics)

978-1-61284-683-5/12/$31.00 ©2012 IEEE

Internet

Keywords-Energy Monitoring; TCP/IP Protocol; Data/Image Transmission; Embedded System; Communications across the Gateway

Data acquisition unit

Abstract—In order to collect energy monitoring data of largescale public buildings, a data/image transmission device based on embedded TCP/IP protocol is designed and made in this paper. This device was designed with STM32 chips, receiving data or original images from meter reading device wirelessly, and transferring the data and images to monitoring center with TCP/IP protocol through the existing Internet communication backbone creatively. The results of the studies showed that the wirelessly effective distance is 90m, Internet communication average transmission rate reaches 11.53 KB/s and this device has a high accuracy, low power consumption, a good stability and supports communications across the gateway, which are suitable for using in consumption monitoring system in large-scale public buildings.

CC2430 chip is used in the ZigBee module, which meets the 2.4 GHz ZigBee technology standards. UART asynchronous serial interface is used to communicate the core processor with CC2430. C. Ethernet interface design Embedded network interface usually has the following kinds: z Using network interface chips such as RTL8019 which has MAC layer protocols. This method has a low price, whereas software development is relatively complicated. z Using network interface chips such as W5100 which has TCP, UDP protocol. This method costs slightly higher than the first one, nevertheless, the complexity of software development is relatively lower. Important protocols such as TCP and UDP are realized through the hardware in W5100 and hardware is more responsible than software, therefore the W5100 method is chosen in this paper as a result of ensuring the system reliability. System hardware is shown as Fig. 2.

2)

Having error checking and flow control mechanism;

3)

Reliable.

Considering the characteristics of TCP and UDP protocol, TCP protocol is chosen in this paper. B. Wireless communication protocol choice Data transmission device designed in this article needs to collect data from the field instruments wirelessly, therefore a short-distance, low power consumption, low transmission rate, low cost wireless communication technology is needed in order to guarantee the system reliable and safe. Contrast and analysis on existing different protocols are shown as following [8]: (1) Bluetooth technology. It works in 2.4 GHz ISM free frequency band with low power consumption and it supports network in small scale less than 10 meters. Therefore Bluetooth technology is technically complicated with a high cost and a short transmission distance; (2) GPRS/CDMA technology. The network environment needs to be paid. It is suitable for long-distance transmission with high power consumption, small size of networks and a wide range[9]; (3) WLAN technology. It works in free frequency band with high power consumption and high transmission rate[10]; (4) ZigBee protocol. The network security is high with high capacity and low cost. Through the contrast and analysis, ZigBee protocol is chosen in this paper. C. ZigBee Data agreement In order to ensure the efficiency and reliability of communication, communication protocol between data sending nodes and data receiving nodes is designed as following. Each packet consists of 8 bytes and the meaning of each byte is shown in Table 3.

Figure 2. System hardware

III.

COMMUNICATION PROTOCOL DESIGN

A. Ethernet communication protocol choice In Ethernet communication, two kinds of agreements are most commonly used. They are TCP protocol and UDP protocol. The characteristics of two kinds of protocol are shown in Table 2. TABLE II.

COMPARISON BETWEEN TCP AND UDP

Connection Error checking and Flow control load Reliability

TCP Yes Yes Heavyweight Reliable

UDP No No Lightweight Unreliable

In this paper the requirements of Ethernet communication are shown as following: 1)

Communication connection is stable;

TABLE III.

PACKET FORMAT OF TRANSMITTING NODE

Energy Order Integer part Decimal consumption meter ValidationStop bit type of Data part of Data type Order Type Data1 Data2 Data3 Data4 Check End

In this agreement, command character and command values are shown in Table 4. TABLE IV. Order TEST SEND RECEIVE SLEEP RETAIN1 RETAIN2

COMMAND CHARACTER AND COMMAND VALUES

Value(decimal) 0 1 2 3 4 5

Function Used to test whether the chip works Send mode Receive mode Sleep mode User-defined User-defined

Energy consumption meter types and values are shown in Table 5.

TABLE V.

ENERGY CONSUMPTION METER TYPES AND VALUES

Type GAS ELEC WATER KEEP1 KEEP2

Value(decimal) 0 1 2 3 4

Start

Description Gas meter Electric meter Water meter Undefined Undefined

Read configuration from SD card

The checking data is the sum of seven digits in the data packet, which is in decimal.

Initialization

According to the order type, sending node can choose different modes to transmit data through ZigBee. When the receiver receives the packet, it will send a packet back for response. The format of the data packet in which receiving node sends back is shown in Table 6.

N

Receive data/image from ZigBee? Y

TABLE VI. Beginning Begin

REPLY PACKET FORMAT

Receive Status Status

User-defined Keep

Store data/image in SD card

Ending End

The value of "Beginning" and "user-defined" are defaulted to 0. The value of "Ending" is defaulted to 1. Receive status is divided into two types. The one is to successfully receive and marked with OK, whose value is 0; the other is to unsuccessfully receive and marked with ERROR, whose value is 1. IV.

Whether data/ images reached the biggest number?

N

Y Sent data/images to destination PC

SYSTEM SOFTWARE DESIGN

A. Software architecture design The main function is receiving data/image information from data acquisition device through ZigBee wirelessly and passing on this information to PC monitoring center on the Internet. Main function flow of system software is shown in Fig. 3. The control process of this device can be divided into three procedures.

Display the number of images stored

Figure 3. Main program flowchart

Procedure 1: Power up the device, initialize the device as the configuration information stored in the SD card. The information include three parts: ZigBee transfer mode, TCP transfer mode, IP configuration. ZigBee transfer mode is used to configure the number of ZigBee devices connected with this device, ZigBee device ID and the receiving frequency. The period of receiving can be calculated as in (1).

TZigBee =

1 f ZigBee

f ZigBee

is the receiving frequency.

TZigBee

is the receiving period.

(1)

TCP transfer mode is used to configure the TCP connection frequency. TCP connection frequency must be lower than the ZigBee receiving frequency. TCP connection period can be derived as in (2).

TTCP =

(2) A socket of W5100 binds IP for 192.168.1.100, and port for 5100;

1 f TCP

(2)

f TCP is TCP connection frequency,

The biggest number of data/image storage can be calculated as in (3).

TTCP TZigBee

launch

request

to

PC

(4) The socket in PC allows the connection request, and a TCP connection is established;

TTCP is TCP connection period.

n max =

(3) This socket (192.168.3.110:30000);

(3)

n max is the biggest number of data/image storage. If the number of storage reaches the biggest, the data and images should be transferred through TCP. IP configuration information includes local IP address, local port, destination IP address and destination port. In the flow, the initialization includes chip clock configuration, chip pins configuration, SPI bus initialization, W5100 initialization, LCD initialization and SD card initialization. Procedure 2: The loop body. This device can operate as the configuration stored in SD card. If the device receives data/images, it stored them in SD card. Then it updates the number of stored images on LCD. If the number of stored images reaches the biggest number, this device transfers the information through TCP. Procedure 3: Go to the next loop. B. TCP protocol communication mechanism across gateway In actual use, many types of equipment are not directly connected to the Internet, but through LAN. Therefore, communications across gateway need to be considered in the design. In Fig. 4 gray boxes represent routers. Communications between PC monitor center and the W5100 chip belong to communications across gateway. W5100 chip must launch request to PC when they need to communicate.

(5)

Both sides use this connection to send data;

(6) When one side launches request to disconnect, connection breaks. C. SD card file system design FatFs library is used in the SD card operating module as an interlayer driver. It is a general file system module, used in embedded systems to realize FAT file system. FatFs follows ANSI C standard, therefore it does not rely on hardware platform. Using the file system is to allow the SD card to be read or written by most devices, which means the information on the SD card written by the embedded system can be read with Windows or Linux. V.

EXPERIMENTAL DATA AND ANALYSIS

In order to validate the communication performance of the device, two experiments are designed as following: (1) Data transmission test. Data terminal sends data by ZigBee module. The device receives data through ZigBee module and passes on data to PC through Ethernet; (2) Image transmission test. PC transfers the pictures to the device via Ethernet. A. Data transmission test Data transmission process is: (1) Data terminal collects data; (2) Data terminal transmit data through ZigBee; (3) TCP/IP transmitting device receive data from ZigBee receiver; (4) TCP/IP transmitting device pass data on to PC receiver. Therefore, Data transmission test can be divided into ZigBee wireless communication test and TCP data communication test. Fig. 5 shows the PC data receiver, the main functions are: a) Show local IP address when system starts; b) Default port is 30000; c)

Show the program state;

d) Operation control is available with simple buttons; e)

The current data are shown with large font;

f)

The data histories are displayed with receiving time;

g) A database is used to store data and receiving time.

Figure 4. Connecting across gateway schemes in TCP protocol layer

The communication procedures are as follows: (1)

PC(IP:192.168.3.110) binds its socket for 30000;

Connect the device and a PC to the same network, use TCP image sender to send the images. Fig. 6 shows that the picture is transferred successfully from PC to device.

Figure 6. Image transmission test from PC to device

2) TCP transmission efficiency The TCP transmission efficiency range from 11.43 KB/s to 11.56 KB/s when different sizes of image files are used to experiment. The average transmission efficiency is 11.53 KB/s, which shows the transmission is pretty stable. The statistics are shown in Table 7. TABLE VII. No. 1 2 3 4 5 Total

Figure 5. PC data receiving system interface

B. Image transmitting experiment 1) Image transmitting process The image transmitting process is that PC image sender transfers the pictures to the device, which can show a picture on LCD after receiving a whole image.

Size(B) 1829 11122 20264 32236 42351 107802

Time(ms) 160 972 1757 2788 3666 46736

Speed(KB/s) 11.43 11.44 11.53 11.56 11.55 11.53

With the data, we can draw a graph as Fig. 7, we can realise that there is a proper amount of file size that can lead to the highest speed. The proper amount of file size is near 32236 B. 11.58 11.56 11.54 Speed(KB/s)

The experiment shows that the TCP communication is well and the PC data receiving system works properly to display and log data.

DOCUMENT TRANSMISSION TEST DATA THROUGH TCP

11.52 11.5 11.48 11.46 11.44 11.42 0

20000

40000

60000

80000

100000

120000

File Size(B)

Main functions of TCP image sender are: a) Show local IP address when system starts; b) Default port is 30000; c) The source directory is the file folder storing the pictures being transferred; d) Display the file size of the picture; e)

Display the time used to transfer each file;

f)

Show the program state;

g) Provide friendly user interface; h) Preview the picture being transferred; i) Log the operations and the TCP transmission efficiency to a predetermined file.

Figure 7. Relationship between file size and speed

When file size is between 0 to 32236 B, the speed increases as the file size increases, because the larger the file size is, the more message can be transferred at once. When the file size is more than 32236 B, the file is divided into too many pieces, and the pieces conflict with each other which results in a longer delay. Therefore, the figure is like that. 3) Relation between TCP transmission efficiency and sub packet size In the transmission efficiency experiment, sub packet size can influence the transmission efficiency.

Therefore, the sub packet size is set to be 200 B, 400 B, 600 B, 800 B, 1000 B and 1200 B separately, and measure the time used to transfer 21 files. The relation between TCP transmission efficiency and sub packet size is shown in Table 8. TABLE VIII. Sub packet size(B) 200 400 600 800 1000 1200 1400

RELATION BETWEEN TCP TRANSMISSION EFFICIENCY File size(B)

Time(ms)

538975 538975 538975 538975 538975 538975 538975

55327 50406 48178 47299 46736 46456 46315

Speed(KB/s) 9.74 10.69 11.19 11.40 11.53 11.60 11.64

12 11.5 Speed(KB/s)

11 10.5 10 9.5 0

200

400

600

800

1000

1200

1400

1600

Sub packet size(B)

Figure 8. Relationship between sub packet size and speed

Fig. 8 shows that transmission efficiency increases when the sub packet size increases. The reason is the larger the sub packet size is, the more data can be transferred through one communication. However, the device can not show the entire picture when the sub packet size is over 1600 B, because of the limitation of the chip buffer. The chip buffer is 2000 B, but some of the space is used by the TCP protocol head, which is not real data [11]. In order to ensure the data integrity, the sub packet size is defined as 1400 B after verification test. In this way, the highest transmission efficiency is 11.64KB/s. VI.

CONCLUSIONS

This paper focuses on communication between embedded system and PC through TCP/IP protocols. A device that can realize this communication is accomplished. The software in the embedded system and the PC client are debugged. The experiments show that this system has a high accuracy, low power consumption, a good stability and support communications across the gateway, which is suitable for using in consumption monitoring system in large-scale public buildings. ACKNOWLEDGEMENT

This work is supported by the Chinese Academy of Sciences and directed by Professor Wu and Lecturer Zhang. REFERENCES [1] D'Ambrosia, J. “THE NEXT GENERATION OF ETHERNET”. Communications Magazine, IEEE, Vol. 46, No. 1, pp. 8-15, 2008. [2] Sommer J, Gunreben S, Feller F, Kohn M, Mifdaoui A, Sass D, Scharf J. “Ethernet – A Survey on its Fields of Application”. Communications Surveys & Tutorials, IEEE, Vol. 12, No. 2, pp. 263-284, 2010. [3] Nan Xie, Haibo Zhang, Weimin Chen, Yan Ma, Jinghua Tian. “Research and Design of Industrial Ethernet Intelligent Gateway Based on ARM”, The 2008 International Conference on Embedded Software and Systems Symposia, Chengdu, Sichuan, China: ICESS, pp.324-327, 2008. [4] Perumal T, Ramli A R, Chui Leong. “Design and implementation of SOAP-based residential management for smart home systems”, Consumer Electronics, IEEE Transactions, Vol. 54, No. 2, pp. 453-459, 2008. [5] Limeng ZHAO, Yunzhou ZHANG. “Design and Research of Digital Meter Identifier Based On Image and Wireless Communication”. International Conference on Industrial Mechatronics and Automation, 2009. [6] Mohd Adib B. Sarijari, Rozeha A.Rashid, Mohd Rozaini Abd Rahim, et al. “Wireless Home Security and Automation System Utilizing ZigBee based Multi-hop Communication”. Proceedings of IEEE20086th National Conference on Telecommunication Technologies and IEEE2008 2nd Malaysia Conference on Photonics. Putrajaya, Malaysia, pp.242-245, 2008. [7] ANG Zhimin, JIN Haihong, FAN Zhiguo, DUAN Yong. “WSN Node Design and Communication Realization Based on ZigBee Protocol”, Modern Electronics Technique, Vol. 10, pp.47-50, 2007. [8] Soo Young Shin, Hong Seong Park, Sunghyun Choi, Wook Hyun Kwon. “Packet Error Rate Analysis of ZigBee under WLAN and Bluetooth Interferences”, Wireless Communications, IEEE Transactions on, Vol. 6, No. 8, pp.2825-2830, 2007. [9] Zhen-qian Hua, Ya-dong Zhang. “Security protection discuss of power load management (LM) based on GPRS/CDMA”, Electricity Distribution, 2008. CICED 2008. China International Conference on, pp.1-3, 2008. [10] Smadi, M., Azhari, V.S., Todd, T.D., Kezys, V. “A Study of WLAN-to-Cellular Handover Using Measured Building-Exit Data”, Vehicular Technology, IEEE Transactions on, Vol. 58, No.4, pp.2044-2054, 2009. [11] Xie Xiren, 2008. Computer Network(In Chinese). Beijing: Electronic Industry Press.