Design and Implementation of CAN-RS232 Communication Conversion Module

Design and Implementation of CAN-RS232 Communication Conversion Module

Abstract: A CAN node and RS232 serial communication conversion module with simple structure, convenient use and wide application is designed. The working principle and implementation method of the module are introduced in detail, that is, the level standard and the communication protocol are converted through the combination of software and hardware to complete the information transmission between the two.

1 Introduction RS232 has been widely used as a standard computer serial interface. At the same time, with the rapid development of field bus technology, the CAN bus with the advantages of good real-time, high reliability and simple structure is also becoming more and more popular in measurement and control systems. Has been adopted more and more. However, due to the different bus structures, communication protocols and transmission characteristics of the two, it brings a lot of inconvenience to the connection between different devices. Therefore, how to implement the communication between the CAN node and the RS232 serial port in the simplest way becomes An unavoidable problem in engineering practice.
In this paper, a typical AT89C51 microcontroller without CAN communication capability is used as a microprocessor, and a simple and practical communication conversion module is designed. The communication conversion module has the characteristics of small size, simple structure, good versatility and convenient use.

2 Working principle The CAN-RS232 communication conversion module realizes related functions through the standard conversion of the hardware circuit and the communication protocol conversion of the software programming.
2.1 Level standard conversion RS232 uses not TTL level interface standard, but negative logic, that is, logic "1" is -3 V--15 V: logic "0" is +3 V-+15 V; and CAN The bus uses "dominant" and "recessive" two complementary logical values ​​to represent "0" and "1", and its signal appears in the form of "differential" voltage between the two lines. This results in a signal voltage mismatch between the two buses. Normal communication cannot be performed directly, therefore. Corresponding hardware interface circuits are needed to achieve the level standard conversion.

2.2 Communication protocol conversion RS232 communication belongs to asynchronous serial communication. Generally, the data format of each frame for two-point transmission is usually: start bit + data bit + parity bit (can be omitted) + stop bit; The format is usually: packet header + data byte + checksum (overflow is not counted). CAN communication belongs to bus communication, and multiple nodes can exist at the same time, so the communication protocol is relatively complicated. Here, the standard frame transmission is used as an example. The data format is usually listed in Table 1. Therefore, software processing is required to realize the conversion of the communication protocol.
can message standard frame format

3 hardware design The module adopts AT89C51 single-chip microcomputer produced by Atmel as the microprocessor. Adopt SJA1000 and TJA1050 as CAN controller and driver respectively. Using MAX202E as the RS232 serial interface driver, its hardware connection circuit diagram is shown in Figure 1.
can-rs232 conversion hardware circuit diagram
AT89C51 uses external crystal oscillator to provide clock input. Access CAN controller SJA1000 through parallel address / data multiplexing. P2.0 pin as chip select port; SJA1000 as CAN controller, also uses a separate external clock input, due to the integration of CAN protocol physical layer and data link layer functions, can complete the frame processing of communication data, its address 0x00-0xFF: TJA1050 serves as the interface between the CAN controller and the physical bus. Adopt high-speed working mode to provide the differential transmission capability of the bus and the differential reception capability of the CAN controller; MAX202E is used to realize the TTL level conversion of the RS232 level to the microcontroller interface circuit.

4 software design The software design of the module mainly includes RS232 communication procedure and CAN communication procedure two parts, adopt the interrupting way. Among them, the baud rate of RS232 communication data transmission is 115200 bit / s, the data format is 1 start bit, 8 data bits, 1 stop bit; the transmission baud rate of the CAN bus is 500 kbit / s, using PeliCAN Standard data frame format of the model. The identifier ID of each message is 11 bits, and the valid data is 0-8 bytes. The software flow is shown in Figure 2.

In the RS232 interrupt program, the microprocessor processes the received serial data to extract the data bytes, and generates the CAN message format by adding frame structure information, frame type, byte length and identifier. Then sent by the send buffer of the CAN controller;
In the CAN interrupt program. The microprocessor analyzes the received valid CAN message, extracts the byte length and byte content, and converts it to RS232 communication format by adding the data header, data tail and checksum to complete the data transmission.

5 Conclusion This design has been applied to a certain type of low-altitude infrared early warning system developed by the author. Use the CAN-RS232 communication conversion module to convert the azimuth and high-low angle of the air target measured by the angle sensor received by the CAN bus (a group of angle measurements of 10 ms, baud rate of 500 kbifs) into RS232 (baud rate of 115200) in real time bit / s) Serial port data, which enables the main control computer (PC104 industrial control computer) to receive, process and display; at the same time, the main control computer command output by RS232 is converted into CAN bus data. It has been proved by practice that the module works stably, reliably, and at low cost, and can fully meet the system's index requirements. Has achieved good application results

LED Party Bulb

Using patented modular design with thermal separation and thermal equilibrium, greatly improve the life time of the product.

No UV rays, environment friendly, high impact and shock resistance.
Prismatic shell designed, RGB power switch to White, Flashing RGB Dynamic light.
Automatically rotating, having the stage lighting effect.
Wide application to bars, disco, ballroom, KTV, home decoration, stage, club, party, etc.

Colorful light and white light two model switching mode switching time<1s.

Energy-saving, Efficiency> 92lm/W, Efficient driver >87%.


LED Party Bulb

LED Party Bulb,LED Dancing Bulb,LED Party Light,LED Party Dimming Bulb

Shenzhen Superlight Technology Co., Ltd. , https://www.superlighttech.com