Optocoupler fault detection circuit, method and communication system
By designing an optocouple fault detection circuit in the communication system, generating signals using the sampling module and judging the optocouple fault through the slave MCU, the problem of low optical coupling fault detection efficiency in the existing system is solved, and fast and effective fault detection is achieved.
Patent Information
- Application Number
- CN202110815587.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-19
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2041-07-19
AI Technical Summary
There is a lack of detection solutions for abnormal optocoupler devices in existing communication systems, which leads to the inability to detect optocoupler faults in time and low detection efficiency.
An optical coupling fault detection circuit is designed, by setting a sampling module between the host MCU and the slave MCU, a first sampling signal and a second sampling signal are generated, and a slave MCU is judged whether the first and second optocouples have a fault.
It realizes rapid detection of optocoupler faults in the communication system, improves the system's fault detection efficiency, and can promptly identify abnormal situations of optocoupler devices.
Smart Images

Figure CN113433485B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electronic power technology, and in particular to an optocoupler fault detection circuit, method and communication system. Background Art
[0002] There are many existing communication systems, including the UART (Universal Asynchronous Receiver / Transmitter) communication system, which is a universal serial data bus system used for asynchronous communication. In this system, the bus communicates bidirectionally and can achieve full-duplex transmission and reception. Figure 1 The structure diagram of the existing UART communication system is as follows: Figure 1 As shown in the figure, the UART communication system is a communication circuit that relies on two optocouplers to build a signal output and return. Generally, communication failures are detected by detecting whether the input and output signals are correct, whether there are any missing signals, whether the communication methods match, etc. However, sometimes communication failures are not caused by signal problems, but may occur in optocouplers. Optocouplers are easily damaged or abnormal due to the operating environment of the unit or some static electricity. If the optocoupler is abnormal, it will affect the normal output of the signal. However, in the existing communication system, there is no detection solution for optocoupler abnormalities, and the existing single optocoupler fault detection method is time-consuming and has low detection efficiency.
[0003] There is no detection scheme for abnormal optocoupler devices in the prior art communication system, resulting in the problem that optocoupler faults cannot be detected in time, and no effective solution has been proposed yet. Summary of the invention
[0004] An optocoupler fault detection circuit, method and communication system are provided in the embodiments of the present invention to solve the problem that there is no detection scheme for the abnormality of the optocoupler device in the prior art, resulting in that the optocoupler fault cannot be detected in time.
[0005] In order to solve the above technical problems, the present invention provides an optocoupler fault detection circuit, the optocoupler fault detection circuit comprising:
[0006] A sampling module is provided between a host MCU and a slave MCU, and is used to generate a first sampling signal based on a signal sent by a transmitting end of the host MCU, and to generate a second sampling signal based on a signal received by a receiving end of the host MCU, and to send the first sampling signal and the second sampling signal to the slave MCU; wherein the host MCU and the slave MCU perform signal transmission via a first optical coupler and a second optical coupler;
[0007] The slave MCU is used to determine whether the first optocoupler fails based on the first sampling signal and the signal received by the receiving end of the slave MCU; and to determine whether the second optocoupler fails based on the signal sent by the sending end of the slave MCU and the second sampling signal; wherein the signal received by the receiving end of the slave MCU is a signal generated by the signal sent by the sending end of the host MCU after passing through the first optocoupler, and the signal sent by the sending end of the slave MCU is transmitted to the receiving end of the host MCU via the second optocoupler.
[0008] Furthermore, the sampling module has a first interface connected to the transmitting end of the host MCU; a second interface connected to the receiving end of the host MCU; a third interface connected to the first feedback interface of the slave MCU and conducted with the first interface, and a fourth interface connected to the second feedback interface of the slave MCU and conducted with the second interface.
[0009] Furthermore, the sampling module comprises:
[0010] a first sampling unit, arranged between the transmitting end of the host MCU and the first feedback interface, for generating the first sampling signal according to the signal sent by the transmitting end of the host MCU, and outputting the first sampling signal to the first feedback interface of the slave MCU;
[0011] The second sampling unit is arranged between the receiving end of the host MCU and the second feedback interface, and is used to generate the second sampling signal according to the signal received by the receiving end of the host MCU, and output it to the second feedback interface of the slave MCU.
[0012] Furthermore, the slave MCU is specifically used for:
[0013] When the first sampling signal is a high-level signal and the signal received by the receiving end of the slave MCU is a high-level signal, it is determined that the first optical coupler has not failed;
[0014] When the first sampling signal is a high-level signal and the signal received by the receiving end of the slave MCU is a low-level signal, it is determined that the first optical coupler fails.
[0015] Furthermore, the slave MCU is also specifically used for:
[0016] When the signal sent by the sending end of the slave MCU is a high-level signal and the second sampling signal is a high-level signal, it is determined that the second optical coupler has not failed;
[0017] When the signal sent by the sending end of the slave MCU is a high-level signal and the second sampling signal is a low-level signal, it is determined that the second optical coupler fails.
[0018] Furthermore, the first sampling unit includes:
[0019] A first comparator has a non-inverting input terminal connected to the transmitting terminal of the host MCU, an inverting input terminal connected to its own output terminal, and an output terminal connected to the first feedback interface of the slave MCU.
[0020] Furthermore, the first sampling unit further includes:
[0021] A first capacitor has a first end connected to the non-inverting input end of the first comparator and a second end connected to ground, and is used to maintain the voltage of the non-inverting input end of the first comparator.
[0022] Furthermore, the second sampling unit includes:
[0023] The second comparator has a non-inverting input terminal connected to the receiving terminal of the host MCU, an inverting input terminal connected to its own output terminal, and an output terminal connected to the second feedback interface of the slave MCU.
[0024] Furthermore, the second sampling unit further includes:
[0025] A second capacitor has a first end connected to the non-inverting input terminal of the second comparator and a second end grounded, and is used to maintain the voltage of the non-inverting input terminal of the second comparator.
[0026] The present invention also provides a communication system, comprising a host MCU, a slave MCU, a first optical coupler and a second optical coupler, and also comprising the above-mentioned optical coupler fault detection circuit.
[0027] The present invention also provides an optocoupler fault detection method, which is applied to the above-mentioned optocoupler fault detection circuit. The optocoupler fault detection method includes:
[0028] Acquire a first sampling signal and a second sampling signal; wherein the first sampling signal is generated based on a signal sent by a transmitting end of the host MCU, and the second sampling signal is generated based on a signal received by a receiving end of the host MCU;
[0029] Determine whether the first optocoupler fails based on the first sampling signal and the signal received by the receiving end of the slave MCU; and / or determine whether the second optocoupler fails based on the signal sent by the sending end of the slave MCU and the second sampling signal; wherein the signal received by the receiving end of the slave MCU is a signal generated by the signal sent by the sending end of the host MCU after passing through the first optocoupler, and the signal sent by the sending end of the slave MCU is transmitted to the receiving end of the host MCU via the second optocoupler.
[0030] Further, judging whether the first optical coupler fails according to the first sampling signal and a signal received by the receiving end of the slave MCU includes:
[0031] If the first sampling signal is a high-level signal, and the signal received by the receiving end of the slave MCU is a high-level signal, it is determined that the first optical coupler is not faulty;
[0032] If the first sampling signal is a high-level signal, and the signal received by the receiving end of the slave MCU is a low-level signal, it is determined that the first optical coupler fails.
[0033] Further, judging whether the second optical coupler fails according to the signal sent by the sending end of the slave MCU and the second sampling signal includes:
[0034] If the signal sent by the sending end of the slave MCU is a high-level signal, and the second sampling signal is a high-level signal, it is determined that the second optical coupler is not faulty;
[0035] If the signal sent by the sending end of the slave MCU is a high-level signal, and the second sampling signal is a low-level signal, it is determined that the second optical coupler fails.
[0036] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the above-mentioned optocoupler fault detection method is implemented.
[0037] By applying the technical solution of the present invention, a sampling module is used to collect a signal sent by a transmitting end of a host MCU and generate a first sampling signal, a signal received by a receiving end of the host MCU is collected and a second sampling signal is generated, and the slave MCU is used to determine whether a first optocoupler fails based on the first sampling signal and a signal received by the receiving end of the slave MCU; and, based on a signal sent by a transmitting end of the slave MCU and the second sampling signal, it is determined whether a second optocoupler fails, thereby realizing rapid detection of an optocoupler fault in a communication system and improving the fault detection efficiency of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 It is a structural diagram of the existing UART communication system;
[0039] Figure 2 is a structural diagram of an optocoupler fault detection circuit according to an embodiment of the present invention;
[0040] Figure 3 is a structural diagram of a sampling module according to an embodiment of the present invention;
[0041] Figure 4 4 is a flow chart of an optocoupler fault detection method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0042] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0043] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings, and "multiple" generally includes at least two.
[0044] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0045] It should be understood that although the terms first, second, etc. may be used to describe the communication subjects in the embodiments of the present invention, these communication subjects should not be limited to these terms. These terms are only used to distinguish different communication subjects. For example, without departing from the scope of the embodiments of the present invention, the host MCU may also be referred to as the slave MCU, and similarly, the slave MCU may also be referred to as the host MCU.
[0046] As used herein, the words "if" and "if" may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.
[0047] It should also be noted that the term "includes", "comprising" or any other variation thereof is intended to cover non-exclusive inclusion, so that a commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprising a ..." do not exclude the existence of other identical elements in the commodity or device including the elements.
[0048] The optional embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0049] Example 1
[0050] This embodiment provides an optocoupler fault detection circuit. The following takes the application in a UART communication system as an example to explain this embodiment in detail. Figure 1 As shown in, the UART communication system includes a host MCU, a slave MCU, a first optocoupler D1 and a second optocoupler D2. The host MCU sends a signal to the slave MCU through the first optocoupler, and the slave MCU sends a signal to the host MCU through the second optocoupler. The first resistor R1, the second resistor R2 and the third resistor R3 are current limiting resistors. VCC is the communication power supply voltage at the slave end, and UART VCC is the communication power supply voltage at the host end. The host MCU includes a transmitting end TXD1 and a receiving end RXD2, and the slave MCU includes a transmitting end TXD2 and a receiving end RXD1. The communication signal is transmitted from TXD1 to RXD1, or, from TXD2 to RXD2.
[0051] like Figure 1 As shown, the anode of the diode in the first optocoupler D1 is connected to the host-side communication power supply voltage UART VCC through the first resistor R1, and the cathode is connected to the transmitting end TXD1 of the host MCU. The first end of the phototransistor in the first optocoupler D1 is connected to the slave-side communication power supply voltage VCC through the second resistor R2, and the second end is grounded; the diode in the second optocoupler D2 is connected to the slave-side communication power supply voltage VCC, and the cathode is connected to the transmitting end TXD2 of the slave MCU. The receiving end RXD1 of the slave MCU is also connected between the second resistor R2 and the first end of the phototransistor in the first optocoupler D1. The line between the first end of the phototransistor in the second optocoupler D2 and the receiving end RXD2 of the host MCU is also connected to the host-side communication power supply voltage UART VCC. The second end of the phototransistor in the second optocoupler D2 is grounded, and the third end of the phototransistor in the second optocoupler D2 is a photosensitive surface, which is used to generate an electromotive force based on the light signal emitted by the diode in the second optocoupler D2, thereby controlling the first end and the second end of the phototransistor in the second optocoupler D2 to be turned on.
[0052] Figure 2 is a structural diagram of an optocoupler fault detection circuit according to an embodiment of the present invention, as shown in Figure 2 As shown, the optocoupler fault detection circuit includes:
[0053] A sampling module, arranged between the host MCU and the slave MCU, for generating a first sampling signal based on a signal sent by a transmitting end of the host MCU, and generating a second sampling signal based on a signal received by a receiving end of the host MCU, and sending the first sampling signal and the second sampling signal to the slave MCU;
[0054] The slave MCU is used to determine whether the first optocoupler fails based on the first sampling signal and the signal received by the receiving end of the slave MCU; and to determine whether the second optocoupler fails based on the signal sent by the sending end of the slave MCU and the second sampling signal; wherein the signal received by the receiving end of the slave MCU is a signal generated by the signal sent by the sending end of the host MCU through the first optocoupler, and the signal sent by the sending end of the slave MCU is transmitted to the receiving end of the host MCU via the second optocoupler.
[0055] The optocoupler fault detection circuit of the present embodiment collects the signal sent by the transmitting terminal TXD1 of the host MCU through the sampling module to generate a first sampling signal, collects the signal received by the receiving terminal RXD2 of the host MCU to generate a second sampling signal, and determines whether the first optocoupler D1 is faulty according to the first sampling signal and the signal received by the receiving terminal RXD1 of the slave MCU by the slave MCU; and determines whether the second optocoupler D2 is faulty according to the signal sent by the transmitting terminal TXD2 of the slave MCU and the second sampling signal, which can realize rapid detection of optocoupler faults in the communication system and improve the fault detection efficiency of the system.
[0056] The first interface 1 of the sampling module is connected to the transmitting end TXD1 of the host MCU; the second interface 2 is connected to the receiving end of the host MCU; the third interface 3 is connected to the first feedback interface of the slave MCU and is connected to the first interface 1, and the fourth interface is connected to the second feedback interface of the slave MCU and is connected to the second interface 2;
[0057] The slave MCU is used to determine whether the first optocoupler D1 is faulty based on the signal sent by the transmitting end TXD1 of the host MCU and the signal received by the receiving end RXD1 of the slave MCU; and to determine whether the second optocoupler D2 is faulty based on the signal sent by the transmitting end TXD2 of the slave MCU and the signal received by the receiving end RXD2 of the host MCU.
[0058] Example 2
[0059] This embodiment provides another optocoupler fault detection circuit. Figure 3 is a structural diagram of a sampling module according to an embodiment of the present invention, such as Figure 3As shown, the sampling module 10 includes: a first sampling unit 101, which is arranged between the transmitting end TXD1 of the host MCU and the first feedback interface 5 of the slave MCU, and is used to generate a first sampling signal according to the signal sent by the transmitting end TXD1 of the host MCU, and output it to the first feedback interface 5 of the slave MCU; a second sampling unit 102, which is arranged between the receiving end RXD2 of the host MCU and the second feedback interface of the slave MCU, and is used to generate a second sampling signal according to the signal received by the receiving end RXD2 of the host MCU, and output it to the second feedback interface 6 of the slave MCU.
[0060] When the signal sent by the slave MCU at the transmitting end TXD1 of the host MCU is a high-level signal, so that the first sampling signal fed back to the first feedback interface 5 is a high-level signal, and the signal received by the receiving end RXD1 of the slave MCU is a high-level signal, it is determined that the first optocoupler D1 is not faulty; when the signal sent by the transmitting end TXD1 of the host MCU is a high-level signal, so that the first sampling signal fed back to the first feedback interface 5 is a high-level signal, and the signal received by the receiving end RXD1 of the slave MCU is a low-level signal, it is determined that the first optocoupler D1 is faulty.
[0061] The slave MCU also determines that the second optocoupler D2 is not faulty when the signal sent by the sending end TXD2 of the slave MCU is a high-level signal, so that the second sampling signal fed back to the second feedback interface 6 is a high-level signal, and the signal received by the receiving end RXD2 of the host MCU is a high-level signal; the second optocoupler D2 is determined to be faulty when the signal sent by the sending end TXD2 of the slave MCU is a high-level signal, so that the second sampling signal fed back to the second feedback interface 6 is a high-level signal, and the signal received by the receiving end RXD2 of the host MCU is a low-level signal.
[0062] In order to realize the generation of the first sampling signal according to the signal sent by the transmitting end TXD1 of the host MCU, as shown in FIG. Figure 3 As shown, the first sampling unit 101 includes: a first comparator A1, whose in-phase input terminal +IN1 is connected to the transmitting terminal TXD1 of the host MCU, whose inverting input terminal -IN1 is connected to its own output terminal OUT1, and whose output terminal OUT1 is connected to the first feedback interface 5 of the slave MCU.
[0063] After the signal sent by the transmitting end TXD1 of the host MCU changes from a high level to a low level, in order to ensure the sampling accuracy, the first sampling signal needs to maintain a high level for a period of time. Therefore, the first sampling unit 101 also includes: a first capacitor C1, a first end of which is connected to the non-inverting input terminal +IN1 of the first comparator A1, and a second end of which is grounded, for maintaining the voltage of the non-inverting input terminal +IN1 of the first comparator A1, and after the signal sent by the transmitting end TXD1 of the host MCU changes from a high level to a low level, the voltage of the non-inverting input terminal +IN1 of the first comparator A1 is kept high, thereby maintaining the first sampling signal at a high level.
[0064] Similarly, in order to generate a second sampling signal according to the signal received by the receiving terminal RXD2 of the host MCU, the second sampling unit 102 includes: a second comparator A2, whose in-phase input terminal +IN2 is connected to the receiving terminal RXD2 of the host MCU, whose in-phase input terminal -IN2 is connected to its own output terminal OUT2, and whose output terminal OUT2 is connected to the second feedback interface 6 of the slave MCU.
[0065] After the signal received at the receiving end RXD2 of the host MCU changes from a high level to a low level, in order to ensure the sampling accuracy, the second sampling signal needs to maintain a high level for a period of time. Therefore, the second sampling unit 102 also includes: a second capacitor C2, a first end of which is connected to the non-inverting input terminal of the second comparator A2, and a second end of which is grounded, for maintaining the voltage of the non-inverting input terminal +IN2 of the second comparator A2. After the signal received at the receiving end RXD2 of the host MCU changes from a high level to a low level, the voltage of the non-inverting input terminal +IN2 of the second comparator A2 is kept high, thereby maintaining the second sampling signal at a high level.
[0066] Specifically, Figure 3As shown, the sampling module 10 is a dual operational amplifier integrated chip, which contains two operational amplifier circuits and 8 pins, namely, 5V input voltage pin, OUT2, -IN2, +IN2, OUT1, -IN1, +IN1, GND. +IN2 collects the signal received by the receiving end RXD2 of the host MCU, and +IN1 collects the signal sent by the transmitting end TXD1 of the host MCU. The periphery of the operational amplifier device is built in a voltage following state. The high-level signal output by the transmitting end TXD1 of the host MCU is input from +IN1 and input to the in-phase input end of the first comparator A1, and the first capacitor C1 is charged at the same time. The high-level signal outputs the high-level signal through the first comparator A1 to the first feedback interface 5 of the slave MCU; when +IN2 inputs a high level, the second capacitor C2 is charged at the same time, and the high-level signal is output by the second comparator A2 to the second feedback interface 6 of the slave MCU. When the signal collected by +IN1 changes from a high level to a low level, the first capacitor C1 is discharged, and the first comparator A1 continues to output a high level for a period of time. Similarly, when the signal collected by +IN2 changes from a high level to a low level, the second capacitor C2 is discharged, and the second comparator A2 continues to output a high level for a period of time, thereby improving the sampling accuracy of detecting the high level.
[0067] The principle when the optocoupler is normal is as follows:
[0068] When the host MCU's transmitting end TXD1 sends a high-level signal, both electrodes of the diode in the first optocoupler D1 are high-level, the diode is cut off and does not emit light, the phototransistor at the back end of the first optocoupler D1 is cut off and does not conduct, and the RXD1 end is directly connected to the slave communication power supply voltage VCC, which is high-level, realizing signal input and output. Conversely, when the host MCU's transmitting end TXD1 sends a low-level signal, the anode of the diode in the first optocoupler D1 is high-level, the cathode is low-level, the diode is turned on and emits light, the phototransistor at the back end of the first optocoupler D1 is turned on, and RXD1 is pulled down to the ground network to present a low level, realizing signal input and output.
[0069] When the receiving end RXD2 of the host MCU is a high-level signal, it indicates that the phototransistor in the second optocoupler D2 is not turned on, and further indicates that the diode in the second optocoupler D2 is not emitting light, and further indicates that the sending end TXD2 of the slave MCU is at a high level, and the signal input and output are realized. Conversely, when the receiving end RXD2 of the host MCU is a low-level signal, it indicates that the phototransistor in the second optocoupler D2 is turned on, and further indicates that the diode in the second optocoupler D2 is turned on, and further indicates that the sending end TXD2 of the slave MCU is at a low level, and the signal input and output are realized.
[0070] From the above principle analysis, it can be seen that when the transmitting end TXD1 of the host MCU sends a high-level signal, if the RXD1 end is also at a high level, it indicates that the first optocoupler D1 is not faulty. Conversely, when the transmitting end TXD1 of the host MCU sends a high-level signal, if the RXD1 end is also at a low level, it indicates that the first optocoupler D1 is not faulty; when the receiving end RXD2 of the host MCU is a high-level signal, if the transmitting end TXD2 of the slave MCU is also at a high level, it indicates that the second optocoupler D2 is not faulty. When the receiving end RXD2 of the host MCU is a high-level signal, if the transmitting end TXD2 of the slave MCU is at a low level, it indicates that the second optocoupler D2 is faulty.
[0071] Table 1 below is the correspondence between signals of different interfaces and abnormal conditions:
[0072] Table 1 Correspondence between signals of different interfaces and abnormal conditions
[0073]
[0074] Note: “1” represents high level, and “0” represents low level.
[0075] As shown in the above table, when the signals of the first feedback interface 5, the transmitting end TXD2 of the slave MCU, and the second feedback interface 6 are all high, and the signal sent by the transmitting end TXD1 of the host MCU is low, it indicates that the first optocoupler is abnormal and the second optocoupler is normal; when the signals sent by the first feedback interface 5, the second feedback interface 6, and the transmitting end TXD1 of the host MCU are all high, and the transmitting end TXD2 of the slave MCU is low, it indicates that the second optocoupler is abnormal and the first optocoupler is normal; when the signals of the first feedback interface 5, the transmitting end TXD2 of the slave MCU, the second feedback interface 6, and the transmitting end TXD1 of the host MCU are all high, it indicates that the first optocoupler and the second optocoupler are both normal; when the signal of the first feedback interface 5 is high, the signal sent by the transmitting end TXD2 of the slave MCU is low, the signal of the second feedback interface 6 is high, and the signal sent by the transmitting end TXD1 of the host MCU is low, it indicates that the first optocoupler and the second optocoupler are both abnormal.
[0076] The optocoupler fault detection circuit of this embodiment has a newly added optocoupler fault detection function, which detects the high and low levels of the signals sent by the first feedback interface 5, the transmitting end TXD2 of the slave MCU, the second feedback interface 6, and the transmitting end TXD1 of the host MCU, without considering the abnormality or lack of signals (this detection is the original function). As far as this newly added function is concerned, within a set detection period, when there is a high level of input signal on the input side of the optocoupler and no signal on the output side, it can be determined that the optocoupler has an abnormality, thereby realizing that the slave MCU can realize a specific fault display or reminder function when there is an abnormality.
[0077] Example 3
[0078] This embodiment provides a communication system, including a host MCU, a slave MCU, a first optocoupler and a second optocoupler, and also includes the optocoupler fault detection circuit in the above embodiment.
[0079] Example 4
[0080] This embodiment provides a fault detection method, which is applied to the optical coupler fault detection circuit in the above embodiment. Figure 4 : is a flow chart of a method for detecting an optical coupler fault according to an embodiment of the present invention. Figure 4 As shown, the method includes:
[0081] S101, obtaining a first sampling signal and a second sampling signal; wherein the first sampling signal is generated based on a signal sent by a transmitting end of the host MCU, and the second sampling signal is generated based on a signal received by a receiving end of the host MCU.
[0082] S102, judging whether the first optocoupler fails according to the first sampling signal and the signal received by the receiving end of the slave MCU; and / or judging whether the second optocoupler fails according to the signal sent by the sending end of the slave MCU and the second sampling signal; wherein the signal received by the receiving end of the slave MCU is a signal generated by the signal sent by the sending end of the host MCU via the first optocoupler, and the signal sent by the sending end of the slave MCU is transmitted to the receiving end of the host MCU via the second optocoupler.
[0083] The optocoupler fault detection method of the present embodiment generates a first sampling signal based on a signal sent by the transmitting end of the host MCU, generates a second sampling signal based on a signal received by the receiving end of the host MCU, and determines whether the first optocoupler has a fault based on the first sampling signal and the signal received by the receiving end of the slave MCU; and / or determines whether the second optocoupler has a fault based on the signal sent by the transmitting end of the slave MCU and the second sampling signal, which can realize rapid detection of optocoupler faults in the communication system and improve the fault detection efficiency of the system.
[0084] Example 5
[0085] This embodiment provides another method for detecting optical coupler faults. The principle when the optical coupler is normal is as follows:
[0086] When the host MCU's transmitting end TXD1 sends a high-level signal, both electrodes of the diode in the first optocoupler D1 are high-level, the diode is cut off and does not emit light, the phototransistor at the back end of the first optocoupler D1 is cut off and does not conduct, and the RXD1 end is directly connected to the slave communication power supply voltage VCC, which is high-level, realizing signal input and output. Conversely, when the host MCU's transmitting end TXD1 sends a low-level signal, the anode of the diode in the first optocoupler D1 is high-level, the cathode is low-level, the diode is turned on and emits light, the phototransistor at the back end of the first optocoupler D1 is turned on, and RXD1 is pulled down to the ground network to present a low level, realizing signal input and output.
[0087] When the receiving end RXD2 of the host MCU is a high-level signal, it indicates that the phototransistor in the second optocoupler D2 is not turned on, and further indicates that the diode in the second optocoupler D2 is not emitting light, and further indicates that the sending end TXD2 of the slave MCU is at a high level, and the signal input and output are realized. Conversely, when the receiving end RXD2 of the host MCU is a low-level signal, it indicates that the phototransistor in the second optocoupler D2 is turned on, and further indicates that the diode in the second optocoupler D2 is turned on, and further indicates that the sending end TXD2 of the slave MCU is at a low level, and the signal input and output are realized.
[0088] From the above principle analysis, it can be seen that when the transmitting end TXD1 of the host MCU sends a high-level signal, if the RXD1 end is also at a high level, it indicates that the first optocoupler D1 is not faulty. Conversely, when the transmitting end TXD1 of the host MCU sends a high-level signal, if the RXD1 end is also at a low level, it indicates that the first optocoupler D1 is not faulty; when the receiving end RXD2 of the host MCU is a high-level signal, if the transmitting end TXD2 of the slave MCU is also at a high level, it indicates that the second optocoupler D2 is not faulty. When the receiving end RXD2 of the host MCU is a high-level signal, if the transmitting end TXD2 of the slave MCU is at a low level, it indicates that the second optocoupler D2 is faulty.
[0089] Therefore, in the above step S102, judging whether the first optocoupler fails according to the first sampling signal and the signal received by the receiving end of the slave MCU includes: if the first sampling signal is a high-level signal, and the signal received by the receiving end of the slave MCU is a high-level signal, judging that the first optocoupler does not fail; if the first sampling signal is a high-level signal, and the signal received by the receiving end of the slave MCU is a low-level signal, judging that the first optocoupler fails.
[0090] Judging whether the second optocoupler fails according to the signal sent by the sending end of the slave MCU and the second sampling signal, includes: if the signal sent by the sending end of the slave MCU is a high-level signal, and the second sampling signal is a high-level signal, judging that the second optocoupler does not fail; if the signal sent by the sending end of the slave MCU is a high-level signal, and the second sampling signal is a low-level signal, judging that the second optocoupler fails.
[0091] In a specific implementation, a first sampling unit is provided between the transmitting end of the host MCU and the first feedback interface of the slave MCU to generate a first sampling signal according to a signal sent by the transmitting end TXD1 of the host MCU, and output it to the first feedback interface 5 of the slave MCU; a second sampling unit 102 is provided between the receiving end RXD2 of the host MCU and the second feedback interface of the slave MCU to generate a second sampling signal according to a signal received by the receiving end RXD2 of the host MCU, and output it to the second feedback interface 6 of the slave MCU.
[0092] When the signals of the first feedback interface 5, the transmitting end TXD2 of the slave MCU, and the second feedback interface 6 are all high, and the signal sent by the transmitting end TXD1 of the host MCU is low, it indicates that the first optocoupler is abnormal and the second optocoupler is normal; when the signals sent by the first feedback interface 5, the second feedback interface 6, and the transmitting end TXD1 of the host MCU are all high, and the transmitting end TXD2 of the slave MCU is low, it indicates that the second optocoupler is abnormal and the first optocoupler is normal; when the signals of the first feedback interface 5, the transmitting end TXD2 of the slave MCU, the second feedback interface 6, and the transmitting end TXD1 of the host MCU are all high, it indicates that the first optocoupler and the second optocoupler are both normal; when the signal of the first feedback interface 5 is high, the signal sent by the transmitting end TXD2 of the slave MCU is low, the signal of the second feedback interface 6 is high, and the signal sent by the transmitting end TXD1 of the host MCU is low, it indicates that the first optocoupler and the second optocoupler are both abnormal.
[0093] Example 6
[0094] This embodiment provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the optocoupler fault detection method in the above embodiment is implemented.
[0095] The circuit embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0096] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0097] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. An optocoupler fault detection circuit, characterized in that: The optical coupler fault detection circuit comprises: A sampling module is provided between a host MCU and a slave MCU, and is used to generate a first sampling signal based on a signal sent by a transmitting end of the host MCU, and to generate a second sampling signal based on a signal received by a receiving end of the host MCU, and to send the first sampling signal and the second sampling signal to the slave MCU; wherein the host MCU and the slave MCU perform signal transmission via a first optical coupler and a second optical coupler; The slave MCU is used to determine whether the first optocoupler fails based on the first sampling signal and the signal received by the receiving end of the slave MCU; and to determine whether the second optocoupler fails based on the signal sent by the sending end of the slave MCU and the second sampling signal; wherein the signal received by the receiving end of the slave MCU is a signal generated by the signal sent by the sending end of the host MCU after passing through the first optocoupler, and the signal sent by the sending end of the slave MCU is transmitted to the receiving end of the host MCU via the second optocoupler.
2. The optocoupler fault detection circuit according to claim 1, characterized in that: The sampling module has a first interface connected to a transmitting end of the host MCU; and a second interface connected to a receiving end of the host MCU; Its third interface is connected to the first feedback interface of the slave MCU and is conducted with the first interface, and its fourth interface is connected to the second feedback interface of the slave MCU and is conducted with the second interface.
3. The optocoupler fault detection circuit according to claim 2, characterized in that: The sampling module comprises: a first sampling unit, arranged between the transmitting end of the host MCU and the first feedback interface of the slave MCU, for generating the first sampling signal according to the signal sent by the transmitting end of the host MCU, and outputting the first sampling signal to the first feedback interface; The second sampling unit is arranged between the receiving end of the host MCU and the second feedback interface of the slave MCU, and is used to generate the second sampling signal according to the signal received by the receiving end of the host MCU, and output it to the second feedback interface.
4. The optocoupler fault detection circuit according to claim 3, characterized in that: The slave MCU is specifically used for: When the first sampling signal is a high-level signal and the signal received by the receiving end of the slave MCU is a high-level signal, it is determined that the first optical coupler has not failed; When the first sampling signal is a high-level signal and the signal received by the receiving end of the slave MCU is a low-level signal, it is determined that the first optical coupler fails.
5. The optocoupler fault detection circuit according to claim 3, characterized in that: The slave MCU is also specifically used for: When the signal sent by the sending end of the slave MCU is a high-level signal and the second sampling signal is a high-level signal, it is determined that the second optical coupler has not failed; When the signal sent by the sending end of the slave MCU is a high-level signal and the second sampling signal is a low-level signal, it is determined that the second optical coupler fails.
6. The optocoupler fault detection circuit according to claim 3, characterized in that: The first sampling unit comprises: A first comparator has a non-inverting input terminal connected to the transmitting terminal of the host MCU, an inverting input terminal connected to its own output terminal, and an output terminal connected to the first feedback interface of the slave MCU.
7. The optocoupler fault detection circuit according to claim 6, characterized in that: The first sampling unit also includes: A first capacitor has a first end connected to the non-inverting input end of the first comparator and a second end connected to ground, and is used to maintain the voltage of the non-inverting input end of the first comparator.
8. The optocoupler fault detection circuit according to claim 3, characterized in that: The second sampling unit comprises: The second comparator has a non-inverting input terminal connected to the receiving terminal of the host MCU, an inverting input terminal connected to its own output terminal, and an output terminal connected to the second feedback interface of the slave MCU.
9. The optocoupler fault detection circuit according to claim 8, characterized in that: The second sampling unit further includes: A second capacitor has a first end connected to the non-inverting input terminal of the second comparator and a second end grounded, and is used to maintain the voltage of the non-inverting input terminal of the second comparator.
10. A communication system, comprising a host MCU, a slave MCU, a first optical coupler and a second optical coupler, characterized in that: It also includes the optocoupler fault detection circuit according to any one of claims 1 to 9.
11. An optocoupler fault detection method, applied to the optocoupler fault detection circuit according to any one of claims 1 to 9, characterized in that: The method comprises: Acquire a first sampling signal and a second sampling signal; wherein the first sampling signal is generated based on a signal sent by a transmitting end of the host MCU, and the second sampling signal is generated based on a signal received by a receiving end of the host MCU; Determine whether the first optocoupler fails based on the first sampling signal and the signal received by the receiving end of the slave MCU; and / or determine whether the second optocoupler fails based on the signal sent by the sending end of the slave MCU and the second sampling signal; wherein the signal received by the receiving end of the slave MCU is a signal generated by the signal sent by the sending end of the host MCU after passing through the first optocoupler, and the signal sent by the sending end of the slave MCU is transmitted to the receiving end of the host MCU via the second optocoupler.
12. The method according to claim 11, characterized in that Determining whether the first optical coupler fails according to the first sampling signal and a signal received by the receiving end of the slave MCU includes: If the signal sent by the transmitting end of the host MCU is a high-level signal, and the signal received by the receiving end of the slave MCU is a high-level signal, it is determined that the first optical coupler is not faulty; If the first sampling signal is a high-level signal, and the signal received by the receiving end of the slave MCU is a low-level signal, it is determined that the first optical coupler fails.
13. The method according to claim 11, characterized in that Determining whether the second optical coupler fails according to a signal sent by a sending end of the slave MCU and the second sampling signal includes: If the signal sent by the sending end of the slave MCU is a high-level signal, and the second sampling signal is a high-level signal, it is determined that the second optical coupler is not faulty; If the signal sent by the sending end of the slave MCU is a high-level signal, and the signal received by the receiving end of the host MCU is a low-level signal, it is determined that the second optical coupler fails.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 11 to 13 is implemented.
Citation Information
Patent Citations
Optocoupler fault detection circuit and communication system
CN215340263U