Aiming at some limiting factors of CAN bus in field application and the problems existing in CAN bus networking control of hydraulic support electro-hydraulic control system in coal mine, this paper proposes a single-line CAN bus isolation repeater based on STMicroelectronics STM32 microcontroller. The characteristics of dual bxCAN controller integrated in STM32F105 series microcontroller and single-line CAN transceiver of Freescale MC33879 are fully utilized to form a soft repeater. Practice has proved that this design effectively solves the problems of multi-point power supply, network scale limitation and electromagnetic compatibility, and has great significance for improving the safety and efficiency of coal mine automation production.
CAN bus is a multi-master serial communication bus with excellent stability, real-time performance, remote communication capability and super hardware CRC error correction. The application of CAN bus technology is no longer limited to the automotive industry, but has expanded to energy, manufacturing and other industries, and is recognized as one of the most promising field buses. Therefore, CAN bus has been increasingly used in various systems in coal mines. Due to the limitation of CAN transceiver, the communication distance of CAN bus and the number of nodes in the network are limited to 10 km and 110 nodes respectively. However, in the coal mine field equipment system with many nodes, long distance and complex power supply system, CAN bus repeater is needed to expand the CAN bus network.
CAN repeater is one of the key technical equipment for system networking. The use of repeater can increase the number of nodes and communication distance of the network, and can connect two CAN bus networks with different baud rates, greatly expanding its scope of use. In view of this, a single-line CAN bus isolation repeater based on STM32 is designed, and it will be applied to the hydraulic support electro-hydraulic control system to realize the communication between hydraulic supports and between hydraulic supports and upper computer monitoring system.
1 Overall system solution
There are generally two design methods for CAN bus repeater: one is to use hard relay mode, that is, only the combination of gate circuits and some discrete devices is used to design the circuit, but the forwarding efficiency is not high; the other is to use soft relay mode, that is, the CPU is used to receive and forward the data on both sides of the CAN bus. Although the structure of this scheme is complex, the forwarding efficiency is high. The data on both sides are received by the CPU and then forwarded to the other side. In addition to the program filtering and self-diagnosis functions, the soft repeater can also realize the connection of network segments with different speeds to meet the actual application requirements; therefore, this design adopts the soft relay method.
2 Hardware Design
2.1 Main Control Circuit Design
The hardware circuit of the repeater designed for the harsh industrial environment of coal mines must not only be stable and reliable, but also have low power consumption. The CPU of the repeater adopts the STM32F105 series microcontroller based on the Cortex-M3 core of ST. The STM32F105 series is specially designed for fast and simple programming and can be used for highly integrated and low-power industrial applications. The operating frequency of the STM32F105 series can reach 72 MHz, and the power consumption is much lower than that of microcontrollers with the same performance. In addition, it also has a 128KB on-chip FLASH program memory with in-system programming (ISP), which brings great flexibility for operations such as data storage and firmware upgrades. The STM32F105 series integrates two independent CAN controllers, which simplifies the hardware circuit design of the repeater; the acceptance filter of its CAN controller has a fast hardware search algorithm, supports a large number of CAN identifiers, and allows clear definition and group definition of 11-bit and 29-bit CAN identifiers, simplifying the software design and operation burden of the system.
2.2 Communication circuit design
The CAN bus interface circuit is shown in Figure 2. The CAN transceiver in the figure uses the single-line CAN transceiver MC33897. It is a single-bus CAN bus transceiver chip launched by Freescale for a ground loop, mainly used in multi-channel transmission applications. It provides a single-line physical interface for data transmission between CAN bus controllers, that is, compared with traditional CAN bus transceivers, it only needs one signal line to complete CAN bus communication, which saves communication costs for mutual communication between nodes and facilitates system installation and subsequent maintenance. In addition, the CAN bus interface and the CPU are isolated by dual-channel magnetic coupling ADuM1201. Compared with high-speed optical coupling, magnetic coupling has small delay and low power consumption. This design method solves the problem of different brackets using different power supplies and signals with different grounds, and improves the anti-interference ability.
3 Software Design
3.1 Initialization Subroutine
The initialization of the CAN controller of STM32 is directly related to whether the CAN controller can work properly. The initialization of the CAN controller of STM32 mainly includes the initialization of the CAN basic unit and the filter. Because ST has launched a set of firmware libraries for STM32, it is only necessary to make corresponding settings at the beginning of the program. The key link in this initialization subroutine is to set the baud rate of CAN. The baud rate calculation formula in the STM32 data sheet is as follows:
where tq=(BRP[9:0]+1)xtPCLK. As in the above CAN unit initialization subroutine: tBS1=tq×(TS1[3:0]+1), tBS2=tqx(TS2[2:0]+1), BRP[9:0], TS1[3:0] and TS2[2:0] are all set in the CAN_BTR register, and the CAN clock of STM32 is provided by APB1. Assuming the system clock is 72 MHz, APB1 is the 9-frequency division of the system clock, combined with the initialization subroutine, BRP[9:0]=0, TS1[3:0]=7, TS2[2:0]=6, and the baud rate can be calculated by substituting it into the baud rate calculation formula to obtain a baud rate of 500Kb/s. In this repeater, the filter of the CAN controller is set to work in the mask bit mode, and any bit of the identifier is processed according to the principle of must match or don't care. In the repeater, since it is necessary to forward the data on all buses, the filter does not need to be set in detail, and it only needs to be set to receive data with any ID number.
3.2 Data forwarding subroutine
The task of the repeater is essentially to realize the forwarding of messages. The STM32F105 integrates a dual bxCAN controller, which includes 3 sending mailboxes and 2 3-level deep FIFOs. Combined with the characteristics of the STM32 F105, a dual FIFO forwarding mechanism is adopted, and its principle is shown in Figure 3. According to Figure 3, when the STM32F105 receives a new message, it is processed by the data processing module and, under the management of the data forwarding process, the receive FIFO buffers of the two bxCAN controllers are monitored. If one buffer is not empty, it is forwarded to the other.
The process of sending a message by STM32F105 is as follows: the application selects an empty sending mailbox; sets the identifier, data length and data to be sent; then sets the TXRQ position of the CAN_TIxR register to 1 to request sending. After the TXRQ position is set to 1, the mailbox is no longer an empty mailbox; once the mailbox is no longer empty, the software no longer has write permission to the mailbox register. After the TXRQ position is set to 1, the mailbox immediately enters the registered state and waits to become the highest priority mailbox. Once the mailbox becomes the highest priority mailbox, its state changes to the scheduled sending state. When the CAN bus enters the idle state, the message in the scheduled sending mailbox is immediately sent. After the message in the mailbox is successfully sent, it immediately becomes an empty mailbox; the hardware correspondingly sets the RQCP and TXOK positions of the CAN_TSR register to 1, indicating a successful transmission.
In order to improve the real-time data transmission of the repeater, the reception of CAN messages adopts the interrupt mode. Therefore, during the CAN initialization process, the CAN1 and CAN2 peripheral interrupts should be enabled, and their corresponding interrupt vector tables and corresponding interrupt levels should be set. The data receiving module process is shown in Figure 4.
In addition, assuming that the total time for data sent from point A on the CAN bus is t, the shortest time for the data to be received at point B on the other side of the soft repeater is t. When the bus rate is not large and the timing requirements for each bus device are not high, this time can be ignored. However, in CAN bus systems where data is frequently exchanged between some nodes, attention must be paid to this issue and its impact on the system must be minimized as much as possible.
4 Conclusion
The CAN bus repeater makes full use of the internal integrated dual bxCAN controller to simplify the design of the hardware circuit, and the rich firmware library functions shorten the development cycle. Practice shows that the single-line CAN bus isolation repeater has completed various design indicators, meets the requirements of the project, and can effectively complete data forwarding and network expansion in the hydraulic support electro-hydraulic control system, and has high practical value.
Previous article:Hardware circuit connection diagram and software program design based on STM32 processor
Next article:Design of closed-loop tension control system based on STM32
Recommended ReadingLatest update time:2024-11-15 15:35
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- EEWORLD University Hall----Computer Organization and Design: RISC-V (Zhejiang University)
- TMS320F28335 ADC Explanation
- The domestic operating system RT-Thread seems to be more powerful and can enter the automotive field
- Use of resolver decoding chip AD2S1200
- GaN goes mobile?
- Is there any MEMS or sensor expert?
- Leakage current and withstand voltage test of low voltage battery products
- MSP430 Registers
- BMS insulation detection circuit
- i.MX6ULL Embedded Linux Development 1-Preliminary Study on Uboot Transplantation