A method and device for identifying and communicating parameters of a plurality of interfaces of an industrial control board
By combining high-impedance sampling and current-limiting detection, the peripheral interface type was gradually confirmed and the communication parameters were verified, thus solving the problem of communication interference under unknown interface types and realizing safe and reliable interface identification and parameter configuration.
Patent Information
- Application Number
- CN202611696741.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-30
- Publication Date
- 2026-11-27
AI Technical Summary
Existing technologies make it difficult to accurately identify and configure communication parameters when the type of peripheral interface is unknown, which may lead to line contention, communication interference or abnormal messages, and active detection carries the risk of misjudgment.
A candidate interface set is formed by high-impedance sampling. Current limiting detection is applied through an independent diagnostic excitation circuit. The candidate interfaces are updated by combining the line response characteristics. The communication transmission path is opened only after the physical interface type is confirmed. The communication parameters are determined and the protocol is verified by using the received signal.
It improves the accuracy and security of identifying unknown peripheral interfaces, reduces the risk of line disturbance, and ensures the reliability and security of communication parameter configuration.
Smart Images

Figure CN123185065A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electronic digital data processing, and in particular to a method and apparatus for multi-interface identification and adaptive configuration of communication parameters for industrial control boards. Background Technology
[0002] When industrial control equipment is connected to external sensors, actuators, or instruments, the external devices may use different communication interfaces, and information such as interface type and communication parameters may not be available in advance. When the industrial control board is directly connected to such unknown peripherals, enabling the corresponding communication transmitter before accurately determining the interface type will apply mismatched levels or drive states to the external lines. For differential buses, this may also cause line contention, communication interference, or abnormal messages, affecting the normal communication of external devices or other nodes on the bus.
[0003] Existing technologies typically detect the voltage, current, signal frequency, pulse width, or waveform characteristics of an external interface, compare the detection results with pre-established interface characteristics to determine the connected communication interface, and switch the corresponding communication circuit after identifying the interface. For example, patent CN112202741B discloses a gateway device for automatically identifying communication buses and protocols based on small-signal analysis. This device can collect voltage, current, and waveform parameters of external interfaces, establish a feature model, compare it with a signal feature library, switch to the corresponding bus circuit after determining the interface type, and output feature data packets for further collection and verification. However, different industrial communication interfaces may have similar static voltages, differential characteristics, or line load characteristics. Especially when the external device is in a silent state, information obtained solely from passive acquisition may not be sufficient to accurately determine the interface type.
[0004] The aforementioned existing technologies, after determining the interface based on preliminary analysis results, require switching the corresponding bus circuit and outputting feature data packets for further verification. When there is a deviation in the preliminary judgment, the communication circuit that does not correspond to the actual interface drives the external line. Using a fixed detection sequence to judge multiple interface features one by one also makes it difficult to balance recognition efficiency and line disturbance. Therefore, it is necessary to provide an automatic access scheme that keeps the normal communication transmission path closed before the interface type is finally confirmed, further narrows down the interface range through independent restricted line detection, and opens the transmission path only after further verification is completed on the receiving side. Summary of the Invention
[0005] This invention overcomes the shortcomings of the prior art and provides a method and apparatus for multi-interface identification and adaptive configuration of communication parameters for industrial control boards.
[0006] To achieve the above objectives, the technical solution adopted by this invention is: a method for multi-interface identification and adaptive configuration of communication parameters for industrial control boards, comprising: S1. After the peripheral device is connected, the normal communication transmission path of the RS232 transceiver, RS485 / RS422 transceiver and CAN transceiver is blocked. Only the high-impedance sampling circuit independent of the three transceivers obtains the line electrical status of the external interface and forms a candidate interface set based on the line electrical status. S2. When the candidate interface set contains at least two interface types, select the corresponding diagnostic detection method according to the current candidate interface set, apply diagnostic excitation to the signal line through a current limiting branch via a diagnostic excitation circuit independent of the normal communication transmission path, and obtain the line response during the diagnostic excitation and after the diagnostic excitation is withdrawn. S3. Update the candidate interface set according to the matching relationship between the line response and the corresponding response features of each candidate interface, and select the subsequent diagnostic detection method according to the updated candidate interface set until the physical interface type is determined; if the physical interface type cannot be uniquely determined after the preset exit condition is met, stop the diagnostic detection and keep the normal communication transmission path blocked. S4. After determining the physical interface type, keep the normal communication transmission path disabled. While keeping the other receiving paths of the three transceivers disconnected, only connect the receiving path of the corresponding physical interface, determine the candidate communication parameters based on the received signal, and perform protocol verification on the candidate communication parameters without sending verification data. S5. After the physical interface type is confirmed, the protocol verification is passed, and the diagnostic stimulus has stopped, the hardware logic circuit, which is independent of the communication controller software configuration, performs a logical combination to open only the normal communication transmission path corresponding to the determined physical interface.
[0007] In a preferred embodiment of the present invention, the high-impedance sampling acquires the voltage to ground of the signal line and the differential voltage between the two signal lines, respectively. When a single signal line exhibits a positive or negative polarity level change that conforms to the characteristics of a single-ended interface, RS232 is retained in the candidate interface set. When two signal lines experience reverse voltage changes and form corresponding differential voltage changes, RS485 / RS422 and CAN are retained in the candidate interface set.
[0008] In a preferred embodiment of the present invention, the diagnostic excitation circuit includes a reference voltage source, a current-limiting resistor, and a controlled switch. The controlled switch is used to selectively connect the reference voltage source or reference potential to the signal line under test through the current-limiting resistor, and disconnect it after the set detection time ends.
[0009] In a preferred embodiment of the present invention, when the candidate interface set includes both single-ended interfaces and differential interfaces, single-line current limiting detection in different directions is applied to at least one signal line. When the candidate interface set includes RS485 / RS422 and CAN, current limiting detection in the same direction and current limiting detection in the opposite direction are applied to the two signal lines respectively to obtain the common-mode response and differential-mode response of the line.
[0010] In a preferred embodiment of the present invention, line voltage change characteristics, differential response characteristics, and recovery characteristics are obtained based on the line state before diagnostic excitation, the line state during diagnostic excitation, and at least one line state after diagnostic excitation is removed. The response characteristics of each interface are obtained in advance by the known interface under the sampling path, diagnostic excitation conditions and sampling timing corresponding to the interface identification stage, and candidate interfaces are retained or deleted according to the matching results of the line voltage change characteristics, differential response characteristics and recovery characteristics with the corresponding response characteristics.
[0011] In a preferred embodiment of the present invention, when the physical interface type is determined to be CAN, the normal CAN communication transmission path is disabled and the CAN reception path is enabled. The candidate bit rate is determined according to the edge interval of the received signal, so that the CAN controller operates in a listening-only state according to the candidate bit rate, and the protocol verification is determined according to the frame format, bit stuffing and cyclic redundancy check results of the received CAN frame.
[0012] In a preferred embodiment of the present invention, when the physical interface type is determined to be RS232 or RS485 / RS422, the candidate baud rate is determined according to the level transition interval of the received signal, and the same segment of the received signal is decoded according to multiple serial frame formats respectively, and the communication parameters and protocol verification results are determined according to the start bit, stop bit and check relationship.
[0013] In a preferred embodiment of the present invention, before performing diagnostic excitation, the expected detection current is determined based on the excitation terminal potential, the potential of the signal line under test, and the resistance value of the current limiting branch. When the expected detection current exceeds the allowable range, the corresponding diagnostic excitation is prohibited. During the diagnostic stimulus, the line status is continuously monitored. When the line response exceeds the preset allowable range, the current diagnostic stimulus is terminated, and the normal communication transmission channel is blocked.
[0014] An industrial control board multi-interface identification and communication parameter adaptive configuration device includes an external interface, an RS232 transceiver, an RS485 / RS422 transceiver, a CAN transceiver, a high-impedance sampling circuit, a diagnostic excitation circuit, a controller, a receiving path control circuit, and a transmitting enable circuit. The high-impedance sampling circuit is connected to the external interface and is used to obtain the electrical status of the line when the normal communication transmission path of each transceiver is blocked. The diagnostic excitation circuit is independent of the normal communication transmission path and is connected to the external interface through a current-limiting branch. The controller is used to form a candidate interface set according to the electrical state of the line. When the candidate interface set contains at least two interface types, it controls the diagnostic excitation circuit to select the corresponding diagnostic detection method according to the current candidate interface set, and updates the candidate interface set according to the line response during the diagnostic excitation and after the diagnostic excitation is withdrawn, so as to determine the physical interface type. The receiving path control circuit is used to connect only the receiving path of the corresponding physical interface after the physical interface type is determined. The controller determines the communication parameters and performs protocol verification based on the received signal while the corresponding normal communication transmission path is kept prohibited. The transmit enable circuit is used to connect only the normal communication transmit path of the corresponding physical interface after the physical interface type is confirmed, the protocol verification is passed, and the diagnostic excitation stops.
[0015] In a preferred embodiment of the present invention, the transmit enable circuit includes transmit switches corresponding to RS232 transceivers, RS485 / RS422 transceivers and CAN transceivers respectively, as well as hardware logic circuits. The hardware logic circuit generates the transmission enable state of the corresponding transmission switch based on the physical interface confirmation signal, the protocol verification signal, the corresponding interface selection signal, and the diagnostic idle signal that indicates the stop of diagnostic excitation, so that all normal communication transmission paths remain disconnected when the diagnostic excitation is in the working state. When the device is powered on or reset, the physical interface confirmation signal and protocol verification signal remain invalid, keeping all transmitting switches open.
[0016] This invention addresses the shortcomings of the prior art and has the following beneficial effects: (1) The present invention forms a candidate interface set based on high impedance sampling, selects a limited diagnostic detection method according to the current candidate interface set, updates the candidate interface set with the detection results and further determines the subsequent detection content, forming a closed-loop identification mechanism driven by candidate state; gradually supplements effective physical information for the current interface ambiguity, reduces invalid detection and cumulative line action time, and improves the interface identification capability under the condition of insufficient peripheral silent or dynamic communication information.
[0017] (2) This invention uses the line response during the diagnostic excitation and the line recovery characteristics after the diagnostic excitation is removed together for interface identification, and combines different detection directions to obtain multi-dimensional features such as line voltage, differential response, and recovery process. Under limited excitation conditions, the differences in response of different interfaces in load characteristics, differential coupling, and equivalent resistance-capacitance characteristics are used to further distinguish interfaces with similar characteristics, improve the identification capability of differential interfaces such as RS485 / RS422 and CAN, and reduce the disturbance of diagnostic detection to unknown external lines.
[0018] (3) After the physical interface type is determined, the present invention continues to keep the normal communication transmission path prohibited, and only uses the existing communication signal of the external line to determine the communication parameters and perform protocol verification through the corresponding receiving path, so that the physical interface confirmation and protocol verification form two-level confirmation conditions with different sources; the corresponding transmission path is only opened after both the physical interface confirmation and protocol verification are passed, reducing the risk of the physical interface judgment deviation directly causing the wrong interface drive, bus competition or abnormal message.
[0019] (4) This invention uses the physical interface confirmation state, protocol verification state, interface selection state, and diagnostic state as the enabling conditions for the normal communication transmission path, thus forming a hardware constraint relationship between diagnostic detection and normal communication transmission. When the diagnostic excitation has not ended, the confirmation condition has failed, or the device is in the power-on or reset state, the corresponding transmission path remains prohibited, reducing the risk that abnormal software state will cause the normal transmission level to directly act on unknown external lines, and improving the safety and reliability of the automatic access process. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Figure 1 This is a flowchart of the method for identifying multiple types of peripheral interfaces on an industrial control board and adaptively configuring communication parameters according to the present invention; Figure 2 This is a structural block diagram of the industrial control board multi-type peripheral interface identification and communication parameter adaptive configuration device of the present invention; Figure 3 This is a schematic diagram of the high-impedance sampling circuit of the industrial control board multi-type peripheral interface identification and communication parameter adaptive configuration device of the present invention; Figure 4 This is a schematic diagram of the diagnostic excitation circuit of the industrial control board multi-type peripheral interface identification and communication parameter adaptive configuration device of the present invention; Figure 5 This is a schematic diagram of the transmission enable circuit of the industrial control board multi-type peripheral interface identification and communication parameter adaptive configuration device of the present invention. Detailed Implementation
[0021] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0022] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention is also practiced in other ways different from those described herein, and therefore the scope of protection of the invention is not limited to the specific embodiments disclosed below.
[0023] Example 1: like Figure 1 As shown, a method for multi-interface identification and adaptive configuration of communication parameters for industrial control boards includes: S1. After the peripheral device is connected, the transmit enable circuit disables the transmit path of RS232 transceiver, RS485 / RS422 transceiver and CAN transceiver; the line voltage, differential voltage and level change of the external interface are detected by the high impedance sampling circuit, and the candidate interface is determined according to the detection results. S2. When the candidate interface cannot be uniquely determined, the detection method is selected according to the current candidate interface. The diagnostic excitation circuit, which is independent of the transmission path, applies the detection action to the signal line through the current limiting resistor and collects the line response. S3. Delete the mismatched candidate interfaces according to the line response. If the candidate interface still cannot be uniquely determined, re-execute S2 according to the updated candidate interface. If the candidate interface is unique, determine the physical interface type. If it is still not unique after the preset exit condition is met, keep the sending path blocked and wait for new line activity. S4. Maintain normal communication transmission path hardware is disabled, only the receiving path corresponding to the physical interface is connected, and the communication parameters are determined and the protocol is verified based on the received signal without sending verification data. The communication parameters that pass the protocol verification are configured to the corresponding communication controller. S5. After the physical interface type is confirmed, the protocol is verified, and the probing action has stopped, only the normal communication transmission path corresponding to the confirmed physical interface is opened.
[0024] This embodiment adopts a candidate interface gradually narrowing identification method. When the passively acquired line information is sufficient to complete the judgment, the physical interface type is directly determined. When the passively acquired information is insufficient, rate limiting detection is performed, and the corresponding detection method is selected according to the current candidate interface. After the physical interface type is determined, the transmission is kept closed. The communication parameters are determined and the protocol is verified by receiving signals. Only when the physical interface confirmation result and the protocol verification result both meet the requirements are the transmission enable control signal generated, forming a processing flow in which interface detection, active detection, reception verification and transmission opening are interconnected.
[0025] The engineering implementation of this invention is not a simple combination of existing technologies; it faces three coupled technical challenges: First, RS485 and CAN exhibit similar implicit differential levels when the bus is idle, and the peripherals lack dynamic excitation during the silent period, making the traditional static threshold method prone to misjudgment. Second, active detection suffers from insufficient injected signal amplitude, failing to stimulate the essential amplitude-frequency response differences of different interface driver circuits, such as the strong current-sinking capability of CAN transceivers and the weak differential-mode drive of RS485; excessively large injected amplitude or long delay may interfere with the established state of the bus or even damage the interface physical layer. Third, if transmission permissions are granted prematurely during the protocol verification phase, misjudgment of the type will directly lead to bus level conflict and overcurrent burnout of driver devices. To address these difficulties, this invention creatively constructs a current-limited time-domain attenuation feature comparison. By constraining the probe current and time window, it collects the passive voltage attenuation curve after injection withdrawal to distinguish subtle differences in line load, achieving strong distinguishability with minimal intrusion. The hardware transmission logic interlocking mechanism physically cuts off all transmission loops throughout the entire identification cycle until a deterministic mapping is formed between physical judgment and protocol parsing.
[0026] Example 2: Based on Example 1, this example is further refined and applied to industrial control boards compatible with RS232, RS485 / RS422, and CAN peripherals. When external devices are connected, the interface type and communication parameters are not provided in advance. The external interface has two signal lines to be tested and a reference ground, where the reference ground is a common zero potential reference point provided in the external interface connector. Before normal communication is established, the industrial control board keeps all transmission paths closed. By passively sampling the lines, performing restricted detection, updating candidate interfaces, verifying the receiving side protocol, and releasing the transmission paths, the board completes the transition from the unknown interface state to the normal communication state.
[0027] Specifically, in step S1, after the peripheral device is connected, the transmit enable circuit disables the transmit paths of the RS232 transceiver, RS485 / RS422 transceiver, and CAN transceiver; the line voltage, differential voltage, and level changes of the external interface are detected by the high-impedance sampling circuit, and candidate interfaces are determined based on the detection results; that is, after the external device is inserted, all transmit paths that can actively output communication levels to the external line are kept in the closed state. In this state, only the electrical state of the external line itself is observed to obtain the voltage of each signal line relative to the reference ground, the differential voltage between two signal lines, and whether there is a continuous level change in the line. Based on these observation results, the interface type that matches the current line state is retained to form the candidate interfaces used for subsequent detection.
[0028] Among them, the transmitting path refers to the electrical path that can apply a normal communication level to the external interface through the transceiver driver terminal. The transmitting path prohibition means that the corresponding driver terminal and the external interface are kept in a high impedance or disconnected state, so that even if the main control side generates data to transmit, it cannot form a normal communication drive for the external line. High impedance sampling means that the sampling path has a high input impedance relative to the line under test. The sampling action mainly obtains the current voltage state of the line and controls the additional load. The candidate interface refers to the interface type that cannot be ruled out temporarily based on the obtained line characteristics.
[0029] Furthermore, the peripheral access in step S1 is determined by interface connection detection, the change of line voltage from open circuit state to stable state, or manual triggering. In one embodiment, after the external interface is inserted, if the sampling voltage of any signal line under test deviates from the reference range when no peripheral is connected for multiple consecutive sampling cycles, it is considered that the external device has been connected. After the device access determination is formed, the transmission control state is maintained in the prohibited state. The transmission control state is only changed after the subsequent physical interface confirmation and protocol verification are completed.
[0030] Specifically, when the transmission path is disabled, the transmission enable signal corresponding to each communication interface is set to invalid, and the series switch of the corresponding transmission path remains open. In one implementation, the transmission enable states corresponding to RS232, RS485 / RS422, and CAN remain invalid during power-on and reset. This state continues after the peripheral is connected. The controller can only read the line sampling results and control diagnostic probes, and cannot directly change the external line level through the ordinary transmission register. When using this method, the transmission disable state has a maintenance condition independent of the communication software. Even if the main control program completes the serial port or CAN controller initialization in advance, it will not allow the normal transmission level to be transmitted to the external interface.
[0031] In one implementation, the equivalent input impedance of the high-impedance sampling branch is set to be no less than 1 MΩ. An input protection circuit and a resistor attenuation bias network are provided at the sampling front end. The resistor attenuation bias network attenuates the voltage of the external line relative to the reference ground by a predetermined ratio and superimposes a DC bias, converting positive and negative voltages within the effective linear sampling range into non-negative input voltages allowed by the subsequent sampler. The effective linear sampling range is jointly determined by the conversion relationship of the resistor attenuation bias network, the non-clamping operating conditions of the input protection device, the input common-mode range and output swing of the voltage buffer, and the allowable input range of the analog-to-digital converter. When the sampling result does not meet the effective linear sampling conditions, the unacknowledged state of the relevant interface and the prohibited state of the normal communication transmission path are maintained.
[0032] The sampling node voltages formed by the first and second signal terminals through their respective resistor attenuation bias networks are denoted as V. s1 and V s2 The controller obtains V through an analog-to-digital converter. s1 and V s2 And when the effective linear sampling condition is met, the line voltages V1 and V2 of the first and second signal terminals relative to the reference ground are restored according to the corresponding ratio and bias relationship, and then the differential voltage V is calculated. d =V1-V2.
[0033] When acquiring line voltage, the controller continuously records V1, V2, and V within the sampling window. d The maximum, minimum, and adjacent sampling point changes within the sampling window are calculated. When a signal line has a stable negative potential relative to the reference ground or changes between positive and negative potentials, RS232 is retained as a candidate interface. When the voltage changes of two signal lines are in opposite directions and the differential voltage changes accordingly with the opposite changes of the two signal lines, RS485 / RS422 and CAN are retained as candidate interfaces. When the external device is in a silent state and there is no level change that can be judged, interfaces that are obviously inconsistent are excluded only based on the static voltage.
[0034] To reduce misjudgments caused by transient interference, a voltage state must remain stable across consecutive sampling points to be considered as a candidate, and line transitions must exhibit a consistent direction of change across multiple adjacent sampling points to be recorded as valid edges. Step S1 is used for safety isolation and preliminary screening, reserving ambiguities that cannot be resolved by passive information for processing in step S2, thus avoiding prematurely opening transmission paths in pursuit of a single judgment result.
[0035] When the candidate interface cannot be uniquely determined in step S2, a detection method is selected based on the current candidate interface. A diagnostic excitation circuit, independent of the transmission path, applies a detection action to the signal line through a current-limiting resistor and collects the line response. When multiple candidate interfaces are still retained after passive sampling, the normal transmitter of RS232, RS485 / RS422, or CAN is not used to send test data to the external line. Instead, a restricted line detection method that can increase distinguishing information is selected based on which candidate interfaces are still remaining. A short-term, current-limiting electrical action is applied to the signal line under test through an independent diagnostic excitation path, and the change in line voltage before and after detection is recorded simultaneously. The obtained line response is used as the basis for updating the candidate interface.
[0036] In this embodiment, diagnostic excitation refers to applying a limited current to the line under test through a controlled branch independent of the normal communication transmission path. The diagnostic excitation does not encode normal communication characters or normal CAN frames. Common-mode current limiting excitation refers to applying a current limiting effect in the same direction to two signal lines under test, causing the two lines to change in the same direction relative to the reference ground, while controlling the differential change between the two lines. Differential-mode current limiting excitation refers to applying a current limiting effect in opposite directions to two signal lines under test, causing a limited differential change between the two lines. Line response refers to the line voltage change, voltage recovery process, and current change calculated by the current limiting branch acquired during and after the detection period.
[0037] Specifically, in one implementation, the diagnostic excitation path consists of a reference voltage source, current-limiting resistors, and an analog switch. Each signal line under test can be connected to the reference voltage source via one current-limiting branch and to the reference ground via another current-limiting branch. The analog switch is briefly turned on by a control signal. In one specific implementation, the reference voltage source is 3.3 V, each current-limiting resistor is 47 kΩ, the duration of a single excitation is 100 μs, and a recovery time of 500 μs is reserved between two adjacent excitations.
[0038] Furthermore, a single diagnostic excitation includes determining the detection method, pre-excitation state detection, applying the diagnostic excitation, line sampling during excitation, canceling the diagnostic excitation, resuming line sampling, and determining the line response. When the candidate interface set cannot uniquely determine the physical interface type, the controller determines the signal line, excitation direction, and excitation method corresponding to this diagnostic excitation based on the current candidate interface set, and executes the diagnostic excitation while keeping the normal communication transmission path disabled. Before applying the diagnostic excitation, the controller obtains the current line voltage of the signal line under test through the high-impedance sampling circuit, and determines the expected detection current based on the reference terminal voltage used for the diagnostic excitation, the voltage of the signal line under test, and the resistance value of the current-limiting branch. When the expected detection current meets the preset allowable conditions, the corresponding analog switch is turned on, so that the reference voltage source or reference ground forms a short-time current-limiting connection with the signal line under test through the current-limiting resistor. During the diagnostic excitation, the high-impedance sampling circuit continuously collects the line voltage and differential voltage. When the line response is detected to exceed the preset allowable range or unexpected line activity occurs, the diagnostic excitation is terminated, and the detection result is marked as invalid.
[0039] After the diagnostic excitation reaches the preset duration, the controller disconnects the corresponding analog switch, causing the signal line under test to disconnect from the diagnostic excitation branch. It then continues to acquire line status at one or more preset sampling times after the diagnostic excitation is removed. Based on the sampling results before, during, and after the diagnostic excitation, it generates line voltage change characteristics, differential response characteristics, and line recovery characteristics, which are compared with the response range corresponding to the current candidate interface. The candidate interface set is updated based on the comparison results. If the updated candidate interface set still contains multiple interface types, the next diagnostic excitation method is reselected based on the updated candidate interface set. If the interface type cannot be uniquely determined even after reaching the preset number of probes or the recovery condition, the diagnostic excitation is stopped, and the normal communication transmission path is disabled.
[0040] Diagnostic excitation current is based on I=(V r -V l The calculation is performed using ) / R, where I is the estimated current of the current-limited branch, and V r V is the reference voltage connected to this current-limiting branch. l To excite the voltage of the signal line under test, R is the resistance value of the current limiting resistor. Before closing the analog switch, the controller calculates I using the most recent high-impedance sampling result. If the calculated result exceeds 0.5 mA, the detection in that direction is not performed. Instead, a current limiting branch with a larger resistance value is used or the transmission is directly prohibited and the line is waited for to recover. For detection that has already started, if the sampled voltage change exceeds the preset allowable range, the analog switch is immediately disconnected.
[0041] In one specific implementation, the RS232 transceiver uses the MAX3232E, which has a supply voltage of 3V to 5.5V, an allowable input voltage range of -25V to +25V at the receiving end, and a receiving input resistance of 3kΩ to 7kΩ; the RS485 / RS422 differential interface transceiver uses the SN65HVD75, which operates on a 3.3V supply, has a common-mode voltage range of -7V to +12V, and an allowable voltage range of -13V at the bus end. +16.5V, with a receive input current of approximately 150μA under 12V bus input conditions; the CAN transceiver uses TCAN1051HV, whose bus-side power supply voltage is 4.5V~5.5V, logic interface voltage supports 3.3V, receive common-mode voltage range is -30V~+30V, single CAN bus input terminal input resistance is 15kΩ~40kΩ, differential input resistance is 30kΩ~80kΩ, and it has a silent operation mode required only for listening to communication.
[0042] In this embodiment, the diagnostic excitation circuit uses a 3.3V reference voltage source and a 47kΩ current-limiting resistor. When the voltage of the signal line under test is close to the reference ground potential, the single-branch diagnostic excitation current is 70μA. 0.5mA is set as the upper limit of the expected current allowed for diagnostic excitation. Based on the 47kΩ current-limiting resistor, the corresponding maximum allowable voltage difference is approximately 23.5V. Before each diagnostic excitation begins, the controller calculates the expected probe current based on the current voltage of the signal line under test. When the expected probe current exceeds 0.5mA, the diagnostic excitation in the corresponding direction is not executed.
[0043] The 0.5mA is the upper limit of the diagnostic excitation current. This upper limit is higher than the expected probe current formed by the 47kΩ current-limiting branch of the RS485 / RS422 differential interface within the normal line voltage range. At the same time, it limits the application of diagnostic excitation when the line is at a high positive or negative potential, so as to maintain a safety margin between the diagnostic excitation current, the detectable response of the line, and the electrical allowable range of the bus terminal of the selected transceiver.
[0044] In this embodiment, the common-mode current-limiting excitation is performed by connecting two signal lines to the same reference voltage source through current-limiting resistors of the same resistance value, and recording the rise of the two signal lines and the differential change between the two lines while maintaining the same excitation time. The differential-mode current-limiting excitation is performed by connecting the first signal line to the reference voltage source through a current-limiting resistor, and simultaneously connecting the second signal line to the reference ground through a current-limiting resistor of the same resistance value. After completing one detection, the excitation directions of the two signal lines are exchanged. By using two types of excitation, namely in the same direction and in opposite directions, the response of the external circuit to common-mode changes and differential-mode changes can be observed respectively. Exchanging the differential-mode direction can also be used to observe whether the responses of the two lines are approximately symmetrical.
[0045] Specifically, when step S1 retains RS232 and differential interface as the two candidate types, forward and reverse current limiting detection is performed on a single signal line first to read the response of the signal line relative to the reference ground and whether the other signal line has changed synchronously; when the candidate interface has been narrowed down to RS485 / RS422 and CAN, common mode current limiting excitation and differential mode current limiting excitation in both forward and reverse directions are performed first.
[0046] When the candidate set includes RS232 and also includes RS485 / RS422 or CAN, single-wire forward current limiting probe is performed first, followed by single-wire reverse current limiting probe. If the updated candidate set only includes RS485 / RS422 and CAN, common-mode current limiting excitation, first-direction differential-mode current limiting excitation, and second-direction differential-mode current limiting excitation are performed sequentially. When only one type remains in the candidate set, a confirmation probe with a different direction than the previous probe is performed. If the confirmation result still falls within the allowed range of the candidate interface, the physical interface confirmation status is output. When the maximum number of probe actions has been performed but a unique determination cannot be made, transmission is prohibited and the system waits for new line activity.
[0047] To identify the transient characteristics of the external line under detection, each excitation should record at least the stable voltage before excitation begins, the line voltage before excitation ends, and the line voltage at one or more fixed moments after excitation is disconnected. Taking the first signal line as an example, let the stable voltage before excitation be V0, and the voltage before excitation ends be V... p The voltage after a 50 μs delay following excitation disconnection is V. 50 Then the voltage change is ΔV = V p -V0, the recovery ratio can be expressed as K=(V 50 -V0) / (V p -V0), when V p When the difference between V0 and the sampling noise is close, K is not calculated and the detection is directly recorded as no effective response. K is used to characterize how fast the line recovers to the original idle level after the excitation stops. Different input biases, terminal networks and line capacitances will cause different combinations of ΔV and K.
[0048] In one implementation, the first signal line and the second signal line calculate ΔV1 and ΔV2 respectively, and simultaneously calculate the differential voltage change ΔV before and after detection. d , where ΔV d =(V 1p -V 2p )-(V 10 -V 20 It also records the absolute difference between the changes in the two signal lines, A = |ΔV1| - |ΔV2|; ΔV d Used to characterize the effect of detection on the differential state, A is used to characterize whether the responses of the two lines are symmetrical. During common-mode detection, the focus is on observing the changes in the same direction of the two lines and ΔV.d Whether it is small, focus on observing ΔV during differential mode detection. d Using multiple physical quantities together, such as A, can reduce interface confusion caused by relying on a single resistance value or a single static voltage.
[0049] This embodiment uses line voltage change, differential voltage change, recovery ratio, and two-line response difference as detection and judgment parameters. Line voltage change directly reflects the equivalent load of the external line on the current-limiting branch, differential voltage change reflects the coupling and termination relationship between the two lines, recovery ratio reflects the equivalent resistance and capacitance characteristics of the line, and two-line response difference reflects the symmetry of the differential line. After using multiple corresponding line response quantities, even if two interfaces are close in a certain static quantity, candidate interfaces are further screened by combining responses under different detection directions.
[0050] It should be noted that the diagnostic excitation duration and current-limiting resistor value are given using a specific hardware example. The two together determine the intensity of the effect of a single probe on the external circuit. In this implementation, the line response falls within the resolvable range of the sampling front end through an excitation time of 100 μs and a current-limiting resistor of 47 kΩ, and the single probe is kept in a short-term limited state. When adjusting the parameters, both the measurability of the sampling and the limitation of external circuit disturbances should be met.
[0051] Since active probing itself may also affect unknown lines, if a normal communication transmitter is used directly for testing, the detection level and output capability are determined by the corresponding communication standard. Once the interface judgment is wrong, a mismatch will be formed. This invention completes the detection through a current-limiting branch that is separate from the normal transmission path. The detection method is determined by the current candidate interface, so that the active acquisition of information is subject to the joint constraints of current, time and line response monitoring, providing a repeatable measurement basis for subsequent candidate updates.
[0052] For step S3, if the candidate interface cannot be uniquely determined after deleting the mismatched candidate interface based on the line response, step S2 is re-executed according to the updated candidate interface. If the candidate interface is unique, the physical interface type is determined. If it is still not unique after meeting the preset exit conditions, the transmission path is blocked and the system waits for new line activity. After each restricted probe is completed, the actual measured line response is compared with the pre-established response range of each candidate interface. Candidate interfaces that are obviously inconsistent with the current measurement results are deleted from the set. If there are still multiple candidate interfaces after deletion, the updated candidate set is used to select the next probe method to continue measurement until a unique physical interface type is obtained or the current line conditions are insufficient to continue distinguishing. At this time, the transmission path is blocked and the system waits for new line activity.
[0053] In this embodiment, the interface response range refers to the acceptable line response interval of a certain type of interface under specified detection methods, specified sampling times, and specified hardware configurations. The response range is obtained by calibration using a reference interface during the product design phase. During calibration, the same high-impedance sampling path and diagnostic excitation path as the actual product are used, connecting the RS232 reference interface, RS485 / RS422 reference interface, and CAN reference interface respectively. With the peripheral device powered on and in an idle state, the same common-mode detection, forward differential-mode detection, and reverse differential-mode detection as in the identification phase are performed, and the ΔV1, ΔV2, and ΔV of each detection are recorded. d K and A, and then write the minimum and maximum values of each parameter into non-volatile memory after expanding the tolerance.
[0054] Specifically, the required calibration data comes from the reference transceiver and terminal connection methods supported by the product under test. For RS485 / RS422 and CAN, which both use terminating resistors, the calibration process retains two connection states: one with a terminal and one without. This allows the same candidate interface to correspond to multiple allowable response ranges. During identification, as long as the current measurement result falls within the allowable range of any calibrated connection state of the candidate interface, the false rejection caused by differences in the field terminal configuration is reduced.
[0055] Candidate deletion is implemented using an item-by-item elimination method. A candidate interface is deleted only when all key response quantities under the current probing mode do not conform to its allowable range. For example, common-mode probing results are used to determine the common-mode load and synchronous changes between the two lines, while differential-mode probing results are used to determine the differential load and the symmetry between the two lines. When a parameter is in the boundary region, the candidate is retained and further judgment is made through the next probing. Using an item-by-item elimination method allows uncertainty to be retained in the identification process, avoiding the direct conversion of a measurement result affected by noise, cable length, or peripheral status into the final interface conclusion.
[0056] In one implementation, when only one candidate interface remains after the update, a confirmation probe in a different direction is still performed. If the key response value obtained from the second confirmation probe still falls within the allowable range of the interface, the physical interface confirmation status is output. If the two results are inconsistent, the unique candidate status is revoked and the previous candidate set is restored. This allows the physical interface confirmation to be supported by responses under different probe conditions, which is used to filter out transients of analog switches, occasional interference from external lines, and single anomalies at the sampling front end.
[0057] It should be noted that RS485 and RS422 have similar electrical characteristics at the physical layer. When the external interface provides only one pair of differential lines and there is no communication activity, both are treated as an RS485 / RS422 interface family for physical confirmation. Treating RS485 and RS422 as an interface family is only used in the physical interface identification stage to determine the corresponding differential transmit / receive paths. In the subsequent communication establishment process, the specific working mode can be determined based on the number of differential line pairs, the direction of communication activity, and the transmit / receive relationship, without affecting the normal communication function of the RS485 or RS422 interface. When the external interface provides two pairs of differential lines, the working mode is further determined by whether there is continuous unidirectional communication activity between each line pair and the directional relationship between the line pairs.
[0058] When CAN and RS485 lines with termination have similar differential resistances, simply detecting the line-to-line resistance is insufficient to establish a stable distinction. Therefore, multiple sets of response quantities are generated through common-mode excitation, positive and negative differential-mode excitation, and recovery characteristics after excitation stops. The establishment of the response range uses the same detection path and sampling time as the identification stage, ensuring consistent measurement conditions for the comparison objects. Step S3 directly feeds back each detection result to the candidate set. Changes in the candidate set determine the content of the next detection, transforming the process of consistently performing all tests into a closed-loop process that continues measurement based on the current ambiguous state.
[0059] Step S3 establishes candidate deletion based on repeatable line responses through reference calibration under the same hardware conditions, joint comparison of multiple parameters, retention of boundary results, and secondary confirmation of the unique candidate. When the existing information is still insufficient to form a unique result, the control state continues to prohibit transmission, and the identification process will not increase the number of normal transmission actions to gain certainty.
[0060] Only the receiving path corresponding to the confirmed physical interface is connected, while the transmitting path remains blocked. Communication parameters are determined based on the received signal, and protocol verification is performed. Communication parameters that pass protocol verification are configured to the corresponding communication controller. After the physical interface has been confirmed through electrical testing, the system does not immediately allow the interface to send data out. Only the receiving path corresponding to the confirmed interface is opened. The original communication signal of the external line is used to determine whether the received data conforms to the timing and frame structure of the interface, and at the same time, the communication parameters that can stably interpret the received signal are determined. Before the protocol verification is completed, the normal transmitting path remains blocked.
[0061] Among them, the receiving path refers to the unidirectional input path of the external interface to the controller through the corresponding transceiver receiving end or the high-impedance comparison sampling path; the protocol verification refers to the determination of whether the physical interface conclusion can be supported by the communication layer data by using the bit timing and frame structure of the received signal in the state of not generating normal communication transmission; the communication parameters include bit rate and receiving sampling related parameters for CAN, and baud rate, data bits, parity mode and stop bits for RS232 and RS485 / RS422.
[0062] Specifically, when the physical interface is confirmed to be CAN, the CAN transceiver's receive path is activated, the transmit enable state remains invalid, and the controller generates candidate bit periods using the previously acquired level edge intervals; let the recorded valid edge times be t1, t2 to t... n The interval between adjacent edges is Δt i =t i+1 -t i For each candidate bit period T supported by the product j Calculate each Δt i With T j The relative deviation between integer multiples is counted, and the number of edges with deviations less than a set proportion is counted. A larger number of T-matches are selected. j The CAN controller configures the bit rate according to the candidate priority and keeps in a listening state. When it receives three consecutive frames of data that meet the requirements of frame format, bit stuffing and cyclic redundancy check, it considers the CAN protocol verification to be successful.
[0063] In one implementation, the CAN edge timing is captured by a 20 MHz timer input with an edge time resolution of 50 ns, and at least 64 valid edges are recorded in a single verification; for a certain candidate bit period Tj, for each Δt i Choose to make |Δt i -mT j The smallest positive integer m, where m ranges from 1 to 10, when |Δt i -mT j | / T j A match less than 0.15 is considered a valid match. The first three candidate bit cycles are selected from high to low based on the number of valid matches and are then monitored and verified by the CAN controller. The calculation is only used to narrow down the number of candidate bit rates that need to be configured. The final protocol verification is still based on the legal frames received by the CAN controller.
[0064] Furthermore, when the physical interface is confirmed to be RS232 or RS485 / RS422, the corresponding receiving path is connected and the transmission is kept disabled. A logic level transition sequence of the received signal is recorded, and the candidate bit period is determined by the edge interval. For adjacent edge intervals, the bit period that can explain most edge intervals is selected by matching according to the same integer multiple of the CAN candidate bit period. Then, the same recorded logic level sequence is software decoded using 8N1, 8E1 and 8O1 respectively. 8N1 represents 8 bits of data, no parity and 1 stop bit, 8E1 represents 8 bits of data, even parity and 1 stop bit, and 8O1 represents 8 bits of data, odd parity and 1 stop bit.
[0065] In one specific implementation, the serial received signal is captured by a timer at the edge and the logic level is synchronously saved at a sampling frequency ten times higher than the candidate baud rate. After the candidate baud rate is determined, the start bit position, data bit sampling position, parity bit position, and stop bit position are determined on the same saved data segment according to different candidate baud rates and different frame formats. If a certain parameter combination can detect a valid start bit and stop bit at the expected position for three consecutive frames, and satisfies the corresponding parity relationship under the configuration including the parity bit, the parameter combination is used as the protocol verification result. If multiple combinations are satisfied simultaneously, the number of received frames continues to increase until one of the combinations remains stable. If multiple parameter combinations simultaneously satisfy the verification conditions, the number of received frames used for verification continues to increase. If more than two parameter combinations are still satisfied after reaching the preset maximum number of verification frames, the protocol verification signal PROTO_OK is not set, the normal communication transmission path is disabled, and re-verification is performed after waiting for a new received edge or frame data.
[0066] It should be noted that using multiple parameter combinations to interpret the same received signal after a single acquisition reduces the number of times hardware receiving configurations need to be switched repeatedly to determine the baud rate and verification method. The external line maintains the same electrical connection state throughout the verification process. If the external device is completely silent, step S4 cannot determine the baud rate and verification method based on the static line. In this case, the physical interface confirmation result and transmission prohibition state are maintained, and communication activity from the external device is waited for.
[0067] Furthermore, the physical line status is monitored simultaneously during the protocol verification process. If the line voltage exceeds the allowable range of the sampling front end, the candidate bit period drifts significantly within multiple consecutive windows, or the received frame structure remains invalid during the reception verification, the protocol verification result is canceled and transmission is prohibited, returning to the high-impedance sampling state. This process ensures that the protocol layer result corresponds to the current line status, preventing the use of old interface conclusions after peripheral plugging / unplugging, line reconnection, or bus status changes.
[0068] Since CAN, RS232, and RS485 / RS422 require different timing interpretation methods, and the unknown baud rate will result in a large search space for direct receiver configuration, step S4 uses the original edge time to first narrow down the candidate bit period, and then performs frame structure verification on the receiving side, so that the protocol evidence comes from the signal that already exists on the external line; physical interface confirmation and protocol verification are at different levels, and the transmission path is kept closed before both are completed, so that interface identification errors will not immediately be converted into normal transmitter driving the line.
[0069] After the physical interface type is confirmed and the protocol verification is successful in step S5, the transmit enable circuit connects the transmit path of the corresponding transceiver. Only after the physical interface type has been confirmed and the corresponding receive path has indeed received valid data that conforms to the interface and communication parameters, is the normal transmit path corresponding to the interface allowed to connect to the external line. Other transmit paths in RS232, RS485 / RS422 and CAN remain closed, and the transmit permissions correspond to the verified interface type.
[0070] In this embodiment, the physical interface confirmation state comes from step S3, the protocol verification state comes from step S4, and the send enable state is used to determine whether the normal communication sending path is allowed to drive the external line. In order to reduce the impact of single point of failure of the main control software on the sending state, the physical interface confirmation state and the protocol verification state are output as two logical conditions, and the final sending enable state is generated by independent combinational logic. For the three types of interfaces, an interface selection state is set. Only when the physical interface confirmation, protocol verification and the corresponding interface selection are valid at the same time are the corresponding sending path allowed to be connected.
[0071] Specifically, when the system is powered on, reset, or the watchdog is reset, both the physical interface confirmation status and the protocol verification status are cleared, and all three transmission paths remain disconnected. After step S3 is completed, only the physical interface confirmation status is set, and after step S4 is completed, the protocol verification status is set. The two statuses are combined with the interface selection status to form the final transmission enable signal. After the transmission enable signal is established, only the transmission path corresponding to the confirmed interface is closed, while the other two types of transmission paths remain disconnected. Even if the software mistakenly selects another communication controller, it cannot affect the external line through an unauthorized transmission path.
[0072] Furthermore, to ensure that the transmission permission continuously corresponds to the current line status, this embodiment also sets a transmission authorization revocation condition. When the external interface re-detects the plugging / unplugging state, the physical line voltage exceeds the allowable range, the number of consecutive received frame errors reaches a set number, or the watchdog is reset, the protocol verification state is immediately cleared and the transmission permission signal is revoked. Specifically, the protocol verification state is revoked when five consecutive frames fail to meet the frame structure requirements of the confirmed protocol. After revocation, the system returns to the high-impedance sampling and transmission prohibition state. By setting a transmission authorization revocation mechanism, normal communication transmission permission can be revoked in a timely manner according to changes in the external line status and protocol verification results. This avoids continuing to drive the external line when the external interface is abnormal, communication parameters are mismatched, or the communication status changes, thereby improving the security and reliability of the communication access process.
[0073] During the actual communication establishment phase, the determined communication parameters are written into the corresponding communication controller, and normal communication frames are only allowed to be generated after the enable signal is sent. For RS485 / RS422 interfaces, the transmit / receive switching timing is adjusted according to the start position of the received data after the transmission frame ends. For CAN interfaces, the sampling point can be adjusted according to the reception stability after the bit rate has been confirmed. All adjustments during operation are based on the confirmation of the physical interface and protocol parameters, and the transmission paths of other interfaces are not reopened.
[0074] In particular, the candidate interface set in this embodiment also directly participates in controlling the subsequent probing content. When the candidate set includes RS232, the probing focuses on the single-ended response of the line to the reference ground. When the candidate set only has differential interfaces, the probing focuses on the common-mode and differential-mode responses. Once a certain interface has been eliminated by a single probing, the probing related to the specific characteristics of that interface will no longer be executed, thereby reducing the cumulative line action time caused by repeated probing under a fixed process.
[0075] In an feasible product calibration process, during the product design phase, known RS232 devices, known RS485 / RS422 devices, and known CAN devices are connected respectively, with the normal transmission path kept closed. Common-mode and differential-mode detection are repeatedly performed according to the same sampling frequency, current-limiting resistor, excitation time, and sampling time as the actual identification. For each supported line connection state, the corresponding response quantity is recorded and an allowable range is formed. The allowable range is based on the recorded extreme values, with device error and temperature drift margin added.
[0076] As another possible implementation, after physical interface confirmation, a confirmation hold time is set. During the confirmation hold time, the static voltage of the line and the receiving edge are continuously monitored. Protocol verification is only entered when the physical characteristics are consistent with the confirmation result. After the protocol verification is passed, periodic back-checks are also retained. When the static voltage of the line or the receiving frame structure deviates from the confirmed state, the transmission authorization is revoked. The confirmation hold time and periodic back-checks make the identification results have temporal continuity, which is used to handle peripheral hot-plugging and bus transient interference.
[0077] The technical solution of this embodiment forms a complete identification and access process through default blocking of the transmission path, independent rate limiting diagnosis, candidate interface driver detection, line response update, receiver-side protocol verification, and transmission authorization release. Step S1 restricts the output of the normal transmitter in an unknown state; steps S2 and S3 supplement information that passive detection cannot obtain under the influence of the restricted line; step S4 uses existing external communication signals to perform a second layer of confirmation on the physical judgment; and step S5 converts the two confirmation results into corresponding transmission permissions. The above steps are interdependent, with the state generated in the previous stage directly serving as the entry condition for the next stage, ensuring that interface identification, line security, and communication establishment remain in the same control chain.
[0078] Example 3: like Figure 2 As shown, based on Embodiment 1 or Embodiment 2, an industrial control board multi-interface identification and communication parameter adaptive configuration device is provided. The device is used for communication access between the industrial control board and unknown peripherals. When the peripherals are accessed, it is not predetermined whether they use RS232, RS485 / RS422 or CAN. The device connects to the peripherals through external interfaces and keeps all normal transmission paths closed before normal communication is established. The device is internally set with independent high-impedance sampling paths, diagnostic excitation paths, receiving paths and normal transmission paths, so that line detection, restricted detection, protocol reception and normal transmission are completed in the corresponding paths, and structurally ensures that different working stages have clear connection relationships and control conditions.
[0079] The receiving path control circuit includes a first receiving switch, a second receiving switch, and a third receiving switch corresponding to the RS232 transceiver, RS485 / RS422 transceiver, and CAN transceiver, respectively. The receiving path control circuit controls the corresponding receiving switch to be turned on or off according to the interface selection signal output by the controller. After the physical interface type is determined, only the receiving path of the corresponding physical interface is turned on, while other receiving paths are kept off.
[0080] Specifically, the device includes an external interface, an RS232 transceiver, an RS485 / RS422 transceiver, a CAN transceiver, a high-impedance sampling circuit, a diagnostic excitation circuit, a controller, a transmit enable circuit, three transmit switches, and three receive switches. The external interface is used to connect the peripheral device to be identified. The high-impedance sampling circuit is directly connected to the external interface and outputs the line sampling value to the controller. The diagnostic excitation circuit is connected to the external interface through an independent current-limiting branch. The receiving ends of the three transceivers are connected to the external interface through their corresponding receive switches, and the transmitting ends of the three transceivers are connected to the external interface through their corresponding transmit switches. The transmit enable circuit is connected to the control terminals of the three transmit switches. The controller is connected to the high-impedance sampling circuit, the diagnostic excitation circuit, the three receive switches, and the transmit enable circuit.
[0081] In one specific implementation, the external interface is provided with a first signal terminal, a second signal terminal, and a reference ground terminal. The first signal terminal and the second signal terminal serve as the initial line under test. For a two-wire differential interface, the first signal terminal and the second signal terminal correspond to a differential line pair. For a single-ended interface, the first signal terminal or the second signal terminal serves as a data line and the reference ground terminal serves as a voltage reference.
[0082] Furthermore, three transmit switches are positioned between the corresponding transceiver's drive output and the external interface. The first transmit switch corresponds to the RS232 transceiver, the second transmit switch corresponds to the RS485 / RS422 transceiver, and the third transmit switch corresponds to the CAN transceiver. The transmit switches are normally open analog switches or electronic switches with a high-impedance off state, and remain open during power-on, reset, and watchdog reset. By positioning the transmit switches between the transceiver and the external interface, the transmit-disabled state does not depend on the software configuration of a single communication controller.
[0083] Three receiving switches are respectively set between the external interface and the receiving input of the corresponding transceiver. During the initial identification phase, all three receiving switches are kept open, and the high-impedance sampling circuit observes the external line separately. After the controller determines the physical interface type based on the line sampling and diagnostic detection results, it closes only the receiving switch corresponding to that physical interface, while the other receiving switches remain open. This ensures that during the protocol verification phase, only the confirmed receiving path is connected to the external interface.
[0084] In one embodiment, the high-impedance sampling circuit provides an input protection resistor, a bias resistor network, and a voltage buffer for the first and second signal terminals, respectively. Each signal terminal is connected to a sampling node via a 1 MΩ input resistor, and the sampling node is connected to a 3.3 V power supply and a reference ground via a 220 kΩ resistor. Assuming that the input current of the subsequent stage is ignored, the protection device is not conducting, and the power supply voltage is stable, let the voltage of the external line relative to the reference ground be V. in The sampling node voltage is V s Then the two satisfy an approximate relationship: V s≈0.0991V in +1.4865.
[0085] The negative voltage of the external line is attenuated and DC biased to be converted into a positive sampling node voltage. For example, when the external line voltage is -10 V, the sampling node voltage is approximately 0.495 V; when the external line voltage is +10 V, the sampling node voltage is approximately 2.477 V. The sampling node is connected to the analog-to-digital converter input of the controller via a voltage follower. The controller reconstructs the external line voltage based on the sampling node voltage and a pre-calibrated conversion relationship.
[0086] The high-impedance sampling circuit incorporates an input protection device and a resistor attenuation bias network. The input protection device limits the impact of abnormal transient voltages or currents on subsequent circuits, while the resistor attenuation bias network converts external line voltages within the effective linear sampling range into allowable sampling node voltages for subsequent stages. The voltage conversion relationship of the resistor attenuation bias network is applicable only when the input protection device is not clamped. When the input protection device is on and the sampling node voltage exceeds the effective operating range of the voltage buffer or analog-to-digital converter, the controller acquires the sampling node voltages at the first and second signal terminals, respectively. If the effective linear sampling condition is met, the controller reconstructs the corresponding external line voltage based on a pre-calibrated ratio and bias relationship, and then calculates the differential voltage from the reconstructed two-line voltages.
[0087] Specifically, the diagnostic excitation circuit is configured with three normal communication transmission paths respectively, without generating a detection level through an RS232 transceiver, RS485 / RS422 transceiver, or CAN transceiver. In this embodiment, the diagnostic excitation circuit is equipped with a 3.3 V reference voltage source, first to fourth current-limiting resistors, and first to fourth analog switches. The first signal terminal can be connected to the reference voltage source through the first analog switch and the first current-limiting resistor, and can be connected to the reference ground through the third analog switch and the third current-limiting resistor. The second signal terminal can be connected to the reference voltage source through the second analog switch and the second current-limiting resistor, and can be connected to the reference ground through the fourth analog switch and the fourth current-limiting resistor.
[0088] In one specific implementation, the first to fourth current-limiting resistors are all 47 kΩ resistors, and the four analog switches are analog switches that are off by default upon power-on. The controller outputs four diagnostic control signals respectively. When performing detection in the same direction, the first and second analog switches are turned on simultaneously, so that the first signal terminal and the second signal terminal are respectively connected to a 3.3 V reference voltage source through the 47 kΩ resistor. When performing detection in the opposite direction, the first and fourth analog switches are turned on simultaneously, so that the first signal terminal is connected to the 3.3 V reference voltage source through the 47 kΩ resistor, and the second signal terminal is connected to the reference ground through the 47 kΩ resistor. When the detection direction is reversed, the second and third analog switches are turned on simultaneously. The conduction time of each analog switch is limited by the controller timer, and all switches are turned off after conduction ends.
[0089] Furthermore, to avoid the diagnostic excitation path and the normal transmission path being activated simultaneously, this embodiment sets a diagnostic status signal DIAG_ACTIVE. When the diagnostic status signal is valid, the transmission enable circuit forces the three transmission switches to remain open. The controller is only allowed to enter the receiver-side protocol verification stage after all four diagnostic analog switches are in the open state and the line recovery waiting time has elapsed. The diagnostic status signal is directly generated by the diagnostic excitation control logic, forming a hardware interlock relationship between diagnostic excitation and normal transmission. The interlock relationship is used to handle the risk of simultaneous activation caused by software process abnormalities, task scheduling errors, or control signal delays.
[0090] Specifically, the diagnostic excitation circuit also uses the real-time line voltage from the high-impedance sampling circuit to calculate the expected current in the current-limiting branch. Before closing a certain analog switch, the controller reads the voltage at the corresponding signal terminal and obtains the expected current by dividing the difference between the reference terminal voltage and the line voltage by the resistance of the current-limiting resistor. When the expected current exceeds the set upper limit, the current detection control signal is not output, the diagnostic state remains in a waiting state, and the line voltage is re-acquired. During the conduction of the analog switch, the high-impedance sampling circuit continues to sample the corresponding signal terminal. When the voltage change exceeds the predetermined allowable range, the current analog switch is immediately closed, enabling the diagnostic excitation circuit to simultaneously possess two levels of control conditions: pre-detection judgment and detection cancellation.
[0091] In this embodiment, the controller employs a microcontroller with an analog-to-digital converter interface, a timer input capture interface, a general-purpose input / output interface, a UART controller, and a CAN controller. The three sampling outputs of the high-impedance sampling circuit are connected to the analog-to-digital converter interface, the digital output of the received signal is connected to the timer input capture interface, and the control terminals of the four diagnostic analog switches are connected to the general-purpose output interface. The controller internally stores the candidate interface status, the corresponding relationship of the detection methods, and the calibration response range of each interface. The candidate interface status is updated based on the high-impedance sampling results and diagnostic detection results. The updated candidate interface status further determines the subsequent combination of diagnostic analog switches that are allowed to conduct.
[0092] Furthermore, the candidate interface status is stored internally in bit states, for example, RS232 candidate bits, RS485 / RS422 candidate bits, and CAN candidate bits are set separately. During initialization, all three candidate bits are valid. Based on the high-impedance sampling results, obviously inconsistent candidate bits are deleted. When multiple valid candidate bits still exist, the controller reads the detection control table corresponding to the candidate status and generates the corresponding analog switch combination and detection duration. After the detection is completed, the controller compares the collected line voltage change, differential voltage change, and recovery characteristics with the calibration range in the non-volatile memory, deletes inconsistent candidate bits, and selects the next detection according to the new candidate status.
[0093] Specifically, the calibration response range is written into non-volatile memory during the product design or production calibration stage. The calibration device uses the same high-impedance sampling circuit and diagnostic excitation circuit as the actual product, and is connected to known RS232 interface, known RS485 / RS422 interface and known CAN interface respectively. The line response is obtained according to the same analog switch combination, current limiting resistor and sampling time as in actual identification. Each interface type can save multiple sets of allowable ranges for terminal, no terminal and different cable connection status. In the actual identification process, as long as the current line response falls into the set of allowable ranges corresponding to the candidate interface, the candidate interface is retained, leaving room for adjustment for field terminal differences and device tolerances.
[0094] To ensure that physical interface confirmation and protocol verification are two confirmation conditions from different sources, the controller generates a physical interface confirmation signal PHY_OK and a protocol verification signal PROTO_OK. PHY_OK is only valid when there is one candidate interface remaining and subsequent confirmation probes are still consistent with the calibration range of that interface. PROTO_OK is only valid after the corresponding receive switch is closed and the frame structure and communication parameters are verified by receiving signals. The two signals are stored in independent status registers and are cleared upon power-on, peripheral disconnection, line abnormality, or watchdog reset.
[0095] Furthermore, when PHY_OK is valid, the controller outputs a selection signal of SEL_232, SEL_485, or SEL_CAN, and closes only the corresponding receive switch. For example, when the physical interface is confirmed to be CAN, SEL_CAN is valid, the CAN receive switch is closed, the CAN transceiver enters the receive state while the transmit switch remains open, and the CAN controller verifies the candidate bit rate and frame structure in a listening-only state. When the physical interface is confirmed to be RS232 or RS485 / RS422, the controller closes the corresponding receive switch and records the receive edges through the corresponding receiver and timer input capture interface to determine the candidate baud rate and serial frame format.
[0096] The transmit enable circuit is implemented using combinational logic independent of the main control program's transmit function. In this embodiment, three AND gates are set up: the first AND gate corresponds to the RS232 transmit switch, the second AND gate corresponds to the RS485 / RS422 transmit switch, and the third AND gate corresponds to the CAN transmit switch. Each AND gate receives the PHY_OK, PROTO_OK, and corresponding interface selection signals, respectively. The outputs of the three AND gates drive the control terminals of the three transmit switches, respectively. Only when the physical interface is confirmed, the protocol is verified, and the interface selection is consistent, will the corresponding transmit switch have the closing condition.
[0097] In the implementation of diagnostic interlocking, the three AND gates also receive the diagnostic idle signal DIAG_IDLE. DIAG_IDLE is only valid after all four diagnostic analog switches are open and the line recovery waiting time has ended. Therefore, the final transmission enable relationship is jointly determined by PHY_OK, PROTO_OK, the corresponding interface selection signal, and DIAG_IDLE. By adding the DIAG_IDLE condition, the diagnostic stimulus path and the normal transmission path remain mutually exclusive in hardware control. Even if PHY_OK and PROTO_OK remain valid due to program abnormalities, the normal transmission switch cannot be closed as long as the diagnostic stimulus is in the working state. This structure can be used as a further implementation of transmission safety control.
[0098] The diagnostic status signal DIAG_ACTIVE indicates whether the diagnostic excitation circuit is in the diagnostic excitation execution state. DIAG_ACTIVE is valid when any diagnostic analog switch is in the diagnostic excitation on state. The diagnostic idle signal DIAG_IDLE indicates that the diagnostic excitation has stopped and the line recovery waiting condition has been met. DIAG_IDLE is valid only when all diagnostic analog switches are off and the preset line recovery waiting time has ended. DIAG_IDLE remains invalid during the diagnostic excitation execution period and during the line recovery waiting period after the diagnostic excitation stops, and the normal communication transmission path remains prohibited.
[0099] In one specific implementation, pull-down resistors are set at the output terminals of PHY_OK and PROTO_OK respectively, so that the two confirmation signals remain invalid when the controller is in a reset, high-impedance, or uninitialized state; the three interface selection signals are also set to a default invalid state, and the enable terminals of the three transmit switches adopt low-level shutdown logic, so that no instantaneous conduction of the transmit path occurs during the entire process from power-on to controller initialization; for switching devices that adopt high-level shutdown, an inverter is added between the transmit enable circuit and the switch control terminal, so that the default state upon power-on still corresponds to the transmit being disconnected.
[0100] The device also has peripheral status detection conditions. The controller continuously monitors the external interface using a high-impedance sampling circuit. When the transmission path is open and the static voltage of the line suddenly deviates from the allowable range of the confirmed interface, the continuous received frame structure error reaches a set number, the external interface is re-plugged or unplugged, or the controller's watchdog is reset, PROTO_OK is immediately cleared, and the three transmission enable logics are disabled. When the physical line changes further cause the original interface confirmation conditions to be invalid, PHY_OK is cleared synchronously, and the device returns to the initial identification state where the three transmission switches are open, the three reception switches are open, and the high-impedance sampling is valid.
[0101] This embodiment also includes a transmit authorization latch in the transmit enable circuit. When PHY_OK and PROTO_OK are both valid, only a transmit authorization request is generated. The transmit authorization latch is only set after confirming that the diagnostic state is invalid, the corresponding receive path is stable, and the external line is in an enabled state. When any cancellation condition occurs, the latch is asynchronously reset and the transmit switch is directly disconnected. The asynchronous reset path does not go through the controller's main loop, reducing the problem of transmit permissions not being revoked in time when the program is blocked.
[0102] In the actual wiring of the device, the high-impedance sampling circuit and the diagnostic excitation circuit are preferentially arranged near the external interface. The transmission paths of the three normal communication transceivers are connected to the external interface after passing through the transmission switch. The diagnostic excitation branch is connected to the external interface side of the transmission switch, so that the real external line can still be limitedly probed when the transmission switch is open. The high-impedance sampling circuit is also connected to the external interface side of the transmission switch, so that the line sampling position is not affected by whether any normal transmission path is connected or not. The sampling and diagnosis are always applied to the real external line, while the normal transmission path is kept under the independent control of the transmission switch.
[0103] It should be noted that external interfaces may have long cables, electromagnetic interference, and differences in terminal configuration. Therefore, the reference ground of the high-impedance sampling circuit, diagnostic excitation circuit, and communication transceiver should adopt a unified signal reference relationship. If necessary, common-mode protection and isolation devices can be added to the external interface side. When using an isolated transceiver, the transmit switch is set on the bus side of the isolation device or the transceiver drive output side, as long as its disconnected state can prevent normal transmit drive from reaching the external interface. The diagnostic excitation branch should be kept independently connected, and the reference voltage and current-limiting resistor should be reselected according to the voltage range allowed by the isolation side.
[0104] The high-impedance sampling circuit passively acquires data in unknown states, while the diagnostic excitation circuit acts as a limited line when passive information is insufficient. The controller controls the combination of diagnostic analog switches and completes candidate updates based on the candidate interface status. The receive switch ensures that protocol verification after physical interface confirmation maintains unidirectional reception. The transmit enable circuit controls the corresponding transmit switch based on PHY_OK, PROTO_OK, and interface selection status. The interconnections between these structures enable the device to keep the normal transmit path closed when both the interface type and communication parameters are unknown, and to open the unique corresponding normal transmit path only after obtaining evidence of the physical interface and protocol reception.
[0105] Example 4: Based on Examples 1 to 3, this example further explains the situations in industrial sites such as peripheral silence, hot-swappable lines, differences between cables and terminals, the inability to uniquely determine candidate interfaces for a long time, and changes in line status after normal communication is established.
[0106] Specifically, the initial state after the peripheral device is connected is set to the waiting identification state. In the waiting identification state, the three transmit switches remain open, and the high-impedance sampling circuit continuously obtains the first signal terminal voltage, the second signal terminal voltage, and the differential voltage. When the line changes from the reference state when no peripheral device is connected to a new stable state, the controller retains a stable observation time. During the stable observation time, it determines whether the line voltage is continuously in a similar range and whether a valid edge appears.
[0107] In one implementation, the stable observation time consists of several consecutive sampling windows, each sampling window using the same sampling frequency as in Example 2; when the changes in the average voltage of the first signal terminal, the average voltage of the second signal terminal, and the differential average voltage in two adjacent sampling windows are all less than one percent of the full scale of the corresponding sampling quantity, the line is recorded as stable; if any sampling quantity continuously deviates from the previous window, the stable observation restarts; after using window continuity as the access confirmation condition, the subsequent candidate interface judgment is based on the state that the line has completed power-on or plug-in transition, reducing the situation where transient changes are interpreted as interface characteristics.
[0108] Furthermore, when data is actively transmitted by an external device during the stable observation period, the controller prioritizes using the level polarity, differential change, and edge time obtained from passive sampling to complete the candidate interface screening and temporarily suspends diagnostic excitation. Only when no effective edge is detected in multiple consecutive observation windows and there are still more than two candidate interfaces will the controller enter the diagnostic excitation state. The triggering conditions for diagnostic excitation are limited by both the number of candidate interfaces and the line activity status. No additional detection is applied when the line itself can provide sufficient information. Physical information is supplemented by limited detection when the line is silent and passive information is insufficient.
[0109] Line silence refers to the absence of any valid level transition exceeding the noise threshold during a stable observation period. Line silence does not indicate the lack of communication capability of the external device. For silent peripherals, the controller determines the physical interface type through high-impedance sampling and diagnostic excitation, and retains the obtained physical interface confirmation results. Until a valid communication signal capable of completing protocol verification is received, PROTO_OK remains invalid, and the normal communication transmission path remains disconnected, waiting for new communication activity from the external device. Only after the receiving side's protocol verification is successful, the diagnostic excitation has stopped, and the interface selection status is consistent, is the corresponding normal communication transmission path allowed to be opened.
[0110] To accommodate response differences arising from different cable lengths, terminal connections, and transceiver models for the same interface type, a working range and a boundary range are set for the interface response range. The working range is formed by the stable response area obtained from repeated probing of the reference interface. The boundary range retains the margin for device error and line variation outside the working range. When the measurement result is within the working range, the corresponding candidate interface is retained. When the measurement result exceeds the boundary range, the corresponding candidate interface is deleted. When the measurement result is between the working range and the boundary range, the candidate interface is not deleted temporarily, and the measurement is repeated using a different direction or a different excitation method.
[0111] In one calibration implementation, multiple common-mode current limiting excitations, forward differential-mode current limiting excitations, and reverse differential-mode current limiting excitations are performed on each reference interface. The maximum and minimum values of line voltage change, differential voltage change, recovery ratio, and the response difference between the two lines are recorded. The maximum and minimum values of each set of parameters form the working range. A fixed percentage of tolerance is added outside the upper and lower limits to form the boundary range. For parameters whose working range span is close to the sampling noise, the peak-to-peak value of the noise measured by the sampling front end in the open-circuit state of the external interface is used as the minimum extension amount to avoid forming an excessively narrow judgment interval due to the parameter span being too small.
[0112] The calibration response range uses the same reference voltage source, current-limiting resistor, analog switch on-time, and sampling time as the actual identification, ensuring that the calibrated values and field measurements have the same physical meaning. After changing the current-limiting resistor, reference voltage source, or sampling front end, the corresponding calibration response range is regenerated. Using the same measurement link for calibration and identification allows the line response comparison to reflect the differences between the external interface and the connecting lines themselves, reducing the impact of changes in measurement conditions on the candidate interface deletion results.
[0113] Specifically, to handle changes in ambient temperature and power supply voltage, a self-check is performed on the actual voltage of the reference voltage source and the zero point of the sampling front end before each identification begins. The actual voltage of the reference voltage source is obtained by the controller through internal reference voltage conversion. The zero point of the sampling front end is obtained when all diagnostic analog switches are disconnected and the external interface is in a known reference state. The diagnostic excitation current is calculated using the currently measured reference voltage value, and the line voltage recovery is calculated using the difference before and after the same detection. This ensures that the power supply deviation and the sampling zero point deviation are mainly manifested as common offsets and are not directly converted into interface type differences.
[0114] When external activity occurs during a probe, the controller immediately terminates the current diagnostic excitation based on the unexpected edge detected by the high-impedance sampling circuit. The four diagnostic analog switches are then disconnected, and the probe result is marked as invalid. After the line returns to a stable idle state, the newly occurred external activity is passively analyzed first. If the candidate interface still cannot be uniquely determined, the probe method corresponding to the current candidate set is reselected to avoid the external device writing the result of the superposition of the two electrical effects into the interface response comparison when it happens to start communicating during the diagnostic excitation period.
[0115] In one implementation, a separate counter is set for the detection failure state. When the same candidate combination fails to complete the detection continuously due to the expected detection current exceeding the upper limit, external activity on the line, or the voltage after detection failing to return to the allowable range within the recovery time, the controller stops increasing the number of detections and keeps the transmission path disabled. The controller enters a waiting state for line changes and resumes candidate judgment only when a new line edge is detected, the peripheral is re-plugged or unplugged, or the identification is manually retried. By limiting the number of consecutive invalid detections, repeated diagnostics are avoided on abnormal lines or unsupported interfaces.
[0116] Specifically, for applications with multiple signal lines under test on the external interface, each signal line is first kept in a high-impedance sampling state to obtain the voltage change of each signal line relative to the reference ground. Then, the correlation between differential voltage and level change is calculated for any two signal lines. When two signal lines show opposite changes at multiple effective edges, they are recorded as candidate differential line pairs. When a single signal line shows a significant positive or negative change relative to the reference ground and lacks an inverse correspondence with other signal lines, the signal line is recorded as a candidate single-ended signal line. Only the terminals marked as candidate line pairs or candidate single-ended signal lines enter the subsequent diagnostic excitation, while other terminals continue to be sampled at high impedance.
[0117] When multiple candidate differential line pairs exist, the controller records the differential activity count, synchronization between the two lines, and common mode variation range of each candidate line pair. Line pairs with stable dynamic characteristics are selected first for physical interface judgment. If all candidate line pairs are in a silent state, restricted common mode detection is performed on each line pair in order of line pair number. The candidate line pair set is updated after each line pair detection is completed. Line pairs that are obviously inconsistent with the supported interface response range will no longer enter differential mode detection.
[0118] It should be noted that the multi-line interface implementation still maintains the correspondence between transmission authorization and physical interface confirmation. When a certain line pair is determined to be a CAN or RS485 / RS422 working line pair, only the receiving path corresponding to that line pair enters the protocol verification, and the normal transmission path of other candidate line pairs remains disconnected. If the subsequent protocol verification fails and the physical interface is re-determined, the original line pair confirmation status is revoked, and the transmission enable circuit will not use the transmission permission generated by the previous line pair.
[0119] After normal communication has been established, the high-impedance sampling circuit continues to read the line static voltage and differential voltage at a monitoring frequency lower than that of the identification stage. At the same time, the controller counts the error status of the received frame. When the monitored value deviates once in a short period of time, only the abnormality is recorded and the transmission authorization is not immediately revoked. When the line voltage deviates from the boundary range of the confirmed interface for multiple consecutive monitoring windows, or when the protocol reception continuously produces errors and reaches the revocation condition, PROTO_OK is cleared first, the transmission enable circuit immediately disconnects the corresponding transmission switch, and then the controller rechecks whether PHY_OK is still true.
[0120] In one implementation, a protection waiting time is set after the transmission authorization is revoked. During the protection waiting time, all three transmission switches remain open. The high-impedance sampling circuit is used to confirm whether the external line has returned to stability. If the line still meets the working range of the original physical interface after recovery, the original PHY_OK is retained and the receiver-side protocol verification is performed again. If the electrical characteristics of the line have exceeded the boundary range of the original interface, the PHY_OK is cleared and all candidate interface states are restored. High-impedance sampling and candidate interface screening are then performed again.
[0121] The transmit authorization latch simultaneously receives a periodic hold signal. This periodic hold signal is updated only when the controller continuously confirms that the physical interface status, protocol status, and diagnostic idle status are all normal. If no new hold signal is received within a specified time, the transmit authorization latch resets and the transmit switch is turned off. In the device implementation, the periodic hold signal can be output from the controller's independent timer to a resettable latch in the transmit enable circuit. The timer is only reloaded after the main program completes one line status check and one protocol status check. When the watchdog timer resets, the program crashes, or the diagnostic status becomes valid again, the timer stops updating, and the latch reset terminal enters a valid state.
[0122] This embodiment also performs anomaly detection on the line recovery process after the diagnostic excitation ends. Assuming the stable voltage before excitation is V0, the recovery voltage V is obtained at multiple fixed moments after the analog switch is disconnected. r1 V r2 and V r3 When the continuous sampling results gradually approach V0, the line is considered to be in a normal recovery process; if the recovery voltage continues to move away from V0, a reverse sudden change occurs, or exceeds the allowable range of the sampling front end, the response will not be used to participate in the candidate interface comparison, and the line will enter an abnormal state.
[0123] For cases where the recovery process can be completed normally but the recovery speed is in the overlapping region of the response ranges of the two candidate interfaces, the controller does not differentiate by increasing the excitation amplitude, but instead selects the current-limiting probe in another direction or extends the passive observation time. In one implementation, when the previous probe is a common-mode current-limiting excitation and the result is in the overlapping region, the next probe uses a positive differential-mode current-limiting excitation. If the positive differential-mode result is still in the overlapping region, a reverse differential-mode current-limiting excitation is used. The probe sequence is pre-written into the probe control table based on the calibration response differences corresponding to the currently unexcluded interfaces, and different connection directions are used to supplement identification information while maintaining the same current-limiting level.
[0124] Specifically, the detection control table stores candidate status codes corresponding to detection action codes. Candidate status codes are composed of three candidate bits: RS232, RS485 / RS422, and CAN. Detection action codes correspond to single-wire forward detection, single-wire reverse detection, two-wire same-direction detection, first-direction differential-mode detection, and second-direction differential-mode detection, respectively. After each update of the candidate status codes, the controller reads the corresponding next detection action code. Actions already executed and whose results are indistinguishable are recorded as used in this round of identification, avoiding repeated execution of the same detection under the same candidate status. After a candidate status changes, a new detection action is selected according to the new status code.
[0125] The detection control table also records the maximum number of times each detection action can be used and the recovery waiting time. The maximum number of times limits the cumulative number of detections on the same line, and the recovery waiting time ensures that the transient effects of the previous excitation have decayed before the next sampling. When the maximum number of times has been reached and the candidate interface still cannot be uniquely determined, the controller does not automatically increase the detection current or extend the excitation time, but maintains the candidate state and waits for external dynamic signals. Through the joint constraints of detection actions, number of times, and recovery conditions, the candidate drive detection can have a clear exit condition.
[0126] Based on the preferred embodiments of the present invention described above, and through the above description, those skilled in the art can make various changes and modifications without departing from the technical concept of the present invention. The technical scope of the present invention is not limited to the contents of the specification, but must be determined according to the scope of the claims.
Claims
1. A method for multi-interface identification and adaptive configuration of communication parameters on an industrial control board, characterized in that, include: S1. After the peripheral device is connected, the normal communication transmission path of the RS232 transceiver, RS485 / RS422 transceiver and CAN transceiver is blocked. Only the high-impedance sampling circuit independent of the three transceivers obtains the line electrical status of the external interface and forms a candidate interface set based on the line electrical status. S2. When the candidate interface set contains at least two interface types, select the corresponding diagnostic detection method according to the current candidate interface set, apply diagnostic excitation to the signal line through a current limiting branch via a diagnostic excitation circuit independent of the normal communication transmission path, and obtain the line response during the diagnostic excitation and after the diagnostic excitation is withdrawn. S3. Update the candidate interface set according to the matching relationship between the line response and the corresponding response features of each candidate interface, and select the subsequent diagnostic detection method according to the updated candidate interface set until the physical interface type is determined; if the physical interface type cannot be uniquely determined after the preset exit condition is met, stop the diagnostic detection and keep the normal communication transmission path blocked. S4. After determining the physical interface type, keep the normal communication transmission path disabled. While keeping the other receiving paths of the three transceivers disconnected, only connect the receiving path of the corresponding physical interface, determine the candidate communication parameters based on the received signal, and perform protocol verification on the candidate communication parameters without sending verification data. S5. After the physical interface type is confirmed, the protocol verification is passed, and the diagnostic stimulus has stopped, the hardware logic circuit, which is independent of the communication controller software configuration, performs a logical combination to open only the normal communication transmission path corresponding to the determined physical interface.
2. The method for multi-interface identification and adaptive configuration of communication parameters for industrial control boards according to claim 1, characterized in that: The high-impedance sampling acquires the voltage to ground of the signal line and the differential voltage between the two signal lines, respectively. When a single signal line exhibits a positive or negative polarity level change that conforms to the characteristics of a single-ended interface, RS232 is retained in the candidate interface set. When two signal lines experience reverse voltage changes and form corresponding differential voltage changes, RS485 / RS422 and CAN are retained in the candidate interface set.
3. The method for multi-interface identification and adaptive configuration of communication parameters for industrial control boards according to claim 1, characterized in that: The diagnostic excitation circuit includes a reference voltage source, a current-limiting resistor, and a controlled switch. The controlled switch is used to selectively connect the reference voltage source or reference potential to the signal line under test through the current-limiting resistor and disconnect it after the set detection time.
4. The method for multi-interface identification and adaptive configuration of communication parameters for industrial control boards according to claim 1, characterized in that: When the candidate interface set includes both single-ended interfaces and differential interfaces, single-line current limiting detection in different directions is applied to at least one signal line. When the candidate interface set includes RS485 / RS422 and CAN, current limiting detection in the same direction and current limiting detection in the opposite direction are applied to the two signal lines respectively to obtain the common-mode response and differential-mode response of the line.
5. The method for multi-interface identification and adaptive configuration of communication parameters for industrial control boards according to claim 1, characterized in that: Based on the line state before diagnostic excitation, the line state during diagnostic excitation, and at least one line state after diagnostic excitation is removed, the line voltage change characteristics, differential response characteristics, and recovery characteristics are obtained. The response characteristics of each interface are obtained in advance by the known interface under the sampling path, diagnostic excitation conditions and sampling timing corresponding to the interface identification stage, and candidate interfaces are retained or deleted according to the matching results of the line voltage change characteristics, differential response characteristics and recovery characteristics with the corresponding response characteristics.
6. The method for multi-interface identification and adaptive configuration of communication parameters for industrial control boards according to claim 1, characterized in that: When the physical interface type is determined to be CAN, the normal CAN communication transmission path is disabled and the CAN reception path is enabled. The candidate bit rate is determined according to the edge interval of the received signal, so that the CAN controller operates in a listening-only state according to the candidate bit rate, and the protocol verification is determined based on the frame format, bit stuffing and cyclic redundancy check results of the received CAN frame.
7. The method for multi-interface identification and adaptive configuration of communication parameters for industrial control boards according to claim 1, characterized in that: When the physical interface type is determined to be RS232 or RS485 / RS422, the candidate baud rate is determined according to the level transition interval of the received signal, and the same segment of the acquired received signal is decoded according to multiple serial frame formats. The communication parameters and protocol verification results are determined according to the start bit, stop bit and check relationship.
8. The method for multi-interface identification and adaptive configuration of communication parameters of an industrial control board according to claim 1, characterized in that: Before performing diagnostic excitation, the expected detection current is determined based on the excitation terminal potential, the potential of the signal line under test, and the resistance of the current-limiting branch. When the expected detection current exceeds the allowable range, the corresponding diagnostic excitation is prohibited. During the diagnostic stimulus, the line status is continuously monitored. When the line response exceeds the preset allowable range, the current diagnostic stimulus is terminated, and the normal communication transmission channel is blocked.
9. A device for multi-interface identification and adaptive configuration of communication parameters for industrial control boards, characterized in that: It includes an external interface, an RS232 transceiver, an RS485 / RS422 transceiver, a CAN transceiver, a high-impedance sampling circuit, a diagnostic excitation circuit, a controller, a receive path control circuit, and a transmit enable circuit. The high-impedance sampling circuit is connected to the external interface and is used to obtain the electrical status of the line when the normal communication transmission path of each transceiver is blocked. The diagnostic excitation circuit is independent of the normal communication transmission path and is connected to the external interface through a current-limiting branch. The controller is used to form a candidate interface set according to the electrical state of the line. When the candidate interface set contains at least two interface types, it controls the diagnostic excitation circuit to select the corresponding diagnostic detection method according to the current candidate interface set, and updates the candidate interface set according to the line response during the diagnostic excitation and after the diagnostic excitation is withdrawn, so as to determine the physical interface type. The receiving path control circuit is used to connect only the receiving path of the corresponding physical interface after the physical interface type is determined. The controller determines the communication parameters and performs protocol verification based on the received signal while the corresponding normal communication transmission path is kept prohibited. The transmit enable circuit is used to connect only the normal communication transmit path of the corresponding physical interface after the physical interface type is confirmed, the protocol verification is passed, and the diagnostic excitation stops.
10. The industrial control board multi-interface identification and communication parameter adaptive configuration device according to claim 9, characterized in that: The transmit enable circuit includes transmit switches and hardware logic circuits corresponding to RS232 transceivers, RS485 / RS422 transceivers and CAN transceivers respectively. The hardware logic circuit generates the transmission enable state of the corresponding transmission switch based on the physical interface confirmation signal, the protocol verification signal, the corresponding interface selection signal, and the diagnostic idle signal that indicates the stop of diagnostic excitation, so that all normal communication transmission paths remain disconnected when the diagnostic excitation is in the working state. When the device is powered on or reset, the physical interface confirmation signal and protocol verification signal remain invalid, keeping all transmitting switches open.
Citation Information
Patent Citations
A gateway device for automatically identifying communication buses and protocols based on small signal analysis
CN112202741B
