Configurable digital input / output method and system with short circuit protection and glitch-free diagnosis

By applying diagnostic stimuli in different operating modes using a microcontroller and monitoring port status using an input acquisition unit, and combining counters and thresholds to determine faults, the problem of not being able to diagnose channel faults in real time in existing technologies is solved. This achieves fast and uninterrupted short-circuit protection and diagnosis, preventing equipment damage.

CN122172690APending Publication Date: 2026-06-09SICHUAN ZERO POINT AUTOMATION SYST CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SICHUAN ZERO POINT AUTOMATION SYST CO LTD
Filing Date
2026-03-16
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Existing configurable digital I/O modules cannot diagnose channel faults in real time during operation, and adding dedicated diagnostic circuits or occupying additional I/O resources will increase hardware complexity and cost.

Method used

By applying diagnostic stimuli in different operating modes using a microcontroller, and using an input acquisition unit to monitor the port status in real time, faults are determined by combining counters and thresholds, thus achieving short-circuit protection and non-disruptive diagnosis.

Benefits of technology

It enables real-time diagnosis of channel faults, rapid identification of short circuit types, and electrical isolation during faults to prevent equipment damage, without affecting normal input signal acquisition, without requiring additional hardware or I/O resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122172690A_ABST
    Figure CN122172690A_ABST
Patent Text Reader

Abstract

This invention relates to the field of industrial automation, specifically to a configurable digital input / output method and system with short-circuit protection and interference-free diagnostics. It includes an interconnected microcontroller and configurable channels. Each channel includes an output driver unit and an input acquisition unit, with the output terminal of the output driver unit and the input terminal of the input acquisition unit connected to the same physical port within a circuit board. The microcontroller is configured to perform the following: determine diagnostic excitation based on the channel's operating mode; acquire the actual voltage state of the corresponding physical port under the diagnostic excitation through the input acquisition unit to obtain a port readback value; and compare the port readback value with the expected logic value corresponding to the diagnostic excitation to generate a channel fault determination result. No modifications are made to the existing hardware structure of configurable digital input / output channels; the diagnostic and protection functions are implemented solely through the microcontroller's internal software logic.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of industrial automation, and specifically to a configurable digital input / output method and system with short-circuit protection and interference-free diagnostics. Background Technology

[0002] In the current field of industrial automation, configurable digital I / O modules are widely used to save space, reduce costs, and improve configuration flexibility. Each channel of these modules can be configured by software as a DI (for connecting sensors, such as photoelectric switches and buttons) or a DO (for driving actuators, such as relays and indicator lights). A typical design involves the DI sampling circuit front end and the DO drive circuit output end of the same channel being physically connected on the PCB board via diodes or switching circuits, ultimately leading to the same external terminal block.

[0003] In traditional applications, once the circuit is statically configured for DI or DO functions, it operates as a single function. It cannot diagnose faults in the channel (such as the driver chip, sampling resistor, optocoupler, wiring, load, etc.) in real time during system operation. To implement diagnostic functionality, additional dedicated diagnostic circuitry (such as additional comparators, reference sources, and signal readback paths) is typically required, increasing hardware complexity and material costs. Another diagnostic approach is to use additional I / O points on the controller to monitor the current channel status, but this wastes valuable system I / O resources and is unsuitable for high-density I / O applications.

[0004] Therefore, there is an urgent need for a solution that can effectively diagnose configurable digital I / O circuits without adding hardware or consuming additional I / O resources. Summary of the Invention

[0005] The purpose of this invention is to provide a configurable digital input / output method and system with short-circuit protection and interference-free diagnostics, which solves the problems in the prior art.

[0006] This invention is achieved through the following technical solution:

[0007] In a first aspect, embodiments of the present invention provide a configurable digital input / output method with short-circuit protection and interference-free diagnostics, applied to a configurable digital input / output system with short-circuit protection and interference-free diagnostics. The system includes a microcontroller and configurable channels interconnected. Each channel includes an output driving unit and an input acquisition unit, and the output terminal of the output driving unit and the input terminal of the input acquisition unit are connected to the same physical port inside a circuit board. The microcontroller is configured to execute the method.

[0008] The diagnostic stimulus is determined based on the channel's operating mode. When the operating mode is output mode, an output drive command is used as the diagnostic stimulus. When the operating mode is input mode, a preset diagnostic test pulse is applied to the physical port through the output drive unit as the diagnostic stimulus.

[0009] The actual voltage state of the corresponding physical port under the diagnostic excitation is acquired by the input acquisition unit to obtain the port readback value;

[0010] The port readback value is compared with the expected logic value corresponding to the diagnostic stimulus to generate a channel fault determination result.

[0011] Preferably, the step of comparing the port readback value with the expected logic value corresponding to the diagnostic stimulus to generate a channel fault determination result includes:

[0012] In output mode, the output drive command and the port readback value are continuously compared. When the output drive command and the port readback value are inconsistent, a counter is started to accumulate the number of consecutive cycles of inconsistency, and the accumulated value of the counter is obtained.

[0013] If the cumulative value of the counter reaches a preset threshold, a fault is determined to have occurred.

[0014] Fault type identification is performed based on the comparison results between the output drive command and the port readback value.

[0015] Preferably, the fault type identification based on the comparison result between the output drive command and the port readback value includes:

[0016] If the port readback value is low when the output drive command is high, it is determined to be a short circuit to ground fault.

[0017] If the port readback value is high when the output drive command is low, it is determined to be a short circuit fault in the power supply.

[0018] Preferably, the method further includes:

[0019] When a fault is detected, the physical port is set to a high-impedance state by the output drive unit, and the corresponding fault code is generated and reported.

[0020] Preferably, the diagnostic test pulse includes a high-level diagnostic test pulse and a low-level diagnostic test pulse, and the step of comparing the port readback value with the expected logic value corresponding to the diagnostic stimulus to generate a channel fault determination result includes:

