Switch signal detection circuit with self-diagnosis function
By combining the interrupt and query detection method and the ADC detection method, the switch signal detection circuit of the smart meter realizes the automatic detection of internal interface open circuit and external interface disconnection, solving the problem of difficult detection of smart meter interface faults, reducing power consumption and enhancing fault handling capabilities.
Patent Information
- Application Number
- CN201711448135.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2017-12-27
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2037-12-27
AI Technical Summary
It is difficult for smart instruments to detect interface faults in complex environments, resulting in high power consumption and the inability to identify signal line disconnections in time, causing economic disputes.
Using the interrupt and query detection method combined with the ADC detection method, through the switch signal detection circuit and the signal line disconnection detection method, automatic detection of internal interface open circuit and external interface disconnection is realized, reducing power consumption and being compatible with active and passive signals.
It realizes automatic monitoring of switch status and interface status, promptly identifies abnormalities, reduces power consumption, extends product life, and notifies relevant personnel through remote alarm.
Smart Images

Figure CN108107357B
Abstract
Description
Technical Field
[0001] The invention belongs to the field of metering signal detection, and in particular relates to a switch signal detection circuit with a self-diagnosis function. Background Art
[0002] With the development of the times and the progress of science and technology, intelligent instruments have become popular. Switch quantity detection technology has been widely used in intelligent instruments due to its advantages of simplicity, reliability and low cost. Such as button triggering, valve in place, metering pulse signal output by flow meter, etc. In the above applications, the detection system will first receive the switch quantity signal through the external interface, and after the process of voltage reduction or filtering, the signal will be transmitted to the controller through the internal interface for final analysis and processing.
[0003] Since the use environment of smart meters is complex and the number of smart meters is huge, their interfaces will inevitably fail. For example, when the internal and external interfaces are short-circuited or the internal interface is open and interfered, it will cause a high power consumption problem, and it can only be identified when the battery is exhausted, resulting in energy waste; when the connection signal line between the external interface and the signal source is broken, it cannot be identified by its interface status in the existing technology, and can only be checked and repaired after it is found that it is not counted. This is easy to cause economic disputes between enterprises and users, service providers and consumers.
[0004] Therefore, it is very necessary to add self-diagnosis function to smart meters to ensure that when a fault occurs, the cause of the fault can be detected in time and handled accordingly so as not to affect the normal operation of other functional modules. After summarizing the shortcomings of the switch quantity detection method in the prior art, this paper takes the industrial Internet of Things smart gas meter as an example and designs a switch quantity detection system with self-diagnosis function that has low power consumption and can detect internal and external interface faults in time, which effectively solves the above practical problems. Summary of the invention
[0005] In order to solve the shortcomings and deficiencies in the prior art, the present invention provides a switch signal detection circuit with a self-diagnosis function that detects a switch signal using an interruption and inquiry detection method, thereby reducing detection power consumption.
[0006] In order to achieve the above technical objectives, on the one hand, the present invention provides a switch signal detection circuit with a self-diagnosis function, the switch signal detection circuit comprising:
[0007] Resistor R1, and resistor R2 connected in series with resistor R1, a POW_CTR pin is provided at the end of resistor R1 away from resistor R2, a SW_IO pin and a capacitor C1 are provided between resistor R1 and resistor R2, one end of capacitor C1 away from the SW_IO pin is grounded, and the other end of resistor R2 away from resistor R1 is a switch signal input interface.
[0008] Optionally, a signal line disconnection detection circuit is connected to the switch signal input interface of the switch signal detection circuit;
[0009] A switch detection circuit is connected to the output end of the signal line disconnection detection circuit;
[0010] Passive signal output circuit or
[0011] Active signal output circuit, or
[0012] Passive signal output circuit and active signal output circuit;
[0013] A signal conversion circuit is also connected between the output end of the signal line disconnection detection circuit and the active signal output circuit.
[0014] Optionally, in the signal line break detection circuit, a transistor Q1 is provided, the base of the transistor Q1 is connected to a first control terminal for sending a control signal, a resistor R4 is provided between the control terminal and the base, a resistor R3 is connected to the collector of the transistor Q1, and the emitter of the transistor Q1 is grounded.
[0015] Optionally, in the switch signal detection circuit, a source signal conversion circuit is also provided, including:
[0016] An active output circuit is included, including a MOS tube Q3 and a triode Q4, wherein the gate of the MOS tube Q3 is connected to the collector of the triode Q4, and the drain of the MOS tube Q3 is connected to the signal conversion circuit via a diode D2;
[0017] A resistor R7 is provided between the collector of the transistor Q4 and the source of the MOS transistor Q3 , and the base of the transistor Q4 is connected to the second control terminal via the resistor R8 .
[0018] Optionally, the active signal circuit further includes an active signal conversion circuit connected to the active output circuit, including:
[0019] MOS tube Q2, the drain of MOS tube Q2 is connected to the switch signal input interface, the source of MOS tube Q2 is grounded, the gate of MOS tube Q2 is connected to resistor R5, one end of resistor R5 away from MOS tube Q2 is grounded through resistor R6, and the other end of resistor R6 away from the ground end is connected to the signal output circuit.
[0020] Optionally, a voltage protection circuit is further provided between the input interface of the switch detection circuit and the output end of the signal line break detection circuit, and the output end of the voltage protection circuit serves as an external interface.
[0021] On the other hand, an embodiment of the present invention further includes a switch signal detection method applied to the switch signal detection circuit, the switch signal detection method including the step of internal interface open circuit detection, specifically:
[0022] Set the SW_IO pin in the switch detection circuit to output state and the POW_CTR pin to input state;
[0023] Make the SW_IO pin output a high level first and then a low level, or make the SW_IO pin output a low level first and then a high level, and detect the level signal output by the SW_IO pin through the POW_CTR pin;
[0024] If the SW_IO pin outputs a high level first and then a low level, and the POW_CTR pin detects a high level first and then a low level, it means that both the SW_IO pin and the POW_CTR pin are normal.
[0025] If the SW_IO pin outputs a low level first and then a high level, and the POW_CTR first detects a low level and then a high level, it means that both the SW_IO pin and the POW_CTR pin are normal.
[0026] If no level change is detected, it means that the internal interface has failed.
[0027] Optionally, the switch signal detection circuit further includes a signal line disconnection detection method, specifically:
[0028] When the passive signal input interface is not triggered or the active signal input interface CTR2 outputs a low level and the MOS tube Q2 is in the cut-off state, the external interface is in a suspended state.
[0029] The timing detection mode is adopted, and the set time is Tf3. When the timing time has not arrived, the CTR1 pin outputs a low level, the transistor Q1 is cut off, the sampling resistor R3 is in a suspended state, there is no current loop, and when the disconnection detection circuit does not work, no current consumption is generated.
[0030] Optionally, the signal line disconnection detection method further includes:
[0031] When the switch is not triggered, that is, the external interface is in a floating state, the POW_CTR pin is configured as an input state, the CTR1 pin outputs a high level, and the SW_IO pin uses the multiplexing microcontroller AD function, that is, the analog to digital conversion function;
[0032] The sampling resistor access / disconnection control line CTR1 outputs a high level, the sampling resistor is connected to the signal bus, the pull-up resistor R1 is connected in series with the protection resistor R2, the voltage protection diode D1, and the sampling resistor R3, and the voltage is divided, and connected to GND through the transistor Q1 to form a current loop, and the SW_IO pin samples the AD voltage of the sampling resistor;
[0033] If the sampling voltage is lower than the threshold value Vt, it is judged that the signal line is connected normally; if the sampling voltage is higher than the threshold value Vt, it can be judged as a disconnection state; the Vt range is 0 to 0.62V as the preferred value, and the Vt threshold value is obtained according to the actual sampling voltage;
[0034] After the sampling is completed, the controller connects / disconnects the sampling resistor to the control line CTR1 and outputs a low level, and the other two pins return to the switch signal detection working state.
[0035] Optionally, when the timing time Tf3 is reached, the signal line disconnection detection circuit works, including:
[0036] The POW_CTR pin outputs a high level, and the SW_IO pin is multiplexed as an AD function, that is, an analog-to-digital conversion function. The sampling resistor is connected / disconnected to the control line CTR1, which outputs a high level and connects the sampling resistor to the signal bus;
[0037] The pull-up resistor R1 is connected in series with the protection resistor R2, the voltage protection diode D1, and the sampling resistor R3 to divide the voltage, and is connected to GND through the transistor Q1 to form a current loop. At this time, the SW_IO pin performs AD sampling, and the judgment is made based on the sampling results combined with formulas 1, 2, and 3;
[0038] When there is no signal and the external interface is suspended,
[0039] V3=V1×(R2+R3) / (R1+R2+R3)+V2, Formula 1;
[0040] When there is a signal and the external interface is at a low level, V3 = V1 × R2 / (R1 + R2) + V2, formula 2;
[0041] When disconnected, V3 = V1, formula 3;
[0042] In the above ADC sampling voltage calculation formula, it is assumed that voltage V1 is the POW_CTR pin voltage, V2 is the protection diode working voltage, and V3 is the SW_IO pin AD sampling voltage.
[0043] The beneficial effects brought by the technical solution provided by the present invention are:
[0044] 1. Through the cooperation of switch signal detection circuit, switch detection software algorithm, self-diagnosis software algorithm (signal line disconnection detection and internal interface open circuit detection), and wireless communication function, the product can automatically monitor the switch status and interface status during use, including: when the input signal line connected to the external interface is disconnected or the controller pin connected to the internal interface is desoldered, etc., when an abnormality occurs, it can be detected in time and handled properly, and relevant personnel can be notified through remote alarm.
[0045] 2. The interruption or query detection method, ADC detection method and other software methods can cooperate with the controllable power supply of the hardware circuit to achieve lower power consumption while meeting the detection work. When the input signal is short-circuited, the power supply of the control circuit can be automatically switched to the timed intermittent power supply mode, and cooperate with the query detection method to avoid power consumption and affect the service life of the product power supply.
[0046] 4. Achieve compatibility with active or passive input signals. Through the design of switch signal detection circuit and active to passive signal conversion circuit, combined with switch detection software algorithm, passive or active signal input, active signal input with different voltages, compatibility with normally open and normally closed input signals, and mixing of single or multiple input signals are achieved.
[0047] 5. By detecting that the power supply of the circuit can be controlled, the probability of failure of components due to aging can be reduced after the product has been used for a long time. In addition, when a circuit fails, the power supply can be disconnected to protect the circuit in the product from being affected. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solution of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0049] Figure 1 It is a structural schematic diagram of a switch signal detection circuit with a self-diagnosis function provided by the present invention;
[0050] Figure 2 It is a structural schematic diagram of a passive switch signal detection circuit provided by the present invention;
[0051] Figure 3 It is a structural schematic diagram of the active signal conversion circuit provided by the present invention;
[0052] Figure 4 It is a structural schematic diagram of an external interface signal line disconnection detection circuit provided by the present invention;
[0053] Figure 5It is a structural schematic diagram of a voltage protection circuit provided by the present invention;
[0054] Figure 6 It is a schematic diagram of the process of internal interface open circuit detection provided by the present invention;
[0055] Figure 7 It is a schematic flow chart of an alternative solution for internal interface open circuit detection provided by the present invention;
[0056] Figure 8 It is a flow chart of a signal line disconnection detection method provided by the present invention;
[0057] Fig. 9 It is a system block diagram based on the switch signal detection circuit provided by the present invention. DETAILED DESCRIPTION
[0058] In order to make the structure and advantages of the present invention more clear, the structure of the present invention will be further described below in conjunction with the accompanying drawings.
[0059] Embodiment 1
[0060] On the one hand, the present invention provides a switch signal detection circuit with a self-diagnosis function, such as Figure 1 As shown, the specific structure of the switch signal detection circuit is a resistor R1 and a resistor R2 connected in series with the resistor R1. A POW_CTR pin is provided at the end of the resistor R1 away from the resistor R2. A SW_IO pin and a capacitor C1 are provided between the resistor R1 and the resistor R2. One end of the capacitor C1 away from the SW_IO pin is grounded, and the other end of the resistor R2 away from the resistor R1 is a switch signal input interface.
[0061] In the implementation, the switch detection circuit POW_CTR is connected to the controller pin, and SW_IO is connected to another pin of the controller. R1 is used as a pull-up resistor to pull the SW_IO pin to a high level state when the button is not pressed. Resistor R2 is used as a protection resistor and a sampling resistor. In the passive switch signal detection circuit, as a protection resistor, when the SW_IO pin outputs a high level and the button is pressed and connected to GND, it prevents SW_IO from being short-circuited with GND. The sampling resistor function is used to detect circuit faults, that is, when the line is broken.
[0062] The resistance value of R1 can be selected as 100k as the preferred value. The selection principle is:
[0063] (1) When the button is not pressed, according to the controller data sheet (different data sheets have different voltages), in this controller, the high-level discrimination voltage threshold is: the SW_IO pin voltage is higher than 0.7 times the POW_CTR high-level voltage. For example, when the POW_CTR high-level voltage is 3V, the SW_IO pin voltage is greater than 2.1V.
[0064] (2) When the button is pressed, the lower the current generated, the better. The low level judgment of the controller pin can be designed according to the controller data sheet. In this controller, the low level judgment voltage threshold is: the voltage of the SW_IO pin is lower than 0.3 times the POW_CTR high level voltage. For example: the POW_CTR voltage is 3V, and a 100k resistor is connected in series. The maximum generated current is
[0065] I0=30uA. SW_IO pin voltage is lower than 0.9V.
[0066] The R2 resistor is preferably 100Ω. When the key is not pressed, the R2 resistor does not work. When the key is pressed, the R1 and R2 resistors are connected in series to form a voltage divider circuit. The voltage after voltage division must follow the sampling principle of SW_IO.
[0067] For example: when the button is pressed, the voltage of the SW_IO pin is less than 0.9V, then the calculation formula is:
[0068] →POW_CTR×R2 / (R1+R2)<0.9V
[0069] →R2<42k
[0070] Selection of C1 filter capacitor capacitance: The C1 filter capacitor range can be between (0.01nF and 1uF). In order to be compatible with the disconnection detection function, the present invention uses a 0.1nF non-polar ceramic capacitor as a preferred embodiment.
[0071] Based on the switch signal detection circuit proposed in the foregoing, passive signals and active signals can be detected. A passive signal refers to a switch signal that can output a low level and a suspended state, and can be a switch device or similar device such as a button, a reed switch, a relay, etc. The embodiment of the present invention preferably uses a button as an analog passive switch input signal source. An active signal refers to a switch signal that can output a low level and a high level state or output a suspended and a high level state, and a device or instrument with a switch signal can be used as an input signal source, for example: a switch signal output by a gas flow meter.
[0072] The passive signal output circuit or the active signal output circuit can be used as the switch signal input alone, or they can be used together as the switch signal input. When the passive switch signal is used as the input signal, the active signal conversion circuit and the active signal output circuit can be omitted. When the active switch signal is used as the input signal, the active output interface needs to be connected to the Vin of the signal conversion circuit, and after the signal is converted, it is connected to the signal bus OUT and connected to the external interface of the switch detection circuit.
[0073] Figure 2A passive switch signal detection circuit is proposed, including a switch detection circuit and a passive signal output circuit, for detecting passive signals. The switch detection circuit POW_CTR is connected to a controller pin, and SW_IO is connected to another controller pin. R1 is used as a pull-up resistor, and when the button is not pressed, the SW_IO pin is pulled to a high level state.
[0074] Resistor R2 is used as a protection resistor and sampling resistor. In the passive switch signal detection circuit, as a protection resistor, when the SW_IO pin outputs a high level and the key is pressed and connected to GND, it prevents SW_IO from short-circuiting with GND. The sampling resistor function is used to detect circuit faults, that is, when the line is broken. The sampling resistor function is described below.
[0075] Capacitor C1 is a filter capacitor at the switch signal sampling end in the switch detection circuit. Its function is to filter out the key mechanical jitter interference signal when the key is pressed and the resistor R2 is connected to GND, so that the controller will not make a misjudgment. According to the different types of switch S1 in the switch signal detection circuit, the detection principle of the switch signal detection circuit is described respectively.
[0076] The button is of normally open type. When the circuit is working normally
[0077] ①When the button is not pressed, the controller configures the POW_CTR pin to output state and outputs a high level. The controller configures the SW_IO pin to input state, and the SW_IO pin can detect that the current state is a high level through the pull-up resistor R1. Since the POW_CTR and SW_IO pins have the same level state, they cannot form a discharge loop, so no current is generated. At this time, the controller can use the query method or interrupt method to detect whether the button S1 is pressed.
[0078] ②When the button S1 is pressed, the resistor R2 is pulled to GND through the button connection end, and the POW_CTR pin, R1, R2, and GND are connected in series to form a loop. After R1 and R2 are connected in series to divide the voltage, the divided low-level voltage signal is transmitted to the SW_IO pin. The controller detects a low-level signal through the SW_IO pin and determines that the button is pressed.
[0079] When it is detected that the button is pressed, before executing the operation, the POW_CTR pin level is first configured from a high level to a low level, in order to save the power consumption caused by the button being pressed and connected to GND. Then execute the operation corresponding to the button. After the execution is completed, the timer is enabled, and the timer time is Tf1 (Tf1 can be adjusted according to the actual situation). When the timing time Tf1 is reached, the timer is stopped. The POW_CTR pin outputs a high level, and then the SW_IO pin is used to detect the input signal of the button. If it is detected that the SW_IO pin level is still at a low level and there is no change, the POW_CTR pin is set low and the timer is restarted until the SW_IO pin detects that the button input signal becomes high again. This button operation is completed.
[0080] If the key is detected n times and the number of detections exceeds the threshold value Cn, and the SW_IO pin continues to detect that the current key input signal is still in a low level state, an audible and visual alarm will be issued, the LCD will display an error code, and the alarm information will be transmitted to the background server through remote communication for technical personnel to handle.
[0081] In the above detection process, the key detection circuit first uses an interrupt or query mode. If it detects that a key is pressed, it uses an intermittent working mode to periodically detect whether the key is released and restore to an open circuit state. This achieves the purpose of saving power. If a key short circuit fault occurs, all control pins output a low level, the circuit power supply is disconnected, and an alarm is issued.
[0082] In contrast, if the button uses the normally closed type, the working process of the switch signal detection circuit is:
[0083] ① The controller configures the POW_CTR pin as an output state and outputs it as a low level. The controller configures the SW_IO pin as an input state, and R2 is used as a pull-down resistor, which is pulled to GND through the key connection terminal. The SW_IO pin detects that the current state is a low level.
[0084] ②The controller uses a timing query method to detect whether the button S1 is pressed. When the timing (T1) time is reached (T1 can be adjusted according to the actual application), the POW_CTR pin outputs a high level, and R1 is used as a pull-up resistor to divide the voltage with R2. After the waiting time (T2) capacitor C1 is charged, the voltage is sampled by the SW_IO pin. Determine whether the SW_IO pin level changes to a high level. If it is detected that the SW_IO pin changes to a high level, it can be determined that the button is pressed. Otherwise, the button is not taken. After the detection is completed, the POW_CTR pin outputs a low level again, and waits for the timing time to arrive for cyclic detection. The timing time needs to take into account the charging and discharging time of capacitor C1. When the POW_CTR output is a high level, it is necessary to wait for time T2 for C1 to charge, and then detect after the voltage stabilizes. When the POW_CTR output is a low level, it is necessary to wait for time T2 for C1 to discharge, and then detect after the voltage stabilizes.
[0085] The purpose of using the timed intermittent power supply in conjunction with the query detection method is to save the power consumption generated when the key is in the normally closed state and POW_CTR is at a high level.
[0086] The waiting time T2 here is common knowledge in the art and will not be described in detail here.
[0087] Based on the above content, the switch signal detection circuit proposed in this embodiment provides a solution for diagnosing the switch signal as follows:
[0088] Through the design of switch signal detection circuit and active to passive signal conversion circuit, combined with switch detection software algorithm, the compatibility of passive and active input signals, active input signals with different voltages, normally open and normally closed input signals, and the mixing of single or multiple input signals are realized. After long-term use of the product, the probability of component failure due to device aging can be reduced. In addition, when the circuit is abnormal due to a fault, the power supply can be disconnected to protect the circuit in the product from being affected. By controlling the power supply, when the timing time has not arrived or the system is not working, the power supply of the detection circuit can be disconnected and the detection circuit will not work. The service life of the product can be extended.
[0089] In addition, the switch signal detection circuit adopts a modular design and can be combined and split according to actual application requirements. Not only can it solve the problems existing in the background technology, but the system can also self-diagnose whether there is a fault inside the circuit or the external interface. When the circuit does not need a voltage protection function, the switch signal detection interface can be directly connected to the signal bus OUT as an external interface. The voltage protection circuit is not selected. When the circuit does not need a disconnection detection function, the signal line disconnection detection circuit can be selected.
[0090] When the circuit uses a passive signal as the input signal, the active to passive signal conversion circuit and the active signal output circuit may not be selected. In addition, the passive signal output circuit or the active signal output circuit may be used as the switch signal input alone. They may also be used together as the switch signal input, and the active signal may be first connected to Vin on the signal conversion circuit, and after the signal is converted, it may be connected to the signal bus OUT to access the external interface.
[0091] Optionally, in the switch signal detection circuit, a source signal conversion circuit is also provided, including:
[0092] An active output circuit is included, including a MOS tube Q3 and a triode Q4, wherein the gate of the MOS tube Q3 is connected to the collector of the triode Q4, and the drain of the MOS tube Q3 is connected to the signal conversion circuit via a diode D2;
[0093] A resistor R7 is provided between the collector of the transistor Q4 and the source of the MOS transistor Q3 , and the base of the transistor Q4 is connected to the second control terminal via the resistor R8 .
[0094] The active signal circuit also includes an active signal conversion circuit connected to the active output circuit, including:
[0095] MOS tube Q2, the drain of MOS tube Q2 is connected to the input end, the source of MOS tube Q2 is grounded, the gate of MOS tube is connected to resistor R5, one end of resistor R5 away from MOS tube Q2 is grounded through resistor R6, and the other end of resistor R6 away from the ground end is connected to the signal output circuit.
[0096] In practice, the structure of the active signal conversion circuit is as follows Figure 3 As shown, when the input signal is an active signal, it is necessary to use an active signal conversion circuit to convert the active signal into a passive signal. In the embodiment of the present invention, a MOS tube signal conversion circuit is preferably used. Under the premise of using MOS tube Q2, the working principle of the signal conversion circuit is:
[0097] When the VIN signal output is high, the MOS tube Q2 is turned on and VOUT outputs a low level. When the VIN signal output is low or suspended, the MOS tube Q2 is turned off and no signal is output at OUT.
[0098] In the signal conversion circuit, MOS tube Q2 can be replaced by MOS tube or triode Q2'. When VIN is suspended and no signal is output, the gate of MOS tube Q2 is suspended. The suspended gate of MOS tube is prone to cause the accumulated static electricity to have nowhere to discharge, which may cause the potential for breakdown. Pull-down resistor R6 plays a role in discharge.
[0099] The resistance value of resistor R5 can be selected in the range of 0.1k to 510k, and in this embodiment, 10kΩ is preferably used as resistor R5. The resistance value of resistor R6 can be selected in the range of 0.1k to 1.5M, and in this embodiment, 470kΩ is preferably used as resistor R6.
[0100] Optionally, a signal line disconnection detection circuit is connected to the input end of the switch signal detection circuit;
[0101] A switch detection circuit is connected to the output end of the signal line disconnection detection circuit;
[0102] Passive signal output circuit or
[0103] Active signal output circuit, or
[0104] Passive signal output circuit and active signal output circuit;
[0105] A signal conversion circuit is also connected between the output end of the signal line disconnection detection circuit and the active signal output circuit.
[0106] In practice, in order to realize the steps of detecting the switch signal proposed in the foregoing, the specific structure of the signal line disconnection detection circuit is provided with a transistor Q1, the base of the transistor Q1 is connected to a first control terminal for sending a control signal, a resistor R4 is provided between the control terminal and the base, a resistor R3 is connected to the collector of the transistor Q1, and the emitter of the transistor Q1 is grounded. A disconnection detection method based on the signal line disconnection detection circuit is embodied in the following embodiment.
[0107] Optionally, a voltage protection circuit is further provided between the switch signal input terminal of the switch detection circuit and the output terminal of the signal line disconnection detection circuit, and the output terminal of the voltage protection circuit serves as an external interface.
[0108] In implementation, Figure 5 As shown, a protection diode D1 can be connected in series between the resistor R2 and the input signal circuit. Its function is that when the input signal is abnormal, the protection diode D1 is reversely cut off, thereby protecting the switch detection circuit from being burned due to abnormalities such as short circuit of the external interface or excessive voltage of the external input signal.
[0109] The working principle of the voltage protection diode D1: when the voltage of the input signal is at a low level, the protection diode D1 is in the on state; when the input signal is at a high level or is suspended, the protection diode D1 is in the off state; the switching circuit can detect the input signal through the external interface.
[0110] The present invention provides a switch signal detection circuit with a self-diagnosis function, including a resistor R1, and a resistor R2 connected in series with the resistor R1, a POW_CTR pin is provided at one end of the resistor R1 away from the resistor R2, a SW_IO pin and a capacitor C1 are provided between the resistor R1 and the resistor R2, one end of the capacitor C1 away from the SW_IO pin is grounded, and the other end of the resistor R2 away from the resistor R1 is a switch signal input interface. Through the cooperation of software methods such as interrupt or query detection method, ADC detection method and the controllable mode of power supply of hardware circuit, it is achieved that lower power consumption is achieved under the premise of meeting the detection work. When the input signal is short-circuited, the power supply of the control circuit can be automatically switched to a timed intermittent power supply mode and cooperate with the query detection method to avoid generating additional power consumption and affecting the service life of the product power supply.
[0111] Embodiment 2
[0112] On the other hand, an embodiment of the present invention also includes a switch signal detection method applied to the switch signal detection circuit, such as Figure 6 As shown, the switch signal detection method includes the steps of internal interface open circuit detection, specifically:
[0113] 21. Set the SW_IO pin in the switch detection circuit to output state and the POW_CTR pin to input state;
[0114] 22. Make the SW_IO pin output a high level first and then a low level, and detect the level signal output by the SW_IO pin through the POW_CTR pin;
[0115] 23. If the SW_IO pin outputs a high level first and then a low level, then POW_CTR detects a high level first and then a low level, which means that both the SW_IO pin and the POW_CTR pin are normal;
[0116] 24. If no level change is detected, it means that the internal interface is faulty.
[0117] Alternatively, the content in step 22 may also be to make the SW_IO pin output a low level first and then output a high level, and detect the level signal output by the SW_IO pin through the POW_CTR pin.
[0118] According to the replacement content of step 22, step 23 may also correspond to that if the SW_IO pin outputs a low level first and then a high level, then POW_CTR detects a low level first and then a high level, which indicates that both the SW_IO pin and the POW_CTR pin are normal.
[0119] Regarding the replaceable contents of steps 22 and 23, the flow chart of the switch signal detection method is as follows: Figure 7 shown.
[0120] In practice, the protection function of R2 resistor: If there is no R2 resistor, when the SW_IO pin outputs a high level, the button S1 is pressed, which will cause the SW_IO pin to be short-circuited to GND through the button S1. Add R2 resistor, when the SW_IO pin outputs a high level and the button S1 is pressed, the resistor R2 plays a current limiting role, so it will not cause a short circuit and will not affect the level signal detection. After the detection is completed, the POW_CTR button is configured to output a high level again, and the SW_IO pin is configured to be in the input state. Perform normal switch signal detection.
[0121] By cooperating with software methods such as interrupt or query detection method, ADC detection method and controllable power supply of hardware circuit, lower power consumption is achieved while meeting the detection work requirements. When the input signal is short-circuited, the power supply of the detection circuit can be automatically switched to avoid power consumption and affect the product power supply life.
[0122] Embodiment 3
[0123] On the other hand, an embodiment of the present invention further includes a switch signal detection method applied to the switch signal detection circuit, and the switch signal detection circuit further includes a signal line disconnection detection method, such as Figure 8 As shown, specifically:
[0124] 31. When the passive signal input interface button S1 is not triggered or the active signal input interface CTR2 outputs a low level and the MOS tube Q2 is in the cut-off state, the input signal is in a suspended state.
[0125] 32. Use the timing detection mode, the timing time is Tf3. When the timing time has not arrived, the CTR1 pin output is low level, the transistor Q1 is cut off, the sampling resistor R3 is in a suspended state, there is no current loop, and when the diagnostic circuit is not working, no current consumption is generated.
[0126] Optionally, when the timing time Tf3 is reached, the signal line disconnection detection circuit works, including:
[0127] When the switch is not triggered, that is, the external interface is in a floating state, the POW_CTR pin is configured as an input state, the CTR1 pin outputs a high level, and the SW_IO pin uses the multiplexed MCU AD function, that is, the analog to digital conversion function;
[0128] The sampling resistor access / disconnection control line CTR1 outputs a high level, the sampling resistor is connected to the signal bus, the pull-up resistor R1 is connected in series with the protection resistor R2, the voltage protection diode D1, and the sampling resistor R3, and the voltage is divided, and connected to GND through the transistor Q1 to form a current loop, and the SW_IO pin samples the AD voltage of the sampling resistor;
[0129] If the sampling voltage is lower than the threshold value Vt, it is judged that the signal line is connected normally; if the sampling voltage is higher than the threshold value Vt, it can be judged as a disconnection state; the Vt range is 0 to 0.62V as the preferred value, and the Vt threshold value is obtained according to the actual sampling voltage;
[0130] After sampling is completed, the sampling resistor is connected / disconnected to the control line CTR1 and outputs a low level, and the other two pins return to the switch signal detection working state.
[0131] In implementation, when the switch is not triggered, that is, it is in a suspended state, the POW_CTR pin can be configured as an input state, the CTR1 pin outputs a high level, and the SW_IO pin uses the ADC (analog to digital conversion) function of the multiplexed microcontroller. The sampling resistor is connected / disconnected to the control line CTR1 to output a high level, and the sampling resistor is connected to the signal bus. The pull-up resistor R1 is connected in series with the protection resistor R2, the voltage protection diode D1, and the sampling resistor R3 to divide the voltage, and is connected to GND through the transistor Q1 to form a current loop. At this time, the SW_IO pin samples the AD voltage of the sampling resistor. If the sampling voltage is 0V, it can be judged that the signal line is connected normally. If the sampling voltage is not 0V, it can be judged as a disconnected state. After the sampling is completed, the sampling resistor is connected / disconnected to the control line CTR1 to output a low level, and the other two pins return to the switch signal detection working state.
[0132] Optionally, when the timing time Tf3 is reached, the signal line disconnection detection circuit works, including:
[0133] The POW_CTR pin outputs a high level, and the SW_IO pin is multiplexed as an AD function, that is, an analog-to-digital conversion function. The sampling resistor is connected / disconnected to the control line CTR1, which outputs a high level and connects the sampling resistor to the signal bus;
[0134] The pull-up resistor R1 is connected in series with the protection resistor R2, the voltage protection diode D1, and the sampling resistor R3 to divide the voltage, and is connected to GND through the transistor Q1 to form a current loop. At this time, the SW_IO pin performs AD sampling, and the judgment is made based on the sampling results combined with formulas 1, 2, and 3;
[0135] When there is no signal and the external interface is suspended,
[0136] V3=V1×(R2+R3) / (R1+R2+R3)+V2, Formula 1;
[0137] When there is a signal and the external interface is at a low level, V3 = V1 × R2 / (R1 + R2) + V2, formula 2;
[0138] When disconnected, V3 = V1, formula 3;
[0139] In the above ADC sampling voltage calculation formula, it is assumed that voltage V1 is the POW_CTR pin voltage, V2 is the protection diode working voltage, and V3 is the SW_IO pin AD sampling voltage.
[0140] In the implementation, the POW_CTR pin outputs a high level, and the SW_IO pin is multiplexed as an ADC (analog to digital conversion) function. The sampling resistor access / disconnect control line CTR1 outputs a high level, and the sampling resistor is connected to the signal bus. The pull-up resistor R1 is connected in series with the protection resistor R2, the voltage protection diode D1, and the sampling resistor R3 to divide the voltage, and is connected to GND through the transistor Q1 to form a current loop. At this time, the SW_IO pin performs AD sampling. The sampling results are judged by comparing the following formulas 1, 2, and 3.
[0141] When the input signal is abnormal (for example, the positive and negative poles are connected in reverse, short circuit, etc.), since the power supply of the CTR1 pin is different from the power supply of the input signal, the diagnostic circuit is in a non-working state and will not be affected.
[0142] ADC sampling voltage calculation formula
[0143] Assume that the POW_CTR voltage is V1, the protection diode operating voltage is V2, and the SW_IO pin AD sampling voltage is V3, then the calculation formula is:
[0144] ①No signal, the interface is suspended
[0145] V3=V1×(R2+R3) / (R1+R2+R3)+V2 (Formula 1)
[0146] ②Signal, low level
[0147] V3=V1×R2 / (R1+R2)+V2 (Formula 2)
[0148] ③Disconnection status
[0149] V3=V1(Formula 3)
[0150] R1, R2, R3 and R4 resistor selection:
[0151] In the present invention, the R1 resistor is selected as 100k, the R2 resistor is selected as 1k, the R3 resistor is selected as 100k, and the R4 resistor is selected as 100k as a preference.
[0152] The V1 voltage is 3V, and the protection diode is a Schottky diode with a rated working voltage of 0.3V.
[0153] ① No signal, the interface is suspended or in high level state, substitute into formula 1 to obtain the sampling voltage V3:
[0154] V3=V1×(R2+R3) / (R1+R2+R3)+V2
[0155] =1.8V
[0156] ② There is a signal, low level, substitute it into formula 2 to obtain the sampling voltage V3:
[0157] V3=V1×R2 / (R1+R2)+V2
[0158] =0.33V
[0159] ③ In the disconnected state, substitute into formula 3 to obtain the sampling voltage V3:
[0160] V3=V1=3V
[0161] It should be noted that the line break detection POW_CTR high level protection time T3 is as follows:
[0162] The timing time range of T3 can be selected between 20us and 1s, and 200us is preferably used in the present invention.
[0163] The timing time of T3 is related to the selection of R1 resistance and C1 capacitance to distinguish the three states of switch short circuit, open circuit and disconnection, which can be obtained through testing.
[0164] If the resistance value of R1 and the capacitance value of C1 are large, C1 needs a long charging time to stabilize the voltage, which will cause the POW_CTR high level to be maintained for a long time T3 during line break detection and a large average current during periodic line detection.
[0165] If the resistance value of R1 and the capacitance value of C1 are small, the charging time of C1 is short, but when the switch is short-circuited, a large short-circuit current is generated. If the T3 time is short, the charging time of capacitor C1 is short. At this time, AD sampling will cause the voltage on C1 to be low, and it will be impossible to distinguish the voltage when the key is in the touch state or disconnected state.
[0166] Based on the switch signal detection circuit and multiple detection methods proposed above, the embodiment of the present invention further proposes the following Fig. 9 The system block diagram based on the switch signal detection circuit is shown.
[0167] The external input signal component includes a disconnection detection module (i.e., the disconnection detection circuit in the aforementioned embodiment), and a passive switch signal and an active switch signal connected to the disconnection detection module for generating a switch signal. Since the active switch signal cannot be directly output from the disconnection detection module, a signal conversion module (i.e., the signal conversion circuit in the aforementioned embodiment) is also provided at the output end of the active switch signal.
[0168] The external input signal component is connected to the single-chip microcomputer via the control signal line, and is connected to the voltage protection circuit via the detection signal line through the external interface. The voltage protection circuit is connected to the switch detection circuit (i.e., the switch signal detection circuit). The switch detection circuit is connected to the single-chip microcomputer via an internal interface to realize power supply control and information collection. The single-chip microcomputer is also connected to an audible and visual alarm circuit, a liquid crystal display circuit, and a wireless communication circuit to realize operations such as an alarm after detecting a disconnection and timely informing the control end.
[0169] The present invention provides a passive signal input interface button S1 that is not triggered or an active signal input interface CTR2 outputs a low level, and the MOS tube Q2 is in a cut-off state, and the input signal is in a suspended state. A timing detection mode is adopted, and the timing time is Tf3. When the timing time has not arrived, the CTR1 pin outputs a low level, the transistor Q1 is cut off, the sampling resistor R3 is in a suspended state, there is no current loop, and when the disconnection detection circuit is not working, no current consumption is generated. When the timing time Tf3 arrives, the signal line disconnection detection circuit works. Through the cooperation of software methods such as interruption and query detection method, ADC detection method, and the controllable power supply mode of the hardware circuit, it is achieved that lower power consumption is achieved while meeting the detection work. When the input signal is short-circuited, the power supply of the detection circuit can be automatically switched to avoid power consumption and affect the service life of the product power supply.
[0170] The serial numbers in the above embodiments are for description only and do not represent the sequence of the components during assembly or use.
[0171] The above descriptions are merely embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A switch signal detection circuit with a self-diagnosis function, characterized in that: The switch signal detection circuit comprises: A resistor R1 and a resistor R2 connected in series with the resistor R1, a POW_CTR pin is provided at one end of the resistor R1 away from the resistor R2, a SW_IO pin and a capacitor C1 are provided between the resistor R1 and the resistor R2, one end of the capacitor C1 away from the SW_IO pin is grounded, and the other end of the resistor R2 away from the resistor R1 is a switch signal input interface; A signal line disconnection detection circuit is connected to the switch signal input interface of the switch signal detection circuit; A switch detection circuit is connected to the output end of the signal line disconnection detection circuit; Passive signal output circuit or Active signal output circuit, or Passive signal output circuit and active signal output circuit; Wherein, a signal conversion circuit is also connected between the output end of the signal line disconnection detection circuit and the active signal output circuit; In the signal line disconnection detection circuit, a transistor Q1 is provided, a first control terminal for sending a control signal is connected to the base of the transistor Q1, a resistor R4 is provided between the control terminal and the base, a resistor R3 is connected to the collector of the transistor Q1, and the emitter of the transistor Q1 is grounded; In the switch signal detection circuit, a source signal circuit is also provided, including: An active output circuit is included, including a MOS tube Q3 and a triode Q4, wherein the gate of the MOS tube Q3 is connected to the collector of the triode Q4, and the drain of the MOS tube Q3 is connected to the signal conversion circuit via a diode D2; A resistor R7 is provided between the collector of the transistor Q4 and the source of the MOS transistor Q3, and the base of the transistor Q4 is connected to the second control terminal via the resistor R8; The active signal circuit also includes an active signal conversion circuit connected to the active output circuit, including: MOS tube Q2, the drain of MOS tube Q2 is connected to the switch signal input interface, the source of MOS tube Q2 is grounded, the gate of MOS tube Q2 is connected to resistor R5, one end of resistor R5 away from MOS tube Q2 is grounded through resistor R6, and the other end of resistor R6 away from the ground end is connected to the signal output circuit.
2. The switch signal detection circuit with self-diagnosis function according to any one of claim 1, characterized in that: A voltage protection circuit is also provided between the input interface of the switch detection circuit and the output end of the signal line disconnection detection circuit, and the output end of the voltage protection circuit serves as an external interface.
3. The switch signal detection circuit with self-diagnosis function according to any one of claims 1 to 2, characterized in that: Also included is a switch signal detection method applied to the switch signal detection circuit, the switch signal detection method including the step of internal interface open circuit detection, specifically: Set the SW_IO pin in the switch detection circuit to output state and the POW_CTR pin to input state; Make the SW_IO pin output a high level first and then a low level, or make the SW_IO pin output a low level first and then a high level, and detect the level signal output by the SW_IO pin through the POW_CTR pin; If the SW_IO pin outputs a high level first and then a low level, and the POW_CTR pin detects a high level first and then a low level, it means that both the SW_IO pin and the POW_CTR pin are normal. If the SW_IO pin outputs a low level first and then a high level, and the POW_CTR pin detects a low level first and then a high level, it means that both the SW_IO pin and the POW_CTR pin are normal. If no level change is detected, it means that the internal interface has failed.
4. The switch signal detection circuit with self-diagnosis function according to any one of claims 1 to 2, characterized in that: The switch signal detection circuit also includes a signal line disconnection detection method, which is specifically: When the passive signal input interface is not triggered or the active signal input interface CTR2 outputs a low level and the MOS tube Q2 is in the cut-off state, the external interface is in a suspended state; The timing detection mode is adopted, and the set time is Tf3. When the timing time has not arrived, the CTR1 pin outputs a low level, the transistor Q1 is cut off, the sampling resistor R3 is in a suspended state, there is no current loop, and when the disconnection detection circuit does not work, no current consumption is generated.
5. The switch signal detection circuit with self-diagnosis function according to claim 4, characterized in that: The signal line disconnection detection method further includes: When the switch is not triggered, the external interface is in a suspended state. The POW_CTR pin is configured as an input state, and the SW_IO pin uses the multiplexed MCU AD function, that is, the analog to digital conversion function; The sampling resistor access / disconnect control line CTR1 outputs a high level, the sampling resistor is connected to the signal bus, the pull-up resistor R1 is connected in series with the protection resistor R2, the voltage protection diode D1, and the sampling resistor R3, and the voltage is divided, and connected to GND through the transistor Q1 to form a current loop, and the SW_IO pin samples the AD voltage of the sampling resistor; If the sampling voltage is lower than the threshold value Vt, it is judged that the signal line is connected normally; if the sampling voltage is higher than the threshold value Vt, it can be judged as a disconnection state; the Vt range is 0 to 0.62V as the preferred value, and the Vt threshold value is obtained according to the actual sampling voltage; After sampling is completed, the sampling resistor is connected / disconnected to the control line CTR1 and outputs a low level, and the other two pins return to the switch signal detection working state.
6. The switch signal detection circuit with self-diagnosis function according to claim 4, characterized in that: When the timing time Tf3 is reached, the signal line disconnection detection circuit starts to work, including: The POW_CTR pin outputs a high level, the SW_IO pin uses the multiplexed AD function, that is, the analog-to-digital conversion function, and the sampling resistor is connected / disconnected to the control line CTR1, which outputs a high level and connects the sampling resistor to the signal bus; The pull-up resistor R1 is connected in series with the protection resistor R2, the voltage protection diode D1, and the sampling resistor R3 to divide the voltage, and is connected to GND through the transistor Q1 to form a current loop. At this time, the SW_IO pin performs AD sampling, and the judgment is made based on the sampling results combined with formulas 1, 2, and 3; When there is no signal and the external interface is suspended, V3=V1×(R2+R3) / (R1+R2+R3)+V2, Formula 1; When there is a signal and the external interface is at a low level, V3 = V1 × R2 / (R1 + R2) + V2, formula 2; When disconnected, V3 = V1, formula 3; In the ADC sampling voltage calculation formula, assume that voltage V1 is the POW_CTR pin voltage, V2 is the protection diode working voltage, and V3 is the SW_IO pin AD sampling voltage.
