GPIO multiplexing circuit and multiplexing method thereof
Through the time-division design of the GPIO multiplexing circuit, the function of controlling six LED lights and four buttons is achieved using the logic combination of five GPIO lines, which solves the problem of the high demand for GPIO pins in the existing technology, reduces costs and increases the System operation efficiency and stability.
Patent Information
- Application Number
- CN202411171085.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-11-12
AI Technical Summary
In the prior art, a single GPIO pin is used to control a GPIO function accordingly, resulting in a large demand for GPIO pins of the MCU, increasing application costs and material use.
A GPIO multiplexing circuit is adopted, including a driver module, an indicator module and a key module, which divides the timing through time division. The logic combination of five GPIO lines is used to control the scanning and lighting of six LED lights and the reading of four key input signals. The function of fetching and an output control reduces the number of GPIO usage.
It effectively reduces the number of GPIO usage, reduces costs, improves the operating efficiency and stability of the system, and can complete eleven input and output operations within 11 milliseconds to meet the use needs of power tools.
Smart Images

Figure CN118944661A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of integrated circuits, and in particular to a GPIO multiplexing circuit and a multiplexing method thereof. Background Art
[0002] The electric tools currently used in the market, such as brushless and sensorless angle grinders, are selling very well and are widely used in various gardening and agricultural sites. The angle grinders on the market require power indicator lights, gear indicator lights, button functions, etc. The power indicator lights generally require six light-emitting diodes, and the buttons are generally set to four, which are used to display the gear status and the circuit system start.
[0003] Traditional technologies often use a single GPIO pin to control a GPIO function, i.e., LED display requires 6 GPIOs, key detection requires 4 GPIOs, and locking the power requires 1 GPIO. This method requires more GPIO pins for the MCU, increasing application costs and material usage. Summary of the invention
[0004] In view of the above-mentioned shortcomings of the prior art, an object of the present invention is to provide a GPIO multiplexing circuit and a multiplexing method thereof, so as to solve the problem of high cost of using a single GPIO pin to control a GPIO function in the prior art.
[0005] To achieve the above-mentioned purpose and other related purposes, the present invention provides a GPIO multiplexing circuit, including a driving module, an indicator light module and a key module, wherein the driving module, the indicator light module and the key module are all controlled by a single-chip microcomputer; The driving module uses a MOS tube Q3 and a transistor Q1, the D pole of the MOS tube Q3 is connected to the base of the transistor Q1, the S pole of the MOS tube Q3 is grounded, and the emitter of the transistor Q1 is used to drive the electric tool to operate; The indicator light module uses six light emitting diodes LED1-LED6 to indicate different power states of the power tool; The button module uses four buttons SW1, SW2, S1, and S2. The buttons SW1 and SW2 are used to correspond to different gear states of the power tool, and the buttons S1 and S2 are used to correspond to the application state of the circuit system. The GPIO multiplexing circuit also uses five GPIO lines Scanline1, Scanline2, Scanline3, RL1, and RL2. The input ends of the light-emitting diodes LED1 and LED2 are connected to Scanline1, the input ends of the light-emitting diodes LED3 and LED4 are connected to Scanline2, and the input ends of the light-emitting diodes LED5 and LED6 are connected to Scanline3; the output ends of the light-emitting diodes LED1, LED3, and LED5 are connected to RL1, and the output ends of the light-emitting diodes LED2, LED4, and LED6 are connected to RL2; The button SW1 is connected to Scanline2, the button SW2 is connected to Scanline3, the button S1 is connected to Scanline1, and the button S2 is connected to RL1; The G pole of the MOS tube Q3 is connected to Scanline1.
[0006] In one embodiment of the present invention, the driving module is further provided with a voltage stabilizing chip U1 , and the voltage stabilizing chip U1 is connected to the collector of the transistor Q.
[0007] In one embodiment of the present invention, a storage capacitor C14 is provided between Scanline1 and the MOS transistor Q3, a resistor R21 is connected between the storage capacitor C14 and Scanline1, and a resistor R24 is connected between the storage capacitor C14 and the MOS transistor Q3, and the resistance value of the resistor R21 is smaller than the resistance value of the resistor R24.
[0008] In one embodiment of the present invention, a unidirectional conducting diode D5 is disposed between the Scanline1 and the resistor R21 .
[0009] In one embodiment of the present invention, a unidirectional conducting diode D6 is provided between Scanline1 and the key S1, and a unidirectional conducting diode D7 is provided between RL1 and the key S2. The output ends of the unidirectional conducting diode D6 and the unidirectional conducting diode D7 are both connected to the D pole of the MOS tube Q3.
[0010] A GPIO multiplexing method, including the GPIO multiplexing circuit, comprises the following steps: S1. Nine time sequences are divided based on the time division method, and only one GPIO function is executed in a single time sequence; S2. In the first timing sequence, Scanline1 is defined to output a high level, and the energy storage capacitor C14 in the driving module is charged and discharged, so as to keep the MOS tube Q3 and the transistor Q1 turned on, thereby maintaining the power supply of the circuit system; S3, in the second to seventh time sequences, define the high and low level states of the input and output ends of the light emitting diodes LED1-LED6 in sequence, so that one or more of the light emitting diodes are lit; S4, in the eighth time sequence, the switch states of the buttons SW1, SW2, and S1 are detected through Scanline1, Scanline2, and Scanline3; S5. In the ninth time sequence, the switch state of the key S1 is detected through RL1 and RL2; The above steps S1 to S5 constitute a complete GPIO multiplexing process.
[0011] In one embodiment of the present invention, the duration of a single time sequence is 1-1.5 milliseconds.
[0012] A GPIO multiplexing device, comprising: Memory for storing computer programs; A processor is used to implement the steps of the GPIO multiplexing method when executing the computer program.
[0013] A computer-readable storage medium stores a computer program, which implements the steps of a GPIO multiplexing method when executed by a processor.
[0014] As described above, the GPIO multiplexing circuit and multiplexing method of the present invention have the following beneficial effects: The present invention adopts a time-division multiplexing design concept. Through the logical combination of five GPIO lines, namely Scanline1, Scanline2, Scanline3, RL1 and RL2, it can realize the functions of controlling the scanning and lighting of six LED lights, reading four key input signals and one output control, thereby meeting the demand of five GPIOs controlling eleven inputs and outputs, greatly reducing the use of GPIOs, effectively reducing costs and reducing the bill of materials; and reducing the number of GPIOs used can also be conducive to better management and control of these nodes, thereby improving the overall operating efficiency and stability of the system; the present invention limits the execution time of a single GPIO function to between 1 and 1.5 milliseconds, and the fastest execution time of eleven inputs and outputs is only 11 milliseconds, which does not affect the visual viewing of the staff at all, can meet the use requirements of power tools, and is conducive to large-scale promotion and application in the market. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 Shown is a circuit schematic diagram of the GPIO multiplexing circuit disclosed in the present invention. DETAILED DESCRIPTION
[0016] The following is a description of the implementation of the present invention by means of specific embodiments. Those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification.
[0017] See also Figure 1 It should be noted that the structures, proportions, sizes, etc. illustrated in the drawings in this specification are only used to match the contents disclosed in the specification for people familiar with this technology to understand and read, and are not used to limit the conditions under which the present invention can be implemented. Therefore, they have no substantial technical significance. Any structural modification, change in proportion or adjustment of size should still fall within the scope of the technical contents disclosed in the present invention without affecting the effects and purposes that can be achieved by the present invention.
[0018] Example 1, please refer to Figure 1 The present embodiment provides a GPIO multiplexing circuit, including a driving module, an indicator light module and a key module, wherein the driving module, the indicator light module and the key module are all controlled by a single chip microcomputer; the driving module adopts a MOS tube Q3 and a transistor Q1, wherein the D pole of the MOS tube Q3 is connected to the base of the transistor Q1, the S pole of the MOS tube Q3 is grounded, and the emitter of the transistor Q1 is used to drive the electric tool to operate; the driving module is also provided with a voltage stabilizing chip U1, which is connected to the collector of the transistor Q; the indicator light module adopts six light emitting diodes LED1-LED6 to indicate different power states of the electric tool; the key module adopts four keys SW1, SW2, S1, S2, keys SW1 and SW2 are used to correspond to different gear states of the electric tool, and keys S1 and S2 are used to correspond to the application state of the circuit system.
[0019] The GPIO multiplexing circuit also uses five GPIO lines Scanline1, Scanline2, Scanline3, RL1, and RL2. The input ends of the light-emitting diodes LED1 and LED2 are connected to Scanline1, the input ends of the light-emitting diodes LED3 and LED4 are connected to Scanline2, and the input ends of the light-emitting diodes LED5 and LED6 are connected to Scanline3; the output ends of the light-emitting diodes LED1, LED3, and LED5 are connected to RL1, and the output ends of the light-emitting diodes LED2, LED4, and LED6 are connected to RL2; for example, when LED1 needs to be lit alone, Scanline1 is defined as a high level, RL1 outputs 0V, Scanline2 and Scanline3 output low levels, and RL2 outputs a high level.
[0020] The button SW1 is connected to Scanline2, the button SW2 is connected to Scanline3, the button S1 is connected to Scanline1, and the button S2 is connected to RL1; when it is necessary to detect the switch state of the buttons SW1, SW2, and S1, the outputs of Scanline1, Scanline2, and Scanline3 are defined as 0, and RL1 is defined as the input state; Scanline2 detects a low level when the button SW1 is in the closed state, and a high level when the button SW1 is in the disconnected state; Scanline3 detects a low level when the button SW2 is in the closed state, and a high level when the button SW2 is in the disconnected state; RL1 detects a low level when the button S1 is in the closed state, and a high level when the button S1 is in the disconnected state; when it is necessary to detect the switch state of the button S2, detection is performed through RL1 and RL2, RL1 detects a low level when the button S2 is in the closed state, and a high level when the button S2 is in the disconnected state. A unidirectional conducting diode D6 is provided between Scanline1 and the button S1, and a unidirectional conducting diode D7 is provided between RL1 and the button S2. The output ends of the unidirectional conducting diode D6 and the unidirectional conducting diode D7 are both connected to the D pole of the MOS tube Q3.
[0021] The G pole of the MOS tube Q3 is connected to Scanline1, and an energy storage capacitor C14 is provided between Scanline1 and the MOS tube Q3; when the output of the driving module needs to be controlled, Scanline1 outputs a high level to charge the energy storage capacitor C14; a resistor R21 is connected between the energy storage capacitor C14 and Scanline1, and a resistor R24 is connected between the energy storage capacitor C14 and the MOS tube Q3. The resistance value of the resistor R21 is less than the resistance value of the resistor R24. Specifically, the resistor R21 is 4.7K, and the resistor R24 is 100K, so that the charging speed of the energy storage capacitor C14 is much greater than the discharging speed, so as to maintain the conduction of the MOS tube Q3, and then maintain the conduction of the triode Q1, and maintain the power supply of the entire circuit system. A unidirectional conducting diode D5 is provided between the Scanline1 and the resistor R21, which is used to control the unidirectional output of the driving module.
[0022] The present invention can realize the functions of controlling the scanning and lighting of six LED lights, reading four key input signals, and one output control through the logical combination application of the five GPIO lines Scanline1, Scanline2, Scanline3, RL1, and RL2, meeting the demand of five GPIOs controlling eleven inputs and outputs, greatly reducing the use of GPIOs, effectively reducing costs and reducing the bill of materials; and reducing the number of GPIOs used can also be conducive to better management and control of these nodes, thereby improving the overall operating efficiency and stability of the system.
[0023] In actual application, the five GPIO lines can be combined in pairs to expand more GPIO functions. In this embodiment, the control of the angle grinder only involves 11 GPIO functions, so this embodiment is described with respect to 11 GPIO functions, but the solution is not limited to this.
[0024] Embodiment 2: This embodiment provides a GPIO multiplexing method, including the GPIO multiplexing circuit, including the following steps: S1. Nine time sequences are divided based on the time division method, and the duration of each time sequence is 1-1.5 milliseconds; only one GPIO function is executed in a single time sequence; S2. In the first timing sequence, Scanline1 is defined to output a high level, and the energy storage capacitor C14 in the driving module is charged and discharged, so as to keep the MOS tube Q3 and the transistor Q1 turned on, thereby maintaining the power supply of the circuit system; S3, in the second to seventh time sequences, define the high and low level states of the input and output ends of the light emitting diodes LED1-LED6 in sequence, so that one or more of the light emitting diodes are lit; S4, in the eighth time sequence, the switch states of the buttons SW1, SW2, and S1 are detected through Scanline1, Scanline2, and Scanline3; S5. In the ninth time sequence, the switch state of the key S1 is detected through RL1 and RL2; The above steps S1 to S5 constitute a complete GPIO multiplexing process.
[0025] The present invention limits the execution time of a single GPIO function to between 1 and 1.5 milliseconds, and can execute eleven inputs and outputs in as fast as 11 milliseconds, without affecting the visual inspection of the staff at all. It can meet the use requirements of power tools and is conducive to large-scale promotion and application in the market.
[0026] Embodiment 3, this embodiment provides a GPIO multiplexing device, including a memory and a processor, the memory is used to store a computer program, and the processor is used to implement the steps of the GPIO multiplexing method provided in Embodiment 2 when executing the computer program.
[0027] Embodiment 4, this embodiment provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by the processor, the steps of the GPIO multiplexing method provided in Embodiment 2 are implemented. It can be understood that if the method in the above embodiment is implemented in the form of 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, the technical solution of the present application is essentially or part of the contribution to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory), ROM, random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.
[0028] In summary, the present invention adopts the design concept of time division multiplexing, and realizes the functions of controlling the scanning and lighting of six LED lights, reading four button input signals, and one output control through five GPIO lines, thereby meeting the requirements of five GPIOs controlling eleven inputs and outputs, greatly reducing the use of GPIOs, effectively reducing costs and reducing the bill of materials; and reducing the number of GPIOs used can also facilitate better management and control of these nodes, thereby improving the overall operating efficiency and stability of the system; the present invention limits the execution time of a single GPIO function to between 1-1.5 milliseconds, and the fastest execution time of eleven inputs and outputs is only 11 milliseconds, which does not affect the visual viewing of the staff at all, can meet the use requirements of power tools, and is conducive to large-scale promotion and application in the market. Therefore, the present invention effectively overcomes the various shortcomings of the prior art and has a high industrial utilization value.
[0029] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by a person of ordinary skill in the art without departing from the spirit and technical concept disclosed by the present invention shall still be covered by the claims of the present invention.
Claims
1. A GPIO multiplexing circuit, comprising a driver module, an indicator light module, and a button module, all of which are controlled by a single-chip microcomputer; The driving module uses a MOS tube Q3 and a transistor Q1, the D pole of the MOS tube Q3 is connected to the base of the transistor Q1, the S pole of the MOS tube Q3 is grounded, and the emitter of the transistor Q1 is used to drive the power tool to operate; The indicator light module uses six light-emitting diodes LED1-LED6 to indicate different power states of the power tool; The button module uses four buttons SW1, SW2, S1, and S2. The buttons SW1 and SW2 are used to correspond to different gear states of the power tool, and the buttons S1 and S2 are used to correspond to the application state of the circuit system. Its characteristics are: The GPIO multiplexing circuit further uses five GPIO lines Scanline1, Scanline2, Scanline3, RL1, and RL2. The input ends of the light-emitting diodes LED1 and LED2 are connected to Scanline1, the input ends of the light-emitting diodes LED3 and LED4 are connected to Scanline2, and the input ends of the light-emitting diodes LED5 and LED6 are connected to Scanline3; the output ends of the light-emitting diodes LED1, LED3, and LED5 are connected to RL1, and the output ends of the light-emitting diodes LED2, LED4, and LED6 are connected to RL2; The button SW1 is connected to Scanline2, the button SW2 is connected to Scanline3, the button S1 is connected to Scanline1, and the button S2 is connected to RL1; The G pole of the MOS tube Q3 is connected to Scanline1.
2. The GPIO multiplexing circuit according to claim 1, wherein: The driving module is further provided with a voltage stabilizing chip U1 , which is connected to the collector of the transistor Q.
3. The GPIO multiplexing circuit according to claim 1, wherein: A storage capacitor C14 is provided between Scanline1 and MOS transistor Q3. A resistor R21 is connected between the storage capacitor C14 and Scanline1. A resistor R24 is connected between the storage capacitor C14 and MOS transistor Q3. The resistance of resistor R21 is smaller than that of resistor R24.
4. The GPIO multiplexing circuit according to claim 3, wherein: A unidirectional conducting diode D5 is provided between the Scanline 1 and the resistor R21 .
5. The GPIO multiplexing circuit according to claim 1, wherein: A unidirectional conducting diode D6 is provided between Scanline1 and the button S1 , and a unidirectional conducting diode D7 is provided between RL1 and the button S2 . The output ends of the unidirectional conducting diode D6 and the unidirectional conducting diode D7 are both connected to the D pole of the MOS tube Q3 .
6. A GPIO multiplexing method, comprising the GPIO multiplexing circuit according to any one of claims 1 to 5, characterized in that: The steps include: S1. Nine time sequences are divided based on the time division method, and only one GPIO function is executed in a single time sequence; S2. In the first timing sequence, Scanline1 is defined to output a high level to charge and discharge the energy storage capacitor C14 in the driver module, thereby keeping the MOS tube Q3 and the transistor Q1 turned on, thereby maintaining the power supply of the circuit system; S3, in the second to seventh time sequences, sequentially define the high and low level states of the input and output terminals of the light-emitting diodes LED1-LED6 so that one or more light-emitting diodes are illuminated; S4. In the eighth time sequence, the switch states of buttons SW1, SW2, and S1 are detected through Scanline1, Scanline2, and Scanline3. S5. In the ninth time sequence, the switch state of the button S1 is detected through RL1 and RL2; The above steps S1 to S5 constitute a complete GPIO multiplexing process.
7. The GPIO multiplexing method according to claim 6, wherein: The duration of a single time sequence is 1-1.5 milliseconds.
8. A GPIO multiplexing device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the GPIO multiplexing method according to any one of claims 6 to 7 when executing the computer program.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the GPIO multiplexing method as described in any one of claims 6 to 7 are implemented.