[0021] In input mode, the currently acquired external input signal value is recorded as a reference value;

[0022] The output driving unit sequentially applies high-level diagnostic test pulses and low-level diagnostic test pulses to the physical port, and immediately after each pulse ends, the input acquisition unit acquires the port readback value to obtain the high-level test value and low-level test value respectively.

[0023] The high-level test value is compared with a first threshold, and the low-level test value is compared with a second threshold to generate a channel fault determination result.

[0024] Preferably, after each diagnostic test pulse is executed and the port is switched back to input mode, the status of the physical port is continuously acquired, and the reference value is restored based on the acquired port readback value to confirm that the external signal connection has not been changed due to the diagnostic pulse;

[0025] Based on the confirmation results, complete the diagnostic process.

[0026] Preferably, the step of comparing the high-level test value with a first threshold and the low-level test value with a second threshold to generate a channel fault determination result includes:

[0027] If the high-level test value is higher than the first threshold and the low-level test value is lower than the second threshold, the channel fault determination result is that the input acquisition unit is functioning normally.

[0028] If the high-level test value is not higher than the first threshold or the low-level test value is not lower than the second threshold, the channel fault determination result is that the input acquisition unit is malfunctioning.

[0029] Preferably, the system includes multiple configurable channels, and the method further includes:

[0030] Perform time-division scanning on multiple channels, sequentially collect port readback values ​​for each channel, and generate fault determination results for each channel;

[0031] The fault status of each channel is summarized in the status register.

[0032] Preferably, during the diagnostic process in output mode, the state changes of the output drive command are monitored. If a jump in the output drive command is detected, the current diagnostic process is stopped, the counter used for fault determination is reset, and the output drive command after the jump is executed.

[0033] Secondly, embodiments of the present invention provide a configurable digital input / output system with short-circuit protection and interference-free diagnostics, including interconnected microcontrollers and configurable channels. Each channel includes an output driving unit and an input acquisition unit, and the output terminal of the output driving unit and the input terminal of the input acquisition unit are connected to the same physical port inside a circuit board. The microcontroller includes:

[0034] The diagnostic stimulus module is used to determine the diagnostic stimulus according to the working mode of the channel. When the working mode is output mode, the output drive command is used as the diagnostic stimulus; when the working mode is input mode, a preset diagnostic test pulse is applied to the physical port through the output drive unit as the diagnostic stimulus.

[0035] The voltage status module is used to acquire the actual voltage status of the corresponding physical port under the diagnostic excitation through the input acquisition unit, and obtain the port readback value.

[0036] The fault determination module is used to compare the port readback value with the expected logic value corresponding to the diagnostic stimulus to generate a channel fault determination result.

[0037] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0038] A closed-loop monitoring mechanism based on software logic is constructed by using an input acquisition unit to read back the execution results of the output drive commands in real time. When there is a persistent inconsistency between the output drive command and the port readback value, the microcontroller can determine that a short circuit or overload fault has occurred in the channel and immediately set the physical port to a high-impedance state. The response speed of this protection action is determined by the sampling period and the counter threshold, which is faster than the physical melting or resistance change speed of traditional fuses or polymer positive temperature coefficient thermistors, and does not require additional current detection elements or comparator circuits. After the protection action is executed, the faulty channel is electrically isolated and the fault current is cut off, which can effectively prevent damage to printed circuit board traces, drive devices, or external connected equipment due to continuous overcurrent. At the same time, based on the correspondence between the output command and the readback value, the microcontroller can distinguish between two fault types: short circuit to ground and short circuit to power supply, providing a direct basis for fault location.

[0039] In input mode, proactive self-testing of the input acquisition path is achieved by temporarily applying diagnostic test pulses, and the diagnostic process is transparent to the application layer. Before diagnostics begin, the microcontroller records a reference value for the external input signal. During and after the application of high-level and low-level pulses, it continuously reports this reference value to the application layer, ensuring that the input data stream received by the application layer remains continuous and stable, unaffected by instantaneous changes in port voltage. After the diagnostic pulse ends, continuous acquisition of the port status and verification that it has returned to the reference value confirms that the external connection has not changed due to the diagnostic process. This mechanism achieves spatiotemporal separation between background self-diagnosis and foreground signal acquisition, enabling comprehensive verification of the high / low level recognition capability of the input acquisition unit without interrupting normal input sampling. Attached Figure Description

[0040] To more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of the present invention and should not be considered as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort. In the drawings:

[0041] Figure 1 This is a flowchart illustrating the configurable digital input / output method with short-circuit protection and interference-free diagnostics provided by the present invention.

[0042] Figure 2 This is a flowchart of the DO-driven mode self-diagnosis process provided by the present invention.

[0043] Figure 3 This is a flowchart of the self-diagnosis process for the DI acquisition mode provided by the present invention;

[0044] Figure 4 Example circuit block diagram of a configurable digital input / output system with short-circuit protection and interference-free diagnostics provided by the present invention;

[0045] Figure 5 This is a timing diagram for the self-diagnostic function of the DO output mode provided by the present invention;

[0046] Figure 6 This is a timing diagram for the self-diagnostic function of the DI acquisition mode provided by the present invention;

[0047] Figure 7 This is a schematic diagram of multi-channel diagnostic management provided by the present invention. Detailed Implementation

[0048] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the embodiments and accompanying drawings. The illustrative embodiments and descriptions of this invention are only for explaining this invention and are not intended to limit this invention.

[0049] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes said element.

[0050] It should be noted that all actions involving the acquisition of signals, information, or data in this invention are carried out in compliance with the relevant data protection laws and regulations of the locality and with authorization from the owner of the relevant device.

[0051] Example 1

