Share this

Design of a CAN-LIN Gateway Based on AT89C51CC01 Microcontroller

2026-04-06 05:41:20 · · #1
Introduction Fieldbus technology has been widely applied in industrial control, especially CAN (Controller Area Network), which has a significant share in practical fieldbus engineering applications due to its high reliability, low cost, and ease of implementation. With the development of bus technology, LIN (Local Interconnect Network), as a low-cost serial communication network, aims to provide auxiliary functions for existing fieldbus control networks, particularly in automotive control networks. Therefore, a communication interface between a LIN bus and other buses is necessary. This paper takes the CAN bus as an example and proposes a CAN-LIN gateway design scheme based on the AT89C51CC03 microcontroller. LIN is a low-cost serial communication network used to implement distributed electronic system control in automobiles. LIN aims to provide auxiliary functions for existing automotive networks (such as the CAN bus). Therefore, the LIN bus is an auxiliary bus network. In situations where the bandwidth and multifunctionality of the CAN bus are not required, such as communication between intelligent sensors and braking devices, using the LIN bus can significantly save costs. LIN communication is based on the SCI (UART) data format, adopts a single master controller/multiple slave device mode, and uses only a single 12V signal bus and a node synchronization clock line without a fixed time base. Gateway Hardware Design The entire gateway module includes six sub-modules: LIN interface, CAN interface, CAN baud rate setting, LIN baud rate setting, power supply module, and status lights (Figure 1). [align=center]Figure 1 System Structure Diagram[/align] The AT89C51CC03 is an 8-bit microcontroller from Atmel with an embedded CAN controller. This design uses the AT89C51CC03 microcontroller as the basis, selects the TJA1020 as the LIN bus transceiver, and uses the microcontroller's UART interface. In the CAN module design, the PCA82C250 is selected as the CAN bus transceiver. The specific circuit connections are shown in Figures 2, 3, and 4. [align=center]Figure 2 Microcontroller Circuit Diagram 3 CAN Interface Circuit Diagram 4 LIN Interface Circuit[/align] In this circuit, we designed a 5-bit DIP switch. Since the transmission methods of the LIN bus and CAN bus differ in different operating systems, software modifications are necessary. Therefore, in this design, a 5-bit DIP switch is used for baud rate setting: three bits for LIN baud rate setting and two bits for CAN baud rate setting. To demonstrate the gateway's operating status, indicator lights are designed, flashing at specific frequencies when receiving and transmitting signals. When a fault occurs, both lights illuminate simultaneously. To enhance the anti-interference capability of the CAN node, the microcontroller's TXDC and RXDC pins are not directly connected to the PCA82C250A's TXD and RXD pins, but rather connected via a high-speed optocoupler 6N137 (Figure 3). This effectively achieves electrical isolation between nodes on the bus. The two power supplies VCC and VDD used in the optocoupler circuit must be completely isolated; otherwise, the use of an optocoupler would be meaningless. Gateway Software Design The gateway software design mainly includes the main control program module, the CAN module software design, and the LIN module software design. The CAN module software design mainly has three sub-functions: CAN_INIT() for CAN initialization, and CAN_RE_ISR() and CAN_SEND(). CAN_INIT() mainly sets the CAN communication baud rate and basic CAN settings. The baud rate can be set according to the DIP switch value. After the system powers on, the self-test program automatically scans and looks up the pre-set baud rate table to set the CAN communication baud rate. CAN_RE_ISR() is responsible for receiving and processing information, and CAN_SEND() is responsible for sending information. The LIN module software design mainly includes several files: LIN.H, LIN.C, TEMR0.H, and TEMRO.C. LIN.H and LIN.C respectively implement the LIN specification settings, UART baud rate settings, and LIN information reception and transmission. TEMR0.H and TEMRO.C are used to generate the LIN bus baud rate. The main control program is designed to handle the information forwarding function of the entire gateway. When a CAN receive interrupt occurs, the LIN transmit flag is set, preparing to forward CAN information to the LIN network; similarly, when a LIN receive interrupt occurs, the CAN transmit flag is set, preparing to send LIN information to the CAN network. The entire software is written in C51 and debugged using KEIL's simulation software. Finally, the complete program is burned into the flash space of the AT89C51CC01. Conclusion This paper proposes a CAN-LIN gateway design based on the AT89C51CC01 microcontroller, solving the information transmission problem between the CAN bus control network and the LIN bus control network in fieldbus control, providing a foundation for the flexible application of fieldbus. This design has been tested in the field, and the experimental results show that the gateway operates well, is reliable and stable, and has been applied in practical work. References: 1. TJA1020 LIN Transceiver Manual, Guangdong Zhouligong Development Co., Ltd. 2. LIN Protocol Implementation on the AT89C51CC03, Atmel Corporation, 4189B-AUTO-04/05
Read next

CATDOLL Bebe 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