Transfer technology between CAN bus and USB

Transfer technology between CAN bus and USB

USB (Universal Serial Bus) is a universal serial bus. With the development and wide application of computer technology, people have put forward higher requirements on the serial bus. Therefore, it has become the common goal of many manufacturers to develop a low-speed and high-speed compatible technology to provide users with a serial bus that can be shared, expanded, and used conveniently.
The USB bus is a new-type, fast, bidirectional, synchronous transmission, and hot-swappable data transmission bus. It meets people's requirements for the bus's ease of use, strong expansion ability, and low cost. Therefore, USB is in PC peripherals The transmission rate in the field has increased from the low speed of 1.5Mbps and the full speed of 12 Mbps to the high-speed data transmission of 480 Mbps today. At present, the USB bus has gradually become the most widely used peripheral bus connection specification in the computer field.

At the same time, CAN (Controller Area Network) bus technology is also becoming more mature, with its long transmission distance, high transmission rate, strong anti-interference ability, easy networking, and cost savings, it has been recognized as one of the most promising field buses , And has received general attention in the field of control at home and abroad. At present, the in-vehicle control systems of Hyundai Motor Company and several other major automobile companies in Europe all use CAN bus, and many domestic industrial control systems (such as in-vehicle control systems, medical control systems, and intelligent control systems in many smart communities) Have adopted CAN bus technology. With the introduction of a more complete CAN2.0B protocol, foreign experts have predicted that the application life of the CAN bus will be at least 20 years.

Although the characteristics of the above two buses are more prominent, but the application of the two in the control field still has its own limitations. The transmission distance of USB is usually not more than tens of meters, and often fails to meet the requirements of industrial applications; and the connection between the CAN adapter and the host on the traditional interface is very cumbersome and complicated, which is not conducive to the expansion of CAN applications. Therefore, this design considers combining the CAN bus technology with a long transmission distance and the plug-and-play USB interface technology, that is, using the USB interface to easily realize the connection between the CAN bus and the host, thereby effectively expanding the monitoring and control of the CAN bus. Management function to expand the application range of CAN bus.

1 Overall design of the interface module

The overall block diagram of the USB-CAN transfer technology introduced in this article is shown in Figure 1. The design is divided into two parts: one is the USB control part connected to the host USB interface; the second is the CAN controller part connected to the CAN bus. The two are connected through a single chip microcomputer. The USB control part uses the USB interface control chip CH372 to achieve data reception and transmission; the CAN controller SJA1000 is used to implement data communication between CAN buses. The single chip microcomputer is used for corresponding control, coordination and system communication.

2 AT89C52 function in the system

The single-chip microcomputer AT89C52 mainly serves as a bridge and coordinated control in the system. The host sends the data to the single-chip microcomputer through CH372, and the single-chip microcomputer sends the data to the CAN bus through SJA1000, so as to realize the communication of the whole system. In addition, the one-chip computer also needs to initialize CH372 and SJA1000, and access CH372 and SJA1000 in multiplexed way through address / data. Because when accessing one of the chips, if the other chip still has an output, then the microcontroller cannot read the correct data. Therefore, the microcontroller must allocate the effective address through the chip selection control signal. The single chip microcomputer mainly monitors the communication of the system through the main loop, and its main loop flow chart is shown in Figure 2.

3 USB control part

The USB control part uses the USB interface control chip CH372 to realize data reception and transmission. CH372 is a universal device interface chip of USB bus. CH372 is on the MCU end, with 8-bit data bus and read, write, chip select control line and interrupt output, so it can be easily connected to the controller of MCU / DSP / MCU etc. On the system bus; in the computer system, the supporting software of CH372 provides a simple and easy-to-use operation interface. Therefore, communication with the local MCU is as simple as reading and writing files.

CH372 provides an application layer interface on the computer side. The application layer interface is an API for functional applications provided by the CH372 dynamic link library DLL. All APIs will return the operation status after being called, but may not have response data. The APIs provided by CH372 dynamic link library include: device management API, data transmission API, interrupt handling API, etc.

In the design of the application layer, the author adopts the method of request plus response. This method uses a downloading active request and an uploading passive response for interactive two-way data communication. The downloading and uploading have a one-to-one correspondence and are related to each other. The active request refers to the data request transmitted to the microcontroller by the computer application layer, and the passive response refers to the response data uploaded to the computer application layer after the microcontroller receives the data request. All communication is initiated by the computer application layer, and then ends with the response received from the microcontroller. The complete process includes the following steps:

