Design and implementation of intelligent window system based on CAN bus

Publisher:CreativeMindLatest update time:2010-11-19 Source: 微计算机信息 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1 Introduction

In the existing market in my country, smart windows, as part of smart homes, are mainly developed around individual families. However, as people's requirements for smart homes become higher and higher, higher requirements are put forward for group control, remote monitoring, real-time performance, etc. Under this premise, new topics are introduced. Combining the outstanding reliability, real-time and flexibility of CAN bus data communication technology, CAN bus technology is applied to the system to achieve the purpose of monitoring the operation of all windows while controlling each individual window.

2 System Structure Design

2.1 Overall system structure

The CAN bus follows the ISO/OSI standard model and is divided into a data link layer (including the logical link control sublayer LLC and the media access control sublayer MAC) and a physical layer. Its communication interface integrates the physical layer and data link layer functions of the CAN protocol, and can complete the frame processing of data, including bit filling. Users can develop application layer communication protocols that meet the actual needs of the system based on it.

Compared with general communication buses, one of the biggest features of the CAN protocol is that it abolishes the traditional station address coding and replaces it with the coding of communication data blocks. The message identifier can reach 2032 (CAN2.0A), and the identifier of the extended standard (CAN2.0B) is almost unlimited, and different nodes can receive the same data at the same time. Therefore, this system can be composed of multiple independent windows as basic units. These units and the host computer form a monitoring network through the CAN field bus, thereby realizing the function of group control.

As shown in Figure 1 below. From this we can see that this system is divided into three layers:

(1) Field device layer: It consists of a rain sensor and multiple window nodes. These input and output devices are connected to the field bus as CAN I/O points. The number of window nodes N is determined by the selected bus driver circuit.

(2) Device control layer: CAN controller P8xC592 and CAN transceiver PCA83C250, which are the core parts of CAN bus control. The CAN controller realizes the functions of communication and node control; the CAN transceiver plays the role of communication between nodes and the bus.

(3) Management and monitoring layer: As the human-computer interaction interface of the control system, it monitors and controls the entire system through the host PC.

1.jpg

Figure 1 System hardware structure diagram

2.2 System Hardware Selection

In this system, the bus controller and transceiver are P8xC592 and PCA83C250 from Philips, respectively. The P8xC592 microcontroller is an 8-bit microcontroller with CAN function manufactured using COMS technology. Its instruction set is fully compatible with 80C51, which is convenient for programming. PCA83C250 is the interface between the CAN controller and the physical bus, and can provide differential transmission and reception functions for the bus. It should be noted that the P8xC592 microcontroller is a high-performance microprocessor with an integrated CAN controller. Therefore, in this system, the P8xC592 not only connects to the CAN, but also controls each window subsystem.

At the same time, as long as the transmission medium uses twisted pair, it has high-speed (1Mbit/s) data transmission capability at short distance (40m), and low-speed (5kbits/s) transmission capability at the maximum distance of 10000m. The main controller uses the 89S51 single-chip microcomputer with high cost performance, simple structure and easy programming. It is mainly used to initialize the CAN controller P8xC592 and its serial port RS232, and realize the communication tasks such as data exchange between the field CAN bus and the management PC through the control operation of the CAN controller 8xC592 and its serial port RS232.

3 User Communication Protocol Design

3.1 Communication Protocol

The CAN2.0A standard is used here. The biggest advantage of this protocol is that it abolishes the traditional station address encoding. Therefore, CAN has no concept of node address. Instead, it uses communication data blocks for encoding and supports data-centric communication mode. When the window nodes are different, you only need to increase or decrease the number of nodes of the controller on the bus and make appropriate modifications to the corresponding data frames. The number of nodes on CAN mainly depends on the bus drive line. When PCA82C250 is used, it can reach up to 110.

3.2 Data Frame

The data frame is shown in Figure 2, which includes seven parts: frame start, arbitration field, control field, data field, CRC sequence, ACK field, and frame end. The arbitration field includes a message identifier (11 bits) and a remote transmission request bit (RTR); the control field consists of six bits, as shown in Figure 3, and the last four bits are data length codes, representing the number of bytes in the data field, which is set to 02H here; the data length of each frame of the transmission signal is 16 bits, and the high byte is encoded with eight bits from D8 to D15 to indicate the location of the node in the building, and the low byte is set to the control word, and each bit of the control word is high level valid. As shown in Figure 4 below, for example: the data field is 0801H, indicating that the window node No. 8 requires hosting; 0802H indicates that the window node No. 8 is in the open state, 0804H indicates that the window No. 8 is in the closed state, 0808H indicates that the window No. 8 is to execute the window opening instruction, and 080F H indicates that the window No. 8 is to execute the window closing instruction. For the upper computer and each node in the lower layer, the data frame information they need to send is different.

