Digital input / output multiplexing circuits, methods, electronic devices and media
By combining digital input/output multiplexing circuits and microcontroller units, flexible switching of digital input/output functions is achieved, solving the problem of low interface resource utilization and improving the flexibility and efficiency of the ports.
Patent Information
- Application Number
- CN202611367004.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-04
- Publication Date
- 2026-11-17
AI Technical Summary
In existing technologies, digital input channels and digital output channels are set up and occupy independent interfaces, resulting in fixed interface functions, low resource utilization, and difficulty in flexibly switching according to actual application needs.
By designing a digital input/output multiplexing circuit, the digital output circuit and the digital input circuit share the same digital input/output port. The microcontroller unit controls the working state of the digital output control unit and the digital input switching unit according to the current working mode, thereby achieving flexible switching of functions.
It improves the utilization rate of digital input/output ports and the flexibility of function configuration, avoids the fixation of interface resources, and meets the flexible switching of actual application needs.
Smart Images

Figure CN123113280A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of industrial control technology, and in particular to a digital input / output multiplexing circuit, method, electronic device, and medium. Background Technology
[0002] In industrial automation control systems, especially programmable logic controller (PLC) systems and distributed I / O modules, it is usually necessary to set up digital input (DI) interfaces and digital output (DO) interfaces. The digital input interface is used to acquire external switching signals, and the digital output interface is used to output digital control signals to external devices.
[0003] Existing digital input / output circuits typically employ a separate design, where digital input channels and digital output channels have their own dedicated input and output circuits, each occupying an independent connection port. In this design, the function of each connection port is usually determined during the hardware design phase, making it difficult to adjust according to actual application requirements. When the number of digital input channels and digital output channels required in actual applications changes, it is easy to encounter situations where some types of channels are insufficient while others are redundant, resulting in low interface resource utilization and increased complexity in equipment selection and wiring. Summary of the Invention
[0004] In view of this, embodiments of this application provide a digital input / output multiplexing circuit, method, electronic device, and medium to solve the problem in the prior art that digital input channels and digital output channels are usually set up and occupy independent interfaces, resulting in fixed interface functions, low interface resource utilization, and difficulty in flexibly switching between digital input and digital output functions of the same interface according to actual application needs.
[0005] A first aspect of this application provides a digital input / output multiplexing circuit, comprising: a digital input / output port, a digital output circuit, a digital output control unit, a digital input circuit, a digital input switching unit, and a microcontroller unit; the digital output circuit is connected to the digital input / output port via the digital output control unit; the digital input circuit is connected to the digital input / output port via the digital input switching unit; the microcontroller unit is connected to both the digital output control unit and the digital input switching unit, and is used to control the operating states of the digital output control unit and the digital input switching unit according to the current operating mode; the digital output control unit is used to, when the current operating mode is digital output mode, to connect the signal transmission path between the digital output circuit and the digital input / output port, so as to output a digital signal through the digital input / output port; the digital input switching unit is used to, when the current operating mode is digital input mode, to connect the signal transmission path between the digital input circuit and the digital input / output port, so as to enable the digital input circuit to acquire the digital signal input through the digital input / output port.
[0006] A second aspect of this application provides a digital input / output multiplexing method, the method comprising: obtaining the current operating mode corresponding to a digital input / output port; when the current operating mode is a digital output mode, controlling a digital output control unit to open the signal transmission path between a digital output circuit and a digital input / output port, so as to output a digital signal through the digital input / output port; and when the current operating mode is a digital input mode, controlling a digital input switching unit to open the signal transmission path between a digital input circuit and a digital input / output port, so as to acquire a digital signal input through the digital input / output port through the digital input circuit.
[0007] A third aspect of this application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described method.
[0008] A fourth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the above-described method.
[0009] The beneficial effects of this application embodiment compared with the prior art are as follows: The circuit in this application embodiment, by enabling the digital output circuit and the digital input circuit to share the same digital input / output port, and utilizing the microcontroller unit to control the working state of the digital output control unit and the digital input switching unit according to the current working mode, allows the same digital input / output port to switch between digital input function and digital output function according to actual application requirements. Furthermore, it reduces the impact of the circuit corresponding to the other function on the current signal transmission path when one function is working, eliminating the need to set separate wiring ports for digital input and digital output functions. This improves the utilization rate of the digital input / output port and the flexibility of digital input / output function configuration, avoiding the problem in the prior art where digital input channels and digital output channels are usually set up and occupy independent interfaces, resulting in fixed interface functions, low interface resource utilization, and difficulty in flexibly switching between digital input and digital output functions of the same interface according to actual application requirements. Attached Figure Description
[0010] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1 This is a schematic diagram of a digital input / output multiplexing circuit provided in an embodiment of this application; Figure 2 This is a schematic diagram of a digital output circuit provided in an embodiment of this application; Figure 3 This is a schematic diagram of a digital output control unit provided in an embodiment of this application; Figure 4 This is a schematic diagram of a digital input circuit provided in an embodiment of this application; Figure 5 This is a schematic diagram of a digital input switching unit provided in an embodiment of this application; Figure 6 This is a schematic diagram of a digital input / output multiplexing circuit provided in an embodiment of this application; Figure 7 This is a schematic diagram of a digital output control signal isolation unit provided in an embodiment of this application; Figure 8 This is a schematic diagram of a digital input / output multiplexing method provided in an embodiment of this application; Figure 9This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application; Explanation of reference numerals in the attached figures: 1-Digital output circuit; 2-Digital output control unit; 3-Digital input circuit; 4-Digital input switching unit; 5-Microcontroller unit; 6-Digital output control signal isolation unit; J1-Terminal block; DI / DO-Digital input / output port; EGND-Ground terminal; U2-Ideal diode driver; U3-Switching transistor; U5-First P-channel MOSFET; Q3-NPN transistor; R5-First resistor; R6-Second resistor; R7-Third resistor Resistor; U8 - First optocoupler; R12 - Input resistor; FGND - Field side grounding terminal; D+3V3 - First power supply; R93 - Output resistor; C11 - First capacitor; R9 - First pull-down resistor; R10 - Second pull-down resistor; C23 - Second capacitor; U1 - Opto-MOS relay; R1 - Current limiting resistor; U7 - Second optocoupler; R260 - First current limiting resistor; R2 - Sixth resistor; C189 - Third capacitor; R257 - Fourth resistor; R258 - Fifth resistor. Detailed Implementation
[0012] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0013] A digital input / output multiplexing circuit and method according to embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0014] Figure 1 This is a schematic diagram of a digital input / output multiplexing circuit provided in an embodiment of this application, as shown below. Figure 1 As shown, the circuit includes: a digital input / output port DI / DO, a digital output circuit 1, a digital output control unit 2, a digital input circuit 3, a digital input switching unit 4, and a microcontroller unit 5.
[0015] The digital input / output port (DI / DO) is used to receive digital signals from external devices or output digital signals to external devices according to the current operating mode. The DI / DO is connected to external devices via terminal J1. The first terminal of terminal J1 is connected to the DI / DO, and the second terminal is connected to ground (EGND). Both the digital output control unit 2 and the digital input switching unit 4 are connected to the DI / DO, allowing the digital output circuit 1 and the digital input circuit 3 to share the same DI / DO.
[0016] Digital output circuit 1 is connected to digital input / output port DI / DO via digital output control unit 2; digital input circuit 3 is connected to digital input / output port DI / DO via digital input switching unit 4; microcontroller unit 5 is connected to digital output control unit 2 and digital input switching unit 4 respectively, and is used to control the working state of digital output control unit 2 and digital input switching unit 4 according to the current working mode; digital output control unit 2 is used to conduct the signal transmission path between digital output circuit 1 and digital input / output port DI / DO when the current working mode is digital output mode, so as to output digital signal through digital input / output port DI / DO; digital input switching unit 4 is used to conduct the signal transmission path between digital input circuit 3 and digital input / output port DI / DO when the current working mode is digital input mode, so as to enable digital input circuit 3 to collect digital signal input through digital input / output port DI / DO, thereby enabling the same digital input / output port DI / DO to realize digital input function or digital output function according to actual use requirements.
[0017] Specifically, when the current working mode is digital output mode, the microcontroller 5 controls the digital output control unit 2 to be in the on state, so as to conduct the signal transmission path between the digital output circuit 1 and the digital input / output port DI / DO. The digital signal provided by the digital output circuit 1 is transmitted to the digital input / output port DI / DO through the digital output control unit 2, and is output to the external device through the digital input / output port DI / DO, so that the digital input / output port DI / DO works in digital output mode.
[0018] When the current working mode is digital input mode, the microcontroller unit 5 controls the digital input switching unit 4 to be in the conducting state, so as to conduct the signal transmission path between the digital input / output port DI / DO and the digital input circuit 3. The digital signal provided by the external device is transmitted to the digital input circuit 3 through the digital input / output port DI / DO and the digital input switching unit 4. The digital input circuit 3 collects the digital signal to realize the input of the external digital signal.
[0019] Understandably, when the current operating mode is digital output mode, the microcontroller 5 will control the digital input switching unit 4 to disconnect, thereby disconnecting the signal transmission path between the digital input circuit 3 and the digital input / output port DI / DO, in order to reduce the impact of the digital input circuit 3 on the digital output path; when the current operating mode is digital input mode, the microcontroller 5 will control the digital output control unit 2 to be in a non-output state, in order to reduce the impact of the digital output circuit 1 on the external input digital signal.
[0020] According to the solution provided in the embodiments of this application, by enabling the digital output circuit 1 and the digital input circuit 3 to share the same digital input / output port DI / DO, and by using the microcontroller unit 5 to control the working state of the digital output control unit 2 and the digital input switching unit 4 according to the current working mode, the same digital input / output port DI / DO can switch between digital input function and digital output function according to actual application requirements. Furthermore, when one function is working, the impact of the corresponding circuit of the other function on the current signal transmission path can be reduced. There is no need to set up separate wiring ports for digital input function and digital output function, thereby improving the utilization rate of the digital input / output port DI / DO and the flexibility of digital input / output function configuration. This avoids the problem in the prior art where digital input channels and digital output channels are usually set up and occupy independent interfaces, resulting in fixed interface functions, low interface resource utilization, and difficulty in flexibly switching between digital input function and digital output function of the same interface according to actual application requirements.
[0021] In some examples, the digital output circuit 1 includes: an ideal diode unit, such as... Figure 2 As shown, the ideal diode unit includes an ideal diode driver U2 and a switching transistor U3. The ideal diode driver U2 is used to control the switching transistor U3 to turn on or off according to the voltage relationship across the switching transistor U3. Specifically, as shown... Figure 2As shown, one end of the switching transistor U3 is connected to the power input terminal, and the other end is connected to the power supply terminal on the side of the digital output control unit 2. The control terminal of the switching transistor U3 is connected to the gate driving terminal of the ideal diode driver U2. The anode of the ideal diode driver U2 is connected to the end of the switching transistor U3 near the power input terminal, and the cathode is connected to the end of the switching transistor U3 near the power supply terminal, so as to obtain the voltage across the switching transistor U3. The ground terminal GND of the ideal diode driver U2 is grounded.
[0022] Specifically, when the voltage on the power input side is higher than the voltage on the digital output control unit 2 side and the conduction condition is met, the ideal diode driver U2 controls the switch U3 to conduct, so that current is transmitted from the power input side to the digital output control unit 2 side; when the voltage on the digital output control unit 2 side is higher than the voltage on the power input side and the turn-off condition is met, the ideal diode driver U2 controls the switch U3 to turn off, so as to block the reverse current transmitted from the digital output control unit 2 side to the power input side.
[0023] It is understood that the switching transistor U3 can be either an N-channel MOSFET or a P-channel MOSFET. When using different types of MOSFETs, the connection method of the MOSFET and the driving method of the ideal diode driver U2 can be set according to the conductivity type of the MOSFET, so that the switching transistor U3 is turned on under forward power supply and turned off when there is a reverse current trend. That is to say, the specific type of the switching transistor U3 is not limited in this application embodiment, as long as it can work with the ideal diode driver U2 to achieve forward conduction from the power input terminal to the digital output control unit 2 and reverse blocking from the digital output control unit 2 to the power input terminal.
[0024] For example, such as Figure 2 As shown, the switching transistor U3 is an N-channel MOSFET. The source of the N-channel MOSFET is connected to the power input terminal, the drain is connected to the power supply terminal on the side of the digital output control unit 2, and the gate is connected to the gate driving terminal GATE of the ideal diode driver U2. The anode terminal ANODE of the ideal diode driver U2 is connected to the source side of the N-channel MOSFET, and the cathode terminal CATHODE is connected to the drain side of the N-channel MOSFET. The ideal diode driver U2 adjusts the gate voltage of the N-channel MOSFET through the gate driving terminal GATE according to the voltage relationship on both sides of the N-channel MOSFET to control the N-channel MOSFET to turn on or off.
[0025] Under forward power supply, the ideal diode driver U2 controls the N-channel MOSFET to turn on, allowing current to be transferred from the power input terminal to the digital output control unit 2 with a low voltage drop, thereby reducing conduction losses in the digital output path. When the voltage on the DI / DO side of the digital input / output port is transmitted in reverse to the ideal diode unit via the digital output control unit 2, and the voltage relationship across the N-channel MOSFET meets the turn-off condition, the ideal diode driver U2 controls the N-channel MOSFET to turn off. At this time, the body diode of the N-channel MOSFET is in a reverse cut-off state, thereby blocking the reverse current from being transmitted to the power input terminal and achieving reverse current protection.
[0026] It is understood that the specific implementation of the digital output circuit 1 in the embodiments of this application is not limited to the above-mentioned ideal diode unit. As long as it can realize the forward power supply from the power input terminal to the digital output control unit 2 and suppress or block the reverse current from the digital output control unit 2 to the power input terminal, it is acceptable.
[0027] In other examples, the digital output circuit 1 may also employ a diode unit with unidirectional conduction function or a reverse current blocking unit. The diode unit includes a general diode or a Schottky diode. The diode unit is connected between the power input terminal and the digital output control unit 2 to conduct the forward current transmitted from the power input terminal to the digital output control unit 2 and to block the reverse current transmitted from the digital output control unit 2 to the power input terminal.
[0028] In other examples, the reverse current blocking unit may employ a reverse current blocking circuit composed of one or more MOSFETs, or an integrated power switch with reverse current blocking function, to achieve forward power supply from the power input terminal to the digital output control unit 2, and to block the reverse current transmitted from the digital output control unit 2 to the power input terminal when there is a reverse current tendency.
[0029] In some examples, such as Figure 3 As shown, the digital output control unit 2 includes: a first P-channel MOSFET U5 and an NPN transistor Q3; the source of the first P-channel MOSFET U5 is connected to the digital output circuit 1, the drain is connected to the digital input / output port DI / DO, and the gate is connected to the collector of the NPN transistor Q3; the base of the NPN transistor Q3 is used to receive the digital output control signal corresponding to the current operating mode, the emitter is grounded, and the NPN transistor Q3 is used to control the first P-channel MOSFET U5 to be turned on or off according to the digital output control signal.
[0030] like Figure 3As shown, the digital output control unit 2 also includes a first resistor R5, a second resistor R2, and a third resistor R7. The first resistor R5 is connected between the source and gate of the first P-channel MOSFET U5; the second resistor R2 is connected between the gate of the first P-channel MOSFET U5 and the collector of the NPN transistor Q3; and the third resistor R7 is connected between the base and emitter of the NPN transistor Q3.
[0031] The first resistor R5 is used to pull the gate potential of the first P-channel MOSFET U5 to the source potential when the NPN transistor Q3 is in the off state, so that the first P-channel MOSFET U5 remains off, thereby reducing the possibility of the first P-channel MOSFET U5 being falsely turned on when it does not receive a valid digital output control signal. The second resistor R2 is used to limit the current in the gate drive path of the first P-channel MOSFET U5 and to buffer the switching process of the first P-channel MOSFET U5. The third resistor R7 is used to pull the base potential of the NPN transistor Q3 low when the base of the NPN transistor Q3 does not receive a valid digital output control signal, so that the NPN transistor Q3 remains off.
[0032] Specifically, when the digital output control signal is used to control the conduction of the digital output path, the NPN transistor Q3 is turned on, so that the gate of the first P-channel MOSFET U5 forms a conduction path with the ground terminal EGND through the second resistor R2 and the NPN transistor Q3, thereby reducing the gate potential of the first P-channel MOSFET U5. When the voltage difference between the gate potential and the source potential of the first P-channel MOSFET U5 meets the conduction condition, the first P-channel MOSFET U5 is turned on, so that the electrical signal provided by the digital output circuit 1 can be transmitted to the digital input / output port DI / DO through the first P-channel MOSFET U5.
[0033] When the digital output control signal is used to control the digital output path to be disconnected, the NPN transistor Q3 is turned off, and the first resistor R5 pulls the gate potential of the first P-channel MOSFET U5 up to the source potential, causing the first P-channel MOSFET U5 to be turned off, thereby disconnecting the signal transmission path between the digital output circuit 1 and the digital input / output port DI / DO.
[0034] It is understood that the digital output control unit 2 in this embodiment is not limited to being implemented using a first P-channel MOSFET U5 and an NPN transistor Q3. In other examples, the digital output control unit 2 can also be implemented using an N-channel MOSFET and a corresponding gate drive circuit, a PNP transistor, a relay, an opto-MOSFET relay, or an integrated switching device. For different types of switching devices, a corresponding drive circuit can be set to match the switching device, so as to control the signal transmission path between the digital output circuit 1 and the digital input / output port DI / DO to be turned on or off according to the digital output control signal.
[0035] In other words, the specific circuit form of the digital output control unit 2 is not limited in the embodiments of this application, as long as it can control the conduction state of the digital output path according to the digital output control signal to realize the output of digital signal.
[0036] In some examples, such as Figure 4 As shown, the digital input circuit 3 includes: a first optocoupler U8 and an input resistor R12; the input terminal of the first optocoupler U8 is connected to the digital input switching unit 4 through the input resistor R12, and the output terminal of the first optocoupler U8 is connected to the microcontroller unit 5; the input resistor R12 is used to limit the current input to the first optocoupler U8, and the first optocoupler U8 is used to electrically isolate the digital signal input through the digital input / output port DI / DO, and transmit the isolated digital signal to the microcontroller unit 5 to realize the acquisition of digital signal.
[0037] More specifically, the first optocoupler U8 has a first input terminal and a second input terminal, and its output terminal has a first output terminal and a second output terminal. The first input terminal of the first optocoupler U8 is connected to the digital input switching unit 4 through the input resistor R12, and the second input terminal is connected to the field-side ground terminal FGND. The first output terminal of the first optocoupler U8 is connected to the first power supply D+3V3, and the second output terminal is connected to the digital input terminal MCU_DI of the microcontroller unit 5 through the output resistor R93. Thus, the digital signal input through the digital input / output port DI / DO is transmitted to the input side of the first optocoupler U8 through the digital input switching unit 4 and the input resistor R12, and after being electrically isolated by the first optocoupler U8, it is transmitted from the output side of the first optocoupler U8 to the digital input terminal MCU_DI of the microcontroller unit 5.
[0038] In some examples, the digital input circuit 3 further includes a first capacitor C11 and a first pull-down resistor R9. The first capacitor C11 and the first pull-down resistor R9 are respectively connected between the first input terminal of the first optocoupler U8 and the field-side ground terminal FGND. The first capacitor C11 is used to filter the digital signal input to the first optocoupler U8 to reduce the impact of high-frequency interference on the acquisition of digital signals. The first pull-down resistor R9 is used to maintain the first input terminal of the first optocoupler U8 at a preset potential when no effective input signal is formed between the digital input switching unit 4 and the digital input circuit 3, so as to reduce the possibility of external interference causing the first optocoupler U8 to be falsely turned on.
[0039] In some examples, the digital input circuit 3 also includes a second pull-down resistor R10 and a second capacitor C23. The second pull-down resistor R10 is connected between the second output terminal of the first optocoupler U8 and the digital side ground terminal DGND, and is used to maintain the second output terminal of the first optocoupler U8 at a preset low level when the first optocoupler U8 does not output a valid signal. The output resistor R93 is connected between the second output terminal of the first optocoupler U8 and the digital input terminal of the microcontroller 5, and is used to limit the current and isolate the digital signal transmitted to the microcontroller 5. The second capacitor C23 is connected between the digital input terminal MCU_DI of the microcontroller 5 and the digital side ground terminal DGND, and is used to filter the digital signal transmitted to the microcontroller 5 through the output resistor R93 to reduce high-frequency interference and improve the stability of digital input signal acquisition.
[0040] In some examples, the value of the input resistor R12 can be determined based on the input current range of the first optocoupler U8 and the external input voltage range corresponding to the digital input / output port DI / DO, so that the current flowing through the input side of the first optocoupler U8 is within the preset operating range, thereby ensuring that the first optocoupler U8 can be reliably turned on and reducing the possibility of the first optocoupler U8 being damaged due to excessive input current.
[0041] According to the circuit structure described above, when the current operating mode is digital input mode and the digital input switching unit 4 is turned on, the external digital signal is transmitted to the digital input circuit 3 via the digital input / output port DI / DO, and then sequentially transmitted to the digital input terminal MCU_DI of the microcontroller unit 5 via the input resistor R12 and the first optocoupler U8. Electrical isolation between the field side and the microcontroller unit 5 via the first optocoupler U8 reduces the impact of field-side voltage fluctuations or electrical interference on the microcontroller unit 5, thereby improving the reliability of digital input signal acquisition.
[0042] It is understood that the digital input circuit 3 in this embodiment is not limited to using the first optocoupler U8 and the input resistor R12. In other examples, the digital input circuit 3 can also be implemented by using a digital isolator in conjunction with an input conditioning circuit, or by using a digital input interface chip with electrical isolation function. The input conditioning circuit may include at least one of a current limiting circuit, a voltage divider circuit, a filter circuit, or a level conversion circuit, used to adjust the digital signal input through the digital input / output port DI / DO to a signal range compatible with the digital isolator. The digital isolator or the digital input interface chip is used to electrically isolate the digital signal and transmit the isolated digital signal to the microcontroller 5.
[0043] In other examples, the digital input circuit 3 can also employ a digital isolation circuit based on capacitive or magnetic coupling to achieve isolated transmission between the field-side digital signals and the microcontroller unit 5.
[0044] In other words, the specific implementation of the digital input circuit 3 is not limited in the embodiments of this application, as long as it can adapt and process the digital signal input through the digital input / output port DI / DO and transmit the processed digital signal to the microcontroller unit 5 to achieve reliable acquisition of the digital signal.
[0045] In some examples, such as Figure 5 As shown, the digital input switching unit 4 includes: an optical MOS relay U1; the control side of the optical MOS relay U1 is connected to the first power supply D+3V3 and the microcontroller unit 5 respectively, and is used to receive the digital input switching control signal output by the microcontroller unit 5; the switching side of the optical MOS relay U1 is connected between the digital input / output port DI / DO and the digital input circuit 3, and is used to turn on or off the signal transmission path between the digital input / output port DI / DO and the digital input circuit 3 according to the digital input switching control signal.
[0046] Specifically, the control side of the optical MOS relay U1 includes a first control terminal and a second control terminal. The first control terminal is connected to the first power supply D+3V3 through a current-limiting resistor R1, and the second control terminal is connected to the digital input switching control terminal MCU_SWITCH_DI of the microcontroller unit 5. The switching side of the optical MOS relay U1 includes a first switching terminal and a second switching terminal. The first switching terminal is connected to the digital input / output port DI / DO, and the second switching terminal is connected to the input terminal DI of the digital input circuit 3.
[0047] The current-limiting resistor R1 is used to limit the current flowing through the control side of the opto-MOS relay U1 so that the control side of the opto-MOS relay U1 operates within a preset current range.
[0048] When the current working mode is digital input mode, the microcontroller unit 5 outputs the corresponding digital input switching control signal through the digital input switching control terminal MCU_SWITCH_DI, so that the switching side of the opto-MOS relay U1 is turned on, thereby turning on the signal transmission path between the digital input / output port DI / DO and the digital input circuit 3, so that the externally input digital signal can be transmitted from the digital input / output port DI / DO to the digital input circuit 3 to realize the acquisition of digital signal.
[0049] When the current operating mode is digital output mode, the microcontroller unit 5 controls the switching side of the opto-MOS relay U1 to disconnect through the digital input switching control terminal MCU_SWITCH_DI, thereby cutting off the electrical connection between the digital input circuit 3 and the digital input / output port DI / DO. This prevents the digital output signal from entering the digital input circuit 3 through the digital input / output port DI / DO, thereby reducing the impact of the digital input circuit 3 on the digital output path and reducing the additional power consumption generated by the digital input path in digital output mode.
[0050] In some examples, the digital input switching unit 4 can also be an analog switch. The signal input and signal output terminals of the analog switch are respectively connected between the digital input / output port DI / DO and the digital input circuit 3. The control terminal of the analog switch is connected to the microcontroller unit 5 to receive the digital input switching control signal output by the microcontroller unit 5, and to control the signal transmission path between the digital input / output port DI / DO and the digital input circuit 3 to be turned on or off according to the digital input switching control signal.
[0051] Specifically, when the current operating mode is digital input mode, the microcontroller 5 controls the analog switch to turn on, so that the digital signal input through the digital input / output port DI / DO can be transmitted to the digital input circuit 3; when the current operating mode is digital output mode, the microcontroller 5 controls the analog switch to turn off, so as to cut off the connection between the digital input circuit 3 and the digital input / output port DI / DO, and reduce the impact of the digital input circuit 3 on the digital output path.
[0052] In some examples, analog switches with low on-resistance can be selected to reduce the on-voltage drop and signal loss generated by the digital input switching unit 4 in digital input mode, thereby improving the integrity of digital input signal transmission.
[0053] In some examples, such as Figure 6As shown, the circuit also includes: a digital output control signal isolation unit 6, which is connected between the microcontroller unit 5 and the digital output control unit 2. It is used to receive the digital output control signal output by the microcontroller unit 5, electrically isolate the digital output control signal, and transmit the isolated digital output control signal to the digital output control unit 2 to control the working state of the digital output control unit 2.
[0054] Among them, such as Figure 7 As shown, the digital output control signal isolation unit 6 includes a second optocoupler U7; the input terminal of the second optocoupler U7 is connected to the microcontroller unit 5 and is used to receive the digital output control signal output by the microcontroller unit 5; the output terminal of the second optocoupler U7 is connected to the digital output control unit 2 and is used to transmit the electrically isolated digital output control signal to the digital output control unit 2.
[0055] Specifically, the input terminals of the second optocoupler U7 include a first input terminal and a second input terminal. The first input terminal is connected to the digital output control terminal MCU_SWITCH_DO of the microcontroller unit 5 through the first current-limiting resistor R260. The second input terminal is connected to the digital side ground terminal DGND. The output terminals of the second optocoupler U7 include a first output terminal and a second output terminal. The first output terminal is connected to the second power supply D+5V. The second output terminal is connected to the control terminal SWITCH_DO of the digital output control unit 2 through the sixth resistor R2.
[0056] In some examples, the digital output control signal isolation unit 6 further includes a third capacitor C189 and a fourth resistor R257, which are respectively connected between the signal node where the first input terminal of the second optocoupler U7 is located and the digital side ground terminal DGND. The third capacitor C189 is used to filter the digital output control signal output by the microcontroller unit 5 to reduce the impact of high-frequency interference on the operating state of the second optocoupler U7; the fourth resistor R257 is used to provide a defined potential state for the input side of the second optocoupler U7 to reduce the possibility of external interference causing the second optocoupler U7 to mis-turn on.
[0057] In some examples, the digital output control signal isolation unit 6 also includes a fifth resistor R258, which is connected between the control terminal SWITCH_DO of the digital output control unit 2 and the field-side ground terminal EGND. This resistor maintains the control terminal SWITCH_DO at a preset potential state when the second optocoupler U7 does not output a valid digital output control signal. A second resistor R2 is connected between the second output terminal of the second optocoupler U7 and the control terminal SWITCH_DO, and is used for current limiting and protection of the signal output from the second optocoupler U7 to the digital output control unit 2.
[0058] More specifically, the control terminal SWITCH_DO is connected to the base of the NPN transistor Q3 in the digital output control unit 2, thereby transmitting the digital output control signal from the second output terminal of the second optocoupler U7 to the base of the NPN transistor Q3 via the second resistor R2.
[0059] When the microcontroller unit 5 outputs a digital output control signal through the digital output control terminal MCU_SWITCH_DO to control the conduction of the digital output path, the input side of the second optocoupler U7 changes its working state according to the digital output control signal, and the output side of the second optocoupler U7 outputs a corresponding control signal. The control signal is transmitted to the control terminal SWITCH_DO through the second resistor R2, and further transmitted to the base of the NPN transistor Q3 to control the digital output control unit 2 to conduct the digital output path.
[0060] When the microcontroller 5 does not output a valid digital output control signal to control the conduction of the digital output path, the output side of the second optocoupler U7 is in the corresponding non-conducting state, and the fifth resistor R258 keeps the control terminal SWITCH_DO at the preset potential state, thereby keeping the digital output control unit 2 in the non-output state.
[0061] All of the above-mentioned optional technical solutions can be combined in any way to form the optional embodiments of this application, and will not be described in detail here.
[0062] The following are embodiments of the method of this application, and the method can be applied to the foregoing circuit embodiments. For details not disclosed in the method embodiments of this application, please refer to the foregoing circuit embodiments.
[0063] This embodiment also provides a digital input / output multiplexing method, such as... Figure 8 As shown, this digital input / output multiplexing method includes: S801. Obtain the current operating mode corresponding to the digital input / output port; S802. When the current working mode is digital output mode, control the digital output control unit to open the signal transmission path between the digital output circuit and the digital input / output port so as to output digital signals through the digital input / output port. S803. When the current working mode is digital input mode, control the digital input switching unit to open the signal transmission path between the digital input circuit and the digital input / output port, so as to acquire the digital signal input through the digital input / output port through the digital input circuit.
[0064] According to the solution provided in the embodiments of this application, by enabling the digital output circuit and the digital input circuit to share the same digital input / output port, and by using the microcontroller unit to control the working state of the digital output control unit and the digital input switching unit according to the current working mode, the same digital input / output port can switch between digital input function and digital output function according to actual application requirements. Furthermore, when one function is working, the impact of the corresponding circuit of the other function on the current signal transmission path can be reduced. There is no need to set up separate wiring ports for digital input function and digital output function, thereby improving the utilization rate of digital input / output ports and the flexibility of digital input / output function configuration. This avoids the problem in the prior art where digital input channels and digital output channels are usually set up and occupy independent interfaces, resulting in fixed interface functions, low interface resource utilization, and difficulty in flexibly switching between digital input and digital output functions of the same interface according to actual application requirements.
[0065] Figure 9 This is a schematic diagram of the electronic device 9 provided in an embodiment of this application. Figure 9 As shown, the electronic device 9 of this embodiment includes a processor 901, a memory 902, and a computer program 903 stored in the memory 902 and executable on the processor 901. When the processor 901 executes the computer program 903, it implements the steps in the various circuit embodiments described above. Alternatively, when the processor 901 executes the computer program 903, it implements the functions of each module / unit in the various device embodiments described above.
[0066] Electronic device 9 can be a desktop computer, laptop, handheld computer, cloud server, or other electronic device. Electronic device 9 may include, but is not limited to, processor 901 and memory 902. Those skilled in the art will understand that... Figure 9 This is merely an example of electronic device 9 and does not constitute a limitation on electronic device 9. It may include more or fewer components than shown, or different components.
[0067] The processor 901 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0068] The memory 902 can be an internal storage unit of the electronic device 9, such as a hard disk or RAM of the electronic device 9. The memory 902 can also be an external storage device of the electronic device 9, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, Flash Card, etc., equipped on the electronic device 9. The memory 902 can also include both internal and external storage units of the electronic device 9. The memory 902 is used to store computer programs and other programs and data required by the electronic device.
[0069] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0070] If an integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the circuits of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various circuit embodiments described above. The computer program may include computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. A computer-readable medium may include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in a computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in a jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.
[0071] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A digital input / output multiplexing circuit, characterized in that, The circuit includes: a digital input / output port, a digital output circuit, a digital output control unit, a digital input circuit, a digital input switching unit, and a microcontroller unit; The digital output circuit is connected to the digital input / output port through the digital output control unit; The digital input circuit is connected to the digital input / output port through the digital input switching unit; The microcontroller unit is connected to the digital output control unit and the digital input switching unit respectively, and is used to control the working state of the digital output control unit and the digital input switching unit according to the current working mode; The digital output control unit is used to connect the signal transmission path between the digital output circuit and the digital input / output port when the current working mode is digital output mode, so as to output digital signals through the digital input / output port. The digital input switching unit is used to connect the signal transmission path between the digital input circuit and the digital input / output port when the current working mode is digital input mode, so that the digital input circuit can collect the digital signal input through the digital input / output port.
2. The circuit according to claim 1, characterized in that, The digital output circuit includes an ideal diode unit, which includes an ideal diode driver and a switching transistor. The ideal diode driver is used to control the switching transistor to turn on or off according to the voltage relationship across the switching transistor.
3. The circuit according to claim 1, characterized in that, The digital output control unit includes: a first P-channel MOSFET and an NPN transistor; The source of the first P-channel MOS transistor is connected to the digital output circuit, the drain is connected to the digital input / output port, and the gate is connected to the collector of the NPN transistor. The base of the NPN transistor is used to receive a digital output control signal corresponding to the current operating mode, and the emitter is grounded. The NPN transistor is used to control the first P-channel MOSFET to turn on or off according to the digital output control signal.
4. The circuit according to claim 1, characterized in that, The digital input circuit includes: a first optocoupler and an input resistor; The input terminal of the first optocoupler is connected to the digital input switching unit through the input resistor, and the output terminal of the first optocoupler is connected to the microcontroller unit. The input resistor is used to limit the current input to the first optocoupler. The first optocoupler is used to electrically isolate the digital signal input through the digital input / output port and transmit the isolated digital signal to the microcontroller unit to realize the acquisition of digital signal.
5. The circuit according to claim 1, characterized in that, The digital input switching unit includes: an optical MOS relay; The control side of the optical MOS relay is connected to the first power supply and the microcontroller unit respectively, and is used to receive the digital input switching control signal output by the microcontroller unit. The switching side of the optical MOS relay is connected between the digital input / output port and the digital input circuit, and is used to turn on or off the signal transmission path between the digital input / output port and the digital input circuit according to the digital input switching control signal.
6. The circuit according to claim 1, characterized in that, The circuit further includes a digital output control signal isolation unit, which is connected between the microcontroller and the digital output control unit. The digital output control signal isolation unit is used to receive the digital output control signal output by the microcontroller, electrically isolate the digital output control signal, and transmit the isolated digital output control signal to the digital output control unit to control the working state of the digital output control unit.
7. The circuit according to claim 6, characterized in that, The digital output control signal isolation unit includes a second optocoupler; The input terminal of the second optocoupler is connected to the microcontroller unit and is used to receive the digital output control signal output by the microcontroller unit; The output terminal of the second optocoupler is connected to the digital output control unit, and is used to transmit the electrically isolated digital output control signal to the digital output control unit.
8. A digital input / output multiplexing method, characterized in that, The method is applied to the circuit as described in any one of claims 1-7, and the method includes: Obtain the current operating mode corresponding to the digital input / output port; When the current working mode is digital output mode, the control unit of digital output is turned on to open the signal transmission path between the digital output circuit and the digital input / output port so as to output digital signal through the digital input / output port. When the current operating mode is digital input mode, the control digital input switching unit opens the signal transmission path between the digital input circuit and the digital input / output port, so as to acquire the digital signal input through the digital input / output port through the digital input circuit.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in claim 8.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in claim 8.
