MATLAB simulation of double-loop PID (voltage loop + current loop) control of flyback switching power supply

In the previous article, I explained the matlab simulation of the pid control of the output voltage of the flyback switching power supply.

"MATLAB Simulation of Output Voltage PID Control of Flyback Switching Power Supply "

       I only control the output voltage, no matter how big the load is, as long as it is within the design power, the voltage can be maintained at 12V. But in the actual circuit design, we also need to consider the limit of the output current .
        Because the device selection is based on the rated value, if the actual value exceeds the rated value, it will fail to work if it is mild, and the device will break down if it is severe.
        For example, the diode D1 on the secondary side, if the current flowing through it exceeds the maximum forward current, it will break down and burn out.

Therefore, the closed-loop control of the output light with voltage (referred to as the voltage loop) is not enough, and the closed-loop control of the current (referred to as the current loop)          is also required .
When the voltage loop works, the output voltage is stable at a value, and the output current varies with the load.


        When the current loop works, it is equivalent to a constant current source, the output current is stable at a value, and the voltage changes with the load.


        Judging from their functions, the voltage loop and the current loop seem to be contradictory. The voltage loop wants to stabilize the voltage, and the current loop wants to stabilize the current.
        It's not actually a contradiction, because they don't work at the same time. Let's analyze the working status of the two loops in detail.

        Assume that there is an existing circuit designed for an output voltage of 12V and a maximum output current of 10A.        
        Then give him a load R, and the resistance of R changes from large to small.
       · When R is infinite , it is equivalent to no load. At this time, the voltage loop should control the output voltage at 12v and the output current at 0A.
       · When R is reduced to 2.4 ohms , the voltage loop still controls the output voltage at 12v, and the current is 12/2.4=5A, which is equivalent to half load.
       ·Continue to reduce to 1.2 ohms , at this time the voltage is still 12V, and the current is 12/1.2=10A. At this point the current has reached the maximum design value.
       · If you continue to reduce R to 1 ohm and keep the output voltage unchanged, the output current will reach 12/1=12A, which exceeds the design value. How to do it?

At this point, it is the turn of the current loop to work.
        The function of the current loop is not to increase the output voltage to stabilize the current, but to limit the current by pulling down the output voltage . That is, the current loop will reduce the output voltage to meet the setting that the output current is not greater than 10A. How much will it be pulled down? The calculation is very simple. When R is 1 ohm, in order to satisfy the current of 10A, the voltage at this time should be 10×1=10v.
        So what about the voltage loop at this time? In order to prevent the voltage loop from raising the voltage to 12v, the voltage loop needs to be opened (open loop means the loop fails), and the output is controlled by the current loop.
        Similarly, when the current does not reach 10A, the current loop is open and does not work, and the entire system is controlled by the voltage loop.
The turning point of the two states is the load R=voltage loop design value/current loop design value=12/10=1.2 ohms,

        When R>1.2, the voltage loop works, and the current loop is open; when R<1.2, the current loop works, and the point pressure loop is open.

In the above circuit, the relationship between the output voltage and current and the load R should be as follows:

        All we have to do is set up two loops to control the duty cycle according to the above logic.

Note: In a switching power supply controlled by an analog circuit, the logic is slightly different from a digitally controlled one. In the analog circuit, the PWM wave for controlling the MOSFET is provided by a special drive IC. The IC has a FB port (feedback, that is, feedback), and the PWM duty cycle of its output depends on the voltage of the FB port, which is generally linear. High, the higher the duty cycle of the output, and the FB is in the maximum voltage state in the floating state, that is, if the FB is floating, the output PWM duty cycle is the largest.

The output voltage loop current loop is to control the voltage and current by pulling down the voltage of FB. It can be understood that when the switching power supply is first turned on, its duty cycle is the largest, and the voltage will rise rapidly. When the voltage reaches the design value, the voltage loop will pull down the voltage of FB to a certain value to keep the output voltage not exceeding the set value. Value. If the voltage loop fails, the output voltage will be out of control and overvoltage. When the current reaches the design value of the current, the current loop will operate and also pull down the FB voltage by a certain value to limit the output current.
However, the PWM driver IC will have open-loop protection, once an open-loop is detected (if the FB voltage remains at the highest voltage for too long), it will automatically lock and stop generating waves.