[0052] Please see Figure 1 This invention provides a configurable digital input / output method with short-circuit protection and interference-free diagnostics, applied to a configurable digital input / output system with short-circuit protection and interference-free diagnostics. The system includes interconnected microcontrollers and configurable channels. Each channel includes an output driving unit and an input acquisition unit, and the output terminal of the output driving unit and the input terminal of the input acquisition unit are connected to the same physical port inside the circuit board. The microcontroller is configured to execute the method.

[0053] S1. Determine the diagnostic stimulus according to the working mode of the channel. When the working mode is output mode, the output drive command is used as the diagnostic stimulus. When the working mode is input mode, a preset diagnostic test pulse is applied to the physical port through the output drive unit as the diagnostic stimulus.

[0054] Specifically, diagnostic stimulus refers to the stimulus signal used to trigger channel self-diagnosis. In output mode, the output drive command itself constitutes the diagnostic stimulus, and the diagnostic process uses the channel's existing output behavior to verify the circuit's health status. In input mode, since the channel itself does not actively generate signals, the diagnostic stimulus is manifested as a preset diagnostic test pulse actively injected into the physical port by the output drive unit. The voltage amplitude, pulse width, and other parameters of this pulse can be predefined according to the actual circuit type, and its function is to provide a known test signal source for the input acquisition unit.

[0055] Based on the channel's hardware connection characteristics, the output driver unit and the input acquisition unit are shorted to the same physical port inside the circuit board. With this structure, when the channel is in output mode, the output drive command directly acts on the physical port. At this time, by using the input acquisition unit to read back the port status, real-time monitoring of the output path can be achieved. When the channel is in input mode, although the channel is configured to receive external signals, by temporarily using the output driver unit as a signal generator to apply a brief diagnostic test pulse with a known amplitude to the port, a test benchmark for self-verification can be provided to the input acquisition unit without affecting the long-term state of the external signal.

[0056] S2. The actual voltage state of the corresponding physical port under the diagnostic excitation is acquired by the input acquisition unit to obtain the port readback value;

[0057] Specifically, the port readback value refers to the voltage logic state actually acquired from the physical port by the input acquisition unit during or after the application of diagnostic excitation. This value is the direct basis for determining whether the channel is working properly, reflecting the actual response result presented on the physical port after the output drive command or diagnostic test pulse passes through the entire channel hardware link (including the drive unit, connection lines, and input acquisition unit).

[0058] In output mode, when an output drive command is applied to the port, the input acquisition unit continuously monitors the port voltage. Theoretically, this readback value should match the output drive command. In input mode, when a diagnostic test pulse is applied to the port, the input acquisition unit immediately acquires the port voltage at the instant the pulse is applied. This readback value should reflect the expected logic level of the pulse. By acquiring the port readback value, the microcontroller obtains measured data corresponding to the diagnostic stimulus, providing the initial basis for subsequent comparison and judgment.

[0059] S3. Compare the port readback value with the expected logic value corresponding to the diagnostic stimulus to generate a channel fault determination result.

[0060] Specifically, the expected logic value refers to the logical state that the port readback value should present under completely normal channel hardware conditions, corresponding to the current diagnostic stimulus. For output drive instructions in output mode, the expected logic value is the logic level of the instruction itself; for diagnostic test pulses in input mode, the expected logic value is the logic level that the pulse is designed to apply. The channel fault determination result is a conclusion based on comparison, used to characterize whether a channel fault exists and the possible types of faults.

[0061] After a diagnostic stimulus is applied, the port should theoretically present a matching logic state. The port readback value serves as the actual measurement result. If it matches the expected logic value, it indicates that the entire path from the stimulus application point to the readback point is functioning correctly. If they do not match, it indicates an anomaly in the path, such as a failure of the output driver unit, a short circuit or open circuit, or a fault in the input acquisition unit. The microcontroller executes this comparison logic, successively comparing the measured value with the theoretical value, thereby achieving real-time diagnosis of the channel's health status and triggering subsequent response actions based on the diagnostic results.

[0062] In some implementations, S3 involves comparing the port readback value with the expected logic value corresponding to the diagnostic stimulus to generate a channel fault determination result, including:

[0063] In output mode, the output drive command and the port readback value are continuously compared. When the output drive command and the port readback value are inconsistent, a counter is started to accumulate the number of consecutive cycles of inconsistency, and the accumulated value of the counter is obtained.

[0064] Specifically, the output drive command is a logic level control signal sent by the microcontroller to the output drive unit to set the desired output state of the physical port. The port readback value is the voltage logic state actually acquired from the same physical port by the input acquisition unit. Since the output terminal of the output drive unit and the input terminal of the input acquisition unit are shorted to the same physical port inside the circuit board, the port readback value should theoretically be consistent with the output drive command after the output drive command is applied. When the two are inconsistent, it indicates that the actual voltage state of the physical port deviates from the expectation, which may be caused by short circuit, overload, or drive unit failure. To avoid misjudging transient interference as permanent fault, a counter is introduced to continuously monitor the inconsistent state. By accumulating the number of cycles of the inconsistent state, a counter accumulation value reflecting the duration of the abnormality is obtained.

[0065] If the cumulative value of the counter reaches a preset threshold, a fault is determined to have occurred.

[0066] Specifically, the preset threshold is a pre-defined upper limit for the counter's accumulated value, used to distinguish between transient interference and persistent faults. In industrial environments, factors such as electromagnetic interference and contact jitter can cause brief fluctuations in port voltage. If a fault is immediately determined upon detecting an inconsistency, it may trigger false protection actions. By setting a threshold and requiring the inconsistent state to persist for that duration, transient interference can be effectively filtered out. When the counter's accumulated value reaches the preset threshold, it indicates that the inconsistent state has lasted long enough to be confirmed as a genuine fault. At this point, a channel fault is determined, providing a basis for subsequent fault type identification and protection actions.

[0067] Fault type identification is performed based on the comparison results between the output drive command and the port readback value.

