CAN is the abbreviation of Controller Area Net, which is a serial communication network that effectively supports distributed control or real-time control. CAN was designed by Bosh of Germany for automobile detection and control systems. Because CAN has excellent characteristics and high reliability, it is very suitable for the interconnection of industrial process monitoring equipment. CAN has become an international standard (ISO-11898) and is one of the most promising fieldbuses.
1 Controller Area Network (CAN)
1.1 Characteristics of CAN bus
(1) CAN bus works in multi-master mode. Any node on the network can actively send information to other nodes on the network at any time, regardless of master or slave. The communication mode is flexible and there is no need to consider the priority of the receiver address.
(2) Node information on the CAN network is divided into different priorities to meet different real-time requirements. High-priority data can be transmitted within 134μs at most.
(3) CAN uses non-destructive bus arbitration technology. When multiple nodes send information to the bus at the same time, the node with a relatively low priority will actively withdraw from sending, while the node with the highest priority can continue to transmit data without being affected, thereby greatly saving bus conflict arbitration time.
(4) CAN can transmit and receive data in several ways such as point-to-point, point-to-multipoint and global broadcast by simply filtering the message, without the need for special "scheduling".
(5) CAN's direct communication distance can reach up to 10 km, at a rate of 5 kbit·s-1; the communication rate can reach up to 1 Mbit·s-1, at a maximum communication distance of 40 m.
(6) The number of CAN nodes depends mainly on the bus driver circuit, which can reach 110 at present; the message identifier can reach 2032 types (CAN2.0A); and the message identifier of the extended standard (CAN2.0B) is almost unlimited.
(7) It adopts a short frame structure, with short transmission time, low interference probability, and good error detection effect.
(8) Each frame of CAN information has CRC check and other error detection measures to ensure that the data error rate is extremely low.
(9) The communication medium of CAN can be twisted pair, coaxial cable or optical fiber, which is flexible to choose.
(10) CAN nodes have the function of automatically shutting down output in the event of serious errors, so that the operation of other nodes on the bus is not affected.
Because the CAN bus has the above characteristics, it can better meet the requirements of multi-point real-time data communication platform.
1.2 CAN bus protocol
The protocol structure of CAN is divided into two layers: data link layer and physical layer. The data link layer is further divided into logical link control sublayer and medium access control sublayer. The physical layer can be divided into physical signal layer PLS, physical medium connection PMA and medium related interface MDI. The ISO/OSI reference layered structure of CAN is shown in Figure 1.
The services and functions of the LLC and MAC sublayers of the data link layer are described as the "target layer" and "transport layer". The main functions of the LLC sublayer are: to provide services for data transfer and remote data requests, to confirm whether the message received by the LLC sublayer has been received, and to provide information for recovery management and notification of overload. The function of the MAC sublayer is mainly the transmission rules, that is, to control the frame structure, perform arbitration, error detection, error calibration and fault definition. The MAC sublayer also determines when to start a new transmission, whether the bus is open or whether to start receiving immediately. The positioning characteristics are also part of the MAC sublayer. The
physical layer defines how the signal is sent, and therefore involves the description of bit timing, bit coding and synchronization. Please refer to the literature for detailed layer functions.
1.3 CAN multi-point real-time communication
CAN is a serial communication network that effectively supports distributed (multi-point) real-time control. In actual system design, users can optimize the bit timing parameters of the CAN controller according to factors such as the oscillator clock frequency, bus baud rate, and the maximum transmission distance of the bus, coordinate the two main factors that affect the bit timing setting: oscillator tolerance and maximum bus length, reasonably arrange the location and number of sampling points in the bit cycle, ensure the effective synchronization of the bit stream on the bus, optimize the communication performance of the system, and further promote the application of the CAN bus.
[page]
Cygnal's 51 series MCU C8051F040 is a mixed signal system-level MCU integrated on a single chip. It integrates almost all analog, digital peripherals and other functional components required to form an intelligent node for MCU data acquisition or control, and represents the current development direction of 8-bit MCU control systems. The chip has a 12-bit multi-channel ADC, 2 12-bit DACs, 2 voltage comparators, 1 voltage reference, 1 32 kB Flash memory, a high-speed CIP-51 core fully compatible with the MCS-51 instruction set, a peak speed of up to 25 MI·s-1, and a hardware-implemented UART serial interface and a CAN controller that fully supports CAN2.0A and CAN2.0B. 3 Design of CAN multi
-point real-time data communication system
3.1 Hardware structure
of CAN multi-point real-time data communication system The designed CAN multi-point real-time data communication system consists of a computer and two development boards based on C8051F040 MCU. The structural block diagram is shown in Figure 2.
In this system, the computer is used as the host, connected to the CAN bus through a USB/CAN converter, and the software tool CANTools-V6.2 is used to send, receive and display data. The two CAN nodes in the system are development board 1 and development board 2. By compiling the corresponding program, the CAN node can send data to the host in real time. The host can send a control signal to the CAN node according to the received data to change the data sent back by the CAN node, so as to achieve the purpose of real-time communication control. At the same time, the two CAN nodes can also communicate with each other and display the received data on the LCD screen of the development board.
3.2 Software Design
The software design is divided into two parts: (1) the design of the main program. (2) the writing of the CAN communication library function program.
The main program mainly involves the program flow, including calling the initialization function, opening the interrupt, and writing the corresponding communication flow according to whether to communicate with the host or with other nodes by calling the CAN communication library function. The flow chart is shown in Figure 3.
The CAN communication library functions mainly include: system initialization function, CAN initialization function, CAN interrupt service function, CAN receive data function and CAN send data function.
Here we describe in detail the CAN communication library functions, CAN receive data function, CAN send data function and CAN interrupt service function.
[page]
The flow chart of CAN receiving data function and sending data function is shown in Figure 4.
The CAN interrupt service function program flow chart is shown in Figure 5.
4 Conclusion
The system can complete the real-time data transmission and reception between each node and between the node and the host, and basically complete the multi-point real-time data communication task. It can achieve fast speed, low delay, low error rate, high stability, and can intuitively see the experimental results on the computer. The oscilloscope measured that the system takes 10.8μs to complete a communication, which can meet the requirements of industrial real-time monitoring. This shows the possibility of CAN multi-point real-time data communication based on C8051F040, and because its multi-node device access is simple, it has a good prospect in remote industrial real-time monitoring. The disadvantage is that the number of nodes is not enough, the distance between nodes is not far enough, and the upper limit of the number of nodes for multi-point communication and the upper limit of the real-time communication distance have not been tested.
Previous article:Design of Laser Password Controller Based on AT89C51
Next article:Small resistance tester based on single chip microcomputer design
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- 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
- The college entrance examination is over, but we are still in the "high-school" mode
- 【Arduino】168 Sensor Series Experiments (211) --- WS2812B Ring 93 Light Module
- The dry goods in the jar are worth the quick surfing ANT series
- Matching of vivado version and modelsim version
- I have some questions about project handover (software) at work. I hope experienced seniors can give me some guidance.
- Learn about RF MEMS switches in one article
- CC2541 Bluetooth Learning-Clock Setting
- Dismantle ABC and CCB U-Shield
- How to view MSP430 technical data
- How to view the status of GPIO ports during CCS5.5 debugging