[ieee 2007 8th international conference on electronic measurement and instruments - xian, china...

5

Click here to load reader

Upload: gong

Post on 10-Aug-2016

217 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: [IEEE 2007 8th International Conference on Electronic Measurement and Instruments - Xian, China (2007.08.16-2007.07.18)] 2007 8th International Conference on Electronic Measurement

The Eighth International Conference on Electronic Measurement and Instruments ICEMI’2007

Research on 1-Wire Bus Temperature Monitoring System Wang Jingzhuo Gong Chenglong

Department of Electronic Engineering, Huaihai Institute of Technology, Lianyungang 222005 China

Abstract: Based on 1-Wire bus technology, the 1-Wire bus

temperature monitoring MicroLan was designed through using

computer serial communication port, protocol transform chip

DS2480 and 1-Wire bus digital temperature sensor DS18B20.

The structure, character, ROM command, function command of

DS18B20 and operating principle of DS2480B were analyzed.

Consequently, the interface circuit between 1-Wrie bus and

COM port is provided. At the same time, operating interface of

1-Wire bus temperature monitoring MicroLan was well

designed by using the DLLs and API functions provided in the

TMEX SKD by Dallas Corporation and taking DELPHI as

developing tool. Finally, the existing problems and improving

methods was put forward.

Keywords: 1-Wire bus; DS18B20; DS2480B; TMEX SKD;

Temperature monitoring; MicroLan.

1 Introduction

Feasible temperature is the most basic parameter for human and all animals and plants. Temperature monitor and control have significant interest in modern life. Unfortunately, the usually used temperature monitoring system has two kinds of shortcoming in current life. One is that it needs a lot of wires to transfer the sensor signal to data acquisition card and the implementation of linking signal wires is very troubling. Also, the cost is high. The other shortcoming is that the signal transferred in wire is analog signal. There will be a log of noise and loss. In order to overcome these shortcomings, a kind of digital 1-Wire bus technology emerges as the times require.

Digital 1-Wire bus technology is implemented by adopting the new device of DALLAS Company.

According to this kind of technology, the address line, data line and control line used the same line. Hundreds of control and monitor objects could be connected to this line by using 1-Wire bus technology. The multi-drop 1-Wire bus measurement system will be constructed very well. All the chips used by control objects are provided by DALLAS Company. Analog signals can be digitalized in the checking position through 1-Wire bus protocol and transferred in 1-Wire bus. Therefore, digital signal will transfer in 1-Wire bus.

The 1-Wire bus temperature measurement system introduced in this paper is built based on 1-Wire bus technology and its device. The 1-Wire bus monitoring system is connected to computer through serial communication port. It has the characteristics of high ratio of hardware performance to price, convenient for construction, good anti-jamming performance and simple software development. It is suitable for field monitor at open country, intelligent building and security alarming et al [1].

2 Hardware Design

2.1 Structure of 1-Wire bus temperature monitoring MicroLAN

The field monitoring network can be constructed by adopting the 1-Wire bus technology of DALLAS Company. This kind network is called MicroLAN normally. It transfers the data, addresses signal and control signal through one line and provides power to devices on the bus through another line. It is different to the popular computer local area network by nature. The computers or peripheral equipments in LAN have their own power and only data information is transferred in the network line. However, the two lines in MicroLan not only transfer

3-722

1-4244-1135-1/07/$25.00 ©2007 IEEE.

Page 2: [IEEE 2007 8th International Conference on Electronic Measurement and Instruments - Xian, China (2007.08.16-2007.07.18)] 2007 8th International Conference on Electronic Measurement

The Eighth International Conference on Electronic Measurement and Instruments ICEMI’2007

data but also should provide power to devices connected to MicroLAn from their host.

This kind of MicroLAN is a master-slave network. It takes PC or single chip computer as its network server and the master device. All other devices in MicorLAN are taken as slave device. They are managed by master device to implement the communication between master device and slave device. The network dimensions can be large or small. The devices counts may vary form several to thousands. There is almost no limit in theory. The structure of MicroLAN is simple and it can be constructed through one pair of twisted-pair. The slave device does not need to have power. Therefore, this kind of MicroLAN can be constructed rapidly and has low cost. It is fit for practical application. Figure 1 shows the temperature monitoring network constructed by 1-Wire bus temperature sensor DS18B20 and DS2480B used as the protocol transformer between computer serial communication port and 1-Wire bus

2.2 1-Wire bus temperature sensor DS18B20[2 4]

2.2.1 Operation principle of DS18B20 DS18B20 is constituted of five main parts: 64-bit

ROM, scratchpad memory, temperature sensor, 1-byte upper and lower alarm trigger registers and configuration registers. The 64-bit ROM stores the device’s unique serial code. The scratchpad memory contains the 2-byte temperature register that stores the

digital output from the temperature sensor. In addition, the scratchpad provides access to the 1-byte upper and lower alarm trigger registers (TH and TL), and the 1-byte configuration register. The configuration register allows the user to set the resolution of the temperature-to-digital conversion to 9, 10, 11, or 12 bits. The TH, TL and configuration registers are nonvolatile (EEPROM), so they will retain data when the device is powered down.

The DS18B20 uses Dallas’ exclusive 1-Wire bus protocol that implements bus communication using one control signal. The control line requires a weak pullup resistor since all devices are linked to the bus via a 3-state or open-drain port (the DQ pin in the case of the DS18B20). In this bus system, the microprocessor (the master device) identifies and addresses devices on the bus using each device’s unique 64-bit code. Because each device has a unique code, the number of devices that can be addressed on one bus is virtually unlimited.

Another feature of the DS18B20 is the ability to operate without an external power supply. Power is instead supplied through the 1-Wire pullup resistor via the DQ pin when the bus is high. The high bus signal also charges an internal capacitor (CPP), which then supplies power to the device when the bus is low. As an alternative, the DS18B20 may also be powered by an external supply on VDD.

Fig. 1 Monitoring Network for Temperature

Based on 1-Wire Bus

2.2.2 Working flow of DS18B20 The transaction sequence for accessing the

DS18B20 is as follows: step 1, Initialization, step 2, ROM Command, step 3, DS18B20 Function Command.

All transactions on the 1-Wire bus begin with an initialization sequence. The initialization sequence consists of a reset pulse transmitted by the bus master followed by presence pulse(s) transmitted by the slave(s). The presence pulse lets the bus master know that slave devices (such as the DS18B20) are on the bus and are ready to operate.

After the bus master has detected a presence pulse, it can issue a ROM command. These commands operate on the unique 64-bit ROM codes

3-723

Page 3: [IEEE 2007 8th International Conference on Electronic Measurement and Instruments - Xian, China (2007.08.16-2007.07.18)] 2007 8th International Conference on Electronic Measurement

The Eighth International Conference on Electronic Measurement and Instruments ICEMI’2007

of each slave device and allow the master to single out a specific device if many are present on the 1-Wire bus. These commands also allow the master to determine how many and what types of devices are present on the bus or if any device has experienced an alarm condition. There are five ROM commands, and each command is 8 bits long. These commands are SEARCH ROM [F0h], READ ROM [33h], MATCH ROM [55h], SKIP ROM [CCh] and ALARM SEARCH [ECh]. The master device must issue an appropriate ROM command before issuing a DS18B20 function command.

After the bus master has used a ROM command to address the DS18B20 with which it wishes to communicate, the master can issue one of the DS18B20 function commands. These commands allow the master to write to and read from the DS18B20’s scratchpad memory, initiate temperature conversions and determine the power supply mode. The DS18B20 function commands are CONVERT T

[44h], WRITE SCRATCHPAD [4Eh], READ SCRATCHPAD [BEh], COPY SCRATCHPAD [48h], RECALL E2 [B8h] and READ POWER SUPPLY [B4h]. 2.3 Protocol transform chip DS2480B[5]

The DS2480B is a serial port to 1-Wire interface chip that supports regular and Overdrive speeds. It

Interfacing to RS232C (± 12V levels) requires a passive clamping circuit and one 5V to ±12V level translator. Internal timers relieve the host of the burden of generating the time-critical 1-Wire communication waveforms. In contrast to the DS9097(E) where a full character must be sent by the host for each 1-Wire time slot, the DS2480B can translate each character into eight 1-Wire time slots, thereby increasing the data throughput significantly. In addition, the DS2480B can be set to communicate at four different data rates, including 115.2 kbps, 57.6 kbps and 19.2 kbps. Command codes received from the host’s crystal controlled UART serve as a reference to continuously calibrate the on-chip timing generator. The DS2480B uses a unique protocol that merges data and control information without requiring control pins. This approach maintains compatibility to off-the-shelf serial to wireless converters, allowing easy realization of 1-Wire media jumpers. The various control functions of the DS2480B are optimized for

MicroLAN 1-Wire networks and support the special needs of all current 1-Wire devices including the crypto iButton, EPROM-based Add-Only Memories, EEPROM devices and 1-Wire Thermometers. 2.4 Interface circuit between DS2480B and

Fig. 2 Interface Circuit

Connecting Computer’s Serial Port and 1-Wire Bus

connects directly to UARTs and 5V RS232 systems.

RS232

aper, the connection between 1-Wire bus device DS18B20 and computer COM port is

COM port In this p

3-724

Page 4: [IEEE 2007 8th International Conference on Electronic Measurement and Instruments - Xian, China (2007.08.16-2007.07.18)] 2007 8th International Conference on Electronic Measurement

The Eighth International Conference on Electronic Measurement and Instruments ICEMI’2007

impl

bus temperature ith Delphi. It calls

the A

ild a

sessio

EPROM (B8H)

Access(session_handle,@StateBuf) = 1) then