[0068] Specifically, fault type identification is the process of inferring the specific manifestation of a fault based on the correspondence between the logic level of the output drive command and the actual level of the port readback value. Physical port faults typically include two basic types: short circuit to ground and short circuit to power supply. When the output drive command is high and the port readback value is low, it indicates that the high-level output is forcibly pulled low, consistent with a short circuit to ground. When the output drive command is low and the port readback value is high, it indicates that the low-level output is forcibly pulled high, consistent with a short circuit to power supply. By identifying the fault type, the microcontroller can generate more targeted fault codes, providing maintenance personnel with accurate fault location information and also providing a basis for subsequent protection actions, such as taking appropriate shutdown measures when a short circuit to ground is determined.

[0069] In some implementations, the fault type identification based on the comparison result between the output drive command and the port readback value includes:

[0070] If the port readback value is low when the output drive command is high, it is determined to be a short circuit to ground fault.

[0071] Specifically, a high-level output drive command means the microcontroller controls the output drive unit to output a high-voltage logic level to the physical port, such as the 24-volt high-level active system commonly used in industrial applications. A low-level port readback value means the actual voltage state acquired by the input acquisition unit from the same physical port is a low-voltage logic level. In a hardware structure where the output drive unit and the input acquisition unit are shorted to the same physical port, a high-level output command should cause the port to be in a high-level state. If the readback value remains low, it indicates that the high-level output of the port has been forcibly pulled low to the low-level region by an external circuit. A typical cause of this phenomenon is a short circuit between the physical port's external connection line and ground or the negative terminal of the power supply, causing the current provided by the output drive unit to flow directly to ground, making it impossible to maintain the port voltage in the high-level range. Through this comparison, the microcontroller can identify a short-circuit fault to ground in the channel.

[0072] If the port readback value is high when the output drive command is low, it is determined to be a short circuit fault in the power supply.

[0073] Specifically, a low-level output drive command means the microcontroller controls the output drive unit to output a low-voltage logic level to the physical port, such as zero volts or the common negative terminal in industrial applications. A high-level port readback value means the actual voltage state acquired by the input acquisition unit from the same physical port is a high-voltage logic level. Under the action of the low-level output command, the physical port should be in a low-level state. If the readback value remains high at this time, it indicates that the low-level output of the port is forcibly pulled high to the high-level region by the external circuit. A typical cause of this phenomenon is a short circuit between the physical port and the external connection line to the positive terminal of the power supply, causing the external power supply voltage to be directly applied to the port, exceeding the ability of the output drive unit to maintain a low level, resulting in the port voltage being boosted. Through this comparison result, the microcontroller can identify that the channel has experienced a power supply short-circuit type fault.

[0074] By judging the results of the two comparisons mentioned above, the microcontroller can not only detect the existence of a fault, but also distinguish the specific manifestation of the fault. This fault type identification capability provides a basis for differentiated protection actions. For example, the same shutdown protection measures can be taken for short circuits to ground and short circuits to power supply, but a specific fault type code can be attached when reporting the fault information, so that the host computer or maintenance personnel can accurately know the nature of the fault, thereby shortening the fault troubleshooting time.

[0075] In some embodiments, the method further includes:

[0076] When a fault is detected, the physical port is set to a high-impedance state by the output drive unit, and the corresponding fault code is generated and reported.

[0077] Specifically, a high-impedance state refers to a connection between the output drive unit and the physical port exhibiting high impedance. In this state, the output drive unit no longer actively applies voltage or current to the port, effectively disconnecting it from the external load electrically. Setting the physical port to a high-impedance state is an active protection measure that cuts off the path of fault current, preventing continuous short circuits or overloads from causing thermal or electrical damage to the output drive unit, printed circuit board traces, or external connected devices.

[0078] In output mode, when the microcontroller determines a channel fault after the aforementioned debouncing verification and fault type identification, it immediately executes a protection action. The microcontroller controls the enable terminal of the output driver unit or the output control register to put its output stage into a high-impedance mode. For driver units using a push-pull output structure, the high-impedance state means that both the upper and lower driver transistors are turned off simultaneously; for driver units using open-collector or open-drain outputs, the high-impedance state means that the output transistor is turned off. Regardless of the specific circuit implementation, their common feature is that the physical port is no longer actively driven, and the external short-circuit current disappears.

[0079] Fault codes are numerical codes or status flags corresponding to specific fault types, used to convey fault information to upper-level systems or maintenance personnel. When the microcontroller sets a port to a high-impedance state, it selects the corresponding code from a predefined fault code table based on the previously identified fault type. If the fault is determined to be a short circuit to ground, a short circuit to ground fault code is generated; if the fault is determined to be a short circuit to power supply, a short circuit to power supply fault code is generated. This fault code can be stored in the channel status register for querying by the system's main controller, or actively reported to a host computer, human-machine interface, or remote monitoring system via the communication interface.

[0080] The significance of generating and reporting fault codes lies in enabling the visualization and traceability of faults. While protective actions can prevent hardware damage, without feedback on fault information, maintenance personnel cannot know which channel was shut down and for what reason, and troubleshooting still requires point-by-point measurement using external instruments. By reporting specific fault codes, the system can directly provide fault location and fault nature information, shortening downtime and improving maintainability. Simultaneously, this fault information can also be recorded in the system log for subsequent fault analysis and equipment health management.

[0081] For example, such as Figure 2 As shown, the short-circuit / overload diagnosis and protection process in DO output mode can be as follows:

[0082] Normal operation: The port is configured as DO, outputting the target level (high / low). The DI circuit continuously samples the port voltage at a fixed scan period (e.g., 1ms).

[0083] Fault determination: The diagnostic logic unit continuously compares the DO output command with the DI retrieval value. When the DI retrieval value is found to be inconsistent with the DO output command, and this state continues for more than the preset "anti-jitter time" (e.g., 2-3 scan cycles), a fault is determined to have occurred.

[0084] Fault type differentiation:

[0085] If the DO command outputs "high" while the DI feedback remains "low", it indicates a "short circuit to ground" or "severe overload". In this case, the port voltage is forcibly pulled low by the external load.

