Abstract: This paper introduces the design of a communication module of USB bus and CAN bus based on DSP CAN controller and USB chip, and proposes a scheme to connect CAN bus network with computer by using USB interface. By using USB100 chip, the computer RS 232 serial port can be upgraded to USB interface without knowing any USB protocol. Meanwhile, the CAN interface uses DSP on-chip CAN controller, and the hardware design is extremely simple. Under the control of DSP, PC and CAN node can communicate bidirectionally, the communication baud rate can be as high as 1 Mb/s, and the data transmission is stable and reliable. Experiments show that it is simpler and more practical to use TMS320F2812 on-chip eCAN module to construct CAN bus communication system.
Keywords: USB; CAN bus; eCAN; TMS320F2812
0 Introduction
With the rapid development of computer technology, the fully electronic computer interlocking control system consists of three layers of upper computer, interlocking machine and intelligent execution unit. The module introduced in this paper serves data communication in this context. CAN bus is the only field bus with international standards so far. Due to the adoption of many new technologies and unique designs, its data communication has outstanding reliability, real-time and flexibility compared with general communication buses. Its application scope is no longer limited to the original automotive industry, but has expanded to the mechanical industry including CNC machine tools, medical equipment, household appliances and other fields. The USB interface has the characteristics of fast speed, simple wiring and plug-and-play, which is a very good peripheral interface for communication with the host computer. Therefore, the research on data communication between CAN bus and PC based on USB interface has certain application significance.
1 System Structure
This system is mainly composed of modules such as USB interface and CAN interface. The microprocessor TMS320F2812 controls the overall situation and realizes the bidirectional communication function of transmitting CAN bus data to PC through USB interface and transmitting PC data to CAN node through USB interface. Traditional CAN bus communication module generally uses independent CAN controller chip. The microprocessor F2812 of this system has eCAN module on chip, which is more convenient to design. The following is a brief introduction to eCAN module.
The eCAN module is an enhanced CAN controller on the TMS320F2812 DSP chip. Its performance is much better than that of the existing DSP embedded CAN controller. The data transmission is more flexible and convenient, the data volume is larger, the reliability is higher, and the functions are more complete. The eCAN module is fully compatible with the CAN2.0B protocol and can use the above protocol to communicate serially with other controllers in an interference environment. In addition to all the functions of the general DSP embedded CAN controller, compared with the CAN module of the TMS320LF240x series DSP, it mainly has the following enhanced features: the number of mailboxes has been increased, up to 32; eCAN is a 32-bit advanced CAN controller; it has a time stamp; and it has a timeout function.
The above enhanced features make the transmission more convenient and flexible, the data volume is larger, and the functions are more complete when the TMS320F2812 performs CAN communication. Figure 1 is a system structure diagram.
2 System Hardware Design
2.1 Hardware Design of USB Module
The USB interface module of this system uses USB100 module as the main control chip. USB100 module is a USB general device interface chip with an 8-bit data bus interface, an internal send buffer of up to 384 B and a receive buffer of 128 B, and a data communication rate of up to 8 Mb/s. The read and write data of USB100 module are controlled by RD and WR2 pins respectively, which is equivalent to having two read and write addresses. Therefore, these two addresses are mapped to the area xzcs01 of F2812 peripheral interface, 0x2000 as the write address, and 0x4000 as the read address. Through the decoding of XA13, XA14, XZCS01, XWE, and XRD5 pins, the data transmission and reception of USB module can be easily controlled. The CPLD chip EPM7032 of Altera Company is selected as the decoding device, which can be used for in-system programming. The above five pins are used as the input pins of CPLD, and the two output pins of CPLD are connected to the RD and WR pins of USB100 module respectively. Since the USB100 module is powered by 5 V and F2812 is powered by 3.3 V, the 8-bit data bus is connected through the level conversion device 741vc4245, and the data direction is controlled by XR/W of F2812. According to the timing diagram of USB100 module, when F2812 detects that the TXE pin of USB100 module is low, it means that the internal sending buffer allows data to be sent to the USB port, and the data can be sent to the USB100 module through the eight-bit bus; when F2812 detects that the RXF of USB100 module is low, it means that there is data from the USB port in the internal sending buffer.
[page]
2.2 eCAN module application design
Since the TMS320F2812 on-chip enhanced controller eCAN is used, the CAN module hardware circuit is extremely simple. It only needs to connect the RX and TX pins of F2812 to the TXD and RXD pins of the CAN transceiver PCA82C250 through a level conversion device, and use F2812 as the microprocessor of the CAN bus system for real-time data transmission and reception. Its hardware system is divided into two layers: the first layer, the CAN bus and F2812 interface layer; the second layer, the information processing between F2812 and peripheral devices. The CAN transceiver uses the low-cost PCA82C250. The system has strong scalability and can connect at least 110 nodes. Its pin 8 (Rs) is used to select the working mode. When working at high speed, a slope resistor is connected to it. It can be adjusted appropriately according to the bus communication speed, generally between 16 and 140 Kb/s.
3 System software design
3.1 DSP program design
In this system, the microprocessor TMS320F2812 mainly completes two functions: one is to initialize the eCAN controller; the other is to complete the data communication between the host computer USB interface and the lower computer CAN interface. The USB interface communication completes the data exchange between the host computer and the microprocessor F2812 by querying the status of the TXE and RXF pins of USB100. The communication of the CAN interface mainly includes the message sending and receiving of the eCAN module.
After the F2812 is powered on and reset, the software must be initialized, and the most important thing is to initialize the eCAN module. When sending a message, it is necessary to initialize the sending mailbox, including enabling the corresponding mailbox to the register CANME, setting the CANMD direction, and setting the ID of the sending mailbox through MBOXn.MSGID (n=0~31). After initialization, write the data sent by the host computer USB interface to the message data register ECanaMboxes.Mboxn.MDR, and then set the EcanaRegs.CANTS.bit. When TRSn is 1, it requests to send a message, and waits for the transmission response bit TA=1, indicating that the message is successfully sent and a sending interrupt is generated. This system counts the number of sent messages through the sending interrupt subroutine. When receiving a message, it is also necessary to initialize the corresponding receiving mailbox. After completing the initialization, when the lower computer sends data through the CAN interface, if the ID of the receiving mailbox of the eCAN module matches the ID of the lower computer message and is successfully received, the corresponding bit of the corresponding receiving message suspension register (CANRMP) is set to 1; if the CPU opens the eCAN receiving interrupt, a receiving message interrupt is also generated at the same time. In the receiving interrupt subroutine, the content of the corresponding message data register can be sent to the write address of the USB100 module, and it is necessary to query whether the TXE end of USB100 allows data to be sent to the USB port.
The upper computer sends data through the USB interface, and the lower computer receives data through the CAN interface. The basic steps are as follows:
(1) F2812 initializes the general IO port and the eCAN controller;
(2) F2812 detects whether the USB module has data from the upper computer;
(3) If so, read the data into the configured eCAN send mailbox;
(4) Start the configured eCAN send mailbox;
(5) When the mailbox successfully sends a message to the lower computer, it will enter the eCAN send interrupt program;
(6) After clearing the corresponding flag, exit the interrupt program and continue waiting for the upper computer to send data.
The basic steps for the host computer to receive data through the USB interface and the slave computer to send data through the CAN interface are as follows:
(1) F2812 initializes the general IO port and the eCAN controller;
(2) When the slave computer sends data through the CAN interface, the configured eCAN receiving mailbox receives the data from the slave computer according to the mailbox identifier, and enters the eCAN receiving interrupt subroutine at the same time;
(3) F2812 detects whether the internal buffer of the USB module allows data to be sent to the host computer. If prohibited, it waits;
(4) If data is allowed to be sent to the host computer, the data is written to the host computer;
(5) After clearing the corresponding flag, the interrupt program is exited and the slave computer continues to send data. Figure 2 is the system software flow chart.
[page]
3.2 Upper computer software writing
NI's LABWINDOWS/CVI8.0 is used to design the upper computer control interface to realize the function of sending and receiving CAN bus system data through the PC.
Since the USB100 module virtualizes the USB interface into an RS 232 standard serial port, the task to be realized by the program is to call the serial port function under WINDOWS, so that the user can complete the sending and receiving of PC data under the CVI interface. The communication between the system and the PC is mainly achieved by calling the RS 232 function library provided in the LABWINDOWS/CVI function library. These functions are specifically implemented in the design driver. The main functions are: configure serial port function: int OpenComConfig(int COMPort, char deviceName[], long baudRate, int parity, int dataBits, int stopBits, int inputQueueSize, int outputQueueSize); write bytes to the specified port function: int ComWrt(int COMPort, char buffer[], int count); read bytes from the specified port function: int ComRd(int COMPort, char buffer[], int count); start the corresponding port function through the corresponding control on the PC, so that the data is sent through the USB interface.
4 Communication test
When testing the system, use the CAN debugger as a CAN node, and use the debugging software that comes with the debugger to display on the lower computer.
First, the upper computer sends data through the USB interface, and the lower computer receives data through the CAN interface. The CAN node is set to an extended frame, the frame format is a data frame, and the frame ID is 0x000000 82. The lower computer CAN debugging software receives data in hexadecimal. The characters '1', '2', '3', '4', and '5' are sent, and the lower computer receives the corresponding ASCII code values 0x31 to 0x35, which are displayed in hexadecimal.
Then, the lower computer sends data through the CAN interface, and the upper computer receives data through the USB port. The CAN node settings remain unchanged, and the data sent is 0x31 to 0x35, and the upper computer receives '1' to '5'. The specific test interface is shown in Figures 3 and 4.
5 Conclusion
A USB-CAN bus communication module is designed, in which the CAN controller uses the F2812 embedded eCAN module. In practical applications, this communication part can effectively and timely communicate with other nodes in the system, effectively combining the high-speed processing capability of DSP and the excellent characteristics of CAN bus. In addition, the hardware circuit design is simpler and more practical, and the C language programming is used to improve the maintainability of the program and greatly shorten the R&D cycle.
Previous article:Discussion on the Electromagnetic Compatibility of DSP
Next article:DDS Design Based on Improved CORDIC Algorithm
Recommended ReadingLatest update time:2024-11-16 18:09
- Popular Resources
- Popular amplifiers
- Virtualization Technology Practice Guide - High-efficiency and low-cost solutions for small and medium-sized enterprises (Wang Chunhai)
- Microcomputer Principles and Interface Technology 3rd Edition (Zhou Mingde, Zhang Xiaoxia, Lan Fangpeng)
- Virtual Instrument and LabVIEW Programming (Higher Vocational) (Edited by Chen Dong and Cui Xiuhua)
- The Art of Kali Linux Penetration (Lee Allen)
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
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
- [ESP32-Audio-Kit Audio Development Board] - 2: Installing "esp-idf-v3.3.5" on Windows 10
- How to realize forward and reverse pulses
- CC2640 Software Architecture
- Recruiting senior analysts in the electronics industry
- Qorvo's 5G Small Base Station
- EEWORLD University Hall----Live Replay: The Latest Isolation Devices Compliant with USB 2.0 Standards
- Sensor Basics and Common Terms
- Introduction to the basic knowledge of lithium batteries (PPT)
- EEWORLD University - Understanding PID Control (English subtitles)
- Live broadcast registration with prizes [Microchip Embedded Security Solutions | Automotive Network Security]