[0055] Specific implementation plan
[0056] The present invention will be further described below in conjunction with the accompanying drawings, which does not limit the scope of protection.
[0057] A dual field bus interface converter is shown in Figure 1: The converter includes SoC microcontroller 9, CAN bus communication interface module 12, Profibus-DP bus communication interface module 7, serial communication interface module 11, and power conversion module 3. And bus selection switch module 8.
[0058] Among them: CAN bus communication interface module 12 is composed of CAN controller 10 embedded in SoC microcontroller 9, first optocoupler isolation circuit 2 and CAN bus transceiver 1; Profibus-DP bus communication interface module 7 is composed of SPC3 protocol controller 4. The second optocoupler isolation circuit 5 and the RS485 driver 6 are composed.
[0059] In this embodiment, as shown in Figure 1, one end of the CAN bus transceiver 1 is connected to the CAN bus network, and the other end of the CAN bus transceiver 1 passes through the first optocoupler isolation circuit 2 and the CAN controller 10 embedded in the SoC microcontroller 9 Connection; one end of the SPC3 protocol controller 4 is connected to the SoC microcontroller 9, the other end of the SPC3 protocol controller 4 is connected to the RS485 driver 6 through the second optocoupler isolation circuit 5, and the RS485 driver 6 is connected to the Profibus-DP bus network; The serial port field device or instrument 13 is connected to the SoC microcontroller 9 through the serial communication interface module 11, and the bus selection switch module 8 is connected to the SoC microcontroller 9. The power conversion module 3 is respectively connected with the SoC microcontroller 9, the CAN bus communication interface module 12, the Profibus-DP bus communication interface module 7 and the serial communication interface module 11.
[0060] The CAN bus communication interface module 12 of this embodiment is composed of the CAN controller 10 embedded in the SoC microcontroller 9, the first optocoupler isolation circuit 2 and the CAN bus transceiver 1. CAN bus communication interface module 12 such as figure 2 Shown: the receiving end RX1 and the transmitting end TX1 of the first optocoupler isolation circuit 2 are connected with the transmitting end CANTX and the receiving end CANRX corresponding to the CAN controller 10 embedded in the SoC microcontroller 9, and the first optocoupler isolation circuit 2 The receiving end RX2 and the transmitting end TX2 of the CAN bus transceiver 1 are connected to the corresponding transmitting end TX2 and the receiving end RX2, and the CAN bus transceiver 1 is connected to the CAN bus network. The 24V to 3.3V voltage output terminal VCC and ground terminal GND of the power conversion module 3 are connected to the corresponding working voltage input terminal VCC and ground terminal GND of the SoC microcontroller 9, and the 24V to 5V isolation voltage output of the power conversion module 3 Terminal VDD1 and ground terminal GND1 are connected to the working voltage input terminal VDD1 and ground terminal GND1 corresponding to the first optocoupler isolation circuit 2. The 24V to 5V isolation voltage output terminal VDD2 and ground terminal GND2 of the power conversion module 3 are respectively connected with The first optocoupler isolation circuit 2 is connected to the corresponding working voltage input terminal VDD2 of the CAN bus transceiver 1 and the ground terminal GND2.
[0061] The Profibus-DP bus communication interface module 7 of this embodiment is as image 3 Shown: It is composed of SPC3 protocol controller 4, second optocoupler isolation circuit 5 and RS485 driver 6. The data/address terminal DB[0...7], address terminal AB[0...7] and interrupt signal terminal INT0 of the SPC3 protocol controller 4 correspond to the data/address terminal P3[0 of the SoC microcontroller 9] …7], the address terminal P2[0…7] is connected with the interrupt signal terminal INT0/P0.2, the read signal terminal RD, the write signal terminal WR and the address latch signal terminal ALE of the SPC3 protocol controller 4 are connected to the SoC microcontroller 9 Corresponding read signal terminal RD/P0.6, write signal terminal WR/P0.7 and address latch signal terminal ALE/P0.5 are connected, the receiving terminal RXD, transmitting terminal TXD and sending enable of SPC3 protocol controller 4 The energy end RTS is connected to the transmitting end TXD, the receiving end RXD and the transmitting enable end RTS corresponding to the second optocoupler isolation circuit 5; the receiving end RXD1, the transmitting end TXD1 and the transmitting enable end RTS1 of the second optocoupler isolation circuit 5 The transmitting terminal TXD1, the receiving terminal RXD1 and the transmitting enable terminal RTS1 corresponding to the RS485 driver 6 are connected, and the RS485 driver 6 is connected with the Profibus-DP bus network. The 24V to 3.3V voltage output terminal VCC and ground terminal GND of the power conversion module 3 are connected to the corresponding working voltage input terminal VCC and ground terminal GND of the SoC microcontroller 9, and the 24V to 5V isolation voltage output of the power conversion module 3 Terminal VDD1 and ground terminal GND1 are respectively connected to the working voltage input terminal VDD1 and ground terminal GND1 corresponding to the SPC3 protocol controller 4 and the second optocoupler isolation circuit 5, and the 24V to 5V isolation voltage output terminal VDD3 of the power conversion module 3 , The ground terminal GND3 is connected to the working voltage input terminal VDD3 and the ground terminal GND3 of the second optocoupler isolation circuit 5 and the RS485 driver 6 respectively.
[0062] The serial communication interface module 11 of this embodiment is such as Figure 4 Shown: the receiving end RXD2, the sending end TXD2 and the sending enable end RTS2 of the serial communication interface module 11 correspond to the sending end TXD2/P0.0, the receiving end RXD2/P0.1 and the output end P0 of the SoC microcontroller 9 .3 Connection; the 24V to 3.3V voltage output terminal VCC and ground terminal GND of the power conversion module 3 are connected with the corresponding working voltage input terminal VCC and ground terminal GND of the SoC microcontroller 9, and the 24V conversion module 3 is connected The 5V voltage output terminal VDD1 and the ground terminal GND1 are connected to the corresponding working voltage input terminal VDD1 and the ground terminal GND1 of the serial communication interface module 11; the receiving terminal RXD3 and the transmitting terminal TXD3 of the serial communication interface module 11 are connected to the serial field device or instrument 13 Corresponding port connection.
[0063] The bus selection switch module 8 of this embodiment is such as Figure 5 As shown: the switch Key1, the switch Key2, and the reset switch Resrt of the bus selection switch module 8 are connected with the input terminal P1.0, the input terminal P1.1 and the reset terminal Resrt corresponding to the SoC microcontroller 9.
[0064] In this embodiment, the SoC microcontroller 9 uses the SoC microcontroller C8051F040 integrated with the CAN protocol controller. This SoC microcontroller has small size, low power consumption, fast processing speed, strong anti-interference ability, large storage space, and convenient JTAG online programming. The system upgrades and integrates functions such as watchdog and power management, which greatly reduces the complexity of hardware design and development costs.
[0065] In this embodiment, the SPC3 protocol controller 4 is a Profibus-DP protocol chip produced by Siemens.
[0066]The working principle of the field bus interface conversion in this embodiment is: CAN bus communication interface module 12 implements CAN bus protocol, Profibus-DP bus communication interface module 7 implements Profibus DP bus protocol, serial communication interface module 11 handles serial port protocol, SoC micro-processing The software in the device 9 realizes the protocol conversion between the serial interface and the CAN bus and Profibus-DP bus interface. The two switches Key1 and Key2 of the bus selection switch module 8 control the conversion of the three interfaces. For example: when CAN and Profibus-DP networks monitor serial devices at the same time, that is, when the bottom-level serial devices send data to the upper-level CAN and Profibus-DP networks, the switches Key1 and Key2 should be selected at the same time; when the master station only passes through the CAN network and the bottom-level serial ports When the device communicates in two directions, the switch Key1 should be selected; when the master station only communicates with the underlying serial device through the Profibus-DP network, the switch Key2 should be selected.
[0067] In this embodiment, the protocol conversion program between the serial interface and the CAN bus and Profibus-DP bus interface is stored in the SoC microcontroller 9. The program consists of a main program, a CAN interface interrupt service subroutine, and Profibus-DP The interface interrupt service subroutine and the serial port interrupt service subroutine are composed. among them:
[0068] The specific steps of the main program of the protocol conversion program between serial interface and CAN bus and Profibus-DP bus interface are:
[0069] Step S1-1, the main program starts, and step S1-2 is entered;
[0070] Step S1-2, configure the operating parameters of the converter, and proceed to step S1-3;
[0071] Step S1-3, initialize each communication module, configure the input and output buffer size of each module, and enter step S1-4;
[0072] Step S1-4, query whether the CAN interface has received data, if yes, go to step S1-5, if not, go directly to step S1-6;
[0073] Step S1-5, run the CAN interface interrupt service subroutine, and proceed to step S1-6 after the subroutine runs;
[0074] Step S1-6, query whether the Profibus-DP interface receives data, if yes, go to step S1-7, if not, go to step S1-8;
[0075] Step S1-7, run the Profibus-DP interface interrupt service subroutine, after the subroutine is run, proceed to step S1-8;
[0076] Step S1-8, query whether the serial port has received data, if yes, go to step S1-9, if not, go to step S1-4;
[0077] Step S1-9, run the serial port interrupt service subroutine, and enter step S1-4.
[0078] The specific steps of the CAN interface interrupt service subroutine of the protocol conversion program between the serial interface and the CAN bus and Profibus-DP bus interface are:
[0079] Step S2-1, the CAN interface interrupt service subroutine starts, and step S2-2 is entered;
[0080] Step S2-2, judge whether the switch Key1 of the bus selection switch module 8 is turned on, if it is turned on, go to step S2-3, if it is not turned on, end the CAN interface interrupt service subroutine;
[0081] Step S2-3, read the CAN bus interface data and write it into the first input buffer, then go to step S2-4;
[0082] In step S2-4, the data in the first input buffer is converted into a serial port protocol and then stored in the first output buffer, and then step S2-5 is entered;
[0083] In step S2-5, the data in the first output buffer is sent to the serial port, and the CAN interface interrupt service subroutine ends.
[0084] The specific steps of the Profibus-DP interface interrupt service subroutine of the protocol conversion program between the serial interface and the CAN bus and the Profibus-DP bus interface are:
[0085] Step S3-1, the Profibus-DP interface interrupt service subroutine starts, and step S3-2 is entered;
[0086] Step S3-2, judge whether the switch Key2 of the bus selection switch module 8 is turned on, if it is turned on, go to step S3-3, if it is not turned on, end the Profibus-DP interface interrupt service subroutine;
[0087] Step S3-3, read the Profibus-DP bus interface data and write it into the second input buffer, then go to step S3-4;
[0088] Step S3-4, the data in the second input buffer is converted into a serial port protocol and then stored in the second output buffer, and then step S3-5 is entered;
[0089] In step S3-5, the data in the second output buffer is sent to the serial port, and the Profibus-DP interface interrupt service subroutine ends.
[0090] The specific steps of the serial port interrupt service subroutine of the protocol conversion program between the serial interface and the CAN bus and Profibus-DP bus interface are:
[0091] Step S4-1, the serial port interrupt service subroutine starts, and step S4-2 is entered;
[0092] Step S4-2, judge whether the switch Key1 or Key2 of the bus selection switch module 8 is turned on, if one of the switches Key1 or Key2 is turned on, go to step S4-3, if neither is turned on, end the serial port interrupt service subroutine;
[0093] Step S4-3, read the serial port data and write it into the third input buffer, go to step S4-4;
[0094] Step S4-4, judge whether the switch Key1 of the bus selection switch module 8 is turned on, if it is turned on, go to step S4-5, and if it is not turned on, go to step S4-7;
[0095] Step S4-5, the data in the third input buffer is converted into the CAN bus protocol and then stored in the third output buffer, and then step S4-6 is entered;
[0096] Step S4-6, output the data of the third output buffer and send it to the CAN interface, and go to step S4-7;
[0097] Step S4-7, judge whether the switch Key2 of the bus selection switch module 8 is turned on, if it is turned on, go to step S4-8, if it is not turned on, end the serial port interrupt service subroutine;
[0098] Step S4-8, the data in the third input buffer is converted into the Profibus-DP bus protocol and then stored in the fourth output buffer, and then step S4-9 is entered;
[0099] Step S4-9, the data in the fourth output buffer is sent to the Profibus-DP interface, and the serial port interrupt service subroutine ends.
[0100] This specific implementation method effectively solves the conversion from a common serial interface to multiple field buses, realizes the monitoring and management and resource sharing of the same serial device by two field bus networks, and achieves the purpose of heterogeneous network interconnection. It has strong flexibility and functions. Complete features. In addition, this specific implementation selects the SoC microcontroller C8051F040 with small size, low power consumption, fast processing speed, and integrated CAN protocol controller, so that the dual field bus interface converter has low hardware complexity and small size.