PWM control circuit and method
By designing the PWM control circuit and adjusting the real-time control parameters using closed-loop feedback, the problem of poor accuracy of the MCU output PWM signal is solved, and higher PWM signal accuracy and peripheral circuit control accuracy are achieved.
Patent Information
- Application Number
- CN202510074857.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-17
- Publication Date
- 2025-05-30
AI Technical Summary
The PWM signal accuracy of the existing MCU output is poor, which is affected by factors such as clock accuracy, power supply stability and hardware conditions.
A PWM control circuit is designed, including a control unit, a first sampling unit and a polarity switching unit. By acquiring real-time control parameters, the accuracy of the PWM signal is ensured.
Through closed-loop feedback control, the accuracy of the PWM signal is improved and the control accuracy of the peripheral circuit is enhanced.
Smart Images

Figure CN120074475A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of clock circuits, and particularly to a PWM control circuit and method. Background Art
[0002] In the prior art, the MCU outputs a PWM signal according to the set values of frequency, duty cycle, and amplitude. Since the PWM signal output by the MCU is affected by factors such as clock accuracy, power supply stability, and the hardware conditions of the MCU, the accuracy of the output PWM signal is poor. Summary of the Invention
[0003] This application aims to provide a PWM control circuit and method that can improve the accuracy of the PWM signal.
[0004] In a first aspect, an embodiment of this application provides a PWM control circuit, including:
[0005] A control unit, the control unit is connected to a peripheral circuit, and the control unit is configured to obtain target control parameters, generate a first PWM signal according to the target control parameters, and output it to the peripheral circuit;
[0006] A first sampling unit, the first sampling unit is connected to the control unit, and the first sampling unit is configured to obtain first real-time control parameters and output them to the control unit. The first real-time control parameters are the real-time control parameters of the first PWM signal, and the control unit uses the first real-time control parameters to adjust the first PWM signal so that the first real-time control parameters are consistent with the target control parameters.
[0007] According to some embodiments of this application, it further includes:
[0008] A second sampling unit, the second sampling unit is connected to the peripheral circuit, and is configured to obtain second real-time control parameters. The second real-time control parameters are the real-time control parameters of a second PWM signal, and the second PWM signal is the signal obtained after the first PWM signal passes through the peripheral circuit. The control unit uses the second real-time control parameters to adjust the first PWM signal so that the second real-time control parameters are consistent with the target control parameters.
[0009] According to some embodiments of this application, a polarity switching unit is provided between the control unit and the peripheral circuit, and the polarity switching unit is configured to switch the polarity of the first PWM signal and output the first PWM signal to the peripheral circuit.
[0010] According to some embodiments of this application, the polarity switching unit includes:
[0011] The first MOS transistor, the gate of the first MOS transistor is connected to the control unit, and the source of the first MOS transistor is connected to the peripheral circuit;
[0012] The first switch, the drain of the first MOS transistor is grounded through the first switch, and the drain of the first MOS transistor is connected to the first positive power supply terminal through the first switch;
[0013] The second MOS transistor, the gate of the second MOS transistor is connected to the control unit, and the source of the second MOS transistor is connected to the peripheral circuit;
[0014] The second switch, the second MOS transistor is grounded through the second switch, and the drain of the second MOS transistor is connected to the first negative power supply terminal through the second switch.
[0015] According to some embodiments of the present application, an output isolation unit is further included, and the output isolation unit includes:
[0016] A triode, the base of the triode is connected to the control unit, and the emitter of the triode is grounded;
[0017] An optocoupler, the positive terminal of the emitter of the optocoupler is connected to the second positive power supply terminal, the negative terminal of the emitter of the optocoupler is connected to the collector of the triode, and the positive terminal of the receiver of the optocoupler is connected to the third positive power supply terminal;
[0018] A first resistor, the first end of the first resistor is connected to the negative terminal of the receiver of the optocoupler, the second end of the first resistor is grounded, and the gates of the first MOS transistor and the second MOS transistor are both connected to the first end of the first resistor.
[0019] According to some embodiments of the present application, an amplitude modulation unit is further included, and the amplitude modulation unit includes:
[0020] The first comparator sub-unit, the non-inverting input terminal of the first comparator sub-unit is used for inputting a positive reference voltage;
[0021] The third MOS transistor, the output terminal of the first comparator sub-unit is connected to the gate of the third MOS transistor, the drain of the third MOS transistor is connected to the fourth positive power supply terminal, and the source of the third MOS transistor is connected to the drain of the first MOS transistor through the first switch;
[0022] The first negative feedback sub-unit, the source of the third MOS transistor is connected to the input terminal of the first negative feedback sub-unit, and the output terminal of the first negative feedback sub-unit is connected to the inverting input terminal of the first comparator sub-unit;
[0023] The second comparator sub-unit, the non-inverting input terminal of the second comparator sub-unit is used for inputting a negative reference voltage;
[0024] The fourth MOS transistor, the output terminal of the second comparator unit is connected to the gate of the fourth MOS transistor, the drain of the fourth MOS transistor is connected to the second negative power supply terminal, and the source of the fourth MOS transistor is connected to the drain of the second MOS transistor through the second switch;
[0025] The second negative feedback sub-unit, the source of the fourth MOS transistor is connected to the input terminal of the second negative feedback sub-unit, and the output terminal of the second negative feedback sub-unit is connected to the inverting input terminal of the second comparator unit.
[0026] In a second aspect, an embodiment of the present application provides a PWM control method, including:
[0027] Obtain a target control parameter, generate a first PWM signal according to the target control parameter, and the first PWM signal is used to be output to a peripheral circuit;
[0028] Obtain a first real-time control parameter, where the first real-time control parameter is a real-time control parameter of the first PWM signal;
[0029] Adjust the first PWM signal by using the first real-time control parameter, so that the first real-time control parameter is consistent with the target control parameter.
[0030] According to some embodiments of the present application, the adjusting the first PWM signal by using the first real-time control parameter so that the first real-time control parameter is consistent with the target control parameter includes:
[0031] Based on the PID algorithm, adjust the first PWM signal by using the first real-time control parameter, so that the first real-time control parameter is consistent with the target control parameter.
[0032] According to some embodiments of the present application, it further includes:
[0033] Obtain a second real-time control parameter, where the second real-time control parameter is a real-time control parameter of a second PWM signal, and the second PWM signal is a signal obtained after the first PWM signal passes through the peripheral circuit;
[0034] Adjust the first PWM signal by using the second real-time control parameter, so that the second real-time control parameter is consistent with the target control parameter.
[0035] According to some embodiments of the present application, the adjusting the first PWM signal by using the second real-time control parameter so that the second real-time control parameter is consistent with the target control parameter includes:
[0036] Based on the PID algorithm, the first PWM signal is adjusted by using the second real-time control parameter, so that the second real-time control parameter is consistent with the target control parameter.
[0037] In the embodiment of the present application, the control unit obtains the target control parameter, generates the first PWM signal according to the target control parameter, and outputs it to the peripheral circuit. Then, the first sampling unit obtains the first real-time control parameter and feeds it back to the control unit. The control unit adjusts the first PWM signal by using the first real-time control parameter, so that the first real-time control parameter is consistent with the target control parameter, realizing closed-loop feedback control and improving the accuracy of the output first PWM signal.
[0038] The additional aspects and advantages of the present application will be partly given in the following description, partly will become obvious from the following description, or will be understood through the practice of the present application. Brief Description of the Drawings
[0039] The following further describes the present application in conjunction with the drawings and embodiments, where:
[0040] Figure 1 is the functional block diagram of the embodiment of the PWM control circuit provided by the present application;
[0041] Figure 2 is the circuit diagram of the output isolation unit and the polarity switching unit in the embodiment of the PWM control circuit provided by the present application;
[0042] Figure 3 is the circuit diagram of the first comparison sub-unit in the embodiment of the PWM control circuit provided by the present application;
[0043] Figure 4 is the circuit diagram of the first negative feedback sub-unit in the embodiment of the PWM control circuit provided by the present application;
[0044] Figure 5 is the circuit diagram of the second comparison sub-unit in the embodiment of the PWM control circuit provided by the present application;
[0045] Figure 6 is the circuit diagram of the second negative feedback sub-unit in the embodiment of the PWM control circuit provided by the present application;
[0046] Figure 7 is the flowchart of the embodiment of the PWM control method provided by the present application;
[0047] Figure 8 is the schematic diagram of the duty cycle sampling of the PWM control method provided by the present application.
[0048] Reference Signs:
[0049] Control unit 100, amplitude modulation unit 200, output isolation unit 300, first frequency duty cycle sampling circuit 400, voltage sampling circuit 500, second frequency duty cycle sampling circuit 600, rectifying circuit 700, sampling isolation circuit 800, D / A conversion unit 900. Detailed implementation manners
[0050] The embodiments of the present application will be described in detail below. Examples of the embodiments are shown in the accompanying drawings, where the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below by referring to the accompanying drawings are exemplary and are only used to explain the present application, and should not be construed as a limitation to the present application.
[0051] In the description of the present application, it should be understood that the orientation or positional relationship indicated by terms such as up and down, etc., is based on the orientation or positional relationship shown in the accompanying drawings, and is only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and thus should not be construed as a limitation to the present application.
[0052] In the description of the present application, "a plurality of" means two or more. If there is a description of first and second, it is only for the purpose of distinguishing technical features, and should not be construed as indicating or implying relative importance or implicitly indicating the quantity of the indicated technical features or implicitly indicating the sequence of the indicated technical features.
[0053] In the description of the present application, unless otherwise clearly defined, terms such as setting, installation, and connection should be understood in a broad sense, and those skilled in the art can reasonably determine the specific meanings of the above terms in the present application in combination with the specific content of the technical solution.
[0054] Next, refer to Figures 1 to 8 Describe a PWM control circuit and method according to an embodiment of the present application.
[0055] The embodiment of the present application provides a PWM control circuit, as Figure 1 shown, including:
[0056] A control unit 100, the control unit 100 is connected to a peripheral circuit, and the control unit 100 is configured to obtain target control parameters, generate a first PWM signal according to the target control parameters, and output the first PWM signal to the peripheral circuit;
[0057] The first sampling unit is connected to the control unit 100. The first sampling unit is used to obtain the first real-time control parameter and output it to the control unit 100. The first real-time control parameter is the real-time control parameter of the first PWM signal. The control unit 100 adjusts the first PWM signal by using the first real-time control parameter to make the first real-time control parameter consistent with the target control parameter.
[0058] In the embodiment of the present application, the control unit 100 obtains the target control parameter, generates the first PWM signal according to the target control parameter, and outputs it to the peripheral circuit. Then, the first sampling unit obtains the first real-time control parameter and feeds it back to the control unit 100. The control unit 100 adjusts the first PWM signal by using the first real-time control parameter to make the first real-time control parameter consistent with the target control parameter, so as to realize closed-loop feedback control and improve the accuracy of the output first PWM signal.
[0059] In some embodiments of the present application, the target control parameter includes any one or more of a preset duty cycle, a preset frequency, and a preset amplitude.
[0060] In some embodiments of the present application, the first real-time control parameter includes any one or more of the real-time duty cycle, the real-time frequency, and the real-time amplitude of the first PWM signal.
[0061] In some embodiments of the present application, the first sampling unit includes a first frequency-duty cycle sampling circuit 400 and a voltage sampling circuit 500. The first frequency-duty cycle sampling circuit 400 is used to collect the real-time frequency and the real-time duty cycle of the first PWM signal and feed them back to the control unit 100. The voltage sampling circuit 500 is used to collect the real-time amplitude of the first PWM signal.
[0062] In some embodiments of the present application, the control unit 100 uses an MCU.
[0063] In some embodiments of the present application, it further includes:
[0064] The second sampling unit is connected to the peripheral circuit and is used to obtain the second real-time control parameter. The second real-time control parameter is the real-time control parameter of the second PWM signal. The second PWM signal is the signal obtained after the first PWM signal passes through the peripheral circuit. The control unit 100 adjusts the first PWM signal by using the second real-time control parameter to make the second real-time control parameter consistent with the target control parameter.
[0065] In this real-time mode, the first PWM signal is output to the subsequent circuit through the peripheral circuit for corresponding control. After passing through the peripheral circuit, the first PWM signal will be affected by the peripheral circuit, resulting in a decrease in accuracy. That is, the second PWM signal output to the subsequent circuit has poor accuracy under the influence of the peripheral circuit. The second real-time control parameter is obtained through the second sampling unit, that is, the real-time control parameter of the second PWM signal is obtained, and the second real-time control parameter is fed back to the control unit 100. The control unit 100 adjusts the first PWM signal using the second real-time control parameter to make the second real-time control parameter consistent with the target control parameter, forming a closed-loop feedback control, improving the output accuracy of the first PWM signal after passing through the peripheral circuit, that is, improving the accuracy of the second PWM signal, thereby achieving a better control effect on the subsequent circuit.
[0066] For example, the peripheral circuit is a motor drive circuit, the subsequent circuit includes a motor, the first PWM signal output by the control unit 100 is a voltage signal, the second PWM signal output after passing through the motor drive circuit is a current signal, and then the current signal is output to the motor to control the operation of the motor. Since the voltage signal is converted into a current signal for output through the motor drive circuit, the accuracy is affected by the motor drive circuit. By forming a closed-loop feedback control through the second sampling unit, the accuracy of the current signal can be guaranteed.
[0067] In some embodiments of the present application, the second sampling unit includes a second frequency-duty ratio sampling circuit 600, a rectifying circuit 700, and a sampling isolation circuit 800. The second frequency-duty ratio sampling circuit 600 is used to collect the real-time frequency and real-time duty ratio of the second PWM signal, and is fed back to the control unit 100 through the sampling isolation circuit 800. The rectifying circuit 700 rectifies the second PWM signal to obtain the real-time amplitude, and is fed back to the control unit 100 through the sampling isolation circuit 800.
[0068] In some embodiments of the present application, the second real-time control parameter includes any one or more control parameters among the real-time duty ratio, real-time frequency, and real-time amplitude of the second PWM signal.
[0069] In some embodiments of the present application, when the control unit 100 adjusts the first PWM signal using the first real-time control parameter and the second real-time control parameter, the control unit 100 preferentially adjusts the first PWM signal according to one of the first real-time control parameter and the second real-time control parameter. For example, the first PWM signal is preferentially adjusted according to the second real-time control parameter.
[0070] In some embodiments of the present application, a polarity switching unit is provided between the control unit 100 and the peripheral circuit. The polarity switching unit is used to switch the polarity of the first PWM signal and output the first PWM signal to the peripheral circuit.
[0071] In this real-time mode, the polarity of the first PWM signal is switched by a polarity switching unit. For example, the first PWM signal is switched to unipolar or bipolar to meet the requirements of different peripheral circuits and subsequent circuits.
[0072] In some embodiments of the present application, as Figure 2 shown, the polarity switching unit includes:
[0073] A first MOS transistor Q2, the gate of the first MOS transistor Q2 is connected to the control unit 100, and the source of the first MOS transistor Q2 is connected to the peripheral circuit;
[0074] A first switch RLY1, the drain of the first MOS transistor Q2 is grounded through the first switch RLY1, and the drain of the first MOS transistor Q2 is connected to the first positive power supply terminal VCC through the first switch RLY1;
[0075] A second MOS transistor Q3, the gate of the second MOS transistor Q3 is connected to the control unit 100, and the source of the second MOS transistor Q3 is connected to the peripheral circuit;
[0076] A second switch RLY2, the second MOS transistor Q3 is grounded through the second switch RLY2, and the drain of the second MOS transistor Q3 is connected to the first negative power supply terminal VEE through the second switch RLY2.
[0077] In this embodiment, the control unit 100 outputs an initial PWM signal to the gates of the first MOS transistor Q2 and the second MOS transistor Q3, controls the second switch RLY2 to short-circuit the drain of the second MOS transistor Q3 to ground, pulls the drain of the second MOS transistor Q3 to 0V, and controls the first switch RLY1 to connect the drain of the first MOS transistor Q2 to the first positive power supply terminal VCC. When the initial PWM signal is at a high level, the first MOS transistor Q2 is turned on and the second MOS transistor Q3 is turned off, and the positive voltage of the first positive power supply terminal VCC is output at the source of the first MOS transistor Q2; when the initial PWM signal is at a low level, the first MOS transistor Q2 is turned off and the second MOS transistor Q3 is turned on, and 0V is output at the source of the second MOS transistor Q3, realizing the positive polarity output of the first PWM signal.
[0078] Control the first switch RLY1 to short-circuit the drain of the first MOS transistor Q2 to ground, pull the drain of the first MOS transistor Q2 to 0V, and control the second switch RLY2 to connect the drain of the second MOS transistor Q3 to the first negative power supply terminal VEE. When the initial PWM signal is at a high level, the first MOS transistor Q2 is turned on, the second MOS transistor Q3 is turned off, and the source of the first MOS transistor Q2 outputs 0V; when the initial PWM signal is at a low level, the first MOS transistor Q2 is turned off, the second MOS transistor Q3 is turned on, and the source of the second MOS transistor Q3 outputs the negative voltage of the first negative power supply terminal VEE, realizing the negative polarity output of the first PWM signal.
[0079] Control the first switch RLY1 to connect the drain of the first MOS transistor Q2 to the first positive power supply terminal VCC, and control the second switch RLY2 to connect the drain of the second MOS transistor Q3 to the first negative power supply terminal VEE. When the initial PWM signal is at a high level, the first MOS transistor Q2 is turned on, the second MOS transistor Q3 is turned off, and the source of the first MOS transistor Q2 outputs the positive voltage of the first positive power supply terminal VCC; when the initial PWM signal is at a low level, the first MOS transistor Q2 is turned off, the second MOS transistor Q3 is turned on, and the source of the second MOS transistor Q3 outputs the negative voltage of the first negative power supply terminal VEE, realizing the bipolar output of the first PWM signal.
[0080] In some embodiments of the present application, the first MOS transistor Q2 is an NMOS transistor, and the second MOS transistor Q3 is a PMOS transistor.
[0081] In some embodiments of the present application, an output isolation unit 300 is further included, as Figure 2 shown, the output isolation unit 300 includes:
[0082] A triode Q1, the base of the triode Q1 is connected to the control unit 100, and the emitter of the triode Q1 is grounded;
[0083] An optocoupler U1, the positive terminal of the emitter of the optocoupler U1 is connected to the second positive power supply terminal VCC1, the negative terminal of the emitter of the optocoupler U1 is connected to the collector of the triode Q1, and the positive terminal of the receiver of the optocoupler U1 is connected to the third positive power supply terminal VCC2;
[0084] A first resistor R1, the first end of the first resistor R1 is connected to the negative terminal of the receiver of the optocoupler U1, the second end of the first resistor R1 is grounded, and the gates of the first MOS transistor Q2 and the second MOS transistor Q3 are both connected to the first end of the first resistor R1.
[0085] In this embodiment, the initial PWM signal output by the control unit 100 is input to the base of the triode Q1. When the initial PWM signal is at a high level, the triode Q1 conducts, the emitting end of the optocoupler U1 emits light, and the receiving end conducts, causing the first MOS transistor Q2 to conduct and the second MOS transistor Q3 to cut off. When the initial PWM signal is at a low level, the triode Q1 cuts off, the emitting end of the optocoupler U1 does not emit light, and the receiving end cuts off, causing the first MOS transistor Q2 to cut off and the second MOS transistor Q3 to conduct. The initial PWM signal output by the control unit 100 is isolated and drives the first MOS transistor Q2 and the second MOS transistor Q3 through the optocoupler U1. Using the first MOS transistor Q2 and the second MOS transistor Q3 can provide a higher current-carrying capacity compared to other devices, realizing the load-carrying capacity of the first PWM signal output.
[0086] In some embodiments of the present application, the gates of the first MOS transistor Q2 and the second MOS transistor Q3 are both connected to the first end of the first resistor R1 through a driving circuit.
[0087] In this embodiment, the driving circuit adopts a MOS transistor driving circuit, and the voltage at the first end of the first resistor R1 drives the first MOS transistor Q2 and the second MOS transistor Q3 through the MOS transistor driving circuit.
[0088] In some embodiments of the present application, it further includes an amplitude modulation unit 200, and the amplitude modulation unit 200 includes:
[0089] A first comparison sub-unit, the non-inverting input terminal of the first comparison sub-unit is used to input a positive reference voltage Vref+;
[0090] A third MOS transistor Q4, the output terminal of the first comparison sub-unit is connected to the gate of the third MOS transistor Q4, the drain of the third MOS transistor Q4 is connected to the fourth positive power supply terminal VCC4, and the source of the third MOS transistor Q4 is connected to the drain of the first MOS transistor Q2 through a first switch;
[0091] A first negative feedback sub-unit, the source of the third MOS transistor Q4 is connected to the input terminal of the first negative feedback sub-unit, and the output terminal of the first negative feedback sub-unit is connected to the inverting input terminal of the first comparison sub-unit;
[0092] A second comparison sub-unit, the non-inverting input terminal of the second comparison sub-unit is used to input a negative reference voltage Vref-;
[0093] A fourth MOS transistor Q5, the output terminal of the second comparison sub-unit is connected to the gate of the fourth MOS transistor Q5, the drain of the fourth MOS transistor Q5 is connected to the second negative power supply terminal VEE1, and the source of the fourth MOS transistor Q5 is connected to the drain of the second MOS transistor Q3 through a second switch;
[0094] The second negative feedback sub-unit, the source of the fourth MOS transistor Q5 is connected to the input end of the second negative feedback sub-unit, and the output end of the second negative feedback sub-unit is connected to the inverting input end of the second comparator sub-unit.
[0095] In this embodiment, the third MOS transistor Q4 and the fourth MOS transistor Q5 operate in the amplification state. The fourth positive power supply terminal VCC4 supplies power to the drain of the first MOS transistor Q2 through the source of the third MOS transistor Q4, and the second negative power supply terminal VEE1 supplies power to the drain of the second MOS transistor Q3 through the source of the fourth MOS transistor Q5. The positive reference voltage Vref+ is input to the non-inverting input end of the first comparator sub-unit. The source of the third MOS transistor Q4 is the first positive power supply terminal VCC, which supplies a positive voltage to the drain of the first MOS transistor Q2. The voltage output from the source of the third MOS transistor Q4 is fed back to the inverting input end of the first comparator sub-unit through the first negative feedback sub-unit to form negative feedback, so that the positive voltage output from the source of the third MOS transistor Q4 is stabilized to the target positive voltage. The negative reference voltage Vref- is input to the non-inverting input end of the second comparator sub-unit. The source of the fourth MOS transistor Q5 is the first negative power supply terminal VEE, which supplies a negative voltage to the drain of the second MOS transistor Q3. The voltage output from the source of the fourth MOS transistor Q5 is fed back to the inverting input end of the second comparator sub-unit through the second negative feedback sub-unit to form negative feedback, so that the negative voltage output from the source of the fourth MOS transistor Q5 is stabilized to the target negative voltage. In other words, by adjusting the magnitudes of the positive reference voltage Vref+ and the negative reference voltage Vref-, the amplification states of the third MOS transistor Q4 and the fourth MOS transistor Q5 can be adjusted, thereby changing the magnitude of the positive voltage at the drain of the first MOS transistor Q2 and changing the magnitude of the negative voltage at the drain of the second MOS transistor Q3, so as to adjust the amplitude of the first PWM signal.
[0096] In some embodiments of the present application, it further includes a D / A conversion unit 900, and the control unit 100 is connected to the amplitude modulation unit 200 through the D / A conversion unit 900.
[0097] In this embodiment, the control unit 100 outputs the positive reference voltage Vref+ or the negative reference voltage Vref- to the amplitude modulation unit 200 through the D / A conversion unit 900, so as to adjust the amplitude of the first PWM signal. The D / A conversion unit 900 uses a D / A converter.
[0098] In some embodiments of the present application, as Figure 3 shown, the first comparator sub-unit includes a first comparator U2, as Figure 5 shown, the second comparator sub-unit includes a second comparator U4.
[0099] In some embodiments of the present application, as Figure 4As shown, the first negative feedback sub-unit includes a first operational amplifier U3. The non-inverting input terminal of the first operational amplifier U3 is connected to the output terminal of the first comparison sub-unit. The inverting input terminal of the first operational amplifier U3 is grounded. The output terminal of the first operational amplifier U3 is connected to the inverting input terminal of the first comparison sub-unit.
[0100] In some embodiments of the present application, as Figure 6 shown, the second negative feedback sub-unit includes a second operational amplifier U5. The non-inverting input terminal of the second operational amplifier U5 is connected to the output terminal of the second comparison sub-unit. The inverting input terminal of the second operational amplifier U5 is grounded. The output terminal of the second operational amplifier U5 is connected to the inverting input terminal of the second comparison sub-unit.
[0101] In some embodiments of the present application, the amplitude modulation unit 200 further includes a first diode D1. The drain of the third MOS transistor Q4 is connected to the anode of the first diode D1. The cathode of the first diode D1 is connected to the drain of the first MOS transistor Q2;
[0102] In this embodiment, the first diode D1 can prevent voltage backflow.
[0103] In some embodiments of the present application, the amplitude modulation unit 200 further includes a second diode D2. The drain of the fourth MOS transistor Q5 is connected to the cathode of the second diode D2. The anode of the second diode D2 is connected to the drain of the second MOS transistor Q3;
[0104] In this embodiment, the second diode D2 can prevent voltage backflow.
[0105] In addition, an embodiment of the present application provides a PWM control method, which is applied to the PWM control circuit as described above. As Figure 7 shown, the method includes:
[0106] Step S100: Obtain a target control parameter, generate a first PWM signal according to the target control parameter, and the first PWM signal is used to output to a peripheral circuit;
[0107] Step S200: Obtain a first real-time control parameter, and the first real-time control parameter is the real-time control parameter of the first PWM signal;
[0108] Step S300: Adjust the first PWM signal by using the first real-time control parameter so that the first real-time control parameter is consistent with the target control parameter.
[0109] In some embodiments of the present application, "adjust the first PWM signal by using the first real-time control parameter so that the first real-time control parameter is consistent with the target control parameter" in step S300 includes:
[0110] Step S310: Based on the PID algorithm, adjust the first PWM signal using the first real-time control parameter so that the first real-time control parameter is consistent with the target control parameter.
[0111] In some embodiments of the present application, the method further includes:
[0112] Step S400: Obtain a second real-time control parameter, where the second real-time control parameter is the real-time control parameter of the second PWM signal, and the second PWM signal is the signal obtained after the first PWM signal passes through the peripheral circuit;
[0113] Step S410: Adjust the first PWM signal using the second real-time control parameter so that the second real-time control parameter is consistent with the target control parameter.
[0114] In some embodiments of the present application, "adjust the first PWM signal using the second real-time control parameter so that the second real-time control parameter is consistent with the target control parameter" in Step S410 includes:
[0115] Step S411: Based on the PID algorithm, adjust the first PWM signal using the second real-time control parameter so that the second real-time control parameter is consistent with the target control parameter.
[0116] In some embodiments of the present application, when collecting the real-time duty cycle of the first PWM signal and the real-time duty cycle of the second PWM signal, when the real-time frequencies of the first PWM signal and the second PWM signal are high and the real-time duty cycles are low, the time of the real-time duty cycle is extremely short, and the deviation of the duty cycle result collected by the counter after passing through the hardware circuit is large. To achieve a wider and more accurate duty cycle collection range, as Figure 8 shown, assuming that the periods of the first PWM signal and the second PWM signal are T and the real-time duty cycle is t1, change the counting method of the PWM so that the first trigger edge collects the rising edge and the second trigger edge collects the falling edge at the T + t1 moment, which can accurately collect the real-time duty cycles of the first PWM signal and the second PWM signal. Calculate the real-time duty cycle through the following formula:
[0117] t1 = t T+t1 -T,
[0118] where t T+t1 is the time of the falling edge at the T + t1 moment collected.
[0119] In some embodiments of the present application, since the device may cause abnormal accuracy due to the influence of environmental temperature and humidity and component temperature drift, the real-time amplitude of the obtained first PWM signal is amplitude calibrated through the following formula:
[0120] Uc * K + B = Ub,
[0121] Among them, Uc is the calibrated amplitude of the first PWM signal, Ub is the real-time amplitude of the acquired first PWM signal, K and B are calibration factors, and K and B are obtained through calibration.
[0122] The embodiments of the present application have been described in detail above with reference to the accompanying drawings. However, the present application is not limited to the above embodiments, and various changes can be made without departing from the spirit of the present application within the scope of knowledge possessed by those of ordinary skill in the art.
Claims
1. A PWM control circuit, characterized in that: include: A control unit, the control unit is connected to the peripheral circuit, the control unit is used to obtain a target control parameter, generate a first PWM signal according to the target control parameter, and output the first PWM signal to the peripheral circuit; A first sampling unit, the first sampling unit is connected to the control unit, the first sampling unit is used to obtain a first real-time control parameter and output it to the control unit, the first real-time control parameter is a real-time control parameter of the first PWM signal, and the control unit uses the first real-time control parameter to adjust the first PWM signal so that the first real-time control parameter is consistent with the target control parameter.
2. The PWM control circuit according to claim 1, characterized in that: Also includes: a second sampling unit, wherein the second sampling unit is connected to the peripheral circuit and is used to obtain a second real-time control parameter, wherein the second real-time control parameter is a real-time control parameter of a second PWM signal, wherein the second PWM signal is a signal obtained after the first PWM signal passes through the peripheral circuit, and the control unit uses the second real-time control parameter to adjust the first PWM signal so that the second real-time control parameter is consistent with the target control parameter.
3. The PWM control circuit according to claim 1, characterized in that: A polarity switching unit is provided between the control unit and the peripheral circuit, and the polarity switching unit is used to switch the polarity of the first PWM signal and output the first PWM signal to the peripheral circuit.
4. The PWM control circuit according to claim 3, characterized in that: The polarity switching unit comprises: a first MOS transistor, wherein a gate of the first MOS transistor is connected to the control unit, and a source of the first MOS transistor is connected to the peripheral circuit; a first switch, wherein the drain of the first MOS tube is grounded through the first switch, and the drain of the first MOS tube is connected to a first positive power supply terminal through the first switch; a second MOS transistor, wherein a gate of the second MOS transistor is connected to the control unit, and a source of the second MOS transistor is connected to the peripheral circuit; A second switch, wherein the second MOS tube is grounded through the second switch, and the drain of the second MOS tube is connected to the first negative power supply terminal through the second switch.
5. The PWM control circuit according to claim 4, characterized in that: Also included is an output isolation unit, the output isolation unit comprising: A triode, wherein the base of the triode is connected to the control unit, and the emitter of the triode is grounded; An optical coupler, wherein the positive electrode of the transmitting end of the optical coupler is connected to the second positive power supply end, the negative electrode of the transmitting end of the optical coupler is connected to the collector of the transistor, and the positive electrode of the receiving end of the optical coupler is connected to the third positive power supply end; A first resistor, wherein a first end of the first resistor is connected to the negative electrode of the receiving end of the optocoupler, a second end of the first resistor is grounded, and gates of the first MOS tube and the second MOS tube are both connected to the first end of the first resistor.
6. The PWM control circuit according to claim 4, characterized in that: It also includes an amplitude modulation unit, the amplitude modulation unit including: A first comparing subunit, wherein a non-inverting input terminal of the first comparing subunit is used to input a positive reference voltage; a third MOS tube, wherein the output end of the first comparison subunit is connected to the gate of the third MOS tube, the drain of the third MOS tube is connected to the fourth positive power supply end, and the source of the third MOS tube is connected to the drain of the first MOS tube through the first switch; A first negative feedback subunit, wherein the source of the third MOS tube is connected to the input end of the first negative feedback subunit, and the output end of the first negative feedback subunit is connected to the inverting input end of the first comparison subunit; a second comparing subunit, wherein a non-inverting input terminal of the second comparing subunit is used to input a negative reference voltage; a fourth MOS tube, wherein the output end of the second comparison subunit is connected to the gate of the fourth MOS tube, the drain of the fourth MOS tube is connected to the second negative power supply end, and the source of the fourth MOS tube is connected to the drain of the second MOS tube through the second switch; The second negative feedback subunit, the source of the fourth MOS tube is connected to the input end of the second negative feedback subunit, and the output end of the second negative feedback subunit is connected to the inverting input end of the second comparison subunit.
7. A PWM control method, characterized in that: include: Acquire a target control parameter, and generate a first PWM signal according to the target control parameter, wherein the first PWM signal is used to output to a peripheral circuit; Acquire a first real-time control parameter, where the first real-time control parameter is a real-time control parameter of the first PWM signal; The first PWM signal is adjusted using the first real-time control parameter so that the first real-time control parameter is consistent with the target control parameter.
8. The PWM control method according to claim 7, characterized in that: The step of adjusting the first PWM signal by using the first real-time control parameter so that the first real-time control parameter is consistent with the target control parameter includes: Based on a PID algorithm, the first real-time control parameter is used to adjust the first PWM signal so that the first real-time control parameter is consistent with the target control parameter.
9. The PWM control method according to claim 7, characterized in that: Also includes: Acquire a second real-time control parameter, where the second real-time control parameter is a real-time control parameter of a second PWM signal, where the second PWM signal is a signal obtained after the first PWM signal passes through the peripheral circuit; The first PWM signal is adjusted using the second real-time control parameter so that the second real-time control parameter is consistent with the target control parameter.
10. The PWM control method according to claim 9, characterized in that: The step of adjusting the first PWM signal by using the second real-time control parameter so that the second real-time control parameter is consistent with the target control parameter includes: Based on a PID algorithm, the first PWM signal is adjusted using the second real-time control parameter so that the second real-time control parameter is consistent with the target control parameter.