USB-a interface and serial port dynamic switching and protection system based on analog switch

By using analog switches and dynamic priority scheduling algorithms, combined with multi-dimensional electrical protection mechanisms, flexible switching and collaborative protection between the USB-A interface and the serial port are achieved, solving the problem of insufficient coordination between switching and protection in existing technologies and improving communication reliability and stability.

CN120803998BActive Publication Date: 2025-11-21BEIJING SATECOMM SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511318764.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-16
Publication Date
2025-11-21
Estimated Expiration
2045-09-16

AI Technical Summary

Technical Problem

In the existing technology, the dynamic switching process between the USB-A interface and the serial port lacks a graded protection mechanism for power overcurrent, overvoltage and signal interference, and the coordination between switching and protection is insufficient, which makes the interface and back-end circuits easy to be damaged and the communication reliability insufficient.

Method used

A dynamic switching and protection system for USB-A interface and serial port based on analog switches is adopted, including a main control unit, an analog switch unit, a hierarchical protection unit, a protocol adaptation unit, and a status detection unit. Through a dynamic priority scheduling algorithm and a multi-dimensional electrical protection mechanism, flexible switching and collaborative protection between USB-A interface and serial port are achieved.

Benefits of technology

It enhances the flexibility and adaptability of interface switching, reduces the risk of hardware damage, improves communication reliability and stability, and ensures the coordination between USB-A interface and serial communication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120803998B_ABST
    Figure CN120803998B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of communication, in particular to a USB-A interface and serial port dynamic switching and protection system based on an analog switch. The system comprises a master control unit, an analog switch unit, a hierarchical protection unit, a protocol adaptation unit and a state detection unit. The master control unit is used for overall planning of dynamic switching and conflict coordination of the USB-A interface and the serial port, generates conflict-free channel switching control instructions by integrating a dynamic priority scheduling algorithm, combining USB data transmission real-time load, serial communication request urgency and device historical interaction records fed back by the state detection unit, and drives the analog switch unit to complete channel gating. The application relies on the master control unit, carries out priority scheduling in combination with multi-dimensional parameters such as transmission load of the USB-A interface and communication urgency of the serial port UART, can flexibly switch the communication channels of the USB-A interface and the serial port, enhances the flexibility and adaptability of interface switching, and solves the switching limitation problem caused by a single triggering condition.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application relates to the technical field of communication, in particular to a USB-A interface and serial port dynamic switching and protection system based on an analog switch. BACKGROUND

[0002] The USB-A interface and the serial port are commonly used communication interfaces in electronic devices. In actual application scenarios, the communication channel needs to be dynamically switched according to the data transmission load of the USB-A interface, the communication request urgency of the serial port and other requirements, so as to avoid interface conflicts. At the same time, the USB-A interface is prone to risks such as power overcurrent, overvoltage and signal high-frequency interference under the conditions of live insertion and complex electromagnetic environment, and needs to be equipped with protection measures to ensure the stability of interface communication and the reliability of backend hardware. This is the core basic problem that needs to be solved in the current application of this type of interface.

[0003] For example, Chinese patent CN202311376986.8 discloses a multifunctional interface and switching system in the form of USB. The system includes a serial port module, a CPLD, a serial-USB conversion circuit, a USB HUB, a USB switch chip, a USB Type A interface and a BMC. Through the combination of software and hardware, the USB Type A interface can realize the functions of CPU serial port, BMC serial port, BMC USB HOST and BMC virtual network, thereby improving the interface utilization rate and operation convenience. For another example, Chinese patent CN201710087535.0 discloses a communication device and a switching method for USB and serial port. The communication device includes a main processor (integrating a USB unit and a UART unit), a USB port and a switching unit connecting the two. The switching unit realizes switching by detecting the level signal of the USB port ID pin. When the level is the first level, the USB port is connected to the USB unit, and when the level is the second level, the USB port is connected to the UART unit. No additional software intervention is required, which reduces the processor workload and improves the switching convenience.

[0004] Although the above technical solutions have corresponding design advantages, they still have the following technical defects: first, the protection mechanism is missing. CN202311376986.8 improves the utilization rate of the USB-TypeA interface, but does not design a hierarchical protection mechanism for power overcurrent, overvoltage and signal anti-interference during the dynamic switching process of the USB-TypeA interface and the serial port. The interface and the backend circuit are prone to damage under complex working conditions. Second, the switching and protection coordination is insufficient. CN201710087535.0 only relies on the single condition of the level of the USB port ID pin for switching, cannot conduct intelligent priority scheduling in combination with multi-dimensional parameters such as USB transmission real-time load and serial port communication urgency, and lacks electrical protection design for the serial port UART, which is insufficient in communication reliability. SUMMARY

[0005] The application aims to provide a USB-A interface and serial port dynamic switching and protection system based on analog switches to solve the problems in the background art.

[0006] To achieve the above technical problems, the application aims to provide a USB-A interface and serial port dynamic switching and protection system based on analog switches, which comprises:

[0007] A master control unit is used to plan the dynamic switching and conflict coordination of the USB-A interface and the serial port, integrate a dynamic priority scheduling algorithm, combine the real-time load of USB data transmission, serial port communication request urgency and device historical interaction record fed back by a state detection unit, generate a conflict-free channel switching control instruction, and drive an analog switch unit to complete channel gating;

[0008] An analog switch unit is used to establish the physical channel gating path of the USB-A interface and the serial port, switch the signal transmission of the USB-A interface or the serial port to the common interface through the analog switch circuit of the switchable signal path, and switch the conduction state according to the control instruction of the master control unit;

[0009] A hierarchical protection unit is used to realize multi-dimensional electrical protection of the USB-A interface, and a cooperative protection mechanism of power supply and signal is formed by connecting an overcurrent protection device in series in the power supply path of the USB-A interface, connecting an overvoltage suppression device in parallel at the power supply end, and connecting a high-frequency interference filter device across the signal path.

[0010] A protocol adaptation unit is used to realize the dynamic compatibility of USB and serial port protocols, integrate a switchable protocol analysis circuit, load the signal encoding and decoding logic of the corresponding protocol based on the instruction of the master control unit, and complete the signal format conversion.

[0011] A state detection unit is used to collect the interface connection and running state, monitor the USB-A interface plug-in signal, serial port communication request signal and power supply state signal, and convert the detection results into electrical signals and transmit them to the master control unit.

[0012] A power management unit is used to provide stable power supply for the master control unit, analog switch unit, hierarchical protection unit, protocol adaptation unit and state detection unit, integrate a voltage conversion circuit and a voltage stabilizing circuit, access an external input power supply and perform multi-stage voltage regulation, and output stable voltage suitable for work requirements.

[0013] As a further improvement to this technical solution, the main control unit includes a parameter quantization module, a priority scheduling module, and an instruction output module, wherein:

[0014] The parameter quantization module is used to collect the real-time USB transmission parameters and serial port parameters output by the status detection unit. Request parameters and convert them into calculable quantized values;

[0015] The priority scheduling module uses a dynamic priority scheduling algorithm to schedule the quantized USB and serial ports. Parameters are prioritized and conflict is determined.

[0016] The instruction output module generates channel switching control instructions that conform to the hardware interface specification of the analog switch unit based on the priority scheduling result.

[0017] As a further improvement to this technical solution, the parameter quantization module includes a USB load quantization submodule and a serial port emergency quantization submodule, wherein:

[0018] The USB load quantization submodule is used to generate USB load quantization values. Based on the nominal speed of the protocol type followed by the USB-A interface (such as USB 2.0, USB 1.1, etc.), and the real-time USB transfer rate, the transfer load percentage is converted into... ;

[0019] The serial port emergency metric submodule is used to generate serial port emergency metric values. By parsing the serial port The request signal will include an emergency level flag that conforms to industry standards, and the serial port will... Urgency mapping to The higher the emergency level, the more... The larger the corresponding value.

[0020] As a further improvement to this technical solution, the priority scheduling module performs priority calculation and conflict determination through a dynamic priority scheduling algorithm, including the following steps:

