Design of CAN/LIN Gateway Based on AT89C51 MCU

Publisher:PositiveVibesLatest update time:2011-05-27 Keywords:AT89C51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Introduction

Fieldbus technology has been widely used in industrial control, especially CAN (Control Area Network) bus, which has the advantages of high reliability, low cost and easy implementation, and occupies a large share in the actual engineering application of fieldbus. With the development of bus technology, LIN (Local Interconnect Network) bus is a low-cost serial communication network, whose goal is to provide auxiliary functions for the existing fieldbus control network, especially the bus application in the automobile control network. Therefore, there must be a LIN bus and other bus communication interface implementation. Taking CAN bus as an example, this paper proposes a CAN-LIN gateway design based on AT89C51CC03 single-chip microcomputer.

LIN is a low-cost serial communication network used to control distributed electronic systems in automobiles. The goal of LIN is to provide auxiliary functions for existing automobile networks (such as CAN bus). Therefore, LIN bus is an auxiliary bus network. In situations where CAN bus bandwidth and multi-function are not required, such as communication between smart sensors and brake devices, using LIN bus can greatly save costs. LIN communication is based on SCI (UART) data format, using single master controller/multiple slave device mode, using only one 12V signal bus and a node synchronization clock line without a fixed time reference.

Gateway Hardware Design

The entire gateway module includes six submodules: LIN interface, CAN interface, CAN baud rate setting, LIN baud rate setting, power module, and status light (Figure 1). Figure 1 System structure block diagram

AT89C51CC03 is an 8-bit microcontroller with built-in CAN controller from Atmel. This design is based on the AT89C51CC03 microcontroller, selects TJA1020 as the LIN bus transceiver, uses the microcontroller UART interface, and selects PCA82C250 as the CAN bus transceiver in the CAN module design part. The specific circuit connection is shown in Figure 2, Figure 3, and Figure 4. Figure 2 Microcontroller circuit Figure 3 CAN interface circuit Figure 4 LIN interface circuit





We designed a 5-bit DIP switch in the circuit. Since the LIN bus and CAN bus transmission are different in different working systems, the software needs to be changed. Therefore, a 5-bit DIP switch is used for baud rate setting in this design, three bits for LIN baud rate setting, and two bits for CAN baud rate setting. At the same time, in order to show the working status of the gateway, a working indicator light is specially designed. It flashes at a certain frequency when receiving and sending signals. When a fault occurs, the two lights are lit at the same time.

To enhance the anti-interference capability of CAN nodes, the TXDC and RXDC pins of the microcontroller are not directly connected to the TXD and RXD pins of the PCA82C250AT, but are connected through the high-speed optocoupler 6N137 (Figure 3). This achieves good 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 optocouplers will lose its meaning.

Gateway software design

The gateway software design mainly includes the main control program module, CAN module software design and LIN module software design. The CAN module software design mainly has three sub-functions, one is CAN initialization CAN_INIT(), and the other two are CAN_RE_ISR() and CAN_SEND(). CAN_INIT() is mainly used to set the CAN communication baud rate and CAN basic settings. The baud rate can be set according to the value of the dip switch. After the system is powered on, it will automatically scan through the self-test program, check the pre-set baud rate table, and set the CAN communication baud rate.

CAN_RE_ISR() is responsible for information reception and processing, and CAN_SEND() is responsible for information sending.

The LIN module software design mainly includes several files: LIN.H, LIN.C, TEMR0.H TEMRO.C, where LIN.H and LIN.C respectively implement LIN specification settings, UART baud rate settings, and LIN information reception and transmission, and TEMR0.H TEMRO.C is used to generate the LIN bus baud rate. The main control program design mainly completes the entire gateway information forwarding function. When a CAN receive interrupt occurs, the LIN send flag is set to prepare to forward the CAN information to the LIN network; similarly, when a LIN receive interrupt occurs, the CAN send flag is set to prepare to send LIN information to the CAN network. [page]

