• 沒有找到結果。

O VERVIEW OF THE S YSTEM D ESIGN

CHAPTER 2 SENSORS DESIGN

2.1. O VERVIEW OF THE S YSTEM D ESIGN

This study develops a wireless senor network system with web-based management, which is a tree topology of three levels with hierarchical routing. The wireless sensor network is comprised of a Personal Area Network (PAN) coordinator, routers and end devices. In the wireless personal area network, there are two types of wireless technology, Bluetooth and ZigBee. Compared to Bluetooth, ZigBee has lower power consumption, smaller size of protocol stacks and higher addressing capability.

This study uses ZigBee wireless technology to develop the wireless sensor network.

The end device of the wireless sensor network includes the ECG sensor and the SpO2 sensor. A micro-controller unit with a ZigBee RF chip selects one of the routers, which is the shortest distance between routers and the end device. When the device had joined a router, the device remains sleeping until it receives a start command from the router. To reduce power consumption, the router sends a start command to the associated devices every 15 seconds, alternately, according to its neighbor table. When the device has received a start command, it starts conversion of ADC and sends the results of the conversion to the router. When the router has received data from the associated device, it sends data to the associated PAN coordinator immediately. The PAN coordinator sends it to the UART that was connected with the UART of a personal computer (PC).

Since the wireless sensor network has many sensor devices, it is very difficult to manage and control. To solve this problem we use a remote database as the interface between the wireless sensor network and a web page. The system architecture is flexible. Users can monitor and control the wireless sensor network easily via the internet.

To achieve this goal we develop a PC application that is responsible for receiving data from

UART and then storing it to a remote database by an open database connectivity application interface (ODBC API).

Finally, this study develops a web page, which is comprised of XML, PHP, java script and Scalable Vector Graphs (SVG) to show the physiological curve. Doctors can access and manage the wireless sensor network conveniently via the internet. The system structure is shown in Fig. 2-1, which includes 3 patients in a net. The user (professional medical personnel) can monitor the ECG or SpO2

signals via the internet.

Fig. 2-1 Structure of the whole wireless sensor network with web-based management

2.2. Sensors

The sensors are responsible for providing an interface between physical signals and the digital world. In the case of home-care, the sensor is used to measure physiological signals. This study uses two sensors: ECG and SpO2 sensors, which will be discussed below.

2.2.1. ECG Sensor

The measurement of the ECG involves the connection of between twelve and fifteen leads to a patient’s chest, arms and right leg via adhesive foam pads. It records a short sampling of the heart’s electrical activity between different pairs of electrodes. This study develops a sensor board that provided continuous ECG monitoring by measuring the differential across a single pair of electrodes.

2.2.1.1. ECG

The ECG measures the electrical activity of heart. The beating heart generates an electric signal that can be used as a diagnostic tool for examining the functions of the heart. This electric activity of the heart can be approximately represented as a vector quantity. Cardiologists have developed a simple model to represent the electric activity of the heart. In this model, the heart consists of an electric dipole located in the partially conducting medium of the thorax. This dipole moment, knew as the cardiac vector, is shown in Fig. 2-2

Fig. 2-2 Cardiac vector diagram [11]

The cardiac vector is defined as including 12 leads to form the exact ECG. However, in our case this is a portable device that cannot employ the whole 12 leads in our sensor, so we choose only lead II (shown in Fig. 2-3), which is considered to be a typical example of ECG monitoring. The lead II ECG waveform is also considered to provide typical clinical data for diagnosing heart disease. In fact, hospitals widely use the portable lead II ECG machine in the emergency ward.

Fig. 2-3 Lead II ECG diagram [11]

2.2.1.2. ECG Waveform

There are two premises in the ECG waveform. One is that the cardiac muscle is formed by excitable nerves that express electrical signals (voltage). The electrical signals are termed the ‘action potential’ of the cardiac nerve cells. The other premise is that the cardiac muscle (the atrium and the ventricle) cells systole and diastole together, which produces every beat of the heart. If they do not systole and diastole together, the heart beat is irregular -- so called cardiac fibrillation -- and the person die.

The explanation of the ECG waveform is that electric stimulation is activated by the SA node; the SA node expresses an action potential, as shown in the first curve of Fig. 2-4. Then the AV node receives the stimulation and expresses its action potential, which is shown on the third curve of Fig. 2-4. Then the signal (electric stimulation by the SA node) keeps conducting to the atrial muscle and then the ventricular muscle.