ssion_handle,LEVEL_SET,LEVEL_

ST

e communication level of 1-Wire bus

ssion_handle);

IMED_NONE); //set

= $01) then //check

e(session_handle,$BE); //send

comma

0 to 8 do

rbuf[i]:= TMTouchByte(session_handle,

$FF);//read temperature value in DS18B20 memory

Fig. 3 Software Operating Interface

emented through DS2480B. Therefore, the hardware design is based on the interface between DS2480B and RS232 COM port. To protect the 1-Wire port of the DS2480B from electrostatic discharge a low capacitance ESD protection diode, DS9503, is used. For 5V operation a single device is sufficient. The interface circuit is shown is Figure 2.

3 Software Design The software of 1-Wire

monitoring network is developed wPI functions in the dynamic link library provided

by the software developing tool kits, TMEX SDK, of DALLAS Company. The ROM commands and function commands is called by the API functions. Since the computer COM port is selected, the applied DLL is IB97U32.DLL. the value of communication port type, DefaultPortType, is 5. The value of communication port number, DefaultPortNum, is 1. The designed operation interface is shown in Figure 3. When expected measuring node is selected, temperature sense will begin and the temperature monitoring curve can be plotted dynamically. At the same time, the temperature value will be stored in SQL Server database for analyses and control.

