Research on the application of CAN bus in home intelligent control system

Publisher:科技创新实践者Latest update time:2014-04-06 Source: eccn Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
O Introduction

The main functions of home intelligent control systems are concentrated in home security alarm, telephone or computer remote control, infrared remote control, automatic meter reading control, lighting and humidity control, etc. According to the different data and functions transmitted by intelligent terminal devices, it can be divided into two types of subnets. One type is home automation control devices that transmit data with small data volume and low speed; the other type is multimedia information (video, audio signals), with large signal volume and fast speed, such as video conferencing, audio on demand, etc. Home intelligent terminal devices can be formed into wired subnets and wireless subnets using bus structures. Because each device is distributed in different places in the home, the wiring for forming a wired subnet is relatively complicated, but if PLC and CAN bus are used to build a network, the cost will be reduced.

CAN (Controller Area Network) is a serial data communication protocol developed by Bosch in Germany for automobile detection and control in the early 1980s. It is a multi-host bus. The communication medium can be twisted pair, coaxial cable or optical fiber, and the communication rate is 1Mb/s. CAN bus has excellent performance, high reliability and unique design, and is widely used in many departments such as industrial automation, transportation, medical equipment, construction, and environmental control.

1 Composition of home intelligent control system

The home intelligent control system is the core of command communication and information management of equipment such as televisions, washing machines, air conditioners, water meters, electricity meters, and gas meters. Its main function is to communicate with remote control systems, receive various control commands, and complete real-time control of corresponding equipment.

All monomers with embedded microprocessors or microcomputers in the control system are interconnected through the CAN bus. A distributed local network is formed to realize data exchange and information resource sharing. This design has the following advantages: reduced communication ports and connecting cables; strong anti-interference ability; flexible configuration, convenient system expansion and upgrading; simple debugging and convenient maintenance.
The principle of the home intelligent control system composed of CAN bus is shown in Figure 1.



2 Connection between PLC and CAN bus

Take GE FANUC series 90 PLC as an example to give a connection scheme between PLC and CAN bus.

GE series 90 PLCs all have converted RS 232 serial communication ports, and the programming computer communicates and programs with PLC through this serial port. RS 232 standard level adopts negative logic, and stipulates that any level between +3 and +15V is the logic "0" level, and any level between -3 and -15V is the logic "1" level. CAN signals are transmitted using differential voltage. The two signal lines are called "CAN_H" and "CAM_L". They are both about 2.5 V in static state. The state at this time is represented by logic "1", which can also be called "recessive"; CAN_H is higher than CAN_L to represent logic "0", which is called "dominant". When dominant, the voltage value is usually: CAN_H=3.5V, CAN_L=1.5V.

The frame format of RS 232 serial port is: 1 start bit, 8 data bits, 1 programmable 9th bit (this bit is the address/data bit for sending and receiving), and 1 stop bit. The data frame format of CAN is: frame information + ID + data (can be divided into two formats: standard frame and extended frame). Therefore, a microcontroller is needed to realize the conversion of level and frame format when designing. The conversion method is shown in Figure 2.



The AT89C52 single-chip microcomputer is used as the microprocessor; SJAl000 is used as the CAN microcontroller. The physical layer and data link layer functions of the CAN protocol are integrated in SJAl000, which can passively handle the frame processing of communication data; high-speed photoelectric isolation is implemented by 6N137, which is used to prevent interference from serial signals; MAX232 is used to complete the conversion from RS 232 level to TTL level of the microcontroller interface chip. For the specific hardware interface circuit, please refer to the information of SJAl000, but there are several points to note:

(1) There is a 120 Ω resistor at both ends of the CAN bus, which is used to match the bus impedance and improve the anti-interference and reliability of data communication. But in fact, it is only necessary to ensure that the jumper resistor between "CAN_H" and "CAN_L" in the CAN network is 60 Ω.

(2) The RX1 pin 20 of SJAl000 can be grounded when not in use, and the bus length can be greatly increased with the setting of CDR.6.

(3) The connection method of pins TX0 and TX1 determines the level of serial output. For the specific relationship, please refer to the setting of the output control register OCR.
(4) There is a slope resistor between the RS pin of AT82C250 and the ground. The size of the resistor can be adjusted appropriately according to the bus communication speed, generally between 16 and 140 kΩ.