Cardiologists have determined that the P wave of the ECG waveform is mainly contributed by the atrial muscle, as shown on the second curve of Fig. 2-4. The QRS complex and the T wave are mainly contributed by the ventricular muscle, seen in the last curve of Fig. 2-4. Because the cardiac muscle is formed by excitable nerves, the electrical stimulus from the SA node is propagated to the other part of the heart. According to the difference between propagation time and action potential of every part of the heart, the ECG wave form is decomposed to the P wave, QRS complex, and T wave. Every component of the ECG waveform is shown in Fig. 2-4. Note that the action potential of bundle branches lags behind the action potential of the AV node by 100 ms., so it takes 100 ms. to pump blood from the ventricle to the atrium.

Fig. 2-4 Components of ECG waveform diagrams [11]

2.2.1.3. Measurement for ECG Signal

Because the ECG has very small signals, at the range of a few mV (usually less than 10) it is often interfered with by the 60 Hz noise created by the power line or the human body. In this case, we knew that signal conditioning is very important for bio-potential measuring. The best-fitting conditioning for the bio-potential signal can make it much simpler to do further signal processing. Therefore, it is necessary to employ an instrumentation amplifier to reduce the 60 Hz noise and to amplify the ECG signals we are interested in. Then, we filter the low frequency DC noise by a low pass filter and amplify the signal by a gain and filter stage. The fault often occurs that the output waveform is very sensitive to

motions like breathing and even slight movement of the human body, so it is necessary to add an anti-motion artifact stage to isolate the signal from motion artifacts. To create clearer signals with less 60 Hz noise interference on the baseline of the ECG waveform, we apply a DRL (Driven Right Leg) circuit to reduce the 60 Hz noise. The block diagram of the ECG sensor is shown in Fig. 2-5.

Fig. 2-5 Block diagram of ECG sensor

2.2.1.4. Circuit Design for the ECG Sensor a. The Different Input Stage

The differential input stage [12] is shown in Fig. 2-6. Here we choose a micro-power consumption instrumentation amplifier AD627 (Analog Device). Its max supply current is only 85 μA, and it has a wide power supply range from +2.2 V to ±18 V. It also provides gain for the signal.

The gain is adjusted by the resister RG, in the term:

5 200

= Ω Gain RG K

1 R G1

Fig. 2-6 semantic diagram of the differential input stage for the ECG sensor We use

b. The Gain and Filter Stage

In the gain and filter stage, shown in Fig. 2-7, we choose OP296 for the operation amplifier. Its max supply current is only 85 μA and consists of 2 OP amplifiers in one chip. For the sake of minimizing the scale, ICs with SMD packages are used. In this stage, the first OP amplifier serves as a gain stage where G2 = 20, and the second OP serves as a low pass second-order Butterworth filter where the cut-off frequency Fc = 75 Hz.

1K

Fig. 2-7 Semantic diagram of the gain and filter stage for the ECG sensor

c. The Anti-Motion Artifact Stage

As for the anti-motion artifact stage, a second-order band-pass filter [12] is used, as in Fig. 2-8, and

the resonance frequency Fr =

Fig. 2-8 Semantic diagram of the anti motion artifact stag for the ECG sensor

d. Driven-Right-Leg (DRL) Circuit

In the last stage, the Driven-Right-Leg (DRL) circuit [8] (Fig. 2-9), we use a small capacitor with a

value of 10 nF to block the 60 Hz noise, and an auxiliary OP amp to feed the noise back to the human

Fig. 2-9 Semantic diagram of the Driven-Right-Leg (DRL) circuit for the ECG sensor

2.2.2. SpO

2

Sensor

A commercial SpO2 sensor is used in this study, which is an integrated pulse oximetry using NONIN OEM . The Ⅲ SpO2 sensor sends physiological data to the UART at the rate of 9600 baud. This study combines the SpO2 sensor with a development board, which is comprised by an MCU and ZigBee chip. The development board receives the physiological data of the SpO2 sensor via UART, parses it to get available data and sends this data to a router wirelessly. This study chooses data of type 2 format for the SpO2 sensor to write its parser, which was used to divide it into SpO2 value, heart rate value and plethysmographic pulse.

2.2.2.1. Data Format of SpO2

The data of format type 2 provides oximeter information on SpO2, heart rate, pulse, sensor alarm, sensor disconnection, out of track, bad pulse, software firmware revision level and plethysmohraphic pulse. There are 75 frames of data sent per second. A frame consists of 5 bytes of data; the 1st byte of the frame is used for byte synchronization; the 2nd byte of the frame is the status of the SpO2 sensor; the 3rd byte of the frame is the plethysmographic pulse value; the 4th byte of the frame may be HR, SpO2 or software reversion.