[0086] If the DO command outputs "low" while the DI feedback remains "high", it indicates a "short circuit to the power supply" or "power supply backflow". In this case, the port voltage is forcibly pulled high by the external power supply.

[0087] Protection Action: Once a fault is detected, the diagnostic logic unit immediately sends a shutdown command to the DO drive circuit, causing the port to enter a high-impedance state, cutting off the fault current, and preventing hardware damage. At the same time, the specific fault code (such as "Channel X short circuit to ground") is reported.

[0088] It achieves the function of electronic fuse with fault type identification at zero hardware cost, and the response speed is much faster than that of one-time fuse.

[0089] In some implementations, S3, the diagnostic test pulse includes a high-level diagnostic test pulse and a low-level diagnostic test pulse. The step of comparing the port readback value with the expected logic value corresponding to the diagnostic stimulus to generate a channel fault determination result includes:

[0090] In input mode, the currently acquired external input signal value is recorded as a reference value;

[0091] Specifically, the baseline value refers to the stable external input signal logic state provided by external sensors or switching devices, acquired by the input acquisition unit from the physical port before diagnostic testing. Since the diagnostic process requires actively applying test pulses to the port, and the injection of these pulses temporarily alters the port state, to avoid the diagnostic activity affecting the system's normal perception of external signals, the currently valid external signal value must be recorded before diagnostics begin. This baseline value represents the actual input information transmitted by the external device and will serve as a substitute source of application layer data during diagnostics.

[0092] The output driving unit sequentially applies high-level diagnostic test pulses and low-level diagnostic test pulses to the physical port, and immediately after each pulse ends, the input acquisition unit acquires the port readback value to obtain the high-level test value and low-level test value respectively.

[0093] Specifically, a high-level diagnostic test pulse refers to a very short-duration high-voltage logic level signal applied to the physical port through the output driver unit. A low-level diagnostic test pulse refers to a very short-duration low-voltage logic level signal applied to the physical port. The two pulses are applied sequentially, and their order can be determined according to the system design. After each pulse ends, the port is immediately switched back to input mode, and the input acquisition unit then acquires the port voltage state at the instant the pulse is applied. The high-level test value refers to the port readback value acquired after the high-level pulse ends, used to verify the input acquisition unit's ability to recognize high-level signals. The low-level test value refers to the port readback value acquired after the low-level pulse ends, used to verify the input acquisition unit's ability to recognize low-level signals.

[0094] The high-level test value is compared with a first threshold, and the low-level test value is compared with a second threshold to generate a channel fault determination result.

[0095] Specifically, the first threshold is a voltage reference limit used to determine whether a high-level signal is valid, typically set as the lower limit of the high-level recognition range of the input acquisition unit. The second threshold is a voltage reference limit used to determine whether a low-level signal is valid, typically set as the upper limit of the low-level recognition range of the input acquisition unit. A high-level test value higher than the first threshold indicates that the input acquisition unit can correctly recognize a high-level pulse signal, and the input path processes high-level signals without abnormalities. A low-level test value lower than the second threshold indicates that the input acquisition unit can correctly recognize a low-level pulse signal, and the input path processes low-level signals without abnormalities. Only when both test values ​​simultaneously meet their respective threshold conditions is the overall function of the input acquisition unit considered normal, indicating that the entire path from the driver unit output through the physical port to the input acquisition unit can correctly transmit and recognize the two logic levels.

[0096] In some implementations, after each diagnostic test pulse is executed and the port is switched back to input mode, the status of the physical port is continuously collected, and the reference value is restored based on the collected port readback value to confirm that the external signal connection has not been changed due to the diagnostic pulse.

[0097] Specifically, continuous acquisition of the physical port status refers to the input acquisition unit repeatedly acquiring the port voltage at a preset sampling period after the port is restored to input mode. Since the external input signal may be driven by mechanical contacts or sensor circuits, its state is relatively stable during normal operation. However, the brief injection of a diagnostic test pulse may cause slight disturbances to the external circuitry. By continuously acquiring the port status multiple times, it can be observed whether the port voltage quickly recovers to the external input signal value recorded before diagnosis after the pulse ends. Recovery to the reference value means that the continuously acquired port readback values ​​are consistent with the reference value recorded before the diagnosis began, indicating that the state of the external signal source did not actually change during the diagnosis process, and that the external circuitry was not damaged or altered in its operating state due to the pulse injection. Confirming that the external signal connection was not changed by the diagnostic pulse is to verify that the diagnostic process itself did not adversely affect the field equipment, ensuring the non-invasiveness of the diagnostic procedure.

[0098] Based on the confirmation results, complete the diagnostic process.

[0099] Specifically, completing the diagnostic process means ending the current diagnostic cycle and returning the channel to normal input acquisition status after confirming that the external signal connection has been restored. The confirmation result refers to the verification conclusion that the external signal has returned to the baseline value. This conclusion indicates that the application of the diagnostic pulse did not have a lasting impact on the external device, and the port has correctly reflected the true state of the external input signal again. Based on this confirmation result, the microcontroller can safely exit the diagnostic mode, and subsequent input acquisition values ​​can be directly used for application layer data updates. If, during the confirmation process, the port state cannot be restored to the baseline value, it indicates a possible secondary fault such as a loose external connection, device malfunction, or channel hardware damage. In this case, the corresponding fault handling mechanism can be triggered. Completing the diagnostic process marks the end of a complete input mode self-diagnosis, preparing for the next periodic or on-demand triggered diagnosis.

[0100] In some embodiments, comparing the high-level test value with a first threshold and comparing the low-level test value with a second threshold to generate a channel fault determination result includes:

[0101] If the high-level test value is higher than the first threshold and the low-level test value is lower than the second threshold, the channel fault determination result is that the input acquisition unit is functioning normally.