For example, NCP1253 is a PWM controller for flyback circuit, and its pins are defined as follows:

 The relationship between the FB frequency and the FB port voltage is as follows:

 Note: The controller maintains a fixed on time, and changes the duty cycle and frequency by changing the off time of the PWM wave.

Application examples of this chip in flyback switching power supply:

         In this circuit, the feedback signal is transmitted through the optocoupler, and on the secondary side is a voltage loop composed of a reference voltage source. The principle will not be analyzed in detail here.

MATLAB simulation

Let's go back to matlab, circuit design technical indicators:

Output voltage 300V, output power 120W, output voltage 12V, output current 10A

Modeled in simlink as follows:

  Divide it into modules:

1. The primary side of the flyback circuit

2. The secondary side of the flyback circuit

3. Voltage PID control loop

4. Current PID control loop

5. Simulate dynamic loads. Through the delay control switch, to control whether R2 is turned on or not, to realize the switching of load size

6. Output voltage, current, power monitoring

7. Voltage loop current loop working state transition. The principle is to calculate the total resistance of the load and compare it with 1.2. If it is greater than 1.2, switch to the voltage loop control duty cycle; if it is less than 1.2, switch to the current loop control.

Regarding the adjustment of PID parameters, I have already talked about it in the last article, so I will not demonstrate it here.

        For a double-loop circuit, generally adjust the voltage loop first. We first disconnect R2 (you can delete or disconnect the line first), and set R=1.5Ω.

        Then set Ki of the PID voltage loop to 0, Kp to 1, and then run to observe the output voltage waveform, whether the waveform is smooth, without obvious oscillation, and whether there is overshoot when the voltage rises to 12V, if so, adjust Small Kp to waveform without oscillation and without overshoot.

         After determining Kp, set Ki=1. After running the simulation, observe whether the output voltage can quickly rise to 12V. If it is very slow, increase the value of Ki until it meets the requirements. If there is overshoot, reduce Ki. Until the rise is fast and does not overshoot.

         The following are my voltage loop PID parameters for reference:

        After the voltage loop PID parameters are set, start the current loop.

        To adjust the current loop, the voltage loop must be opened, so we need to set the resistance R to be less than 1.2Ω, here I set it to 0.1Ω.

        The adjustment method is similar to the voltage loop. It is just to observe the output current waveform to determine whether the parameters are appropriate, so it will not be demonstrated here.

        The following parameters are available for reference:

The following is the final effect of the current loop 

After the PID parameter adjustment is completed, always look at the actual effect.

----------------------------

1. When R=2.4Ω, the output waveform is as follows:

 After stabilization, the output voltage is 12V, the output current is 5A, and the output power is 60W, which meet the requirements

---------------------------------------

2. When R=1.2Ω, the output waveform is as follows;

After stabilization, the output voltage is 12V, the output current is 10A, and the output power is 120W, which meet the requirements

----------------------------------------------

3. When R=1Ω, the output waveform is as follows:

 After stabilization, the output voltage is 10V, the output current is 10A, and the output power is 100W

----------------------------------------------

4. When R=0.5Ω, the output waveform is as follows:

After stabilization, the output voltage is 5V, the output current is 10A, and the output power is 50W.

dynamic load

Test the response speed of the loop with a dynamic load. R is set to 4Ω, R2 is set to 4Ω, and the pulse generator is set as follows:

 That is, at 0.02s, the load is switched to 2Ω (R and R2 are connected in parallel), and at 0.45s, it is switched back to 4Ω.

Run the simulation to see the effect:

         When the load is switched from 4Ω to 2Ω, the voltage drops slightly, but remains stable, and the output voltage increases from 3A to 6A;

        When the load is switched back from 2 ohms to 4 ohms, the voltage rises slightly, then stabilizes, and the current drops back to 3A.

Try the effect of the current loop again, R is set to 1Ω, and R2 is set to 1Ω.

         When the load is switched from 1Ω to 0.5Ω, the instantaneous current reaches 20A. This is because the output capacitor voltage cannot change suddenly, but the current quickly returns to 10A. When switching from 0.5Ω back to 1A, the current drops sharply to 5A, which is also caused by the sudden change in the output capacitor voltage , and the current returns to 10A later.

Overall, the effect is good.

-------------------

If you find it useful, give it a thumbs up~


 

Guess you like

Origin blog.csdn.net/qq_55203246/article/details/127113116