(1) The computer application layer sends the data request to the CH372 chip in the format agreed in advance;

(2) The CH372 chip notifies the single-chip microcomputer by interrupt;

(3) The single-chip computer enters the interrupt service program to obtain the interrupt status of CH372 and analyze it;

(4) If it is an upload, release the current USB buffer and then exit the interrupt program;

(5) If it is a download, read the data block from the data download buffer;

(6) Analyze the received data block, prepare the response data, or exit the interrupt program before processing;

(7) The microcontroller writes the response data to the upload buffer of the batch endpoint, and then exits the interrupt program;

(8) The CH372 chip returns the response data to the computer;

(9) The computer application layer receives the response data.

On the MCU side, the CH372 chip occupies two address bits. When the A0 pin is high, the system selects the command port, and the command can be written at this time; when the A0 pin is low, the data port is selected, and can be read at this time. Write data. When the MCU reads and writes the CH372 chip through an 8-bit parallel port, all operations are composed of a command code, several input data, and several output data.

However, some commands do not require input data, and some commands may not output data.

CH372 chip is specially used to handle USB communication. After receiving the data or sending the data, CH372 will notify the microcontroller to process it in an interrupted manner. The flow chart of MCU receiving and sending data through CH372 is shown in Figure 3.

4 CAN controller part

The CAN controller SJA1000 can receive the signal on the CAN bus through the bus driver PCA82C250 and transmit it to the microcontroller, at the same time receive the signal from the microcontroller, and then transmit it to the CAN bus through the driver.

Because the address / data bus of SJA1000 and CH372 are shared, it should be distinguished by chip selection. During operation, the address latch pins ALE / AS can be connected to the ALE / P of the microcontroller, and the WR and RD pins can be connected to the WR and RD of the microcontroller, respectively. When the MODE pin is pulled high, the INTEL mode is selected. In application, the interrupt pin INT should be connected to INT1 of AT89C52, and external interrupt 1 should be connected. At the same time, the pull-up 10 kΩ resistor should be connected. Decoupling capacitors should be connected between the power supply and ground.

The TX0 and RX0 pins of the SJA1000 are connected to the TX and RX of the driver 82C250, respectively, and can be used to send and receive data to the CAN bus. At this time, you need to connect the RX1 pin to a stable level and ground RX1 in the system.

On the CAN bus side, the single-chip computer controls the transmission process. The initialization of SJA1000 is done by the single-chip microcomputer. The initialization flow chart is shown in Figure 4. In the normal working mode, the single-chip microcomputer can control the operation of SJA1000 to send and receive to complete the communication with the CAN bus. When data comes from the host, the MCU forwards the data to the send buffer of the SJA1000, and it is automatically encapsulated by the SJA1000 according to the CAN protocol and sent to the CAN bus; when the SJA1000 receives a valid message from the CAN bus, The system will generate a hardware interrupt signal (active low) on the INT pin. When the MCU receives the interrupt signal, it enters the interrupt service program to complete the data reception and processing. The interrupt service flow is shown in Figure 5.

5 Conclusion

The USB-CAN transfer system introduced in this article can achieve the desired goal. It can realize data transmission, thus providing a convenient and practical USB interface for the connection between CAN bus and PC.

Introduction

SCOTECH manufactures a full range of pad mounted distribution transformers, it consists of HV compartment, LV compartment and Transformer compartment, they are compact power system for utility, commercial and industrial applications. the Pad Mounted Transformer can be installed indoor or outdoor and designed to withstand most of the environments. it can also be designed specifically for the solar photovoltaic generator applications.

 

Scope of supply

Primary voltage up to 35KV

Rated power: up to 5MVA

 

Standards

SCOTECH`s pad mounted distribution transformers are designed and manufactured in accordance with all major international standards (IEC, ANSI, UL, etc.) 


Why SCOTECH

Long history- Focus on transformer manufacturing since 1934.

Technical support – 134 engineers stand by for you 24/7.

Manufacturing-advanced production and testing equipment, strict QA system.

Perfect service-The complete customer service package (from quotation to energization).


Pad Mounted Transformer

Pad Transformer,Pad Mounted Transformer,3 Phase Pad Mounted Transformer,Pad Mounted Distribution Transformer

Jiangshan Scotech Electrical Co.,Ltd , https://www.scotech.com