CAN (Controller Area Network) bus, or controller area network. Due to its high performance, high reliability and unique design, CAN bus is gaining more and more attention. Bosch of Germany originally designed CAN bus for automobile monitoring and control system. Now, its application has been developed in the fields of process industry, machinery industry, textile industry, agricultural machinery, robot, CNC machine tool, medical equipment and sensor. CAN bus has formed international standard and has been recognized as one of the most promising field buses. CAN bus specification has been formulated as international standard ISO11898 by International Organization for Standardization, and has been supported by many semiconductor device manufacturers, who have launched various products with integrated CAN protocol. Intelligent node of CAN bus system is the receiving and sending station of messages on the network, which is generally composed of single chip microcomputer and CAN controller or the combination of the two.
MCP2510 is an independent programmable CAN controller chip produced by Microchip. This paper will introduce the new independent CAN communication controller MCP2510 and give its application example in the intelligent node of CAN bus system.
1 Introduction to MCP2510 chip
MCP2510 is a CAN controller with SPI interface, DIP package is shown in Figure 1. It supports CAN technical specification V2.0A/B. It can send or receive standard and extended information frames, and has the functions of receiving filtering and information management. MCP2510 transmits data with MCU through SI interface, and the maximum data transmission rate can reach 5 Mbps. MCU can communicate with other MCU units on CAN bus through MCP2510. MCP2510 contains 3 sending buffers and 2 receiving buffers, and also has flexible interrupt management capabilities. These features make it very easy for MCU to operate CAN bus.
1.1 Main features of MCP2510
◇Support CANV2. OA/B;
◇With SPI interface, supporting SPI modes 0, 0 and 1, 1;
◇ Contains 3 transmit buffers and 2 receive buffers, and their priorities can be programmed;
◇With 6 receiving filters and 2 receiving filter shields;
◇Have flexible interrupt management capabilities;
◇Using low-power CMOS process technology, its operating voltage range is 3.0~5.5V, effective current is 5mA, and maintenance current is 10μA;
◇Working temperature range is -40~+125℃.
1.2 Structure and working principle
MCP2510 has three packaging forms: PDIP, SOIC and TSSOP. Figure 2 is the internal structure diagram of MCP2510. The CAN protocol machine is responsible for the interface with the CAN bus, the SPI interface logic is used to realize the communication with the MCU, and the register, buffer group and control logic are used to complete various settings and operation controls. Now, the functions and principles of each part are introduced in combination with its working process.
(1) Sending and receiving operations
The transmission operation of MCP2510 is realized through three transmission buffers. These three transmission buffers each occupy 14 bytes of SRAM. The first byte is the control register TXBNCTRL, which is used to set the conditions for information transmission and gives the transmission status of the information; the second to sixth bytes are used to store standard and extended identifiers and arbitration information; the last 8 bytes are used to store the data information to be sent. Before sending, these registers must be initialized. [page]
(2) Interrupt management
MCP2510 has 8 interrupt sources, including transmit interrupt, receive interrupt, error interrupt and bus wake-up interrupt. The interrupt enable register (CANINTE) and interrupt mask register (CANINTF) can be used to conveniently manage various interrupts. When an interrupt occurs, the INT pin becomes low and remains at a low level until the MCU clears the interrupt.
(3) Error detection
The CAN protocol has detection functions such as CRCF error, response error, form error, bit error and stuffing error. MCP2510 contains two error counters: receive error counter (REC) and transmit error counter (TEC). Therefore, for any node in the network, it is possible that it will be in one of the three states: error-activated, error-accepted and bus-disconnected due to different values of the error counters.
2 Application examples of MCP2510 in intelligent nodes
A CAN bus distributed measurement and control network can be constructed by using MCP2510 and CAN bus transceiver TJA1050. The system can include a main controller and multiple node controllers. Such node controllers can monitor the current, voltage and ambient temperature of the motor. Its structure is shown in Figure 3.
This network topology adopts bus structure and passive tap connection, and has simple structure and low cost, so the system reliability is high. Its information transmission adopts CAN communication protocol, and the communication medium adopts twisted pair. Since the CAN bus is based on the encoding of the sent message, the CAN control node is not encoded, so the system is more expandable, and adding or deleting the control node on the CAN bus will not have any impact on the other nodes of the system.
The MCU of the node controller can use a microprocessor with an SPI interface or a microprocessor without an SPI interface. This system uses a microprocessor AT89C51 without an SPI interface. AT89C51 can be directly connected to the SPI interface of the CAN controller through the P1 port, and the SPI interface protocol is implemented using a software algorithm. The CAN bus transceiver TJA1050 serves as the interface between MCP2510 and the physical bus. If the anti-interference ability of the system needs to be further improved, an optoelectronic isolator can be added between MCP2510 and TJA1050.
The circuit schematic diagram of the intelligent node is shown in Figure 4.
2.1 Software Design
Before the MCP2510 works properly, it needs to be initialized correctly, including setting the data transmission rate of the SPI interface, the baud rate of the CAN communication, the receiving filter and mask of the MCP2510, and the transmit and receive interrupt enable flags, etc. Unlike the SJA1000, the microcontroller must use the built-in read and write commands of the MCP2510 to operate the receive buffer and transmit buffer of the MCP2510 through the SPI interface. The read and write command timing diagrams are shown in Figures 5 and 6.
In this paper, MCP2510 mainly adopts interrupt mode to receive and send bus data. The whole system main sequence provides two kinds of interrupts: timer interrupt and external interrupt. The interrupt subroutine of timer interrupt is mainly responsible for processing A/D data from analog channels AIN0~AIN7, sending "data send request command" to MCP2510 and sending data. The interrupt processing subroutine of external interrupt mainly includes CAN bus error processing subroutine and data receiving subroutine.
2.2 Software design process
The main software design process is shown in Figure 7. The following issues need to be paid attention to when designing the software:
①Because MCP2510 is in the default Configuration mode after initialization, it is necessary to set it to Normal mode after initialization, otherwise MCP2510 will stay in Configuration mode and cannot work normally. Setting MCP2510 to Normal mode can be achieved by using the BitModify (bit modification) 4 instruction built into MCP2510 to write a 0 byte to the CANCTRL control word.
② Before performing any operation on MCP2510, the microprocessor must output a low level to the chip select CS of MCP2510 to enable MCP2510.
③ When executing the "read" operation of MCP2510, after sending the read instruction and its address code, it is still necessary to provide a clock to MCP2510 to receive the "read" data. This can be achieved by sending a 0 byte to MCP2510.
④ After completing any operation on MCP2510, there will be a delay for a period of time so that it has enough time to prepare to receive the command for the next operation to prevent the MCP2510 from being "busy".
3. Conclusion
CAN bus has been recognized as one of the most promising field buses. It is favored by more and more R&D personnel due to its outstanding advantages such as high cost performance and simple implementation. The intelligent node in this paper can connect multiple distributed control systems, and its software and hardware circuit design method is also suitable for the node design of other distributed control systems based on CAN bus.
Previous article:Wireless communication system based on MSP430 microcontroller and nRF905
Next article:Design Technology of Multiple Serial Ports in Single Chip Microcomputer System
Recommended ReadingLatest update time:2024-11-16 18:04
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
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!
- 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
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- 【Silicon Labs Development Kit Review 03】+IO/Uart Usage
- Even if we give the complete set of drawings, Chinese people still cannot build high-end lithography machines?
- System Verilog 1800-2012 Syntax Manual
- aos multithreading and mutex lock
- Now many circuits do not have watchdogs, but some watchdog circuits are necessary. I would like to ask in which applications,...
- Brief discussion: Electromagnetic compatibility (EMC) radio frequency electromagnetic field radiation immunity test plan
- How to improve the frequency accuracy of the resonant circuit?
- [FS-IR02 + D1CS-D54] - 3: Electrical performance index detection (D1CS-D54)
- RF application scenarios——Q value
- Last three days! Apply for the free Zhongke Yihai Micro-Shenzhen series FPGA development board EQ6HL45