
“With the development of the digital sonar system, the sonar array is getting bigger and bigger, and the system functions are becoming more and more complex. It has become an important topic in sonar design. The Ethernet transmission method used in the past is a timeout retransmission mechanism, and a single point of failure is easy to spread, causing the paralysis of the entire network system. CAN bus has become one of the most widely used field buses in the world because of its long transmission distance, fast speed and strong anti-electromagnetic interference capability.
“
Authors: Wang Dan, Hua Hongyan,
With the development of the digital sonar system, the sonar array is getting bigger and bigger, and the system functions are becoming more and more complex. It has become an important topic in sonar design. The Ethernet transmission method used in the past is a timeout retransmission mechanism, and a single point of failure is easy to spread, causing the paralysis of the entire network system. CAN bus has become one of the most widely used field buses in the world because of its long transmission distance, fast speed and strong anti-electromagnetic interference capability. CAN works in a multi-master mode, its nodes are divided into different priorities, non-destructive arbitration technology is adopted, and the message adopts a short frame structure, the data error rate is extremely low, and the node can automatically close the output in the case of serious errors. The system utilizes double-layer CAN bus to realize sonar data communication, which has outstanding reliability, real-time and flexibility.
1. Design principle
This data communication system needs to transmit and manage and control the data information of multi-area and multi-unit at the same time, so it adopts the idea of layering and sub-area to realize communication. The system adopts the single-chip intermediate controller as the core controller of each acquisition area to realize the data exchange between the upper and lower layers. The acquisition unit itself has a microcontroller and memory, which can be used as an important part of the system to participate in the realization of system functions, and can also be used as an independent unit to complete the data acquisition function. The data acquisition function can be realized independently, and data storage can be carried out, which improves the reliability of the system. The single-chip intermediate controller is a regional controller for data communication, providing dual interfaces for upper-layer network and lower-layer network communication. On the one hand, it communicates with each acquisition unit through the bottom network (Bot-CAN Bus) to realize the transmission and processing of data in this area; on the other hand, it communicates with the host computer through the upper layer network (Top-CAN Bus) to realize the Information collection and control of each collection area and collection unit. The principle block diagram of the system structure is shown in Figure 1.
2. System design
The system is mainly composed of host computer, single-chip intermediate controller PIC18F4580, CAN bus controller MCP2510, transceiver TJA1040T, high-speed optocoupler HCPL0600, and various acquisition units. The interface includes the CAN bus interface of the acquisition unit, the dual CAN bus interface of the single-chip intermediate controller and the CAN bus interface of the host computer. The CAN bus interface of the acquisition unit adopts the standard CAN bus interface. The upper computer adopts an industrial control computer, which can be connected to the CAN bus network through a CAN adapter card. The double-layer CAN bus interface circuit of the single-chip intermediate controller is the key to the system design, and its principle block diagram is shown in Figure 2.
2.1 Double-layer CAN bus interface circuit
The single-chip intermediate controller PIC18F4580 itself integrates a CAN controller, and this CAN bus communicates with each acquisition unit. In order to realize two independent CAN buses, it is necessary to expand one CAN controller through the SPI port of the single-chip microcomputer, and this CAN bus realizes the communication with the upper computer.
The external expansion CAN controller adopts the independent programmable CAN controller chip MCP2510 produced by MieroChip. MCP2510 is a CAN controller with SH interface. It supports CAN2.0A/B protocol and can send and receive standard and extended information. frame, and has the functions of receiving filtering and information management at the same time. MCP2510 carries out data transmission with PIC18F4580 through SPI interface, the highest data transmission rate can reach 5 MB/s, PIC18F4580 can communicate with other MCU units on CAN bus through MCP2510. MCP2510 contains 3 transmit buffers, two receive buffers, and also has flexible interrupt management capabilities. These features make the operation of the MCU on the CAN bus become flexible and simple. In order to improve the anti-interference ability of the system, a high-speed optocoupler HCPL0600 is added between the CAN controller and the CAN transceiver. The data transmission rate is 10 MB/s and the isolation voltage is 2 500 V. The CAN data transceiver uses the TJA1040T produced by Philips, which has the characteristics of low power consumption and good electromagnetic compatibility. Use MCP2510 to expand the interface circuit schematic diagram of CAN bus, as shown in Figure 3.
In Figure 3, the single-chip microcomputer only gives some pins to illustrate the specific design method. The RA5 pin of the microcontroller is used to output the chip select signal of MCP2510, the INT1 pin of the microcontroller is used as the interrupt input pin when a valid data packet is received, and the SPI ports SDO, SDI and SCK of the microcontroller and MCP251O are used to achieve data reception and transmission. In order to enhance the anti-interference ability of CAN bus nodes, TXCAN and RXCAN of MCP2510 are not directly connected to TXD and RXD of TJA1040, but are connected through high-speed optocoupler HCPL0600, which can realize electrical isolation between CAN nodes on the bus. In addition, a 120 Ω resistor is connected to both ends of the CAN bus, and its function is to match the bus impedance. Experiments have proved that ignoring the access of matching resistance will reduce the anti-interference and reliability of data communication, and even fail to realize data communication.
The communication between the single-chip microcomputer and each acquisition unit is realized by its own integrated CAN controller. It is only necessary to directly interface the high-speed optocoupler HCPL0600 with the CAN controller part of the PIC18F4580, and will not repeat them. In order to facilitate the system measurement and design, three LED indicator lights are set up to Display the CPU status and the operating status of the two-layer CAN bus network respectively.
2.2 Power Monitoring and Isolation Circuits
The power supply is the energy guarantee of the communication system, and the reliability and stability of the power supply circuit play a crucial role in the normal operation of the system. In order to minimize noise and interference, the two power supplies VCC and VDD used in the optocoupler part must be completely isolated, otherwise the optocoupler will be meaningless.
2.3 Software Design
The communication procedure mainly includes the node initialization procedure, the data sending procedure, the data receiving procedure and the CAN bus error processing procedure and so on. In order to facilitate transplantation and resource sharing, the system software design is implemented in C language, the software follows the modular design idea, and adopts a structured programming scheme to make it have good expansibility.
In the CAN communication process, the initialization includes setting the data transmission rate of the SPI interface, the baud rate of the CAN communication, the MCP2510’s receive filter and mask, and the send and receive interrupt enable flag bits, etc. The internal and external CAN controllers use interrupt mode when receiving data, and use query mode when sending data. Unlike the internal CAN controller, reading and writing the transmit and receive buffers of the MCP2510 must be implemented through the read and write commands of the SPI interface protocol. The write command is first sent to the SI pin of the MCP2510 and latches each data bit on the rising edge of SCK, then sends the address and data. After the instruction is executed, the data is written into the specified address unit, and then the send bit is set through the write command of the SPI interface protocol to start sending. During read operation, the read command and address are first sent to the SI pin of MCP2510, and each data bit is latched on the rising edge of SCK. At the same time, the data stored in this address unit is output to the SO pin on the falling edge of SCK. When performing read and write operations, the CS pin should always be held low. The flow chart of the external expansion CAN bus software design is shown in Figure 5.
3. System test
The CAN bus protocol has good error checking measures. When the hardware detects that the data has an error during transmission, it will automatically resend the data. When the error of a node is serious, the bus will automatically close the node without affecting the Data transfer from other nodes.
In order to verify the reliability of system data acquisition and communication, real-time simulation tests were carried out on the CAN bus host computer and each intermediate controller node, and the intermediate controller and each acquisition unit node respectively. The simulated communication medium adopts 100 m long shielded cable, and adopts various data frame structures. Carry out single-frame and multi-frame communication between the host computer and the node respectively. Judging from the display of the master control state, there is no data transmission error and data loss, the performance is stable, and the verification system has a certain reliability.
4 Conclusion
In this paper, combined with the application of CAN bus in the field of navigation, on the basis of studying the CAN bus technology and the function of PIC microcontroller, a sonar data transmission system based on double-layer CAN bus is designed. By combining the built-in CAN controller of PIC18F4580 and the external expansion CAN controller, this system takes the MCU intermediate controller with dual CAN bus interfaces as the core, and adopts the idea of grading and sub-regional combination to realize the collection of two-level and multi-region data information. . The system fully integrates the characteristics of CAN bus transmission distance, high transmission rate and strong anti-interference ability. Through experimental testing, the design scheme proposed in this paper is feasible and fully meets the requirements of high stability and high reliability of sonar data transmission system. The system is not only suitable for the collection of ship sonar data, but also can provide reference for the application of CAN bus in the aviation field.
The Links: AT070TN07-VC SKIIP38AC126V2 IGBT