[0102] If the high-level test value is not higher than the first threshold or the low-level test value is not lower than the second threshold, the channel fault determination result is that the input acquisition unit is malfunctioning.

[0103] For example, such as Figure 3 As shown, the non-intrusive self-diagnostic process in DI input mode can be as follows:

[0104] Normal operation: The port is configured as DI and continuously scans for external signals. It records the current stable external signal value V_external.

[0105] Diagnostic trigger: Diagnostics are initiated when the system is idle or during a set maintenance cycle.

[0106] Non-intrusive diagnostic execution:

[0107] A. High-level injection test: Temporarily configure the port as DO, outputting a very short high-level pulse, and then immediately switch back to DI mode. Read the DI value V_high at this time. Ideally, V_high should be high.

[0108] B. Result Storage and Recovery: V_high is not reported immediately. After the port resumes DI mode, due to the influence of external circuitry, the DI sample value will quickly recover to the external signal V_external. The diagnostic logic verifies whether the value read at this time is V_external to ensure that the external connection has been restored.

[0109] C. Low-level injection test: Similarly, temporarily output a very short low-level pulse, switch back to DI, and read V_low. Ideally, it should be low.

[0110] D. Diagnostic Decision: Internally compare whether V_high is high and whether V_low is low. If both are correct, the DI acquisition circuit is deemed to be functioning correctly. Throughout the diagnostic process, the value reported to the upper-layer application remains V_external and is unaffected by diagnostic pulse interference.

[0111] It achieves background self-testing that is transparent to the application layer, so users are completely unaware of the diagnostic process. Signal acquisition is uninterrupted and does not jump, meeting the requirements of high reliability applications.

[0112] In some embodiments, the system includes multiple configurable channels, and the method further includes:

[0113] Perform time-division scanning on multiple channels, sequentially collect port readback values ​​for each channel, and generate fault determination results for each channel;

[0114] Specifically, time-sharing scanning refers to the microcontroller dividing the diagnostic task into multiple time slices, with each time slice performing port readback value acquisition and fault determination operations only for one channel. Since there are multiple configurable channels in the system, simultaneously diagnosing all channels could cause instantaneous overload of the microcontroller's processing resources or a sudden power surge. With time-sharing scanning, the microcontroller accesses each channel sequentially, completing acquisition and determination on one channel before switching to the next. Sequentially acquiring the port readback values ​​of each channel means reading the voltage status of the current physical port from the input acquisition unit of each channel one by one according to a predetermined channel order. Generating the fault determination results for each channel involves combining the port readback values ​​acquired for each channel with the channel's current operating mode and diagnostic stimulus, executing the aforementioned comparison logic, and determining whether a fault exists in each channel and the type of fault. The time-sharing scanning mechanism ensures the orderly execution of diagnostic tasks in a multi-channel environment, avoids resource conflicts, and evenly distributes the diagnostic load across the time axis.

[0115] The fault status of each channel is summarized in the status register.

[0116] Specifically, a status register is a set of storage units within the microcontroller's internal or external memory specifically used to centrally store fault information for each channel. This register is typically organized using a bit-mapped method, with each bit corresponding to a specific fault state of a channel, or each channel is allocated an independent fault code storage area. Summarizing the fault states of each channel into the status register means that after the microcontroller completes the fault determination for each channel, it writes the determination result into the corresponding channel's fault flag bit or fault code field in the status register. Through the status register, system software, host computers, or maintenance personnel can obtain a fault overview of all channels through a single read operation, without needing to query each channel individually. The status register can be read periodically or by event triggering, and its contents can also be uploaded to a remote monitoring system via a communication interface, enabling centralized management of the overall health status of multi-channel devices.

[0117] In some implementations, during the diagnostic process in output mode, the state changes of the output drive command are monitored. If a jump in the output drive command is detected, the current diagnostic process is stopped, the counter used for fault determination is reset, and the output drive command after the jump is executed.

[0118] Specifically, monitoring the state changes of output drive commands refers to the microcontroller continuously monitoring whether the logic level of the output drive commands changes during fault diagnosis in output mode. Output drive commands are generated by the system application layer or control logic, and their transitions may originate from host computer commands, control algorithm outputs, or user operations. The diagnostic process typically involves multiple sampling cycles, during which the microcontroller continuously compares the output drive commands with port readback values ​​and uses a counter to accumulate the duration of inconsistent states.

[0119] The termination of the current diagnostic process upon detecting a transition in the output drive command means that the microcontroller immediately pauses the ongoing fault diagnosis task once it recognizes that the logic level of the output drive command has changed from high to low or from low to high. Termination of the diagnostic process includes stopping the current port readback value acquisition, stopping the counter accumulation, and pausing the execution of the fault determination logic. This is because a transition in the output drive command signifies a change in the expected output state of the channel, rendering previous fault determinations based on the old command meaningless. Continuing to compare based on the old command would produce invalid diagnostic results.

[0120] The counter used for fault determination during reset refers to the microcontroller resetting the counter used to accumulate the duration of inconsistency to zero, returning it to its initial state. This counter originally recorded the number of cycles in which the output drive command and the port readback value were inconsistent, used to distinguish between transient interference and genuine faults. When the output drive command changes, the original inconsistency record should be cleared to avoid confusing the inconsistency time spanning different states before and after the command change, leading to misjudgment.

[0121] Executing the output drive instruction after the transition means that the microcontroller controls the output drive unit to output the corresponding logic level to the physical port according to the new output drive instruction. After aborting the diagnostic process and resetting the counter, the channel should respond to the new output instruction first to ensure that the real-time performance of the control function is not affected by the diagnostic task. After the new output drive instruction is executed, the microcontroller can restart the diagnostic process based on the new instruction in subsequent sampling cycles. This mechanism ensures that the diagnostic function does not interfere with normal output control and maintains the system's response speed and reliability in scenarios where the output instruction changes dynamically.

[0122] Example 2