if (TMAccess(session_handle,@StateBuf)= 1) then //bu

n

begin

TMTouchByte(session_handle,$B8); //send command of

calling E

if (TM

begin

TMOneWireLevel(se

RONG_PULL_UP,PRIMED_BYTE);

//set th

TMTouchByte(session_handle,$44); //send temperature

convert command (44H)

st := GetTickCount + 1000; //config convert tiem 1S

While (GetTickCount < st) do

TMValidSession(Se

TMOneWireLevel(session_handle,

LEVEL_SET,LEVEL_NORMAL,PR

communication level

if (TMTouchBit(session_handle,$01)

if the convert is ended or not

begin

If (TMAccess(session_handle,@StateBuf) = 1 ) then

begin

TMTouchByt

nd of read DS18B20 scratch pad (BEH)

for i :=

The following is the main program for accessing DS18B20 and measuring temperature.

//dealing temperature …

3-725

Page 5: [IEEE 2007 8th International Conference on Electronic Measurement and Instruments - Xian, China (2007.08.16-2007.07.18)] 2007 8th International Conference on Electronic Measurement

The Eighth International Conference on Electronic Measurement and Instruments ICEMI’2007

4 Conclusion

erature monitoring sThe 1-Wire bus temple to the traditiona

ystem is preferab l data acquisition system. It

of multi-drop temperature monitoring However, the reliability to drive the bus is not s

Thermometer DS18B20, Jiangsu Machine

ol.33, No 2, pp47-49, 2004 (In

[3] communication between FPGA

[4] Z 18B20 in

, 2006 (In Chinese)

Wan

coun in Dept. of Electronic

stitute of Technology as a teacher, Main

IS, EDA, Measurement and Control,

can be used in the field

table when the network is too large. Therefore, the load driven ability should be enhanced with bus coupler.

References

[1] YU Kelong, BI Xiaolong, QIU Lijun. The Application of

Digital

Building & Automation. V

Chinese)

[2] Jiang Taihui, Deng Zhanwei. Character and application of

digital temperature sensor DS18B20, Electronic

Technology. No 12, pp46-49, 2003 (In Chinese)

Li Nong. Realization of

and DS18B20, International Electronic Elements. No.2,

pp48-51, 2006 (In Chinese)

Hao Hongqi, Wang Yujing. Application of DS

16-channel Temperature Measuring System,

Instrumentation Technology. No 1, pp69-71,2006 (In

Chinese)

[5] Ming Degang. The Application of DS18B20 at the MCU

System of Temperature Measure and Control, Journal of

Guizhou University(Natural Science). Vol. 23, No 1,

pp106-110

Author Biography

g Jingzhuo: Male(1971-), Han nationality, Born in Linshu

ty, Shandong province, Working

Engineering, Huaihai In

research directions are M

Instruments and meters.

3-726