a. SpO2

The measurement of the SpO2 in the range of 0 to 100 is sent three times per second in the 4th byte at frames 3, 28 and 53.

b. Heart Rate

The detection of heart rates in the range of 18 to 300 is 2 bytes. The heart rate’s most significant byte is sent three times per second in the 4th byte at frames 1, 26 and 51. The heart rate’s least significant byte is sent three times per second in the 4th byte at frames 2, 27 and 52.

c. Plethysmographic Pulse

The plethysmographic pulse is a representation of the IR signal; it has a range of 0 to 255 and is sent 75 times per second in the 3rd byte at all 75 frames.

2.2.2.2. SpO2 Parser

This study develops a simple SpO2 parser to get the heart rate, SpO2 and SpO2 diagram according to a data format of type 2. The data format of type 2 is described below. The flowchart of the SpO2 parser is shown in Fig. 2-10.

a. Heart Rate

The parser gets the most significant byte of the heart rate by the 4th byte of the 1st frame, and the least significant byte of the heart rate by the 4th byte of the 2nd frame.

b. SpO2

The parser gets the SpO2 value by the 4th byte of the 3rd frame.

c. Plethysmographic Pulse Value

The parser gets the plethysmographic pulse value by the 3rd byte of the frame.

d. Flowchart of the SpO2 Parser

Fig. 2-10 Flowchart of the SpO2 parser

Chapter 3 Wireless Sensor Network

3.1. Introduction to Wireless Transmission Specifications

In this chapter ZigBee and Bluetooth will be described, and the comparison between the two will be analyzed. Finally, design methods will be illustrated including hardware structure, firmware structure, message flow chart and PC application.

3.1.1. Bluetooth

The Bluetooth is a wireless personal area network that focuses on short range ad-hoc connectivity.

Its operating frequency is in the Industrial-Scientific-Medical (ISM) frequency band of 2.402 GHz to 2.483 GHz. It uses a Time Division Multiplexing (TDM) technique to divide a channel into 625 micro sec slots. With Bluetooth each packet is transmitted on a different hop frequency. The Bluetooth device can be divided into two types, master and slave; a master connects with at most seven slave devices. A unit network of Bluetooth is called Piconet, as shown in Fig. 3-1, which includes a master device and a slave device.

Fig. 3-1 Piconet diagram for Bluetooth

3.1.2. ZigBee

ZigBee is based on IEEE 802.15.4 wireless protocol, which focuses on sensor networks, control and home-care related applications. It has several advantages such as self-organization, lower power consumption, smaller size of protocol stacks and larger addressing space. The ZigBee can be classified into two types when accessing channels, unslotted networks and slotted networks. In unslotted networks, all devices are considered peers with respect to one another and the entire wireless resource is available.

Slotted networks comprise three time periods.The first period is the beacon frame; two beacon frames bound this structure. The second period is an active period that consists of a contention access period and a contention free period. All devices compete equally to get channel resources by using a Carrier Sensed Multiple Access with Collision Avoidance (CSMA/CA) mechanism during the contention access period. The channel resource can be allocated to specific devices during the contention free period. The third period is the inactive period. Channel access is not permitted during the inactive period. The IEEE 802.15.4 standard defines the lower two layers as Physical (PHY) and Medium Access Control (MAC) layers. ZigBee alliance builds on this foundation by providing a Network (NWK) Layer and Application (APP) layer.

3.1.2.1. Physical (PHY) Layer

The IEEE802.15.4 has three PHY layers that operate in three separate frequency ranges of 868-868.6 MHz, 902-928 MHz and 2.4-2.4835 GHz. There are 20 kb/s, 40 kb/s and 250 kb/s using the frequency bundles of 868-868.6 MHz, 902-928 MHz and 2.4-2.4835 GHz.

3.1.2.2. MAC Layer

The IEEE802.15.4 MAC layer is responsible for accessing the radio channel using two CSMA-CA mechanisms, transmitting a beacon frame, synchronization and providing a reliable transmission mechanism.

3.1.2.3. NWK Layer

The NWK Layer is responsible for implementing a mechanism that is used to join and leave a network. The NWK Layer also provided discovery and maintenance of routes between devices devolving to the NWK Layer.

3.1.3. Advantages of ZigBee

ZigBee has low power consumption and high addressing capability. ZigBee can receive 65536 devices to connect, significantly more than the seven devices of Bluetooth. ZigBee was developed to serve different applications than Bluetooth and its technology has led to optimizations in power consumption. According to the ZigBee Alliance, ZigBee has many advantages such as a very low duty