The entire software is written in C51 and debugged using KEIL's simulation software. Finally, the complete program is burned into the AT89C51CC01 flash space.

Conclusion

This paper proposes a CAN-LIN gateway design based on AT89C51CC01 single-chip microcomputer, which solves the problem of information transmission between CAN bus control network and LIN bus control network in field bus control, and provides a basis for flexible application of field bus. This design has been tested on site, and the experimental results show that the gateway runs well, works reliably and stably, and has been applied to actual work.

Keywords:AT89C51 Reference address:Design of CAN/LIN Gateway Based on AT89C51 MCU

Previous article:Design of multifunctional electronic password lock based on AT89S51
Next article:Wireless identification device system based on 51 single chip microcomputer

Recommended ReadingLatest update time:2024-11-16 17:37

Freescale S12 series CAN initialization summary and sharing
CAN initialization process: 1. Check whether it has entered the initialization state. If not, it enters the initialization state. Here, the CANCTL0 and CANCTL1 registers need to be set. 2. Set the CAN baud rate. Here you need to set the CANBTR0 and CANBTR1 registers. For the specific calculation process, please r
[Microcontroller]
Freescale S12 series CAN initialization summary and sharing
CAN filter content using STM8 as an example
IntroductionIn the CAN protocol, the identifier of the message does not represent the address of the node, but is related to the content of the message. Therefore, the sender sends the message to all receivers in the form of broadcast. When receiving the message, the node determines whether the software needs the mess
[Microcontroller]
Mercedes-Benz CAN FD embedded controller development hardware design and application trends
CAN FD is a remote network communication control method  with reliable performance, complete functions and reasonable cost. MCUs , core boards, industrial control boards and Internet of Things solutions integrating CAN/CAN FD controllers have been widely used in various control systems . For example , various fields
[Automotive Electronics]
Mercedes-Benz CAN FD embedded controller development hardware design and application trends
Using PIC18F458 CAN module to realize CAN bus communication
  CAN (Controller Area Network) is a network mainly used for monitoring and controlling various equipment . CAN has a unique design concept, good functional characteristics, high reliability, and strong anti-interference ability on site. It has been widely used in the field of industrial control at home and abroad and
[Microcontroller]
Using PIC18F458 CAN module to realize CAN bus communication
Distillation CAN bus control system based on LABVIEW and OPC technology
Introduction For the sewage treatment process based on the activated sludge method, the addition of coagulants is a key issue in the process of treating sewage with high concentration of organic matter. The amount of coagulants directly affects the final water treatment effect and the operating cost of the sewa
[Industrial Control]
Distillation CAN bus control system based on LABVIEW and OPC technology
Design of agricultural environment temperature monitoring system based on AT89C51 microcontroller and DS18B20
Modern facility agriculture is a high-tech, high-efficiency modern agricultural production method that integrates biotechnology, engineering technology, and environmental technology. It is an effective way to adjust the agricultural industry, adapt to the development of market economy and improve the utilization rate
[Microcontroller]
Design of agricultural environment temperature monitoring system based on AT89C51 microcontroller and DS18B20
Design of CAN/PCI Intelligent Communication Card Based on ARM Controller LPC2294
introduction LPC2294 is a powerful, ultra-low power 32-bit microcontroller with ARM7TDMI core launched by PHILIPS . It has rich on-chip resources and can fully meet the needs of general industrial control. At the same time, it can also reduce the complexity of system hardware design and improve system st
[Industrial Control]
Design of CAN/PCI Intelligent Communication Card Based on ARM Controller LPC2294
Design of Multi-channel CAN Bus Interface and Driver Based on AT91RM9200
introduction   In the railway system, in order to ensure the safe operation of trains, it is necessary to conduct real-time detection of the rails and surrounding conditions. The current method is to install multiple detection devices along the railway to detect natural disasters such as floods, strong winds, mudslide
[Microcontroller]
Design of Multi-channel CAN Bus Interface and Driver Based on AT91RM9200
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号