introduction
CAN (Controller Area Network) bus is a serial data communication protocol developed by Bosch of Germany to solve the data exchange between numerous control and test instruments in modern automobiles. It is a multi-master bus. The communication medium can be twisted pair, coaxial cable or optical fiber. The communication rate can reach 1Mbps and the communication distance can reach 10km. One of the biggest features of the CAN protocol is that it abolishes the traditional station address coding and replaces it with encoding the communication data block, so that the number of nodes in the network is theoretically unlimited. Because the CAN bus has strong error correction capabilities and supports differential transmission and reception, it is suitable for high interference environments and has a long transmission distance. Therefore, the CAN protocol is very attractive for distributed measurement and control in many fields. At present, CAN has become the ISO11898 standard, and its characteristics are as follows:
(1) CAN is a serial communication network that effectively supports distributed control and real-time control.
(2) The CAN protocol follows the ISO/OSI model and uses the physical layer, data link layer and application layer.
(3) CAN can work in multi-master mode, which is essentially a CSMA/CD mode. Any node on the network can actively send information to other nodes on the network at any time, regardless of master or slave. There are priorities between nodes, so the communication method is flexible. CAN uses non-destructive bit arbitration technology and priority transmission, which can greatly save bus conflict arbitration time and show good performance under heavy load. CAN can transmit and receive data in several ways, such as point-to-point, point-to-multipoint (grouping) and global broadcast.
(4) The maximum direct communication distance of CAN can reach 10km (transmission speed is 5 Kbps); the maximum communication rate can reach 1Mbps (transmission distance is 40m).
(5) The actual number of node data on CAN can reach 110.
(6) The CAN data link layer uses a short frame structure, with each frame consisting of 8 bytes, which is easy to correct errors. Each CAN frame has CRC check and other error detection measures, which effectively reduce the error rate of the data. In the event of serious errors, the CAN node has the function of automatically shutting down so that other nodes on the bus are not affected.
(7) The signal modulation and demodulation method adopts the NRZ encoding/decoding method, and the insertion of fill bits (bit filling) technology is adopted.
(8) The data bit has two logical values: dominant bit (0) and recessive bit (1). It uses clock synchronization technology and has the functions of hardware self-synchronization and automatic tracking of timing time.
Design of home controller bus based on CAN bus
In today's information age, people have higher and higher requirements for safety and comfort in their living environment. It is imperative to establish a computer management local area network for residential areas and realize the networking of comprehensive management of residential areas. Through home controllers and central computer systems throughout the residential area, intelligent management of residential buildings can be achieved.
Figure 1 is a schematic diagram of the overall structure based on the CAN bus. The system adopts a bus network that supports the CAN standard. The central computer system (host PC) is connected to the CAN bus through a CAN interface adapter card for data exchange. The central computer system and the home controller (lower intelligent node) are connected to a bus through twisted pair cables to form a low-level communication network. Due to the use of CSMA/CD information transmission control technology, each node on the bus is allowed to compete for the bus equally, thereby forming a redundant network structure with multiple master nodes.
In the low-level communication network, the central computer system and the home controller each have their own ID mark. Since the CAN standard is used as the network communication protocol, each node has the same status in the network, so we can virtualize the central computer system as the host, and the home controller as the slave to respond to the host's requirements. The central computer system is responsible for monitoring and managing the entire CAN bus system, and has functions such as system parameter (such as transmission rate, node address, etc.) setting, data transmission, data request, local status query, node status query, interrupt status query, etc. The system working process is that the upper computer sends commands to the lower node (home controller), and the lower node recognizes and executes the corresponding command. At the same time, each lower node can also exchange information as required.
[page]
In the data link layer, two frame types supporting the CAN protocol are specified: data frame and remote frame. Data frame is used to send data, and is used by a node to transmit information to any or all other nodes; remote frame is used for "remote transmission request", and is used by a node to actively request other nodes to send information. The specific formats of the two frames are shown in Figure 2.
Hardware circuit design
Home Controller Hardware Design
This system is a controller local network composed of many smart home controllers connected through CAN bus, so the design of CAN bus is extremely important. Among them, the selection of CAN controller, CAN transceiver and anti-interference measures will become the key to the design.
①Selection of CAN controller
In order to further expand the system, SJA1000 that supports CAN2.0B communication protocol can be selected. SJA1000 is the latest CAN controller produced by PHILIPS that supports both CAN2.0B and CAN2.0A. It is fully compatible with the CAN controller PCA82C200 that only supports CAN2.0A in hardware and software.
②CAN transceiver
PCA82C250 is the interface between PHILIPS's CAN controller and the physical bus, providing differential transmission and reception capabilities for the bus. It is fully compatible with the ISO11898 standard and has three different working modes: high speed, slope control and standby, which can be selected according to actual conditions.
③Photoelectric isolation
In order to further improve the anti-interference ability of the system, an isolation circuit consisting of a high-speed isolation device 6N137 is added between the controller SJA1000 and the transceiver PCA82C250, and the power supply uses a DC-DC converter.
The purpose of using PCA82C250 in the hardware circuit is to increase the communication distance, improve the system's instantaneous anti-interference ability, protect the bus, reduce radio frequency interference (RFI), and achieve thermal protection.
The hardware structure diagram of CAN device and microprocessor is shown in Figure 3.
CAN interface adapter card and CAN bus repeater
The CAN interface adapter card completes the communication of the CAN-PC bus. The adapter card consists of a single-chip microcomputer 89C51, a CAN controller SJA100, a CAN transceiver 89C250 and its control circuit.
Due to the limitation of CAN transceivers, there can be at most 110 CAN nodes in a CAN bus network. The CAN bus can be expanded by using a repeater, which can not only increase the total number of CAN nodes to 2032, but also double the CAN communication distance. At the same time, two CAN networks with different speeds can be connected together to form a more complex CAN network.
The repeater uses a specific control logic to control a pair of CAN transceivers 82C250. The CAN transceivers are connected back-to-back to connect two physically independent CAN networks and transmit data in both directions. From the physical layer point of view, the repeater realizes the transparent relay of CAN bus signals.
Software Design
Host computer software
[page]
The software is developed using Visual Basic 6.0. It is divided into two functional modules: high-level system management module and low-level communication module. The program flow chart is shown in Figure 4.
Home Controller (Node) Software
Realize information exchange with the host computer and other nodes.
In software design, we follow the modular design concept and adopt structured programming scheme to make it have good modularity, modifiability and portability.
The initialization design of the CAN bus system is the key to software design. If this part is not designed well, the system will not be able to work properly. Therefore, the initialization design is a difficult point and a key point.
Before initialization, the reset request bit of the output control register (OCR) should be set high, and then other registers should be set. The control register (CR) sets the interrupt; the command register (CMR) controls the receiving status of the buffer; the interrupt register (IR) and the status register (SR) query the working status of SJA1000; the receiving code register (ACR) sets the working address; the receiving mask register (AMR) sets the working mode, and the bus timing register (BTR0, BTR1) sets the working frequency and sampling frequency; the output control register (OCR) is generally a normal output mode. Finally, the reset request bit should be changed from high to low to make the CAN controller enter the normal working state. Therefore, initializing the CAN controller is actually accessing the registers ACR, AMR, BTR0, BTR1 and OCR.
After successfully initializing the SJA1000, the system can use it to transmit messages.
Conclusion
CAN bus is gaining more and more attention due to its high performance, high reliability and unique design, and is recognized as one of the most promising buses. We applied this bus technology in the home controller system, designed the hardware circuit and software, and put it into practical use.
Previous article:Design and implementation of an instant messaging monitoring system
Next article:Design of three-level intelligent fire alarm system based on CAN bus
Recommended ReadingLatest update time:2024-11-17 05:27
- Mir T527 series core board, high-performance vehicle video surveillance, departmental standard all-in-one solution
- Akamai Expands Control Over Media Platforms with New Video Workflow Capabilities
- Tsinghua Unigroup launches the world's first open architecture security chip E450R, which has obtained the National Security Level 2 Certification
- Pickering exhibits a variety of modular signal switches and simulation solutions at the Defense Electronics Show
- Parker Hannifin Launches Service Master COMPACT Measuring Device for Field Monitoring and Diagnostics
- Connection and distance: A new trend in security cameras - Wi-Fi HaLow brings longer transmission distance and lower power consumption
- Smartway made a strong appearance at the 2023 CPSE Expo with a number of blockbuster products
- Dual-wheel drive, Intellifusion launches 12TOPS edge vision SoC
- Toyota receives Japanese administrative guidance due to information leakage case involving 2.41 million pieces of user data
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- Renovation of old items + modification of vehicle-mounted DC fans
- Highlight Review | “Big Names” Gathered at 2018 IMS
- AD19AD19, on a PCB that has already been copper-plated, I deleted the copper and changed the layout to redraw a PCB, but when I entered the 3D view, the original copper outline would be displayed. How can I delete this outline?
- [ST NUCLEO-H743ZI Review] + 1. Unboxing and setting up the environment
- Asking for help from experts: How to improve data reliability when using MCU + GSM to send text messages?
- [TI Recommended Course] #[High Precision Lab] Operational Amplifier: 2 Input Offset Voltage and Input Bias Current#
- Configuration issues of SEED-XDS510PLUS in CCS5.5.0
- STM32F4 hardware I2C driver 0.96 OLED screen
- Analog electronics course selection test + isolation course learning
- Is using Keil to develop stm32 considered cross-compilation?