[0123] This invention provides a configurable digital input / output system with short-circuit protection and interference-free diagnostics, including interconnected microcontrollers and configurable channels. Each channel includes an output driving unit and an input acquisition unit, with the output terminal of the output driving unit and the input terminal of the input acquisition unit connected to the same physical port inside the circuit board. The microcontroller includes:

[0124] The diagnostic stimulus module is used to determine the diagnostic stimulus according to the working mode of the channel. When the working mode is output mode, the output drive command is used as the diagnostic stimulus; when the working mode is input mode, a preset diagnostic test pulse is applied to the physical port through the output drive unit as the diagnostic stimulus.

[0125] The voltage status module is used to acquire the actual voltage status of the corresponding physical port under the diagnostic excitation through the input acquisition unit, and obtain the port readback value.

[0126] The fault determination module is used to compare the port readback value with the expected logic value corresponding to the diagnostic stimulus to generate a channel fault determination result.

[0127] For example, such as Figure 4 The diagram shows the circuit block diagram of a configurable digital input / output system with short-circuit protection and interference-free diagnostics, including: a microcontroller (MCU), a DO driver unit, a DI sampling unit, and a common port (Port).

[0128] The MCU’s two GPIO pins are connected to the DO path and the DI path, respectively.

[0129] DO path: Connected to the DO driver unit. The DO driver unit typically contains a driver chip (such as ULN2003, MOSFET) and necessary protection circuitry (such as freewheeling diode, TVS diode), and its final output is DO_OUT.

[0130] DI path: Connected to the DI sampling unit. The DI sampling unit typically contains an optocoupler isolator, Schmitt trigger, or buffer, and its output is DI_IN to the MCU.

[0131] Key connectivity features: The DO_OUT and DI sampling unit inputs are shorted on the PCB via circuit traces, connecting together to a physical port for connecting external sensors or actuators. The DO drive unit and DI sampling unit can be PNP type (input / output active level is high) or NPN type (input / output active level is low).

[0132] Based on this hardware, the diagnostic and protection logic is implemented in the MCU software, and the specific steps are as follows:

[0133] like Figure 5 The following is Case A: Short-circuit diagnosis and protection in DO output mode.

[0134] Scenario: The port is configured in DO mode, normally outputting a high level (24V) to drive a relay coil.

[0135] Step 1: Initial state. If the MCU controls the DO driver unit to output a high level (DO_OUT=1), the DI path is ignored, and the port voltage is high.

[0136] Step 2: Continuous monitoring. The MCU executes diagnostic routines at fixed intervals T (e.g., 1ms). In each interval T:

[0137] The MCU maintains the current output through the DO enable signal IO.

[0138] The MCU reads the value DI_IN of the DI sampling unit through the DI sampling signal IO.

[0139] Step 3: Fault diagnosis. The MCU compares the DO output instruction (1) with the DI sampled value.

[0140] If DI_IN is also 1, then the path is normal and output continues.

[0141] If DI_IN is 0, then the "inconsistency counter" is started.

[0142] Step 4: Fault Confirmation and Protection. If the "Inconsistency Counter" accumulates to N within N consecutive cycles (e.g., 3 cycles, or 3ms), it is determined to be a permanent fault. MCU executes:

[0143] Fault type identification: Because the command is "1" but the sampled value is "0", it is determined to be "short circuit to ground".

[0144] Protection action: The MCU sends a "disable" signal to the DO drive unit, or sets the DO output to a high impedance state through the switch selection unit to cut off the current.

[0145] Fault reporting: The MCU sends fault codes to the host computer through communication interfaces (such as UART, CAN), such as "CH1_SHORT_TO_GND".

[0146] Abort Diagnosis: If a control signal causes the DO output to change during the diagnosis period, such as from low to high or from high to low, the diagnosis will be aborted and the DO command of the control signal will be executed immediately.

[0147] like Figure 6 The following is Case B: Unobtrusive self-diagnosis in DI input mode.

[0148] Scenario: The port is configured in DI mode to acquire the signal of a normally open button (normally, the external pull-up resistor keeps the port at a high level).

[0149] Step 1: Normal Sampling. The MCU controls the DI sampling unit to continuously monitor the port voltage. The MCU reads a stable DI_IN=1 and reports it as a valid value V_ext to the application layer.

[0150] Step 2: Trigger diagnostics. The system triggers background diagnostics when idle or at regular intervals (e.g., every minute).

[0151] Step 3: Low-level test.

[0152] The MCU records the current reported value V_ext=1.

[0153] The MCU controls the DO driver unit to output a low-level pulse (e.g., lasting 0.5ms). Note: The output here is a test level opposite to the external state, to rigorously test the DI's "0" acquisition capability.

[0154] After the pulse ends, the MCU immediately switches the switch back to the DI path and reads the value of DI_IN, which is recorded as V_test_low. It should be 0 as expected.

[0155] Step 4: High-level test.

[0156] The MCU controls the DO driver unit to output a high-level pulse (0.5ms) to test the DI's "1" acquisition capability.

[0157] After the pulse ends, switch back to the DI path, read the value of DI_IN, and record it as V_test_high. It should be 1.

[0158] Step 5: Restore Verification. After switching back to DI, the MCU samples several times to confirm that DI_IN has been restored to the external state V_ext=1. This is an important step to ensure that the external connection has not been changed due to the diagnostic pulse.

[0159] Step 6: Diagnostic decision and disturbance-free output.

[0160] The MCU internally determines that if (V_test_low==0)&&(V_test_high==1) is true, then the DI channel function is normal.

[0161] If the judgment fails, the MCU will record the fault in the background or report an abnormal channel health status.

[0162] The key point is that throughout the entire diagnostic process, regardless of the values ​​of V_test_low and V_test_high, the MCU consistently reports V_ext=1 to the upper-layer application. The transient changes caused by the diagnostic pulse are completely transparent to the application layer.

