陕西理工学院毕业设计
data and several CAN nodes can request the bus simultaneously. It covers the lowest two layers of the ISO/OSI reference model which includes the data link and physical layer. The Datalink layer recognises and understands the format of messages [5]. CAN protocol define messages as frames. Embedded in the data frames are arbitration fields, control fields, data fields, cyclic redundancy check sum (CRC) fields, a 2 bit acknowledge field, and an end of frame. The arbitration field prioritizes messages on the bus. For a standard data frame, the arbitration field consists of 11 bit identifier and for extended data frame 29 bit identifier [8], [9].
The physical layer specifies the physical and electrical characteristics of the bus. Most CAN systems implement the physical layer of the protocol by using some kind of transceiver which connects the CAN_H and CAN_L pins to the CAN bus with a differential signal of 0–3 V. ISO 11898- 2 is the most used physical layer standard for CAN networks in which data rate is defined up to 1 Mbit/s with a theoretically possible bus length of 40 m at 1 Mbit/s. The high-speed standard specifies a two-wire differential bus with a maximum of 30 nodes [9]. The bus level is determined by a potential difference between the CAN_H and CAN_L wires. The CAN bus line can have one of two logical states: recessive and dominant. Typically, the voltage level corresponding to recessive (logical 1) is 2.5 V and the levels corresponding to dominant (logical 0) are 3.5 V for CAN_H and 1.5 V for CAN_L. The voltage level on the CAN bus is recessive when the bus is idle.
The CAN protocol handles bus accesses according to the concept called Carrier Sense Multiple Access with Arbitration on message priority. If two or more bus nodes start their transmission at the same time after having found the bus to be idle, collision of messages are avoided by bitwise arbitration. Each node sends the bits of its message identifier and monitors the bus level. When a dominant bit is being sent, the resulting bus state according to wired-AND principle is also dominant. Otherwise, if a recessive bit is being sent, the resulting bus state depends on what other nodes are sending in the same time [8], [9]. The recessive bus state means that there is no collision, the dominant state means that at least one node is sending dominant bit. When the node receives a dominant bit during sending a recessive one, it loses the arbitration and withdraws from the transmission. It means that messages with lower ID values higher priority. Nodes that lose arbitration automatically try to repeat their transmission once the bus return to the idle state.
III. HARDWARE APPROACH A.Sensing Module
In the proposed system the sensing nodes are designed and implemented using low cost gas sensors. The used gas sensors are sintered SnO2 semiconductor heated sensors provided by Figaro [7]. The TGS 2620 is a volatile organic compound sensor and TGS 2600 is air contaminant sensor. TGS 2620 has high sensitivity to the vapours of organic solvents as well as other volatile vapours. It also has sensitivity to a variety of combustible gases such as carbon monoxide, making it a good general purpose sensor. TGS 2600 has high sensitivity to gaseous air contaminants such as hydrogen and carbon monoxide. In the presence of a detectable gas, the sensor's conductivity increases depending on the gas concentration in the air. A simple electrical circuit can convert the change in conductivity to an output signal which corresponds to the gas concentration.
B.Signal Conditioning Module
The output of the sensor is in the range of 0-5V. But the maximum analog input the inbuilt ADC can support is 3V. So a scaling circuit using the operational amplifier LM741 is used as the signal conditioning circuit. The gain of the op- amp and the input determines the output of the circuit. C.Microcontroller Module
AT89C51CC03 is an 8-bit microcontroller with inbuilt 10-bit resolution ADC and CAN controller from Atmel Corporation. The proposed system uses the very thin quad flat package IC. An adapter is used
第26页共47页
陕西理工学院毕业设计
as the IC cannot be programmed directly. The conditioned sensor output is given to one of the analog input channel of the ADC, which converts it into corresponding digital output. The digital output is given to the CAN message channel of the inbuilt CAN controller. The sensor data is processed by the CAN controller based on the CAN protocol version 2.0A. D.CAN Transceiver Module
The ATA6660 is a high speed CAN transceiver from Atmel Corporation. It is especially designed for high speed CAN Controller differential mode data transmission between CAN Controllers and the physical differential bus lines. It supports a maximum transmission speed of 1Mb/s. Fig. 2 shows the circuit connection for the microcontroller and the CAN Transceiver. E.Motor Control and the Alarm Module
This module consists of an exhaust fan controlled by +5V brushless DC motor and a motor driver ULN2803 which is connected to the microcontroller. If the received sensor data is higher than the predefined limit the motor starts and the exhaust fan will start rotating continuously. At the same time alarm will also turn on. As the voltage from the microcontroller is not sufficient to run the motor, the motor driver ULN2803 is used which supplies sufficient voltage to the motor to run.
Figure 2. Microcontroller and CAN Transceiver connection
The alarm unit mainly consists of a buzzer. The triggering of the alarm unit is directly controlled by the microcontroller. As the fan rotates it expels out the contaminated air out and fresh air will replace it. As the concentration of gas decreases the sensor output decreases and when it becomes less than the limit the fan will stop. F.Display Module
LED display is used to display the received data in hex values.LCD display also can be used, which will show the corresponding ASCII values of the received data. The display node can also contain a computer which continuously monitors the data coming from the sensor nodes. IV.SOFTWARE IMPLEMENTATION
Keil μVision 2 IDE is used to develop the application software. Fig 3 shows the flowchart to transmit CAN signal to CAN bus by the sensor node and fig. 4 shows the flowchart to receive CAN signal from CAN bus by the motor control node with display. The program is written in Keil C language and simulated using Keil μVision IDE to generate the hex file. This hex file is then downloaded into the microcontroller for it to function as programmed. As the functions related to CAN are readily available in Keil μ Vision IDE the compilation and there after development process is easy. V.EVALUATION
The sensor data is transmitted and received as either standard or extended format based on the CAN standard being used. Here the data is transmitted as CAN standard format with 11-bit identifier. Fig. 5 shows the Digital Signal Oscilloscope (DSO) output of CAN signal for sensor node 1 and fig. 6 shows the
第27页共47页
陕西理工学院毕业设计
DSO output of CAN signal for sensor node 2. This is used to verify CAN data and estimate the CAN timing. The transmission speed of CAN is set to 1Mb/s.The identifier set for sensor 1 node is 123 and for sensor 2 nodes is 214. As CAN arbitration is based on wired AND mechanism the sensor 1 node will transmit the data first as it has the lowest identifier number which has got highest priority. Start Reset CAN Clear CAN Interrupts and message buffer Set transmission rate and enable CAN controller Initialize ADC Select analog input channel and start conversion No End of conversion Yes Select channel for transmission and set its ID Store the value in CAN message buffer Enable transmission Figure 3. Flowchart of CAN transmission program
第28页共47页
陕西理工学院毕业设计
Start Reset Can Controller Initialize CAN interrupts and message buffer Configure the CAN bit transmission rate Enable CAN controller Select channel, set channel ID and enable reception No Signal Received ? Yes No CAN ID Matches? Yes Display to LED Delay No Data limit exceeds ? Yes Motor starts Alarm turn on Reset buffer LED off Figure 4. Flowchart of CAN receiver program
第29页共47页
陕西理工学院毕业设计
Figure 5. DSO output of CAN signal for sensor node 1
Figure 6. DSO output of CAN signal for sensor node 2
Fig. 7 shows the experimental set up of the proposed indoor air quality monitoring and control system. The motor control node action is checked with +5V brushless DC motor with fan which is used in CPU for cooling purpose. The maximum concentration of gases which the sensor can sense is 10000ppm which gives the maximum output voltage of 5V.When the concentration of gases exceeds 6000ppm, the output voltage will go beyond 2.85V. Then the alarm will turn on and the fan will start rotating. I.CONCLUSION
CAN based smart sensor network for indoor air quality monitoring has been designed with two transmitter nodes and one receiver node. The transmitter nodes are designed as sensor nodes and the receiver node as the motor control node with display which accepts messages from the sensor nodes and uses the information to switch on and off the fan, there by controlling the concentration of air contaminant gases. CAN communication between the two sensor nodes and the motor control node has been implemented through the CAN physical layer standard ISO 11898-2, which defines CAN bus as two wire differential bus.
第30页共47页