[0021] S120.1 Obtain the USB load quantization value output by the parameter quantization module. and serial port emergency metric value Combined with preset USB load weights Serial port urgency weight ( (Initial weights are set via the hardware configuration interface), calculating the USB interface and serial port. Initial priority;

[0022] S120.2 Dynamically adjust the weights based on the continuous monitoring results of the status detection unit:

[0023] If the USB transfer rate is detected to meet the high-load characteristics defined by its protocol type N times consecutively, then increase... And reduce synchronously After adjustment The maximum weight limit for hardware adaptation shall not be exceeded.

[0024] If the serial port is detected M times consecutively Sending the highest urgency level request conforming to industry standards will increase the risk. And reduce synchronously After adjustment The maximum weight limit for hardware adaptation shall not be exceeded.

[0025] S120.3, Calculate USB and serial ports The priority difference, if the priority difference is greater than or equal to the conflict threshold. ( Based on the nominal switching time specified in the analog switch unit hardware specifications (ensuring stable communication establishment after signal switching), the higher priority channel is directly determined as the current selected channel; if the priority difference is < Then the USB data frame interval obtained by the status detection unit and the serial port... Request timeout period, prioritizing channels that require a response before the timeout period;

[0026] S120.4 Real-time monitoring of USB load quantization values Serial port emergency quantization value If any quantization value exceeds its physical definition range (e.g., the USB load quantization value exceeds the maximum transmission capacity of the corresponding protocol), the current weight adjustment logic is frozen, and the existing priority calculation method is maintained until the status detection unit sends back an abnormality cancellation signal.

[0027] As a further improvement to this technical solution, the analog switch unit includes a control interface module, a channel switching module, and a signal transmission module, wherein:

[0028] The control interface module is used to receive channel switching control commands output by the main control unit, and convert the 8-bit channel identifier, 8-bit switching delay parameter, and 8-bit CRC check code contained in the command into control signals that conform to the logic level of the analog switch circuit.

[0029] The channel switching module includes at least two independent single-pole double-throw (SPD) switch circuits, one of which corresponds to the power and signal paths of the USB-A interface, and the other corresponds to the serial port. The sending and receiving signal path of the USB interface module is switched on or off by the control signal output by the control interface module;

[0030] The signal transmission module is used for connecting the channel switching module and the public interface, and the circuit impedance of the signal transmission module matches the USB-A interface and the serial port with the characteristic impedance requirement, ensuring that the signal transmission has no reflection attenuation.

[0031] As a further improvement of the technical solution, the channel switching module comprises a USB channel submodule, a serial port channel submodule and an interlocking logic submodule, wherein:

[0032] The USB channel submodule adopts a 4-way independent analog switch (corresponding to the VCC, D+, D- and GND signals of the USB, respectively), and the on-resistance of the switch meets the low-loss transmission requirement of the USB differential signal, and the off-isolation resistance meets the signal isolation requirement between channels;

[0033] The serial port channel submodule adopts a 2-way independent analog switch (corresponding to the TXD and RXD signals of the serial port , respectively), supports the level range specified in the serial port protocol, and the switching time of the switch meets the timing requirement corresponding to the serial port communication rate;

[0034] The interlocking logic submodule is used for preventing the USB channel and the serial port channel from being switched on at the same time: when it is detected that the control signal of the USB channel submodule is in the on state, the control signal of the serial port channel submodule is automatically locked in the off state; when it is detected that the control signal of the serial port channel submodule is in the on state, the control signal of the USB channel submodule is automatically locked in the off state, and the interlocking response time meets the timing constraint of the channel switching.

[0035] As a further improvement of the technical solution, the signal transmission module comprises an impedance matching submodule and a signal filtering submodule, wherein:

[0036] The impedance matching submodule adjusts the impedance by connecting precise resistors in series, specifically including: connecting matching resistors in series on the D+ and D- signal lines of the USB channel, and connecting corresponding matching resistors in series on the signal lines of the serial port channel according to the protocol type, to ensure that the impedance of each channel meets the characteristic impedance standard specified in the interface protocol;

[0037] The signal filtering submodule is used for connecting a filtering capacitor across the D+ and D- signals and the ground of the USB channel, and connecting an RC low-pass filter circuit in series on the signal path of the serial port channel to suppress high-frequency interference signals and meet the signal integrity requirement of the interface protocol.

[0038] As a further improvement of the technical solution, the hierarchical protection unit comprises a power overcurrent protection module, a power overvoltage suppression module, a signal anti-interference filter module and a protection state linkage module, wherein:

[0039] The power overcurrent protection module is used for being connected in series in the power path of the USB-A interface, and matches the maximum interface power supply current specified by the USB protocol through a self-resetting fuse; when the current of the power path exceeds the rated threshold and the duration meets the USB power supply safety timing requirement, the fuse is automatically switched to a high resistance state to cut off the current; after the current falls below the rated threshold and the safety reset timing is maintained, the fuse is automatically restored to a low resistance conduction state;

[0040] The power overvoltage suppression module is used for being connected in parallel in the power end of the USB-A interface, and takes a TVS transient voltage suppression diode as a core device, the response speed meets the USB power end transient overvoltage protection requirement, and the clamping voltage is adapted to the safety threshold of the USB power supply nominal voltage; when the transient overvoltage occurs in the power end, the diode is quickly turned on to discharge the surge current;

[0041] The signal anti-interference filter module is used for being connected across the signal path of the USB-A interface, and adopts a combined structure of a common mode inductor and a ceramic capacitor, wherein: the common mode inductor is connected in series in the signal path and the common mode impedance characteristic is adapted to the high frequency interference suppression requirement of the USB signal transmission, and the ceramic capacitor is connected across each signal and GND respectively to suppress the high frequency differential mode interference and common mode interference in the signal path, and to ensure that the signal meets the signal integrity standard of the USB protocol;

[0042] The protection state linkage module is electrically connected with the power overcurrent protection module and the power overvoltage suppression module, monitors the on-off state of the power overcurrent protection module through a current sampling circuit, monitors the clamping state of the power overvoltage suppression module through a voltage sampling circuit, and converts the on-off state and the clamping state into a standard digital level (protection trigger output high level, normal output low level), which is fed back to the main control unit through an independent pin, and the main control unit suspends the USB channel switching until the protection is released after receiving the signal.

[0043] As a further improvement of the technical solution, the protocol adaptation unit comprises a protocol selection module, a USB protocol analysis module, a serial port protocol analysis module and a signal format conversion module, wherein:

[0044] The protocol selection module is electrically connected with the main control unit, and is used for receiving the protocol adaptation instruction output by the main control unit (100), and performing the following operations according to the protocol type identifier (corresponding to USB or serial port protocol) in the instruction: if the instruction is USB protocol adaptation, the USB protocol analysis module is enabled and the power supply of the serial port protocol analysis module is turned off; if the instruction is serial port Protocol adaptation, then enable the serial port protocol analysis module and turn off the power supply of USB protocol analysis module;

[0045] The USB protocol analysis module parses the original signal of the USB interface through a hardware circuit, loads the signal encoding logic (such as the Manchester encoding of the USB differential signal) and decoding logic (such as the level judgment of the differential signal and the extraction of the synchronous clock) corresponding to the USB2.0 and USB1.1 protocols, and converts the signal of the USB interface into a parallel signal conforming to the data format of the host unit;

[0046] The serial port protocol analysis module is used to load the frame structure analysis logic and the baud rate adaptation logic corresponding to the RS232 and RS485 serial ports According to the protocol, the start bit, data bit, check bit, and stop bit in the serial port signal are identified, and the sampling clock period is adjusted to convert the serial signal into a serial data frame;

[0047] The signal format conversion module is used to receive the parallel signal output by the USB protocol analysis module and the serial data frame output by the serial port protocol analysis module, and uniformly converts them into an 8-bit data format recognizable by the host unit, and the conversion delay does not exceed the channel switching time of the analog switch unit.

[0048] As a further improvement of the technical solution, the state detection unit includes a USB state detection module, a serial port state detection module, a power supply state detection module, and a state signal processing module, wherein:

[0049] The USB state detection module is used to monitor the device access state of the USB-A interface, and judges whether the USB device is inserted (the D+ voltage is higher than the D- when the USB device is inserted, and the voltages of the two tend to be consistent when it is pulled out) by detecting the voltage difference of the D+ and D- lines, and the monitoring period is synchronized with the scheduling period of the host unit;

[0050] The serial port state detection module is used to monitor the communication request state of the serial port device, identifies the request by detecting the level jump (high level indicates that the serial port device initiates a communication request, and low level indicates no request) of the serial port request signal line (such as the RTS line), and records the duration of the request signal to filter out transient interference;

[0051] The power supply state detection module is used to monitor the power supply state of the USB-A interface and the serial port device, and judges whether the power supply is normal by comparing the voltage collected by the voltage dividing resistor at the power supply end with the preset voltage threshold;

[0052] ​The state signal processing module is used for converting analog detection signals output by the USB state detection module, the serial port state detection module and the power supply state detection module into standard TTL digital levels (high level indicates abnormal state or request, and low level indicates normal state or no request), and transmitting the signals to the main control unit through three independent pins, and the signal transmission delay is less than the instruction generation period of the main control unit.

[0053] As a further improvement of the technical solution, the power management unit 600 is used for providing stable power supply for the main control unit 100, the analog switch unit 200, the hierarchical protection unit 300, the protocol adaptation unit 400 and the state detection unit 500, the input end of the power management unit 600 is provided with a basic input protection component, a self-recovery fuse is connected in series to adapt to the rated current of an external power supply to prevent overcurrent, and a TVS transient suppression diode is connected in parallel to adapt to the input voltage range to resist transient overvoltage, and a filter capacitor is connected after the protection circuit to filter high-frequency noise of the input power supply; then a DC-DC converter with a wide input range is used to form a voltage conversion component to convert the external input power supply into a system intermediate bus voltage such as 12V, the converter uses conventional PWM modulation to realize conversion, and a capacitor is connected in parallel at the output end to suppress ripple; and a multi-way voltage stabilization component is designed based on a low-dropout linear regulator, 3.3V voltage is output to supply power to logic circuits such as the main control unit 100 and the state detection unit 500, 5V voltage is output to supply power to the USB path of the analog switch unit 200 and the hierarchical protection unit 300, and auxiliary voltages such as ±12V required by special units such as a serial port can be generated as needed through a small converter, and different voltage domains are isolated by diodes to avoid interference.

[0054] Compared with the prior art, the present application has the following advantages:

[0055] 1. The present application relies on the main control unit to carry out priority scheduling in combination with multi-dimensional parameters such as the transmission load of the USB-A interface and the communication urgency of the serial port UART, can flexibly switch the communication channels of the USB-A interface and the serial port according to actual communication needs, enhances the flexibility and adaptability of interface switching, and solves the switching limitation problem caused by a single triggering condition.

[0056] 2. The hierarchical protection unit of the present application not only sets power overcurrent protection, power overvoltage suppression and signal anti-interference filtering modules for the USB-A interface, but also cooperatively protects the electrical safety of the serial port UART through protection state linkage, reduces the case of hardware damage caused by power supply abnormalities, signal interference and the like during dynamic switching and communication of the USB-A interface and the serial port, and improves the overall communication reliability of the system.

[0057] 3. The protocol adaptation unit of the present application can parse and format convert the communication protocol of the USB-A interface and the serial port UART, cooperate with the state detection unit to obtain the interface state in real time, enable the host control unit to more accurately master the interface running status, provide a more reliable basis for dynamic switching and hierarchical protection, and further ensure the stability and coordination of the USB-A interface and serial port communication. BRIEF DESCRIPTION OF DRAWINGS

[0058] Figure 1 The figure is a schematic diagram of the system framework of the present application.

[0059] The meanings of the various reference numerals in the figure are as follows:

[0060] 100, host control unit; 110, parameter quantization module; 111, USB load quantization sub-module; 112, serial port emergency degree quantization sub-module; 120, priority scheduling module; 130, instruction output module;

[0061] 200, analog switch unit; 210, control interface module; 220, channel switching module; 221, USB channel sub-module; 222, serial port channel sub-module; 223, interlocking logic sub-module; 230, signal transmission module; 231, impedance matching sub-module; 232, signal filtering sub-module;

[0062] 300, hierarchical protection unit; 310, power overcurrent protection module; 320, power overvoltage suppression module; 330, signal anti-interference filtering module; 340, protection state linkage module;

[0063] 400, protocol adaptation unit; 410, protocol selection module; 420, USB protocol parsing module; 430, serial port protocol parsing module; 440, signal format conversion module;

[0064] 500, state detection unit; 510, USB state detection module; 520, serial port state detection module; 530, power supply state detection module; 540, state signal processing module;

[0065] 600, power management unit. DETAILED DESCRIPTION

[0066] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of protection of the present application.

[0067] As Figure 1As shown, the embodiment provides a USB-A interface and serial port dynamic switching and protection system based on analog switch, comprising:

[0068] The master control unit 100 is used for overall planning of dynamic switching and conflict coordination of USB-A interface and serial port. Through integration of dynamic priority scheduling algorithm, the USB data transmission real-time load, serial port communication request emergency degree and device historical interaction record fed back by the state detection unit 500, a conflict-free channel switching control instruction is generated, and the analog switch unit 200 is driven to complete channel gating;

[0069] In the embodiment, the master control unit 100 includes a parameter quantization module 110, a priority scheduling module 120 and an instruction output module 130, wherein:

[0070] The parameter quantization module 110 is used for collecting USB real-time transmission parameters and serial port request parameters output by the state detection unit 500 and converting them into quantized values that can be calculated;

[0071] The priority scheduling module 120 performs priority calculation and conflict determination on the quantized USB and serial port parameters through a dynamic priority scheduling algorithm;

[0072] The instruction output module 130 generates a channel switching control instruction conforming to the hardware interface specification of the analog switch unit 200 according to the priority scheduling result.

[0073] As a further description of the embodiment, the instruction output module 130 of the embodiment specifically includes: reading the hardware interface specification (such as SPI interface communication protocol) of the analog switch unit 200, converting the priority determination result output by the priority scheduling module 120 into a channel switching control instruction conforming to the specification (for example, “0x01” corresponds to a USB channel gating instruction, and “0x02” corresponds to a serial port channel gating instruction); sending the control instruction to the analog switch unit 200 through a hardware interface (such as a GPIO pin) to drive it to complete the gating operation of the specified communication channel; and recording the switching instruction and corresponding USB load weight , USB interface priority , serial port UART priority and other parameters to provide device historical interaction record support for weight adjustment of the priority scheduling module 120 in the future.

[0074] In the embodiment, the parameter quantization module 110 includes a USB load quantization submodule 111 and a serial port emergency quantization submodule 112, wherein:

[0075] The USB load quantization submodule 111 is used for generating a USB load quantization value , the USB real-time transmission rate, the transmission load ratio is converted into ;

[0076] The serial port emergency quantification submodule 112 is configured to generate a serial port emergency quantification value , by parsing the emergency level identification bit in the serial port request signal that conforms to the industry standard, mapping the serial port emergency to , the higher the emergency level, the larger the corresponding value.

[0077] As a further description of the present embodiment, in the USB load quantification submodule 111 of the present embodiment: first, the state detection unit 500 collects the total number of USB data bytes according to the system scheduling period (the collection interval configured by the master control unit 100 timer), and the total number of bytes transmitted by the internal USB-A interface ( ), and then calculates the USB real-time transmission rate (the actual transmission rate of the USB-A interface) according to the following formula: ; then, the nominal rate of the protocol matched with the USB-A interface (such as 480 for USB2.0 and 12 for USB1.1, pre-stored by the hardware configuration interface) is combined, and the USB load quantification value (indicating the percentage of transmission load to the nominal rate of the protocol, taking values from 0 to 100) is generated by the following formula: ; if , it is forcibly set to 0, , it is forcibly set to 100.

[0078] As a further description of the present embodiment, the serial port emergency quantification submodule 112 of the present embodiment specifically includes: parsing the 3-5 bit emergency level identification bit in the serial port UART request signal that conforms to GB / T19892-2005, converting the 3-bit binary identification bit to the serial port emergency level (taking values from 1 to 5, with level 1 being the lowest and level 5 being the highest); then, the serial port emergency quantification value (taking values from 10 to 50, with the value increasing as the emergency level increases) is generated by the formula , if the identification bit is 000 (no emergency level), it is defaulted to , and if the identification bit is 110-111 (out of the standard level), it is defaulted to .

[0079] ​In the embodiment, the priority scheduling module 120 performs priority calculation and conflict determination through a dynamic priority scheduling algorithm, including the following steps:

[0080] S120.1, obtaining the USB load quantization value and the serial port emergency quantization value output by the parameter quantization module 110 , combining the preset USB load weight and the serial port emergency weight ( , the initial weights are set through a hardware configuration interface), calculating the initial priorities of the USB interface and the serial port ;

[0081] S120.2, dynamically adjusting the weights according to the continuous monitoring results of the state detection unit 500:

[0082] If the USB transmission rate meets the high load characteristics defined by the protocol type for N consecutive times, the weight is increased and the weight is simultaneously decreased, and the adjusted weight does not exceed the maximum weight limit of hardware adaptation;

[0083] If the serial port sends a request meeting the highest emergency level of industry specifications for M consecutive times, the weight is increased and the weight is simultaneously decreased, and the adjusted weight does not exceed the maximum weight limit of hardware adaptation;

[0084] S120.3, calculating the priority difference between the USB and the serial port , if the priority difference is greater than or equal to the conflict threshold ( determined based on the nominal switching time in the hardware specification book of the analog switch unit 200, to ensure stable communication establishment after signal switching), it is directly determined that the high-priority channel is the current selected channel; if the priority difference is less than , the USB data frame interval and the serial port request timeout time obtained by the state detection unit 500 are called to preferentially select the channel that needs to complete the response before the timeout time;

[0085] S120.4, monitoring the effectiveness of the USB load quantization value and the serial port emergency quantization value in real time, if any quantization value exceeds its physical definition range (such as the USB load quantization value exceeding the maximum transmission capacity of the corresponding protocol), the current weight adjustment logic is frozen, the existing priority calculation method is maintained, and the state detection unit 500 feedbacks an abnormality removal signal.

[0086] ​As a further illustration of the present embodiment, the initial priority calculation in the priority scheduling module 120 of the present embodiment includes the following steps: first, define the parameters as follows: (USB load weight, initial 0.5, maximum 0.8, hardware configuration interface setting), (seriously weight, derived from , maximum 0.8), (USB interface priority, value 0-80), (serial port UART priority, value 0-40); and then obtain the output of the parameter quantization module 110 and , and calculate the initial priority of the USB interface and the serial port UART according to the following formula respectively:

[0087]

[0088]

[0089] As a further illustration of the present embodiment, the weight dynamic adjustment in the priority scheduling module 120 of the present embodiment specifically includes the following steps: first, define the parameters as follows: (weight adjustment step, pre-stored in hardware firmware), N (USB high load continuous detection times, hardware configuration interface can be modified), M (serial port highest emergency level continuous detection times, hardware configuration interface can be modified); if the USB high load is detected for N consecutive times (e.g. ), then , increase and simultaneously decrease , and the adjusted does not exceed 0.8; if the serial port highest emergency level request is detected for M consecutive times (i.e. ), then , increase and simultaneously decrease , and the adjusted does not exceed 0.8.

[0090] Further, in the priority scheduling module 120 of the present embodiment, the default value of the serial port highest emergency level continuous detection times M is set to 2, which is determined based on the technical characteristics of the serial port UART highest emergency level request, i.e. the highest emergency level request needs to consider the timeliness of response and the anti-transient interference ability, and continuous detection for 2 times can avoid single false triggering (e.g. false emergency request caused by signal fluctuation), while not delaying the channel switching of the emergency task; at the same time, the value of M can be modified through the hardware configuration interface (e.g. the I2C configuration pin of the main control unit 100) to adapt to the emergency response requirements in different scenarios (for example, in the industrial control scenario which requires higher response speed, M can be adjusted to 1), and the adjustment of M needs to be synchronized with the weight adjustment step ​​(0.1) Coordination to ensure that when an emergency serial port request triggers a weight adjustment, The increase should be matched with the urgency of the request to avoid sudden changes in priority.

[0091] Furthermore, the default value for the number of consecutive USB high-load detections N is set to 3. This value is designed in conjunction with the transmission characteristics of the USB-A interface, namely, that USB transmission may experience instantaneous high-load fluctuations (such as frame interval fluctuations in batch data transmission). Continuous detection of 3 times can eliminate interference from instantaneous load peaks, ensuring that the determined "high load" is a continuous state (which must meet the following conditions). This means the transmission load accounts for more than 80% of the protocol's nominal rate; the value of N can be modified through the hardware configuration interface. For example, in scenarios with high USB data transmission stability requirements (such as continuous file transfer), N can be adjusted to 4 to further reduce the probability of false positives; at the same time, the value of N must be related to the system scheduling cycle. Coordination is needed to ensure the total duration of continuous testing ( Do not exceed the USB protocol timeout period (such as the USB 2.0 bulk transfer timeout period) to avoid affecting normal data transmission.

[0092] Furthermore, for The value must be adapted to the USB load weight. (Initial 0.5, maximum 0.8 for hardware adaptation) and serial port urgency weight The upper limit requirement (initial 0.5, maximum 0.8 for hardware adaptation) ensures that the weight limit is not exceeded after multiple adjustments. It also matches the judgment logic for the number of consecutive USB high-load checks N (default 3 times) and the number of consecutive serial port emergency level checks M (default 2 times), ensuring that the weight can reasonably rise to the required threshold after continuous checks without exceeding the limit. Furthermore, it guarantees stable priority calculation to avoid issues caused by… Excessive size causes USB interface priority issues. UART priority Sudden changes lead to frequent channel switching, and it is necessary to adapt to the system scheduling cycle to ensure timely response to communication needs in high-load or high-urgency scenarios through weight adjustment within the total duration of N / M consecutive detections.

[0093] As a further explanation of this embodiment, the conflict determination in the priority scheduling module 120 of this embodiment is specifically implemented by combining parameter comparison: First, the relevant parameters are clarified: It is the priority difference, calculated using the following formula: ; It is the conflict threshold, based on the nominal switching time of the chip used in the analog switch unit 200. (The nominal switching time matches the chip model and is pre-stored in the hardware configuration interface) to calculate and ensure signal stability after switching; is the USB data frame interval, collected by the state detection unit 500; is the serial port UART request timeout time, pre-stored in the serial port protocol. Calculate After that, if , directly select the high-priority channel as the current gating channel; if , compare and , preferentially select the channel that needs to complete the response before the timeout time, that is, if , select the USB channel, otherwise select the serial port channel.

[0094] As a further description of the embodiment, the validity monitoring in the priority scheduling module 120 of the embodiment specifically includes: monitoring the numerical validity of the USB load quantization value and the serial port urgency quantization value in real time, wherein needs to be in the physically reasonable range of 0-100, needs to be in the quantization range of 10-50; if any quantization value exceeds the corresponding range, immediately freeze the current weight adjustment logic, maintain the existing priority calculation method, and after the state detection unit 500 feedbacks the abnormality removal signal, restore the weight dynamic adjustment function.

[0095] The analog switch unit 200 is used to establish the physical channel gating path of the USB-A interface and the serial port. Through the analog switch circuit of the switchable signal path, the signal of the USB-A interface or the serial port is transmitted to the common interface, and the conduction state is switched according to the control instruction of the master control unit 100;

[0096] In the embodiment, the analog switch unit 200 includes a control interface module 210, a channel switching module 220, and a signal transmission module 230, wherein:

[0097] The control interface module 210 is used to receive the channel switching control instruction output by the master control unit 100, and convert the 8-bit channel identifier, 8-bit switching delay parameter, and 8-bit CRC check code contained in the instruction into a control signal that conforms to the logic level of the analog switch circuit;

[0098] As a further description of the embodiment, the control interface module 210 of the embodiment communicates with the master control unit 100 using the SPI interface, and the communication parameters need to be consistent with the SPI configuration of the master control unit 100: the clock polarity is set to 0 (the clock signal is low when idle), the clock phase is set to 0 (data is sampled on the rising edge of the clock), and the communication rate matches the SPI output rate of the master control unit 100 (such as 1MHz, to ensure that the instruction transmission has no packet loss);

[0099] Further, the 8-bit instruction register and the 8-bit state register integrated inside the control interface module 210 need to realize the bidirectional interaction of "instruction latching-state feedback" through the hardware circuit:

[0100] The latching logic of the 8-bit instruction register: after the host unit 100 sends the 1-byte channel switching instruction (including 8-bit channel identification, 8-bit switching delay parameter, and 8-bit CRC check code), the instruction register is triggered to latch through the falling edge of the SPI chip selection signal, so as to avoid parameter errors caused by signal fluctuation during instruction transmission;

[0101] The feedback mechanism of the 8-bit state register: the state register collects the current conduction state of the channel switching module 220 in real time (for example, "0x01" represents the USB channel conduction, "0x02" represents the serial port channel conduction, and "0x00" represents no channel conduction), and the host unit 100 can read the state value through the SPI read instruction, and the reading period is synchronized with the state detection period of the host unit 100 (for example, 100 μs);

[0102] The analysis rule of the instruction parameter: in the 8-bit channel identification, "0x01" corresponds to the USB channel selection instruction, and "0x02" corresponds to the serial port channel selection instruction; the unit of the 8-bit switching delay parameter is μs (the value range is 1-255 μs), which is used to set the delay time from the output of the control signal to the actual action of the switch (adapt to the action timing of different switch chips); the 8-bit CRC check code adopts the CRC-8 standard algorithm, and the check value is calculated through the "channel identification + switching delay" 16-bit data, if the instruction register detects that the check code does not match, the control signal is not output, and the "error identification bit" (the 7th bit) of the state register is set to 1, prompting the host unit 100 to resend the instruction.

[0103] The channel switching module 220 includes at least two groups of independent single-pole double-throw switch circuits, one group of single-pole double-throw switch circuits corresponds to the power supply and signal path of the USB-A interface, and the other group of single-pole double-throw switch circuits corresponds to the transmission and reception signal path of the serial port , and the conduction state of the switch is switched through the control signal output by the control interface module 210;

[0104] The signal transmission module 230 is used to connect the channel switching module 220 and the public interface, and the circuit impedance of the signal transmission module 230 matches the characteristic impedance requirements of the USB-A interface and the serial port , so as to ensure that the signal transmission is not reflected and attenuated.

[0105] In the embodiment, the channel switching module 220 includes a USB channel submodule 221, a serial port channel submodule 222, and an interlocking logic submodule 223, wherein:

[0106] The USB channel sub-module 221 adopts four independent analog switches (corresponding to the VCC, D+, D-, and GND signals of the USB, respectively), and the on-resistance of the switches meets the low-loss transmission requirement of the USB differential signals, and the off-isolation resistance meets the signal isolation requirement between channels.

[0107] As a further illustration of the embodiment, the USB channel sub-module 221 adopts four independent analog switches, corresponding to the VCC (power supply), D+ (differential signal positive), D- (differential signal negative), and GND (ground) signals of the USB-A interface, respectively. The switch chip needs to meet the following characteristics:

[0108] On-resistance requirement: The on-resistance of the two switches corresponding to the D+ and D- differential signals needs to be ≤5Ω (to meet the low-loss transmission requirement of the USB protocol for differential signals, and to avoid communication errors caused by signal attenuation); the on-resistance of the two switches corresponding to the VCC and GND needs to be ≤1Ω (to reduce the voltage drop in the power transmission process and ensure stable power supply for the USB device);

[0109] Off-isolation resistance requirement: The off-isolation resistance of all switches needs to be ≥10MΩ (to avoid signal crosstalk of the non-conducting channel, such as when the USB channel is off, the serial port signal will not interfere with the USB line through the isolation resistance);

[0110] Circuit connection mode: The VCC path switch is connected in series between the VCC pin of the USB-A interface and the VCC pin of the common interface, and a self-resetting fuse is connected in series at the front end of the switch (adapted to the maximum working current of the USB device, such as 2A), to prevent overcurrent damage to the switch chip; the D+ and D- path switches are directly connected in series between the corresponding signal lines, and test points need to be reserved at both ends of the switch for easy measurement of signal integrity during debugging.

[0111] The serial port channel sub-module 222 adopts two independent analog switches (corresponding to the TXD and RXD signals of the serial port , respectively), supports the voltage level range specified in the serial port protocol, and the switching time of the switch meets the timing requirements corresponding to the serial port communication rate.

[0112] As a further illustration of the embodiment, the serial port channel sub-module 222 adopts two independent analog switches, corresponding to the TXD (transmission signal) and RXD (reception signal) of the serial port UART, respectively. The hardware configuration needs to adapt to the protocol characteristics of the serial port UART:

[0113] Voltage level support: The switch chip needs to be compatible with the TTL voltage level or RS232 voltage level commonly used in the serial port UART, and the specific selection is determined according to the actual application scenario (such as RS232 voltage level commonly used in industrial control scenarios, and TTL voltage level commonly used in embedded device scenarios);

[0114] Switching time constraint: The switching time of the switch (the time from the control signal trigger to the switch being fully turned on / off) must match the communication rate requirements of the serial UART to ensure that it matches the communication rate requirements of the serial UART (e.g., the data transmission time for each bit corresponding to 9600bps is about 104μs, and a switching time of 10μs will not affect the data timing).

[0115] Signal protection measures: A TVS transient suppression diode (with a breakdown voltage adapted to the serial port level, such as a 5VTVS diode corresponding to TTL level) is connected in parallel at both ends of the TXD and RXD signal lines to prevent instantaneous high voltage from damaging the switch chip during hot-plugging.

[0116] Interlock logic submodule 223 is used to prevent the USB channel from interfering with the serial port. Simultaneous channel activation: When the control signal of the USB channel submodule 221 is detected to be in the activated state, the control signal of the serial channel submodule 222 is automatically locked to the deactivated state; when the control signal of the serial channel submodule 222 is detected to be in the activated state, the control signal of the USB channel submodule 221 is automatically locked to the deactivated state, and the interlock response time meets the timing constraints of channel switching.

[0117] As a further explanation of this embodiment, the interlocking logic submodule 223 implements the USB channel and serial port through hardware logic circuitry. The "mutual exclusion conduction" of channels avoids signal conflicts and hardware damage caused by two channels conducting simultaneously. The implementation logic is as follows:

[0118] Control signal detection method: The interlock logic submodule 223 uses two voltage comparators to collect the control signal levels of the USB channel submodule 221 and the serial port channel submodule 222 respectively (e.g., high level represents "conduction command" and low level represents "deactivation command"). The threshold voltage of the comparator is set to 1 / 2 of the power supply voltage (e.g., 3.3V power supply corresponds to 1.65V threshold) to ensure that the level detection is error-free.

[0119] Interlock response mechanism: When the comparator detects that the USB channel control signal is high, it forces the serial channel control signal low (locks it to the off state) through a NAND gate circuit; similarly, when the serial channel control signal is detected to be high, the USB channel control signal is forced low. The interlock response time must be less than the switching action time of the channel switching module 220 (e.g., 10μs) to ensure that the interlock is completed before the switch is fully turned on.

[0120] Fault protection logic: if two control signals are detected to be high at the same time (an abnormal scenario), the interlocking logic submodule 223 will force both control signals to be low, and send an "interlocking fault" signal to the state register of the control interface module 210 (set the 6th bit of the state register to 1), prompting the host unit 100 to troubleshoot the instruction abnormality.

[0121] In this embodiment, the signal transmission module 230 includes an impedance matching submodule 231 and a signal filtering submodule 232, wherein:

[0122] The impedance matching submodule 231 achieves impedance adjustment by connecting precise resistors in series. Specifically, it includes connecting matching resistors in series on the D+ and D- signal lines of the USB channel, connecting corresponding matching resistors in series on the signal lines of the serial port channel according to the protocol type, to ensure that the impedance of each channel meets the characteristic impedance standard specified by the interface protocol;

[0123] As a further illustration of this embodiment, the impedance matching submodule 231 achieves impedance adjustment by connecting precise resistors (with a precision of 1%, meeting the impedance error requirements of the interface protocol) in series. The resistance values need to be determined according to the characteristic impedance standard of the interface protocol, and specifically include:

[0124] Impedance matching of the USB channel: The D+ and D- differential signal lines of the USB-A interface need to meet the characteristic impedance requirement of 90Ω±10%, so 1-way 10Ω precise resistors are connected in series on the D+ and D- signal lines (if the PCB trace impedance has been designed as 80Ω, the total impedance after connecting a 10Ω resistor is 90Ω, which meets the protocol requirements); The VCC and GND signal lines do not need to be connected with additional resistors, and their impedance is determined by the cross-sectional area and length of the wire (such as a 24AWG wire with an impedance of about 0.08Ω / m, which meets the low impedance requirements of power transmission);

[0125] Impedance matching of the serial port channel: The characteristic impedance of the serial port UART is determined according to the protocol type, such as 75Ω characteristic impedance for RS232 protocol and 120Ω characteristic impedance for RS485 protocol, so precise resistors matching the characteristic impedance need to be connected in series on the TXD and RXD signal lines (such as 15Ω resistors in the RS232 scenario, which adapt to the impedance of 60Ω PCB traces, with a total impedance of 75Ω); The series position of the resistor needs to be close to the common interface end to reduce the impedance mutation on the signal transmission path.

[0126] The signal filtering submodule 232 is used to cross-connect a filter capacitor between the D+ and D- signals of the USB channel, and connect an RC low-pass filter circuit in series on the signal path of the serial port channel to suppress high-frequency interference signals and meet the requirements of the interface protocol for signal integrity;

[0127] As a further illustration of the present embodiment, the signal filtering sub-module 232 suppresses high-frequency interference through a differential filtering circuit for the signal characteristics of the USB and serial ports, ensuring signal integrity:

[0128] USB channel filtering: a high-frequency filtering capacitor (with a value adapted to the USB protocol EMI suppression requirements) is connected across the D+ and D- signal lines and the ground in the USB channel, used to filter out high-frequency interference above 100 MHz, and the capacitor is arranged close to the common interface end to shorten the filtering path;

[0129] Serial port channel filtering: an RC low-pass filter circuit is connected in series on the TXD and RXD signal paths of the serial port channel, with a cutoff frequency determined according to the maximum communication rate of the serial port (e.g. for a rate of 115200 bps, the cutoff frequency is about 100 kHz), to avoid interference signals affecting serial data transmission;

[0130] Component selection: high-frequency characteristic ceramic capacitors are selected for filtering capacitors, and precise resistors with stable resistance values are selected for filtering resistors, to ensure long-term reliable filtering effect.

[0131] The hierarchical protection unit 300 is used to realize multi-dimensional electrical protection of the USB-A interface, by connecting overcurrent protection devices in series in the power supply path of the USB-A interface, connecting overvoltage suppression devices in parallel at the power supply end, and connecting high-frequency interference filter devices across the signal path, to form a coordinated protection mechanism for the power supply and signal;

[0132] In the present embodiment, the hierarchical protection unit 300 includes a power overcurrent protection module 310, a power overvoltage suppression module 320, a signal anti-interference filtering module 330, and a protection state linkage module 340, wherein:

[0133] The power overcurrent protection module 310 is used to be connected in series in the power supply path of the USB-A interface, and matches the maximum interface power supply current specified by the USB protocol through a self-resetting fuse; when the current in the power supply path exceeds the rated threshold and the duration meets the USB power supply safety timing requirements, the fuse automatically switches to a high resistance state to cut off the current; after the current falls below the rated threshold and the safety reset timing is maintained, the fuse automatically restores to a low resistance conduction state;

[0134] As a further illustration of the present embodiment, the power overcurrent protection module 310 of the present embodiment uses a self-resetting fuse as the core device, which is connected in series in the VCC power supply path of the USB-A interface (one end is connected to the USB-A interface VCC pin, and the other end is connected to the VCC input of the back-end power supply circuit), and the device selection and action logic need to strictly adapt to the USB protocol requirements, as follows:

[0135] Self-resetting fuse selection basis: Determine the rated current according to the protocol followed by the USB-A interface, for example, the USB2.0 protocol stipulates that the maximum power supply current of the interface is 500mA, and the USB3.0 protocol is 900mA, and the rated current of the fuse needs to be 10%-20% higher than the maximum current of the protocol (such as 600mA rated current of the fuse in the USB2.0 scenario), to avoid false triggering of the overcurrent protection when normal power supply; The on-state resistance of the fuse at room temperature needs to be ≤50mΩ, to reduce the power transmission voltage drop and ensure stable power supply of the USB device;

[0136] Overcurrent action timing: When the power path current exceeds the rated threshold (such as 600mA) and the duration meets the USB power supply safety timing requirement (such as ≥100μs, matching the transient current fluctuation characteristics of the USB device), the fuse quickly switches to a high resistance state (resistance ≥1kΩ) due to the Joule heating effect, cutting off the power path; After the current falls below the rated threshold (such as ≤500mA) and maintains a safe reset timing (such as ≥1s, to ensure that the fault is completely eliminated), the fuse temperature drops, and the fuse automatically returns to a low resistance on-state (returns to the initial on-state resistance), without the need for manual intervention;

[0137] Circuit protection design: A 1-way LED indicator light (with a 1kΩ current limiting resistor in series) is connected in parallel across the fuse, when the fuse triggers overcurrent protection and switches to a high resistance state, the indicator light is lit due to the voltage difference across the two terminals, providing a direct indication of the overcurrent fault; The indicator light goes out after the fault is recovered, facilitating troubleshooting and maintenance.

[0138] The power overvoltage suppression module 320 is connected in parallel across the power supply end of the USB-A interface, and uses a TVS transient voltage suppression diode as the core device, with a response speed that meets the transient overvoltage protection requirements of the USB power supply end, and a clamping voltage that is adapted to the safety threshold of the USB power supply nominal voltage; When a transient overvoltage occurs at the power supply end, the diode quickly conducts to discharge the surge current;

[0139] As a further description of the present embodiment, the power overvoltage suppression module 320 of the present embodiment uses a TVS transient voltage suppression diode as the core device, and is connected in parallel between VCC and GND of the USB-A interface (close to the power supply end of the USB-A interface, to shorten the transient surge path), and the device parameters and action logic need to be adapted to the USB power supply characteristics, specifically including:

[0140] TVS tube selection requirements: The response speed needs to meet the rapid protection requirements of the transient overvoltage of the USB power supply end, to avoid damage to the back-end circuit after the surge voltage breaks down; The clamping voltage needs to be adapted to the safety threshold of the USB power supply nominal voltage, for example, when the nominal power voltage of the USB-A interface is 5V, the clamping voltage is set to 6-7.5V (to prevent overvoltage damage to the device, and to avoid false triggering due to normal voltage fluctuations); The peak pulse power of the TVS tube needs to be adapted to common power transient surge power, such as static electricity surge during plugging;

[0141] Over-voltage action logic: when a transient over-voltage (such as a spike voltage caused by plugging static electricity) occurs on the USB-A interface power supply terminal, the TVS tube enters a nanosecond-level fast conduction state, discharges the surge current to GND, and clamps the power supply terminal voltage within a set safety threshold (such as 7V); after the transient over-voltage disappears and the power supply voltage falls back to the nominal value (5V), the TVS tube automatically returns to the off state, without affecting normal power supply;

[0142] Auxiliary protection: a 1-way magnetic bead is connected in series between the TVS tube and the USB-A interface to suppress high-frequency surge signals and prevent interference with other circuits when the surge is discharged through the TVS tube.

[0143] The signal anti-interference filter module 330 is used to cross the signal path of the USB-A interface, and adopts a combination structure of common-mode inductance and ceramic capacitor, wherein: the common-mode inductance is connected in series in the signal path and the common-mode impedance characteristic is adapted to the high-frequency interference suppression requirement of USB signal transmission, and the ceramic capacitor is connected across each signal and GND to suppress high-frequency differential-mode interference and common-mode interference in the signal path, ensuring that the signal meets the signal integrity standard of the USB protocol;

[0144] As a further description of the present embodiment, the signal anti-interference filter module 330 of the present embodiment adopts a combination of "common-mode inductance + ceramic capacitor" and is connected across the D+ and D- signal paths of the USB-A interface. Specifically:

[0145] Common-mode inductance: connected in series in the D+ and D- paths, with a common-mode impedance ≥ 1kΩ at 100MHz to suppress high-frequency common-mode interference, a rated current ≥ 100mA, and a differential-mode impedance ≤ 5Ω to avoid affecting signal transmission;

[0146] Ceramic capacitor: 0.01-0.1μF (such as 0.047μF) X7R material capacitors are connected across D+ and GND and D- and GND to filter out high-frequency differential-mode interference, with a capacitance deviation ≤ 5% to ensure differential signal balance;

[0147] Layout: filter components are arranged close to the USB-A interface to ensure that interference is filtered out before entering the back-end circuit.

[0148] The protection state linkage module 340 is electrically connected with the power overcurrent protection module 310 and the power over-voltage suppression module 320, monitors the on-off state of the power overcurrent protection module 310 through a current sampling circuit and monitors the clamping state of the power over-voltage suppression module 320 through a voltage sampling circuit; and converts the on-off state and clamping state into standard digital levels (protection trigger output high level, normal output low level), which are fed back to the main control unit 100 through independent pins. After receiving the signals, the main control unit 100 suspends the USB channel switching until the protection is removed.

[0149] As a further illustration of the present embodiment, the protection state linkage module 340 of the present embodiment monitors the power supply protection state and feeds back to the master control unit 100, realizing cooperative control, which specifically includes:

[0150] The sampling circuit: current sampling is collected by a 10 mΩ resistor output current of the power supply overcurrent protection module 310, and voltage sampling is collected by a voltage dividing resistor to collect the voltage across the TVS tube of the power supply overvoltage suppression module 320;

[0151] State conversion: the sampling signal is converted to a 3.3V standard digital level (protection trigger output high level, normal output low level) by a voltage comparator, and the comparator threshold is set to 0.5V (to distinguish the overcurrent state) and 2V (to distinguish the overvoltage state) respectively;

[0152] Feedback and linkage: the state is fed back to the master control unit 100 through two independent GPIO pins, and the master control unit 100 suspends the USB channel switching after receiving a high level (protection trigger), and restores the switching function until the signal returns to a low level and the delay is ≥500μs.

[0153] The protocol adaptation unit 400 is used to realize the dynamic compatibility of USB and serial port protocols, and through the integration of switchable protocol analysis circuit, based on the instruction loading of the master control unit 100, the signal coding and decoding logic of the corresponding protocol is completed. Signal format conversion;

[0154] In the present embodiment, the protocol adaptation unit 400 includes a protocol selection module 410, a USB protocol analysis module 420, a serial port protocol analysis module 430, and a signal format conversion module 440, wherein:

[0155] The protocol selection module 410 is electrically connected with the master control unit 100, and is used to receive the protocol adaptation instruction output by the master control unit 100, and according to the protocol type identification in the instruction, the USB or serial port Protocol execution: if the instruction is USB protocol adaptation, enable the USB protocol analysis module 420 and turn off the power supply of the serial port protocol analysis module 430; if the instruction is serial Protocol adaptation, enable the serial port protocol analysis module 430 and turn off the power supply of the USB protocol analysis module 420;

[0156] As a further explanation of this embodiment, the protocol selection module 410 of this embodiment adopts a dual-channel power switch chip (supporting 3.3V power supply, on-resistance ≤50mΩ) to control the power supply of the USB protocol parsing module 420 and the serial port protocol parsing module 430 respectively; the chip enable terminal is connected to the GPIO pin of the main control unit 100 to receive 8-bit protocol adaptation instructions ("0x01" corresponds to the USB protocol, and "0x02" corresponds to the serial port protocol). After the instruction is stored in the module register via the SPI interface, the logic circuit controls the power enable of the corresponding module according to the instruction: the enable terminal is set high when the target module is enabled, and the enable terminal is set low when the non-target module is turned off, with a switching delay ≤10μs and a module power consumption ≤10μA in the off state.

[0157] The USB protocol parsing module 420 parses the original signals of the USB interface through hardware circuitry, loads the signal encoding logic corresponding to the USB 2.0 and USB 1.1 protocols, such as the Manchester encoding and decoding logic of the USB differential signal, such as the level decision of the differential signal and the extraction of the synchronization clock, and converts the signals of the USB interface into parallel signals that conform to the data format of the host control unit 100.

[0158] As a further explanation of this embodiment, the input terminal of the USB protocol parsing module 420 is connected in series with a resistor that matches the characteristic impedance of the USB differential line. The high-speed differential receiver converts the D+ and D- differential signals into single-ended signals, supporting USB 2.0 (high-speed / full-speed mode) and USB 1.1 (low-speed mode). It incorporates a Manchester encoder / decoder, extracts a synchronization clock via a phase-locked loop (frequency adaptively adjusted according to the transmission rate), performs level determination on the differential signals, converts them into parallel signals via a shift register, and then outputs them to the signal format conversion module 440 through a data buffer. The output delay meets the high-speed transmission requirements of the USB protocol.

[0159] The serial port protocol parsing module 430 is used to load RS232 and RS485 serial ports. The protocol's corresponding frame structure parsing logic and baud rate adaptation logic identify the serial port. The start bit, data bit, parity bit, and stop bit in the signal are sampled according to the protocol, and the sampling clock period is adjusted for the serial port. Serial signals are converted into serial data frames;

[0160] As a further illustration of the present embodiment, the serial port protocol analysis module 430 receives signals through a level conversion chip (which can support RS232 and TTL level conversion), identifies the start bit (low level) through edge detection, samples the data bit (5-8 bits optional), the check bit (odd check / even check / no check optional), and the stop bit (1-2 bits optional) in turn according to the frame structure, and the sampling point is located at the middle moment of each bit signal to reduce noise interference. At the same time, a built-in baud rate generator supports 1200 bps to 115200 bps standard baud rate, and the sampling clock period is adjusted by the pre-configured parameters of the main control unit 100 (the error meets the requirements of the serial port protocol), the parsed data is packaged into a serial data frame (including a frame valid flag), and output to the signal format conversion module 440.

[0161] The signal format conversion module 440 is used for receiving the parallel signal output by the USB protocol analysis module 420 and the serial data frame output by the serial port protocol analysis module 430, and uniformly converting them into an 8-bit data format recognizable by the main control unit 100, and the conversion delay does not exceed the channel switching time of the analog switch unit 200.

[0162] As a further illustration of the present embodiment, when the signal format conversion module 440 receives the parallel signal of the USB protocol analysis module 420, it processes it in a slicing manner; when it receives the serial data frame of the serial port protocol analysis module 430, it extracts the valid data bit (if less than 8 bits, the high bits are filled with 0, and if more than 8 bits, it is processed in a slicing manner). After conversion, it is uniformly converted into an 8-bit format of "1-bit start bit + 8-bit data bit + 1-bit stop bit", the timing is synchronized with the reading clock of the main control unit 100, the total conversion delay does not exceed the channel switching time of the analog switch unit 200, and a built-in buffer is used to prevent data overflow.

[0163] The state detection unit 500 is used for collecting the interface connection and running state, monitoring the USB-A interface plug signal, the serial port communication request signal and the power supply state signal, and converting the detection results into electrical signals and transmitting them to the main control unit 100;

[0164] In the present embodiment, the state detection unit 500 includes a USB state detection module 510, a serial port state detection module 520, a power supply state detection module 530, and a state signal processing module 540, wherein:

[0165] The USB state detection module 510 is used for monitoring the device access state of the USB-A interface, and determining whether a USB device is inserted by detecting the voltage difference of D+ and D- lines (when a USB device is inserted, the voltage of D+ is higher than that of D-, and when it is pulled out, the voltages of the two tend to be consistent), and the monitoring period is synchronized with the scheduling period of the main control unit 100;

[0166] As a further illustration of the present embodiment, the USB state detection module 510 of the present embodiment monitors the device access state of the USB-A interface through a voltage comparison circuit, specifically as follows:

[0167] Circuit configuration: The voltage dividing resistors (the resistance values are determined according to the signal level range of the USB protocol) connected in series between the D+ and D- signal lines and the ground respectively reduce the signal voltage to the input range (such as 0-3.3V) of the comparator; the two-way signals are respectively connected to the non-inverting and inverting terminals of the differential voltage comparator, and the output terminal of the comparator is connected to the state signal processing module 540;

[0168] Detection logic: When the USB device is inserted, the voltage of the D+ line (about 3.3V) is higher than that of the D- line (about 0V), and the output of the comparator is high; when the device is pulled out, the voltages of D+ and D- tend to 0V, and the output of the comparator is low;

[0169] Period synchronization: The detection period of the USB state detection module 510 is triggered by the timer of the main control unit 100, which is consistent with the system scheduling period (such as 1ms), ensuring the timing matching of the state monitoring and scheduling logic; the detection circuit is built-in 100nF filter capacitor, which filters out high-frequency noise on the signal line to avoid false judgment caused by transient voltage fluctuation.

[0170] The serial port state detection module 520 is used to monitor the communication request state of the serial port device, which detects the level jump (high level indicates that the serial port device initiates a communication request, and low level indicates no request) of the serial port request signal line (such as RTS line) to identify the request and record the request signal duration to filter out transient interference;

[0171] As a further illustration of the present embodiment, the serial port state detection module 520 of the present embodiment identifies the communication request of the serial port device through level jump detection and duration judgment, specifically including the following contents:

[0172] Signal conditioning: The serial port RTS line is connected to the serial port state detection module 520 after being shaped by the Schmitt trigger, and the threshold voltage of the trigger is adapted to the high / low level standard of the serial port to eliminate the burr interference of the signal edge;

[0173] Request identification: The edge detection circuit is built-in the serial port state detection module 520, which starts the counter to record the high level duration when detecting the jump of the RTS line from low level to high level; if the duration exceeds the preset interference filtering threshold (such as 50μs, which can be configured by the main control unit 100), it is determined as a valid communication request; if the duration is insufficient, it is determined as transient interference, and the request signal is not triggered;

[0174] State holding: after the valid request is identified, the serial port state detection module 520 outputs a high level, until the RTS line jumps back to a low level, ensuring that the host unit 100 can stably capture the request state.

[0175] The power supply state detection module 530 is used for monitoring the power supply state of the USB-A interface and the serial port , and collecting the voltage of the power supply end through the voltage dividing resistor, and comparing with the preset voltage threshold to determine whether the power supply is normal;

[0176] As a further description of the embodiment, the power supply state detection module 530 of the embodiment monitors the power supply state by comparing the threshold value through voltage division sampling, and designs independent detection branches for the power supply ends of the USB-A interface and the serial port , specifically as follows:

[0177] Sampling circuit: each power supply end (such as the 5V power supply of USB and the 3.3V power supply of serial port) is connected in series with two voltage dividing resistors (the resistance ratio is determined according to the nominal voltage of the power supply and the input range of the sampling chip), and the power supply voltage is proportionally reduced to a safe sampling range (such as 0-3.3V), and the sampling point is connected to the voltage comparator through a 10kΩ current limiting resistor;

[0178] Threshold setting: the reference voltage end of the comparator is connected to a preset threshold (determined according to the allowable fluctuation range of the nominal voltage of the power supply, such as the normal threshold of the USB 5V power supply is set to 4.5-5.5V, and the corresponding comparison threshold after sampling is 3.0-3.6V); when the sampling voltage exceeds the threshold range, the comparator outputs a high level (indicating that the power supply is abnormal), otherwise it outputs a low level (indicating normal);

[0179] Isolation design: the two detection branches are isolated by an optocoupler to avoid interference between different power supply domains and ensure the independence of the detection signal.

[0180] The state signal processing module 540 is used for converting the analog detection signals output by the USB state detection module 510, the serial port state detection module 520 and the power supply state detection module 530 into standard TTL digital levels (high level indicating abnormal state or request, low level indicating normal or no request), and transmitting them to the host unit 100 through three independent pins, and the signal transmission delay is less than the instruction generation period of the host unit 100.

[0181] As a further description of the embodiment, the state signal processing module 540 of the embodiment converts the outputs of the USB state detection module 510, the serial port state detection module 520 and the power supply state detection module 530 into standard TTL signals through level conversion and signal shaping, and transmits them to the host unit 100, specifically including:

[0182] Level conversion: the analog or quasi-digital signals output by the USB state detection module 510, the serial port state detection module 520, and the power supply state detection module 530 are converted into 3.3V TTL level through a triode inverter or a dedicated level conversion chip, ensuring compatibility with the IO port level of the host unit 100;

[0183] Signal distribution: the converted three-way state signals (corresponding to USB access, serial port request, and power supply state, respectively) are transmitted through independent PCB wiring, each signal is connected in series with a 100Ω matching resistor and arranged close to the IO port of the host unit 100, reducing signal attenuation and crosstalk during transmission;

[0184] Delay control: the signal conversion and transmission of the USB state detection module 510, the serial port state detection module 520, and the power supply state detection module 530 are implemented by shortening the circuit path and selecting high-speed conversion components, ensuring that the total delay is less than the instruction generation period of the host unit 100, avoiding the impact of state signal lag on scheduling decisions.

[0185] The power management unit 600 is used to provide stable power supply for the host unit 100, the analog switch unit 200, the hierarchical protection unit 300, the protocol adaptation unit 400, and the state detection unit 500. Through the integration of voltage conversion circuit and voltage stabilizing circuit, the external input power is connected and multi-level voltage regulation is performed, and stable voltage suitable for work requirements is output.

[0186] Further, the power management unit 600 is also equipped with a monitoring component, which samples the output voltage of each channel through resistance voltage division, compares it with the preset threshold value suitable for the normal range of each voltage through a voltage comparator, and feeds back the monitoring result to the host unit 100 through a signal line. When the power supply is abnormal, trigger the basic protection logic of suspending the power supply of unnecessary units; the overall circuit adopts independent PCB wiring layout, reducing the interference of power supply noise on other units, meeting the basic power supply stability requirements of the system.

[0187] Those skilled in the art can understand that the process of implementing all or part of the steps of the above-mentioned embodiments can be completed by hardware, or by program to instruct related hardware.

[0188] The above shows and describes the basic principles, main features and advantages of the present application. Those skilled in the art should understand that the present application is not limited to the above-mentioned embodiments, and the above-mentioned embodiments and descriptions in the specification are only preferred examples of the present application and are not intended to limit the present application. Without departing from the spirit and scope of the present application, various changes and improvements can be made to the present application, and these changes and improvements all fall within the scope of the claimed present application. The scope of protection of the present application is defined by the appended claims and their equivalents.

Claims

1. A dynamic switching and protection system for USB-A interface and serial port based on analog switches, characterized in that, include: The main control unit (100) is used to coordinate the dynamic switching and conflict resolution between the USB-A interface and the serial port. It integrates a dynamic priority scheduling algorithm and combines the real-time load of USB data transmission and the serial port data transmission feedback from the status detection unit (500). Based on the urgency of the communication request and the device's historical interaction records, a conflict-free channel switching control command is generated, and the analog switch unit (200) is driven to complete the channel selection; An analog switch unit (200) is used to establish a physical channel selection path between the USB-A interface and the serial port. Through an analog switch circuit that can switch signal paths, it switches between the USB-A interface and the serial port. The signal is transmitted to the common interface and the conduction state is switched according to the control command of the main control unit (100); The graded protection unit (300) is used to realize multi-dimensional electrical protection of the USB-A interface. It forms a collaborative protection mechanism for power supply and signal by connecting overcurrent protection devices in series in the power path of the USB-A interface, overvoltage suppression devices in parallel at the power end, and high-frequency interference filtering devices across the signal path. Protocol adaptation unit (400) is used to realize dynamic compatibility between USB and serial port protocols. By integrating a switchable protocol parsing circuit, it loads the signal encoding and decoding logic of the corresponding protocol based on the instructions of the main control unit (100) to complete the signal format conversion. Status detection unit (500), the status detection unit (500) is used to collect interface connection and operation status, by monitoring USB-A interface plug-in / plug-out signals, serial port... The system transmits communication request signals and power supply status signals, and converts the detection results into electrical signals and transmits them to the main control unit (100). The power management unit (600) is used to provide stable power supply to the main control unit (100), analog switch unit (200), graded protection unit (300), protocol adaptation unit (400) and status detection unit (500). Through the integration of voltage conversion circuit and voltage regulation circuit, it connects to the external input power supply and performs multi-level voltage regulation to output a stable voltage that meets the working requirements.

2. The USB-A interface and serial port dynamic switching and protection system based on analog switches according to claim 1, characterized in that, The main control unit (100) includes a parameter quantization module (110), a priority scheduling module (120), and an instruction output module (130), wherein: The parameter quantization module (110) is used to collect the USB real-time transmission parameters and serial port parameters output by the status detection unit (500). Request parameters and convert them into calculable quantized values; The priority scheduling module (120) uses a dynamic priority scheduling algorithm to schedule the quantized USB and serial ports. Parameters are prioritized and conflict is determined. The instruction output module (130) generates channel switching control instructions that conform to the hardware interface specification of the analog switch unit (200) based on the priority scheduling result.

3. The USB-A interface and serial port dynamic switching and protection system based on analog switches according to claim 2, characterized in that, The parameter quantization module (110) includes a USB load quantization submodule (111) and a serial port emergency quantization submodule (112), wherein: The USB load quantization submodule (111) is used to generate USB load quantization values. Based on the nominal rate of the protocol type followed by the USB-A interface and the real-time USB transfer rate, the transfer load percentage is converted into... ; The serial port emergency metric submodule (112) is used to generate serial port emergency metric values. By parsing the serial port The request signal will include an emergency level flag that conforms to industry standards, and the serial port will... Urgency mapping to The higher the emergency level, the more... The larger the corresponding value.

4. The USB-A interface and serial port dynamic switching and protection system based on analog switches according to claim 3, characterized in that, The priority scheduling module (120) performs priority calculation and conflict determination through a dynamic priority scheduling algorithm, including the following steps: S120.1 Obtain the USB load quantization value output by the parameter quantization module (110). and serial port emergency metric value Combined with preset USB load weights Serial port urgency weight Calculate the USB interface and serial port The initial priority; S120.2, Dynamically adjust the weights based on the continuous monitoring results of the status detection unit (500): If the USB transfer rate is detected to meet the high-load characteristics defined by its protocol type N times consecutively, then increase... And reduce synchronously After adjustment The maximum weight limit for hardware adaptation shall not be exceeded. If the serial port is detected M times consecutively Sending the highest urgency level request conforming to industry standards will increase the risk. And reduce synchronously After adjustment The maximum weight limit for hardware adaptation shall not be exceeded. S120.3, Calculate USB and serial ports The priority difference, if the priority difference is greater than or equal to the conflict threshold. If so, the high-priority channel is directly determined as the current selected channel; If the priority difference is < Then, the USB data frame interval and serial port data obtained by the status detection unit (500) are called. Request timeout period, prioritizing channels that require a response before the timeout period; S120.4 Real-time monitoring of USB load quantization values Serial port emergency quantization value If any quantized value exceeds its physical definition range, the current weight adjustment logic is frozen, and the existing priority calculation method is maintained until the state detection unit (500) sends back an abnormality cancellation signal.

5. The USB-A interface and serial port dynamic switching and protection system based on analog switches according to claim 4, characterized in that, The analog switch unit (200) includes a control interface module (210), a channel switching module (220), and a signal transmission module (230), wherein: The control interface module (210) is used to receive the channel switching control command output by the main control unit (100), and convert the 8-bit channel identifier, 8-bit switching delay parameter and 8-bit CRC check code contained in the command into a control signal that conforms to the logic level of the analog switch circuit. The channel switching module (220) includes at least two independent single-pole double-throw (SPDT) switch circuits, one of which corresponds to the power and signal paths of the USB-A interface, and the other corresponds to the serial port. The transmission and reception signal paths are switched on and off by the control signal output by the control interface module (210); The signal transmission module (230) is used to connect the channel switching module (220) and the common interface. The circuit impedance of the signal transmission module (230) is matched with that of the USB-A interface and the serial port. The characteristic impedance requirement ensures that signal transmission is free from reflection and attenuation.

6. The USB-A interface and serial port dynamic switching and protection system based on analog switches according to claim 5, characterized in that, The channel switching module (220) includes a USB channel submodule (221), a serial port channel submodule (222), and an interlock logic submodule (223), wherein: The USB channel submodule (221) uses 4 independent analog switches. The on-resistance of the switches meets the low-loss transmission requirements of USB differential signals, and the off-resistance meets the signal isolation requirements between channels. The serial port channel submodule (222) uses two independent analog switches to support serial ports. The protocol specifies the voltage level range and the switch switching time to meet the requirements of the serial port. Timing requirements corresponding to communication rates; The interlock logic submodule (223) is used to prevent the USB channel from interfering with the serial port. Simultaneous channel activation: When the control signal of the USB channel submodule (221) is detected to be in the activated state, the control signal of the serial channel submodule (222) is automatically locked to the deactivated state; when the control signal of the serial channel submodule (222) is detected to be in the activated state, the control signal of the USB channel submodule (221) is automatically locked to the deactivated state, and the interlock response time meets the timing constraints of channel switching.

7. The USB-A interface and serial port dynamic switching and protection system based on analog switches according to claim 6, characterized in that, The signal transmission module (230) includes an impedance matching submodule (231) and a signal filtering submodule (232), wherein: The impedance matching submodule (231) achieves impedance adjustment by connecting precision resistors in series, specifically including: connecting matching resistors in series on the D+ and D- signal lines of the USB channel, and connecting them in series on the serial port. A matching resistor is connected in series on the signal line of the channel according to the protocol type to ensure that the impedance of each channel meets the characteristic impedance standard specified by its interface protocol. The signal filtering submodule (232) is used to connect a filter capacitor between the D+ and D- signals of the USB channel and ground, in the serial port An RC low-pass filter circuit is connected in series on the signal path of the channel to suppress high-frequency interference signals and meet the signal integrity requirements of the interface protocol.

8. The USB-A interface and serial port dynamic switching and protection system based on analog switches according to claim 7, characterized in that, The graded protection unit (300) includes a power overcurrent protection module (310), a power overvoltage suppression module (320), a signal anti-interference filtering module (330), and a protection status linkage module (340), wherein: The power overcurrent protection module (310) is connected in series in the power path of the USB-A interface. It matches the maximum power supply current of the interface specified by the USB protocol through a self-resetting fuse. When the power path current exceeds the rated threshold and the duration meets the USB power supply safety timing requirements, the fuse automatically switches to a high-resistance state to cut off the current. After the current drops below the rated threshold and maintains the safety reset timing, the fuse automatically returns to a low-resistance conduction state. The power supply overvoltage suppression module (320) is used to be connected in parallel to the power supply terminal of the USB-A interface. It uses a TVS transient suppression diode as the core device. The response speed meets the transient overvoltage protection requirements of the USB power supply terminal, and the clamping voltage is adapted to the safety threshold of the nominal voltage of the USB power supply. When a transient overvoltage occurs at the power supply terminal, the diode is quickly turned on to discharge the surge current. The signal anti-interference filtering module (330) is used to bridge the signal path of the USB-A interface. It adopts a combination structure of common-mode inductor and ceramic capacitor. The common-mode inductor is connected in series in the signal path and its common-mode impedance characteristics are adapted to the high-frequency interference suppression requirements of USB signal transmission. The ceramic capacitor is connected between each signal and GND to suppress high-frequency differential-mode interference and common-mode interference in the signal path and ensure that the signal complies with the signal integrity standard of the USB protocol. The protection status linkage module (340) is electrically connected to the power overcurrent protection module (310) and the power overvoltage suppression module (320). It monitors the on / off state of the power overcurrent protection module (310) through the current sampling circuit and monitors the clamping state of the power overvoltage suppression module (320) through the voltage sampling circuit. It converts the on / off state and the clamping state into standard digital levels and feeds them back to the main control unit (100) through independent pins. After receiving the signal, the main control unit (100) suspends the USB channel switching until the protection is released.

9. The USB-A interface and serial port dynamic switching and protection system based on analog switches according to claim 8, characterized in that, The protocol adaptation unit (400) includes a protocol selection module (410), a USB protocol parsing module (420), a serial port protocol parsing module (430), and a signal format conversion module (440), wherein: The protocol selection module (410) is electrically connected to the main control unit (100) and is used to receive the protocol adaptation command output by the main control unit (100). According to the protocol type identifier in the command, it performs the following operations: if the command is USB protocol adaptation, it enables the USB protocol parsing module (420) and turns off the power of the serial port protocol parsing module (430); if the command is serial port... If the protocol is compatible, the serial port protocol parsing module (430) will be enabled and the power to the USB protocol parsing module (420) will be turned off. The USB protocol parsing module (420) parses the original signal of the USB interface through hardware circuitry, loads the signal encoding logic and decoding logic corresponding to the USB2.0 and USB1.1 protocols, and converts the signal of the USB interface into a parallel signal that conforms to the data format of the main control unit (100). The serial port protocol parsing module (430) is used to load RS232 and RS485 serial ports. The protocol's corresponding frame structure parsing logic and baud rate adaptation logic identify the serial port. The start bit, data bit, parity bit, and stop bit in the signal are sampled according to the protocol, and the sampling clock period is adjusted for the serial port. Serial signals are converted into serial data frames; The signal format conversion module (440) is used to receive the parallel signal output by the USB protocol parsing module (420) and the serial data frame output by the serial port protocol parsing module (430), and convert them into an 8-bit data format that can be recognized by the main control unit (100). The conversion delay does not exceed the channel switching time of the analog switch unit (200).

10. The USB-A interface and serial port dynamic switching and protection system based on analog switches according to claim 9, characterized in that, The status detection unit (500) includes a USB status detection module (510), a serial port status detection module (520), a power supply status detection module (530), and a status signal processing module (540), wherein: The USB status detection module (510) is used to monitor the device access status of the USB-A interface. It determines whether the USB device is inserted by detecting the voltage difference between the D+ and D- lines. The monitoring cycle is synchronized with the scheduling cycle of the main control unit (100). The serial port status detection module (520) is used to monitor the serial port. The device's communication request status is identified by detecting level transitions on the serial port request signal line, and the duration of the request signal is recorded to filter out transient interference. The power supply status detection module (530) is used to monitor the USB-A interface and serial port. The power supply status is monitored by collecting the voltage at the power supply terminal through a voltage divider resistor and comparing it with a preset voltage threshold to determine whether the power supply is normal. The status signal processing module (540) is used to convert the analog detection signals output by the USB status detection module (510), the serial port status detection module (520), and the power supply status detection module (530) into standard TTL digital levels, and transmit them to the main control unit (100) through three independent pins. The signal transmission delay is less than the instruction generation cycle of the main control unit (100).

Citation Information

Patent Citations

  • Method for switching communication equipment and USB with serial port

    CN108459982A

  • Universal serial bus (USB) type multifunctional interface and switching system

    CN117609127A