Share this

Design and Implementation of CAN-RS232 Communication Conversion Module

2026-04-06 02:15:59 · · #1
1. Introduction RS232, as a standard computer serial interface, has been widely used. Meanwhile, with the rapid development of fieldbus technology, CAN bus, with its advantages of good real-time performance, high reliability, and simple structure, is increasingly being adopted in measurement and control systems. However, due to the differences in bus structure, communication protocol, and transmission characteristics between the two, many inconveniences arise in connecting different devices. Therefore, how to achieve communication between CAN nodes and RS232 serial ports in the simplest way has become an unavoidable problem in engineering practice. This paper uses the AT89C51 microcontroller, which typically lacks CAN communication capabilities, as the microprocessor and designs a simple and practical communication conversion module. This communication conversion module features small size, simple structure, good versatility, and ease of use. 2. Working Principle The CAN-RS232 communication conversion module achieves its functions through hardware circuit level standard conversion and software programming communication protocol conversion. 2.1 Level Standard Conversion RS232 does not use the TTL level interface standard, but rather negative logic, meaning logic "1" is -3V to -15V; logic "0" is +3V to +15V. The CAN bus, however, uses two complementary logic values, "dominant" and "recessive," to represent "0" and "1," with signals appearing as differential voltages between the two lines. This leads to a voltage mismatch between the two buses, preventing direct communication. Therefore, appropriate hardware interface circuitry is needed to implement level standard conversion. 2.2 Communication Protocol Conversion RS232 communication is asynchronous serial communication, typically a two-point transmission. Each frame's data format is usually: start bit + data bits + parity bit (optional) + stop bit; each data packet's format is usually: data packet header + data byte + checksum (overflow ignored). CAN communication, on the other hand, is bus communication, allowing multiple nodes to exist simultaneously. Therefore, its communication protocol is relatively complex. Taking standard frame transmission as an example, its data format is typically as listed in Table 1. Therefore, software processing is needed to implement communication protocol conversion. 3 Hardware Design The module uses the AT89C51 microcontroller from Atmel as the microprocessor, the SJA1000 and TJA1050 as the CAN controller and driver respectively, and the MAX202E as the RS232 serial interface driver. The hardware connection circuit diagram is shown in Figure 1. The AT89C51 uses an external crystal oscillator for clock input and accesses the CAN controller SJA1000 via parallel address/data multiplexing. Pin P2.0 is used as the chip select port. The SJA1000, as the CAN controller, also uses a separate external clock input. Since it integrates the physical layer and data link layer functions of the CAN protocol, it can perform frame processing of communication data, and its address is 0x00~0xFF. The TJA1050 serves as the interface between the CAN controller and the physical bus, operating in high-speed mode to provide differential transmission capability for the bus and differential reception capability for the CAN controller. The MAX202E is used to implement the TTL level conversion from RS232 level to the microcontroller interface circuit. 4. Software Design The software design of the module mainly consists of two parts: an RS232 communication program and a CAN communication program, both using an interrupt-driven approach. The RS232 communication data transmission baud rate is 115,200 bit/s, with a data format of 1 start bit, 8 data bits, and 1 stop bit. The CAN bus transmission baud rate is 500 kbit/s, using the standard PeliCAN data frame format. Each message has an 11-bit identifier (ID) and 0-8 bytes of valid data. The software flow is shown in Figure 2. In the RS232 interrupt program, the microprocessor processes the received serial port data, extracts the data bytes, and generates a CAN message format by adding frame structure information, frame type, byte length, and identifiers. This message is then sent out by the CAN controller's transmit buffer. In the CAN interrupt program, the microprocessor parses the received valid CAN messages, extracts the byte length and byte content, and converts them into RS232 communication format by adding a data header, data trailer, and checksum, thus completing the data transmission. 5. Conclusion This design has been applied to a low-altitude infrared early warning system developed by the author. A CAN-RS232 communication conversion module converts the azimuth and elevation angles of aerial targets measured by angle sensors (angle measurement in 10 ms intervals, baud rate of 500 kbit/s) received from the CAN bus into RS232 (baud rate of 115,200 bit/s) serial port data in real time, enabling the main control computer (PC104 industrial computer) to receive, process, and display the data. Simultaneously, it converts the main control computer commands output from RS232 into CAN bus data. Practical experience has proven that this module is stable, reliable, and low-cost, fully meeting the system's performance requirements and achieving excellent application results.
Read next

CATDOLL Mimi Hard Silicone Head

The head made from hard silicone does not have a usable oral cavity. You can choose the skin tone, eye color, and wig, ...

Articles 2026-02-22