cycle, long primary battery life, static and dynamic star and mesh networks. A comparison between ZigBee with Bluetooth is shown in Table 3-1.

Operation Table 3-1 Comparison between Bluetooth and ZigBee [1]

To compare ZigBee with Bluetooth in low power consumption accurately, this study compares Bluetooth [W7020, Lucent, USA] with ZigBee [UZ2400, UBEC, Taiwan] in terms of power consumption. The comparison is illustrated in Table 3-2, with which we can see that the power consumption of ZigBee is smaller than Bluetooth. Therefore, in this study we use ZigBee as the specification for wireless transmission.

Sleep Mode TX RX

Bluetooth 2.8 V/ 50 μA 2.8 V/ 33 mA 2.8 V/ 40 mA ZigBee 3.3 V/ 2 μA 3.3V / 22 mA 3.3V/ 18 mA

Table 3-2 Comparison between Bluetooth and ZigBee in Power consumption [15] [16]

This study uses the unslotted method to access channels in the 2450 MHz band. The 2450 MHz band provides the most channels (16 channels), highest data rate (250 kb/s), least overhead and least complexity, relative to the slotted method.

3.2. Hardware Design

The development board (DEB) used in this study is comprised of a micro-controller and a ZigBee chip (UZ2400, UBEC, Taiwan) to act as hardware platform for each device in the wireless sensor

network.

3.2.1. Micro-Controller Unit (MCU)

The MCU of the development board us the Texas Instruments MSP430F1611, which incorporates a 16-bit RISC CPU, peripherals, and a flexible clock system.

3.2.2. ZigBee Chip

The ZigBee chip (UZ2400, UBEC, Taiwan) integrates a wireless RF transceiver operating at 2.4 GHz, the 802.15.4 PHY layer baseband and the MAC layer architecture. The block diagram of the DEB is shown in Fig. 3-2.

Fig. 3-2 Block diagram of the development board

The MAC of the ZigBee chip is comprised of six components, which are RX MAC, TX MAC, security, control register, FIFO and SPI interface. The FIFO of the MAC consists of five components, which are TX FIFO, RX FIFO, TX GTS1 FIFO, TXGTS2 FIFO and TX Beacon FIFO. These FIFO are listed in Table 3-3, which contains the FIFO name and its length.

Table 3-3 Length for each FIFO

3.2.3. SPI Mode

The ZigBee chip communicates with the MCU by the SPI mode of the UART. This study uses 4-pin SPI including four serial signals, SPI enable, SPI clock, Master Input Slave Output (MISO) and Master Output Slave Input (MOSI). The MCU is the master and the ZigBee chip is the slave. If the MCU wants to read any register of the ZigBee chip, it should pull down SPI enable to zero voltage and send the register address with variable size according to the different types registered to the ZigBee chip.

If the first bit of the address is 1, indicating that the register type the MCU wants to access is a long address register, it should send a 10-bit address of the register to the MCU. If the first bit of the address is 0, indicating that the register type the MCU wants to access is a short address register, it should send a 6-bit address of the register to the MCU. The last bit of the address is used to determine that the MCU wants to write or read the register. If the last bit of the address is 0, this indicates that the MCU wants to read the register. If the last bit of the address is 1, this indicates that the MCU wants to write the register.

Furthermore, the ZigBee chip should send serial data to the MCU via a MISO pin if the register operation is read. If the register operation is writing, the MCU should send serial data to ZigBee via a MOSI pin.

3.3. Firmware and Software Design

The firmware of this study is a Real Time Operating System (RTOS) called CMX to interrupt the handle, provide a Timer and ZigBee protocol stack. First, the RTOS is described and the kernel functions used in the firmware are. Secondly, the ZigBee protocol stack, network layer design method based on the MAC layer, flowchart and message sequence chart are described. Finally, the design methods of the hardware and firmware are illustrated.

3.3.1. Introduction to RTOS

The firmware uses an RTOS called CMX, which is a real time multi-tasking operating system that supports many functions to develop real time multi-tasking applications. The heart of the operating system is the scheduler based on true preemption, which allows for tasks and interrupts to cause an immediate task switch. The firmware uses some tasks to handle the necessary jobs and a software timer

to do periodical jobs by calling the kernel functions of the RTOS. These task related functions and cyclic timer functions are described below.

3.3.1.1. Task Related Functions a. K_Task_Create Function

This function is used to create a task before entering the CMX RTOS. The ROM TCB task is a

This function is used to create a task before entering the CMX RTOS. The ROM TCB task is a

相關文件