(5) MAX232 requires four electrolytic capacitors C1, C2, C3, and C4 on the periphery. These capacitors are also required for internal power conversion. Their values ​​are all 1μF/25 V. Tantalum capacitors should be selected and the position should be close to the chip. A 0.1μF decoupling capacitor should be connected between the power supply Vcc and the ground.

Under the control of the microprocessor, when RS 232 and CAN exchange data, the use of serial port reception and CAN interrupt mode can improve work efficiency. The initialization of SJAl000 can only be performed in reset mode, which mainly includes the setting of working mode, clock frequency division and acceptance filter register, baud rate parameter setting, and interrupt enable register setting. The main program flow chart is shown in Figure 3. [page]



Whether data can be accurately transmitted also depends on baud rate and flow control, which is also a point that cannot be ignored in software design. Therefore, the following mainly introduces the setting of CAN baud rate, automatic detection of serial port baud rate, and serial port data flow control.

One of the elements in the CAN protocol is the baud rate. The bit sampling point position and sampling times in the bit period can be set so that the application network performance can be freely optimized, but in the optimization process, attention should be paid to the relationship between the tolerance of the bit timing parameter reference oscillator and the propagation delay of different signals in the system.

The system's bit rate fbit represents the amount of data bits transmitted per unit time, that is, the baud rate fbit=1/tbit. The rated bit timing consists of three non-overlapping segments SYNC_SEG, TSEG1 and TSEG2, and these three time periods are tSYNC_SEG, tTSEG1 and tTSEG2 respectively. Therefore, the rated bit period tbit is the sum of the three time periods: tbit=tSYNC_SEG+tTSEG1+tTSEG2. These segments in the bit period are represented by integer basic time units. This time unit is called time share TQ, and the duration of the time share is one cycle tSCL of the CAN system clock, which can be obtained from the oscillator clock period tCLK. The CAN system clock can be adjusted by programming the pre-scaling factor (baud rate preset value BRP), that is, tSCL=BRP×2tCLK=2BPR/CLK.

Another very important time period for CAN bit timing calculation is the synchronization jump width (SJW), which lasts for tSJW. The SJW segment is not a segment of the bit period, but only defines the maximum TQ number of the bit period that is increased or shortened in the resynchronization event. In addition, the CAN protocol also allows users to specify the bit sampling mode (SAM), which is single sampling and triple sampling mode (selecting 1 out of 3 sampling results). In the single sampling mode, the sampling point is at the end of the TESG1 segment. The triple sampling mode takes two more sampling points than the single sampling, which are in front of the end of the TSEGl segment, with a difference of one TQ between them. The above-mentioned BPR, SJW, SAM, TESGl, and TESG2 can all be defined by the user through the built-in registers BTR0 and BTRl of the CAN controller. After setting BTR0 and BTR1, the actual transmission baud rate range is: maximum = 1/(tbit-tSJW), minimum = 1/(tbit+tSJW).

To detect the serial port baud rate of the converter, first set the host's receiving baud rate (9600 b/s as an example) and send a specific character (carriage return as an example) at the terminal. In this way, the host can determine the communication baud rate of the converter based on the received character information. The ASCII value of the carriage return is 0DH, and the values ​​received at different baud rates are listed in Table 1.



When data is transmitted between two serial ports, data loss often occurs. Since the microcontroller buffer is limited, if the buffer is full when receiving data, the data that continues to be sent will be lost. Flow control can effectively solve this problem. When the receiving end cannot process the data, the flow control system will send a "no more receiving" signal, and the sending end will stop sending until it receives a "can continue sending" signal and then sends data. Therefore, flow control can control the process of data transmission and prevent data loss. The two commonly used flow controls are hardware flow control (including RTS/CTS, DTR/CTS, etc.) and software flow control XON/XOFF (continue/stop). The following only describes the hardware flow control RTS/CTS.