4.jpg

Figure 4 Data field composition

3.3 Multi-host broadcast mode

When the bus is idle, any node can send data, and other nodes can receive data on the bus. CAN can realize point-to-point, point-to-multipoint and global broadcast transmission and reception modes only through message filtering, without special scheduling. Here, the receiving code register and the receiving code shielding register are used to realize message filtering, so that the host computer receives all the information on the bus, and the layer station controller only receives the signal sent by the CAN controller of the host computer, and different nodes can receive the data sent by the CAN controller of the host computer at the same time. This is very useful. The use of broadcast mode can greatly save transmission time, improve transmission rate, and enhance the real-time performance and reliability of the system.

3.4 Bus Arbitration

The message identifier is used to provide information about the transmitted message and bus access rights. When multiple bus controllers send messages at the same time, arbitration is required to avoid conflicts. During arbitration, each P8xC592 that sends compares its transmit bit level with the monitored bus level. If a recessive bit is sent and a dominant bit level is monitored, the node loses arbitration, gives up bus control, stops transmitting information, and the P8xC592 immediately becomes the receiver of the higher priority message on the bus without destroying any information on the bus. The transmitted data on the data field is stored in the data area of ​​the transmit buffer, and the data of the received data frame will be stored in the receive buffer. Each message segment includes a unique identifier and the RTR bit that describes the data type in the message. The identifier and the RTR bit together define the bus access priority of the message. During arbitration, the highest bit of the identifier is sent first, and the RTR bit is sent last. The message with the lowest binary value corresponding to the identifier and RTR bit has the highest priority. 11 bits can form 2032 different identifiers, and due to the limitation of the driving circuit, the number of window nodes in this system can only be 110 at most, so using identifiers to determine priority is more than enough.

4 System Software Design

The design ideas of the network management and application programs of the host computer, i.e. the operation station, are mainly to initialize the CAN interface adapter card, determine when there is a conflict between network nodes, set node priority, data access, compare with historical data, process and send back according to the actual situation of the node, etc.

The communication software of CAN controller P8xC592 includes three parts: CAN initialization, message reception and message transmission. When the controller is powered on, the CAN controller P8xC592 is initialized first, mainly including the setting of working mode, receiving filter mode, receiving mask register and receiving code register, baud rate parameter setting and interrupt enable register setting. After completing the initialization setting of P8xC592, it returns to the working state and starts to cyclically monitor the information on the CAN bus.

From the user's perspective, the operation of the window is closely related to it. The software design of the lowest-level field CAN intelligent measurement and control node adopts a structured design scheme. As shown in Figure 5 below, P8xC592 determines the operation status based on the information sent by the remote control. If it needs to be hosted, it receives the signal from the CAN controller and uses it to control the opening/closing of the window. If it does not need to be hosted, it will continuously scan the remote control, receive the signal and then execute it. At the same time, at the end of the program, there is a 10ms timing operation, which can ensure that the microcontroller can send the detection signal to the PC in an orderly manner.

20080807091321780.jpg

Figure 5 Window node software flow chart

5 System Function Effect

In this system, users can operate conveniently through the remote control. The remote control panel has three buttons: one is to open the window, the second is to close the window, and the third is to host. When the remote control's hosting button is not pressed, the user can control the opening and closing of the window by himself. When the user needs to open/close the window, just press the corresponding button on the remote control to achieve the function. When the remote control is in the hosting state, if it rains, the rain sensor detects the signal of rain, and sends a signal through P8XC592. The signal reaches the PC host through the CAN bus, and then the PC host sends the window closing command to all window nodes in the hosting state.

In terms of application, intelligent fault diagnosis is very important. In this system, a detection method is designed. Each window node sends a detection signal to the PC host every 10ms by P8XC592. If the host does not receive the detection signal of the node, it is considered that the node has failed. Then the PC will alarm the management personnel, indicating that the window node has failed.

6 Conclusion

Based on CAN bus technology, P8XC592 and PCA82C250 chips are used to form an advanced bus intelligent node controller. In this article, the author uses the intelligent window design as a fulcrum to outline the design scheme based on CAN bus technology applied to the field of smart home. Combine water meters, gas meters and other home devices in a single node controller, connect each node with CAN bus to form a control local area network. The design scheme proposed in this article provides new ideas and new methods for the development and design of smart home systems in the future.

The innovation of this paper is to introduce CAN bus into the design of smart home on the basis of realizing single node design, realize remote monitoring and operation of windows in buildings, and thus put forward new methods and ideas for the development of smart home.

Reference address:Design and implementation of intelligent window system based on CAN bus

Previous article:Design of music playing control circuit based on FPGA
Next article:A digital video mixer based on single chip microcomputer control

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号