Simulating Switched-Mode Power Supply | Developing Electrical Systems with Simscape Electrical - MATLAB & Simulink
Video Player is loading.
Current Time 0:00
Duration 21:46
Loaded: 0.76%
Stream Type LIVE
Remaining Time 21:46
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected
    Video length is 21:46

    Simulating Switched-Mode Power Supply | Developing Electrical Systems with Simscape Electrical

    From the series: Developing Electrical Systems with Simscape Electrical

    Learn how to model and simulate a switched-mode power supply that is generally used for laptop or mobile phone chargers. Using Simulink® and Simscape Electrical™, MathWorks engineers will show how to develop, simulate, and tune a controller that maintains desired output voltage in the presence of input voltage variations and load changes to achieve a fast and stable response. Highlights include:

    • Modeling and simulating passive circuit elements, power semiconductors, and varying power sources and loads
    • Simulating the converter in continuous and discontinuous conduction modes
    • Calculating power factor and total harmonic distortion (THD) via spectrum analyzer of the switched-mode power supply  
    • Tuning the PID controller to meet rise time, overshoot, and settling time

    Published: 24 May 2022

    Hello, everyone. Welcome to the second session of Developing Electrical Systems with Simscape. My name is Shang-Chuan Lee. I'm a senior application engineer at MathWorks. My focus is on motor control and power electronics. So in today's webinar, I'm happy to show you how to simulate a switched-mode power supply.

    So here are some key takeaways for today's webinar. First, I will show you how to simulate a switched-mode power supply by using Simscape Electrical. And in this case, we are going to use an AC-to-DC topology of switched-mode power supply and validate its control design.

    Then I will show you how to quickly and easily build a buck converter with Simscape Electrical. Last but not least, once we can build the physical components of power electronics, then we can implement a voltage regulator and carry out PID tuning to meet rise time, overshoot, and settling time for our design requirements.

    So what is switched-mode power supply? As you can see, it's an AC-to-DC power supply, and its main job is to convert AC into a stable DC voltage, and then which can be used to power different electrical devices, such as laptops, phone chargers, or even larger device in desktop computers.

    So to transform AC power into a DC power, we can go through a few stages when it comes to designing the switched-mode power supply, and in this case, starting with the AC power source, then rectifying into DC power with diode bridges and a large capacitor to filter out some high-frequency noises, and then a DC-to-DC converter in the draws of voltage and loads.

    And notice that between the AC to DC power conversion, we have an active harmonic filter. And it is essential to have this because we want to have a quality and reliable power supply to prevent from any harmonics contents traveling upstream to the power supply.

    And speaking of harmonics, by definition, it is a byproduct of electronics. And it often comes from single-phase loads, VFDs, or any solid-state switching devices. And in our case, because we have a single-phase diode rectifier, which turns on and off very often, and because of this, it causes harmonic distortion to the supply currents, and even lowering the power factor at the input AC source. So this is the cause of the harmonics distorted currents, which is why we have this active harmonic filter in place to generate a compensating current to canceling out the harmonics current from the load. So let's see how we can turn this topology into a Simulink model in action.

    So here we are in the Simulink model to simulate a switched-mode power supply using Simscape Electrical. As we discussed earlier, we have an AC power source. And in this case, well, we are giving 60 hertz and 100 volts peak-to-peak voltage source. And we also have a shunt active harmonic filter, diode rectifier, and DC-to-DC buck converter with a variable load.

    So now let me quickly run the simulation. And on the Measurements side, we compute the power factor based on the measured voltage and current source. And as you can see, it's 1, meaning that we have a very good power quality in this network. And it also indicates that the source voltage and currents are pretty much in phase and have a very low harmonics contents.

    And we can even further look at the oscilloscope to see-- this is the-- source voltage and currents are really nice in phase. And why we can have that is because-- remember we were talking about, it's important to have this shunt active harmonic filter in place. We were talking about a typical issue coming from the diode rectifier is because it has a turning on and off switching event. It typically will cause the current distortion and further impact the power quality to the source. Right?

    So as you can see, this is the blue curve. The blue wave on here is the current that measures from here. This is because the diode rectifier switching events. And because we implement this active harmonic filter, it's canceling out this distorted currents. And that's why in our yellow current waveform here, it's actually measured from the source. So you can think of this shunt active harmonic filter-- it's like a wall to prevent anything, noise, coming to the source.

    So now after we validate the power quality at the source, we can also check on the rectifier DC voltage, and it's around 85 volts. And since we are also implementing a variable load with a DC-to-DC buck converter, here you can see we can step down from 85 volts to around 30 to 40 volts. This is meets our expectation.

    So this is an entire switched-mode power supply simulated by Simscape Electrical. It's a system-level simulation, allows you to check each stage of power conversion process. So now since we talk about a DC-to-DC buck converter, so now how about we just build a component-level power electronics, and we can see how we can build from scratch.

    So now we are going to build the Simulink model, and we will navigate into the model front page. And we can navigate into this Simulink icon to launch the Simulink start page. And typically, you can definitely build a blank model from scratch in here. But in our case, we already know we are going to build a DC-to-DC buck converter by Simscape Library. So we can navigate to here. And as we know, Simscape allows you to simulate multiphysics components-- right-- like electrical, magnetic, mechanical, or thermal. But in our case, we are going to build an electrical circuit, so we can click on it here.

    So here we are at the Electrical Circuit template, and I just clean up some of unnecessary blocks for this model. And we will navigate into a library browser, and looking for a buck converter. And first, we can navigate into Simscape, and under Electrical domain, we will find under Semiconductor and Converters, and Buck Converter should be over there. So I can just quickly drag and drop the buck converter into the Simulink Canvas.

    And just to remind myself, I would like to set my design goal here. So in this case, I would like to have my input voltage to be 20 volts, and I would like to step down my voltage to be 10 volts. And I will need a voltage source. Then I can quickly just type on the white canvas, and it will pop up the components that I need. And I just start building the buck converter.

    And I also need a resistor as a load for the buck converter. And notice that there's a gate signal on the buck converter, so I will need a PWM generator in this case to drive the duty cycle to turn on and off on the buck converter. Notice that here I try to connect my Simulink block to the Simscape. It couldn't connect it because we need to have this Simulink to physical converter in order to connect the Simulink language into a Simscape language here.

    And I will also need a constant blocks to represent my duty cycle. And I'm just giving a 0.5 as my duty cycle here. I also probably need to look at the switching time periods. Now it's 1,000 hertz. It's fine, and 20 kilohertz sample time. Yeah, and I also need to change my constant voltage to be 20 volts to meet my design goal.

    And under the Buck Converter, you can parameterize a lot of different devices. You can choose IGBT or MOSFET, but in this case, we can just stick with an Ideal Semiconductor Switch. And remember, the threshold voltage should be 0.5 volts because the PWM pulses is between 0 and 1. And in this case, my LC filter should be 0.01 henry.

    And I think I'm pretty much all set on the-- only thing I can check my simulation is I need a voltage sensor. So I just quickly put this voltage sensor both on my input voltage and output voltage, and use the oscilloscope to measure the voltage. And again, here we also need to have a PS-to-Simulink converter to observe our signal.

    So next step, I can just quickly set my simulation time and run the simulation model. So here is the simulation result. And you can see that 20 volts is our input voltage, and through the buck converter, the output response. And the output voltage is 10 volts now with the 0.5 duty cycle.

    So in this example, we just simply give you a PWM duty cycle to control the output voltage on the single-phase topology. Now what if we have a more complex system? In this case, we have a three-phase DC-to-AC inverter, and we want to do a closed-loop PID-control voltage control.

    And in this model, we have a DC voltage source and three-phase DC-to-AC inverter block. And it's an average value converter because we are feeding a three-phase modulation waveform, a three-phase voltage into the inverter. And we also got a LC filter and Y-connected load.

    And on the control side, since we are doing a voltage regulator with a commanded voltage, a one per unit step-down to a 0.5 per unit at 0.1 second. So now I can quickly-- to run the simulation and see. This is my three-phase voltage and current waveform. Supposedly, at 0.1 second, we expect to see a voltage drop in our simulation. It should be decreased to 50% of the rated voltage. But in this case, it doesn't seems meet our expectations. So we can further investigate into our voltage regulator to check on each signals.

    We have a d-q frame voltage control by converting three-phase voltage into a d-q reference frame, right? And the first thing we can check is the voltage command tracking. So the yellow one is our commanding voltage, and the blue one is our feedback. And as we can see, it's a huge steady-state arrows. Or we can interpret this as a slowly converged or track the commanded voltage, in this case.

    So what we can do is definitely we can try to tune our PID gains in our PID blocks, right? This is one way we can do, and we can play with the parameter and run the simulation over and over again. But another systematic approach you can do is you can do automatic tuning methods through PID Tuning App.

    You just click on this Tune button, and then the PID Tuning App will launch a GUI interface. It can help you to identify the plan model of your overall physical system, and then propose a fine-tuned PI gains for your controller. So in this case, we are doing a reference command tracking, reference tracking in time domain. And the solid blue line here shows the tuned response from a PID Tuning App. And this dashed blue line are the original block response. And you can see that, obviously, they have a huge steady-state arrow. And so this is one way you can look at the time response.

    Another way you can look at is frequency response. So then we can add, like, Bode plot and reference tracking. In the same thing, you can see that with a tuned response, you can see the perfect DC gains on the magnitude of the Bode plot. However, for the original dashed blue line, it has a steady-state arrows also showing up on the Bode plot.

    Right, so and this is one way you can analyze your system, your control system. And the other way you can do is, definitely, you can look at the more interactive way to tune your system is through this sliding bar here. You can adjust how much response time you want to achieve, like, you want to have a faster response time, or you want to have a slower response time, but most smooth command tracking, right? Or you want to have a more robustness of your overall system, or you want to have a more aggressive, but a large overshoot, right?

    So it's a really nice way to give you a systematic approach to evaluate your control system. And we can also click on this Show Parameters, and it will show up the comparison between the tuned PID gains versus the original blocks. And you can also see the rise time, settling time, how much overshoot, and gain margin, phase margin, and stability information with the update to tuned PID gains. Right?

    And once I'm happy with that, I can just click on Update to the Block. So the PID gains will automatically update to the Simulink. Right. Now I can quickly-- to validate my simulation with the new PI gains. So as we can see, that after we update our PID gains, now the command tracking on the voltage regulator is really good, right? And so does-- on the three-phase voltage and current output here, we see that it also meets our requirement.

    To wrap up the presentation, we have simulated a switched-mode power supply using Simscape Electrical. And with this example, we have learned that how to design a switched-mode power supply under different power-conversion stages, including how to compensate current harmonics using active harmonic filter. And very quickly, with Simscape Electrical, we also built a simple buck converter to achieve our desired output voltage.

    Last but not least, in the example of three-phase inverter control, we can use this systematic approach-- the PID Autotuner App to identify the physical plant model through time domain and frequency domain analysis, such as Bode plot. And then this app will help you propose the fine-tuned PID gains. So the whole idea behind is to accelerate the control design process in power electronics.

    In the webinar, we have gone through three examples when it comes to modeling power electronics. But if you want to be more familiar with Simscape Electrical, I highly recommend this Circulation Simulation Onramp class. In this two-hour Onramp, you can get a variety of hands-on experience to build your own electrical circuit, including Bridge Rectifier, Modeling Faults, Op Amps, and Filter. And through the exercise, you can get exposed to analyze the circuits in both time domain and frequency domain response.

    So Simscape Onramps give you a fundamental knowledge to show you how to simulate circuit simulation in general. And if you're looking for a more advanced power electronics control design, we have this instructor-led one-day training course. And this class really deep dives into model different level of fidelity for your power electronics control, and including how to properly selecting a solver to speed up for your simulation, and also maintain the high fidelity of your model to have a correct accuracy for motor drive application. And many of my customers found these classes very helpful for their power electronics project.

    So thank you, everyone, for your attention.