[0163] like Figure 7 The example shown is Case C: Application in an industrial distributed I / O module.

[0164] The module's main controller (such as an ARM Cortex-M) manages multiple channels.

[0165] DO mode diagnostics: The main controller performs time-division scanning of each channel. The DI retrieval time for each channel is extremely short, and its impact on the output duty cycle is negligible (<0.1%). The short-circuit status of all channels can be summarized in a single status register.

[0166] DI mode diagnostics: During communication idle periods (such as the synchronization gap of the PROFINET / EtherCAT communication cycle), the main controller performs non-intrusive self-diagnostics on all channels configured as DI in turn, forming a channel health status table.

[0167] Diagnostic results can be uploaded to the PLC along with fault information via industrial fieldbus (such as PROFINET, EtherCAT, ModbusTCP).

[0168] It should be noted that each module and unit in this embodiment corresponds one-to-one with each step in the configurable digital input / output method with short-circuit protection and interference-free diagnosis in the aforementioned embodiment. Therefore, the specific implementation of this embodiment can refer to the implementation of the aforementioned configurable digital input / output method with short-circuit protection and interference-free diagnosis, and will not be repeated here.

[0169] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0170] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A configurable digital input / output method with short-circuit protection and interference-free diagnostics, characterized in that, A configurable digital input / output system with short-circuit protection and interference-free diagnostics is applied. The system includes interconnected microcontrollers and configurable channels. Each channel includes an output driver unit and an input acquisition unit, and the output terminal of the output driver unit and the input terminal of the input acquisition unit are connected to the same physical port inside the circuit board. The microcontroller is configured to execute the method described above. The diagnostic stimulus is determined based on the channel's operating mode. When the operating mode is output mode, an output drive command is used as the diagnostic stimulus. When the operating mode is input mode, a preset diagnostic test pulse is applied to the physical port through the output drive unit as the diagnostic stimulus. The actual voltage state of the corresponding physical port under the diagnostic excitation is acquired by the input acquisition unit to obtain the port readback value; The port readback value is compared with the expected logic value corresponding to the diagnostic stimulus to generate a channel fault determination result.

2. The method according to claim 1, characterized in that, The step of comparing the port readback value with the expected logic value corresponding to the diagnostic stimulus to generate a channel fault determination result includes: In output mode, the output drive command and the port readback value are continuously compared. When the output drive command and the port readback value are inconsistent, a counter is started to accumulate the number of consecutive cycles of inconsistency, and the accumulated value of the counter is obtained. If the cumulative value of the counter reaches a preset threshold, a fault is determined to have occurred. Fault type identification is performed based on the comparison results between the output drive command and the port readback value.

3. The method according to claim 2, characterized in that, The fault type identification based on the comparison result between the output drive command and the port readback value includes: If the port readback value is low when the output drive command is high, it is determined to be a short circuit to ground fault. If the port readback value is high when the output drive command is low, it is determined to be a short circuit fault in the power supply.

4. The method according to claim 2, characterized in that, The method further includes: When a fault is detected, the physical port is set to a high-impedance state by the output drive unit, and the corresponding fault code is generated and reported.

5. The method according to claim 1, characterized in that, The diagnostic test pulses include high-level diagnostic test pulses and low-level diagnostic test pulses. The step of comparing the port readback value with the expected logic value corresponding to the diagnostic stimulus to generate a channel fault determination result includes: In input mode, the currently acquired external input signal value is recorded as a reference value; The output driving unit sequentially applies high-level diagnostic test pulses and low-level diagnostic test pulses to the physical port, and immediately after each pulse ends, the input acquisition unit acquires the port readback value to obtain the high-level test value and low-level test value respectively. The high-level test value is compared with a first threshold, and the low-level test value is compared with a second threshold to generate a channel fault determination result.

6. The method according to claim 5, characterized in that, After each diagnostic test pulse is executed and the port is switched back to input mode, the status of the physical port is continuously acquired. The port readback value is then restored to the reference value to confirm that the external signal connection has not been changed due to the diagnostic pulse. Based on the confirmation results, complete the diagnostic process.

7. The method according to claim 5, characterized in that, The step of comparing the high-level test value with a first threshold and the low-level test value with a second threshold to generate a channel fault determination result includes: If the high-level test value is higher than the first threshold and the low-level test value is lower than the second threshold, the channel fault determination result is that the input acquisition unit is functioning normally. If the high-level test value is not higher than the first threshold or the low-level test value is not lower than the second threshold, the channel fault determination result is that the input acquisition unit is malfunctioning.

8. The method according to claim 1, characterized in that, The system includes multiple configurable channels, and the method further includes: Perform time-division scanning on multiple channels, sequentially collect port readback values ​​for each channel, and generate fault determination results for each channel; The fault status of each channel is summarized in the status register.

9. The method according to claim 1, characterized in that, During the diagnostic process in output mode, the state changes of the output drive command are monitored. If a jump in the output drive command is detected, the current diagnostic process is stopped, the counter used for fault determination is reset, and the output drive command after the jump is executed.

10. A configurable digital input / output system with short-circuit protection and interference-free diagnostics, characterized in that, The system includes interconnected microcontrollers and configurable channels, each channel comprising an output driver unit and an input acquisition unit, wherein the output of the output driver unit and the input of the input acquisition unit are connected to the same physical port within the circuit board. The microcontroller includes: The diagnostic stimulus module is used to determine the diagnostic stimulus according to the working mode of the channel. When the working mode is output mode, the output drive command is used as the diagnostic stimulus; when the working mode is input mode, a preset diagnostic test pulse is applied to the physical port through the output drive unit as the diagnostic stimulus. The voltage status module is used to acquire the actual voltage status of the corresponding physical port under the diagnostic excitation through the input acquisition unit, and obtain the port readback value. The fault determination module is used to compare the port readback value with the expected logic value corresponding to the diagnostic stimulus to generate a channel fault determination result.