Temperature Measurement and Control System Based on Embedded WEB

The Web-based Distributed Measurement and Control is becoming more and more prevalent in recent years. With programmable 1-wire Digital Temperature Sensor DS18B20, an embedded system is used as the field processing unit. With application mode of B/S, a remote temperature-measurement and control system is designed by embedded Web on embedded system. The experimental result shows that the system has high reliability and precision.


Introduction
Along with the rapid development of the technology of computer, network and communications, equipment test and control are gradually shifting from field test to the network, the original field operations are replaced by the distributional remote real-time control.As the Ethernet, the internet and the embedded system application technology starts to apply to the distributional long-distance real-time control field, embedded Web system has attracted increasing attention for its superior performance.The kernel of the embedded Web system is the embedded system, it operates not only for the field data acquisition, but also as the embedded Web server, tests the network by sending and receiving data to and from other equipments, realizing the distributional long-distance real-time control function.Compared to the traditional ways, it realizes wider usages, higher rates and more open to users, much easier to connect the system to the intranet and internet, therefore, the embedded Web system are recognized by more and more people worldwide.
A remote temperature measurement and control system directly to the Internet, we need a sort of gateway between temperature measurement and control system and the Internet.There can be many possible solutions to this problem, but these can be boiled down to the following three categories.

1) Field devices integrated with web server
One possible way of connecting field devices to the Internet is to fit an entire web server into the field device.But, most of the microcontrollers do not have enough computing power and memory for the web server.

2) PC as a gateway
Most of the field devices connected to the Internet are using PC or workstation as a gateway to the Internet.The devices send minimum required information such as the status of the sensor to the PC through it's communication ports(usually RS-232) and the web server running on the PC collects the information from the device and makes HTML pages and sends the HTML page back to the web client requesting the page.But, the PC is too big and expensive to be used for this purpose.

3) Small network computer
Other way of connecting field devices to the Internet is using a small network computer, It is a small, inexpensive web server.But it is too expensive to be used for a remote temperature measurement and control system.
The embedded system, which emphasizes on the applications, with the computer technology as its foundation, based on necessary software and hardware, realizes a special system with strict qualifications like high reliability, low cost, low power consumption.It is also the next generation of the computer technology, the communication, the semiconductor technology, the microelectronic technology, the sound/image data transmission technology and so on, so it can be widely used in many fields, like electrical appliances, industry, communication, national defense.In this paper the field temperature sensor is the programmable 1-wire Digital Temperature sensor DS18B20, the PHILIPS Corporation LPC2210 with ARM7TDMI-S core as its microprocessor, realizes the information interacts with the client by HTTP protocol, the user transmits the parameters and the request information by HTTP to the embedded Web server, and the server controls the sensor state according to the user parameters and the field temperature; at the same time, it returns the terminal data back to the browser, for the long-distance user monitoring, in this way it realizes embedded Web temperature control system with B/S structure.A sample has been carried out by this design, which meets all requirements and works perfectly.

Systems solutions and principle of work
The overall structure of the temperature measurement and control system based on embedded WEB is shown in Figure 1.
The embedded Web server is located at the monitor field, the temperature sensor, heater stick and the LCD monitor and so on communicates with the embedded microprocessor I/O ports.The user's browser goes on the Internet and to the embedded Web server.When it's working, the user can login the embedded Web server, set the parameters on browser and can see the values of field's temperature.In the field, the DS18B20 passes the data by I/O to the microprocessor, the microprocessor control the heating rod condition pursuant to the parameters and values of field temperature measured; all these data can be displayed on the LCD monitor, as well as the browser.In this way the long-distance temperature monitoring based on B/S structure is realized.

Hardware designs
For the hardware system structure, see Figure 2. On the hardware side, the embedded system uses the LPC2210 processor from PHILIPS Corporation with the ARM7TDMI-S core as its processor.The LPC2210 is a 16/32 ARM7TDMI-S CPU micro controller supporting real-time simulation and the embedded track.The application which was limited to strict code scale can still work by using 16 Thumb instructions to reduce the code scale by 30%, while the performance loss is actually very little.With low power consumption, several 32 bit timers, 8 Channel 10 bit ADC, PWM channels and up to 9 external interrupts, this microcontroller is particularly suitable for industrial control, medical system, network access control, etc. LPC2210/2220 can provide up to 76 GPIO by bus configuration.With a wide range of serial interfaces inside, it is also very suitable for gateways, protocol converters and embedded soft modems as well as many other general-purpose applications.The network chip is RTL8019, the LCD display is SMG240128, the programmable 1-wire Digital Temperature sensor DS18B20 works for temperature Data Acquisition, the data in or out of DS18B20 only to need a single line for read/write, the temperature transformation power originates from the data bus, the main bus itself can also supply power to the DS18B20 without external power source.It's easy to read temp as 9-12 numbers by programming.The embedded system communicates with the sensor by GPIO port.

Software Designs
Software system structure is shown in Figure 3.The real-time operating system is µC/OS-II.µC/OS-II is a complete, portable, scalable, ROMable, multi-tasking, fully-preemptive real-time kernel.Most of µC/OS-II is written in highly portable ANSI C, containing a small part of assembly codes, which enables the OS to be ported to a large number of processors by modifying its codes.ZLG/IP is an embedded system development oriented TCP/IP protocol stack, developed by Guangzhou Zhouligong MCU development Ltd. co, as well as an important member of ZLG middle wares.ZLG/IP provides IP switch function in the Internet, and it is an embedded TCP/IP protocol stack software with high performance.It realizes a parallel re-entry multi-tasks protocol stack by the µC/OS-II real-time operating system signal mechanism, totally written by ANSI C, supporting many kinds of CPU as µC/OS-II.ZLG/IP is clear in structure, easy to upgrade and be modified.It connects to the network by network driver downward, provides HTTP service upward.The data of temperature is processed by HTTP between client browser's HTMLS.