When using hardware for flow control, the serial terminal RTS and CTS are connected to the I/O port of the microcontroller, and the start and stop signals are received and sent by setting the I/O port to 1 or 0. The data terminal equipment (such as a computer) uses RTS to start the data stream sent by the microcontroller, while the microcontroller uses CTS to start and pause the data stream from the computer. When implementing this hardware handshake method, a high flag and a low flag are set according to the size of the receiving end buffer during programming. When the amount of data in the buffer reaches the high level, the CTS line is set low (send logic 0) at the receiving end, and when the program at the sending end detects that CTS is low, it stops sending data until the amount of data in the receiving end buffer is lower than the low level and CTS is set high. RTS is used to indicate whether the receiving device is ready to receive data.

The following is the CAN receiving subroutine:




3 Conclusion

Through the analysis of the home intelligent control system, PLC and CAN bus are used to build a control local area network. Through the test of the simulation system, the bus can fully complete the control of home intelligent terminal devices, but in order to further improve its control stability and real-time performance, more in-depth research is needed on this basis.
Reference address:Research on the application of CAN bus in home intelligent control system

Previous article:Application of PROFIBUS-DP Bus Technology in Coke Oven Vehicles
Next article:LVDS is obsolete? LVDS and JESD204B will continue to develop in the long term

Recommended ReadingLatest update time:2026-03-29 19:03

CAN bus BUS OFF state send buffer processing strategy
In the field of modern automotive electronic control systems and industrial automation, the CAN (Controller Area Network) bus plays a vital role as an efficient and reliable communication protocol. However, during the operation of the CAN network, due to various internal and external factors, the node may enter the
[Embedded]
Nidec Servo launches new motor for vending machines equipped with Can-Bus communication function
  Nidec Servo Corporation has officially launched a brushless DC motor equipped with Can-Bus communication function. This motor is mainly used for the push mechanism of vending machines.        "Brushless DC motor equipped with Can-Bus communication function"   CAN-Bus (Controller Area Network-Bus) is an internal co
[Embedded]
Nidec Servo launches new motor for vending machines equipped with Can-Bus communication function
Analysis and testing of CAN node recovery process in bus off state
Bus off is a relatively important error handling mechanism for CAN nodes. So, what is the recovery process of CAN nodes in the bus off state? And how to understand the "fast recovery" and "slow recovery" mechanisms of the node recovery process? This article will analyze the mechanism and principle of bus off and recov
[Automotive Electronics]
Analysis and testing of CAN node recovery process in bus off state
How to automatically recover from bus-off in STM8CAN
Hardware requirements: STM8AF52A8, TJA1040T Software requirements: IAR This is just one case of bus-off: when CANH and CANL are short-circuited together, the STM8 CAN controller stops working. How to make CAN work again? Theoretically: Look at the reference manual of STM8, where the sixth bit ABOM of the CAN master
[Microcontroller]
How to automatically recover from bus-off in STM8CAN
What does CAN-bus device mean?
Overview CAN-bus (Controller Area Network) is one of the most widely used fieldbuses in the world. At first, CAN-bus was designed as a communication between microcontrollers in the automotive environment, exchanging information between various electronic control units (ECUs) on board, forming an au
[Embedded]
Analyzing CAN-BUS data bus
Nowadays, there are various forms of on-board networks in automobiles. The most widely used one is the controller area network, the so-called CAN Bus system. In 1986, Bosch of Germany developed the CAN communication protocol for automobiles. Since then, CAN has been standardized through ISO11898 and ISO11519. The
[Embedded]
RS232 transparent transmission CAN-bus | rs232can
1. Product Introduction CAN232MB/CAN485MB module is a key tool for industrial bus transformation and interconnection of multiple bus devices. It is an industrial-grade CAN-bus and serial bus communication connector (bridge) that integrates 1 standard CAN-bus interface and 1 standard serial inte
[Embedded]
How to detect BUS-OFF on CAN bus
1. What is BUS-OFF? When the number of CAN controller errors exceeds 255, a BUS-OFF error will be triggered. Generally, the condition for BUS-OFF is that the CAN bus is disturbed by the surrounding environment, causing the data sent by the CAN transmitter to the bus to be judged as abnormal by the BUS bus. How
[Embedded]
Latest Embedded Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

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-2026 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号