Abstract: This design is a data control system of the CAN bus based on the C8031F040 microcontroller with a CAN controller. Through the USB port, data transmission between two CAN nodes and the host computer is realized. The CAN node is a temperature acquisition system designed based on the C8051F040 microcontroller and can receive data from the host computer. The host computer software is an interface designed based on VB language to interact with the CAN node. It mainly realizes the functions of receiving temperature data and displaying it in real time through charts and sending data to the CAN node. This design is of great significance for studying and understanding the application of communication and control between CAN multi-nodes.
Keywords: CAN bus; CAN-USB; Design
0 Introduction
In the early 1980s, the German Bosch company proposed the CAN (Controller Area Network) bus, that is, the controller local area network solution to solve the communication problem between automotive control devices. After more than 20 years of development, CAN bus is now widely used in the automotive field. The application of CAN bus in automotive control systems can realize the software implementation of hardware solutions, greatly simplify the design, reduce hardware costs and design and production costs, and reduce data duplication. Data sharing reduces data processing and saves costs. It can reduce signal lines to a minimum, reduce wiring, and further reduce costs. Due to the high performance, high reliability, unique design and suitable price of CAN bus communication, it can be widely used in industrial field control, intelligent buildings, medical equipment, transportation and sensors. It is recognized as one of the most promising field buses.
1 System Overall Design
The overall structure of the CAN bus system is shown in Figure 1, which mainly includes host computer control software, USB-CAN conversion module, CAN node, and CAN bus medium (twisted pair cable is used here). One of the CAN nodes is connected to the PC through the USB interface. The host computer control software can display the data of each CAN node in real time and can send data to each CAN node through the host computer software to control the light or off of the 8 light-emitting diodes of each node.
2 System Hardware Circuit
This system consists of a microcontroller peripheral circuit, a CAN bus hardware circuit, and a USB-CAN conversion circuit. The microcontroller peripheral circuit includes a power supply circuit module, a reset circuit module, and a serial communication module. The CAN bus hardware circuit includes an electrical isolation module, an optical coupler isolation module, and a CAN driver circuit. The USB-CAN conversion circuit includes a CH375 and microcontroller interface circuit module and a USB interface circuit module.
The controller area network (CAN) controller inside the C8051F040 microcontroller is a protocol controller that does not provide a physical layer driver (i.e., a transceiver) and requires an external reconnection to the physical layer driver. TJ1050 is used here. TJA1050 is an interface between the controller area network (CAN) protocol controller and the physical bus and is a standard high-speed CAN transceiver. TJA1050 can provide differential transmission performance for the bus and differential reception performance for the CAN controller.
TJA1050 is the successor of the PCA82C250 and PCA82C251 high-speed CAN transceivers. Its functional block diagram is shown in Figure 2.
2.1 CAN bus anti-interference design
(1) Bus impedance matching Two 120 Ω resistors must be connected to the end of the CAN bus. They play an important role in bus impedance matching and cannot be omitted. Otherwise, the reliability and anti-interference of bus data communication will be greatly reduced, and it may even lead to communication failure.
(2) Two 30 pF small capacitors are connected in parallel between the CANH and CANI terminals of TJA1050 and the ground to filter out high-frequency interference on the bus and prevent electromagnetic radiation.
(3) A 5 Ω resistor is connected in series between the CANH and CANL terminals of TJA1050 and the CAN bus to limit the current and protect TJA1050 from overcurrent shock.
(4) A 100 nF decoupling capacitor is added between the power supply terminal and the ground of integrated circuits such as TJA1050 and TLP113 to reduce interference.
3 System software design
The system software design mainly includes the design of CAN communication program and CAN-USB conversion program. In addition, in order to collect the data of CAN nodes and send them to the host computer for display, a program for collecting the temperature sensor data inside the microcontroller is also added. The CAN communication program mainly completes the CAN data transmission of each node. It can send data to other nodes and receive data from other nodes to control the corresponding LED. The CAN-USB conversion program mainly completes the data transfer. It can receive data from the host computer and package it into data corresponding to the CAN protocol, and can send CAN protocol data to the host computer. The temperature sensor acquisition mainly converts the voltage on the internal thermistor through ADC0 and converts it into the actual temperature.
3.1 CAN communication program flow circle
As shown in Figure 3, the main program includes IO configuration, crystal oscillator initialization, clearing message RAM, sending and receiving function initialization and CAN initialization.
3.2 System interrupt handling program flow chart
The system interrupt handling program flow chart is shown in Figure 4. This program responds to the interrupt request sent by the CAN control and mainly completes the data reception work.
3.3 USB-CAN conversion program flow
All communications are initiated by the computer application layer and then end with the receipt of the response from the microcontroller. The detailed process of USB-CAN conversion is shown in Figure 5.
4 System and host computer interaction results
Figure 6 shows the running status of the host computer software during data collection. The two curves in the figure have a large rise and fall because the temperature rises when the fingers are placed on the microcontrollers of the two CAN nodes. When the fingers are released, the temperature gradually drops.
Click the setting button to make the window in the upper right corner effective. You can set the sampling time, which indicates how long it takes to send a data packet to the lower computer. The left side shows the current temperature value of each node in real time, and the curve on the right shows the temperature change. The figure also shows that 15 is sent to node 1 and 170 is sent to node 2.
5 Conclusion
This paper uses C8051HNO microcontroller as CAN controller, uses USB interface to communicate with the upper computer, realizes the function of CAN bus, and achieves the expected effect, reflecting the practicality of CAN bus. However, the USB interface chip can reach full speed mode, but this design does not reflect its fast transmission rate, which will be improved in future work.
Previous article:Design of campus self-guided tour device based on C51 single chip microcomputer
Next article:Software Implementation of Digital Filter in High Impact Signal Acquisition System
- 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!
- 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
- A simulation of a differential circuit, but the output waveform is distorted when the high and low levels of the square wave are converted
- Getting down to business - Understanding MLC machine learning of LSM6DSOX
- Design of UHF RFID reader/writer
- [NUCLEO-L552ZE Review] Expansion Board Finished Product
- A bunch of Smith charts PDF
- BLE Primer: Understanding BLE from the perspective of air data transmission and reception (Part 1)
- It took two years for a 19-year-old boy to build a 32-bit Risc-V processor using 230 pure 74 logic chips!
- Carrier-less pulse position modulation UWB communication system
- The combined application of FPGA technology in the field of automotive electronics;
- TI C6000 Data Storage Processing and Performance Optimization