µC/OS-II port
Most of µC/OS-II is written in highly portable ANSI C, with target microprocessor specific code written in assembly language.Assembly language is kept to a minimum to make μC/OS -II easy to port to other processors.For instance, µC/OS-II can only work in the assembly language when reading/writing processor or registers.So the processor has to satisfy the following requests: 1) Processor's C compilers can produce re-entry code.
2) it can enable/disable interrupt in the program.
3) Processor supports interrupt, and can produce fixed time interrupts (usually between 10Hz and 1000Hz).4) Processor can hold the some data in the hardware stack.5) Processor has stack pointer and other instructions on restore/load CPU register/stack.
It's all implemented in LPC2210.In fact, µC/OS-II may be regarded as simply a multi-tasks scheduler.Some system services relating to the multi-task operating system are added and its 90% code is in the C language, which may be ported directly to processor with C language compiler.The ported work mainly concentrates on the multi-task switch, for this part of code works is used to preserve and restore the CPU scene, therefore we cannot use the C language but the assembly language to complete.The µC/OS-II be ported process, needs to 3 files related to the ARM architecture, related code in OS_CPU.H with the processor and the compiler, the assembly code in OS_CPU_A related to the processor, the 6 functions in OS_CPU_C related to the µC/ OS-II.

Implement of HTTP Server
The HTTP protocol is the application layer object-oriented protocol above the TCP/IP protocol.The HTTP protocol is the standard Web application protocol, which is used by the Web server to communicate with the browser.HTTP had stipulated the standard transmission and the processing request way, transmission message format and control information.The HTTP protocol has two functions, to transmit file and interact.The HTTP protocol is based on request/reply mechanism, the client requests to the server, and the server returns the file object back to the client as response.Every HTTP interaction is from the client to the sever in this way, and then backward as the response.The form of the HTTP request is very simple, request and response is all expressed by simple ASCII code.The server response to the customer request, the server resolves the client request, then acts the corresponding behavior according to the method, and transmits a response to the client.The response form is similarly very simple, including a state code indicating request successfully (for example, if not successful, it will show the reason), and the object set.Afterwards, the server then will transmit any data requesting.After the data transmission, the server finishes this connection.As the Web server application, the HTTP protocol mainly resolves the client side requests; here we realizes the simple HTTP protocol, mainly analyzing the GET way, thus we can obtain the parameter and the request from the client, then return the information in the HTML form onto the client browser.The HTTP protocol is above the TCP/IP protocol; TCP/IP protocol is the connection oriented.The TCP protocol stipulates that, before the data transmission, the TCP connection establish process must be used to establish connection between two nodes.With successful connection, it then carries on the data transmission.The TCP connection interrupt process must also be used for connection termination.The SOCKET connection is TCP/IP API.We adopt the TCP communication here.The TCP programming is divided into two kinds, the server way and the client way.The server way needs to listen to the connection, and it can process data only after establishing connection with the client.The client way is to connect the server initiatively and it processes data after establishing connection, too.ZLG/IP provides standard BSD socket.The socket programming works with the client/server mechanism.A complete socket network application is shown in Figure 4.
The relationship between client and the server is not asymmetrical.The server starts first, then client requests on own initiative at some time, the server replies passively.The client program first calls socket(), this function produces socket for various subsystems connection, and one ID number for each connection, then initializes a socket connection , sets its ID number as well as the sever end IP address and port number, and takes it as the parameter of function connect(), calling the connect() function to connect the sever side initiatively.
After the establishment of connection between the client end and the sever end, it can send (write) or receive (read) data.

Data Acquisition
The field temperature sensor is programmable 1-wire Digital Temperature sensor DS18B20, it links to a pin of GPIO on LPC2210.LPC2210 orders and receives the temperature value through this pin, processes digital filter and two-decimal transformation.DS18B20 will directly output the temperature value as digital, it has only three effective pins: DQ (data), VDD (power supply) and GND .DS18B20 reads and transmits information in the DQ line with 5K pull-up resistance.It can run without power supply and it can also links to one 3v to 5.5v power supply in the VDD line.DS18B20 has ROM and RAM internally, an independent sequence number is restored in its ROM, thus many DS18B20 can work at the same time on a bus.The process of visiting DS18B20 through the single bus is as follows: initialize DS18B20, then write the ROM operational code and the memory operation code and finally read the data.According to the DS18B20 initialization timing, write timing and read timing, we program separately 3 sub-procedures: Init_DS18B20 as the initialization subroutine, WriteOneChar() as write (order or data) subroutine, ReadOneChar() as read subroutine, all data read-write starts from the lowest bit.

Experiment Result
As regarding to the temperature-measurement and control system based on embedded Web, the experiment on the internet indicates that, its measuring accuracy and the control speed meet the requirements , It has an operating temperature range of -55°C to +125°C, and is accurate to ±0.5°C over the range of -10°C to +85°C.

Conclusion
Temperature measurement and control system based on embedded Web contains the 1-wire Digital Temperature sensor DS18B20 as its measurement device and the embedded microprocessor LPC2210 as its core, realizing a remote control system based on B/S structure.The experiment on the internet indicates that, the measuring accuracy and the control speed meet the requirement.Of course, the UI in the client end appears a little simple, to which we will make further improvements.

References
Figure 1.System Structure Chart