Why am I getting a near 0 current in the flyback converter?

Hi,
I am simulating this flyback converter where Vin is 48 V, Vout should be 380 V, the mutual inductance has L1 = 1e-5 H, L2 = 0.036 H, VF in the diode is 2.1 V and C = 87e-6 F. As you can see in the diagram, I tried to control it first by close-loop but as I couldn't get the right values, I tried by fixing a constant which is 0.116564 which is the calculated duty cycle for Vin= 48 V. The problem I get is the values of V_out which is -1.428 V and I_out near 0 but negative. I tried moving the current measurement block to the bottom and the top branch, changing the connection with the secondary inductance or the polarity in the voltage measurement. I never get positive voltage and positive current with high values. According to my calculations, I_out should be 2.53 A and V_out, as I said 380 V. Could someone with knowledge in power electronics and simulink help me with this issue? It's R2022b version.
Thanks.
Carlos

3 Comments

@Antonino Riccobono but why should I put a load if I am measuring the current after the secondary winding? Anyway, I put a load in parallel with the capacitor and anything changed. There must be anything else.
Update: This is (with the last update) how the diagram looks like. V_out and I_out are positie but for some reason the V_out increases very slowly and I don't know if it will reach the voltage I expected (380 V). The current is still almost 0 (but positive).
I see that you placed the load in a wrong location - it must be placed in parallel to the output capacitor.
Also pay attention to the connection to the transformer secondary side to either make a noninverting or inverting topology.
Please, refer to the following example: https://www.mathworks.com/help/sps/ug/flyback-converter.html

Sign in to comment.

Answers (4)

Hi @Carlos,

After going through your plots and comments, I would like to pinpoint some important points which are critical and I did mention earlier in my comments.

Let’s talk about your initial problem where you were getting near-zero current and negative voltage, the main issues were related to load placement and duty cycle calculations. When Antonino and I pointed out that you needed the load resistor in parallel with the output capacitor, that was critical because without it, the converter had nowhere to deliver energy. Your original duty cycle calculation of 0.116564 for 48V input to get 380V output was actually correct. The transformer turns ratio you calculated from the inductances (square root of 36 milliheneries divided by 10 microheneries equals 60:1) was spot on.

The breakthrough came when you divided your inductances by 7. What happened there is really interesting from an engineering perspective. Your turns ratio stayed the same because you divided both primary and secondary inductances equally, but the smaller inductances allowed much faster current ramps during each switching cycle at 24kHz. The original inductances were simply too large for your switching frequency, preventing complete energy transfer in each cycle. By reducing them, you enabled the magnetic field to build up and collapse fast enough to actually deliver power to the output. Regarding your plots showing the voltage hitting 380V intermittently but not stabilizing, this is actually revealing something important about flyback converters. They have what's called a right-half-plane zero in their transfer function, which makes them notoriously difficult to stabilize with simple PI control. This is why your linearization attempts failed - the system behavior changes significantly with operating conditions, and standard linearization tools struggle with this. The voltage oscillations you're seeing are the PI controller hunting for the setpoint but overshooting and undershooting because the compensation isn't properly designed for the flyback's complex dynamics. When you increased the capacitor to 330microfarads you improved the ripple because you gave the system more energy storage to smooth out the switching frequency variations. This is good practice and shows you're thinking correctly about the output stage design.

Now, here's where things get really important. You've realized that your application actually needs constant current control, not constant voltage control. This is a fundamental shift in your design philosophy, and honestly, it changes everything. For battery discharge applications, constant current is absolutely the right approach. The battery voltage will naturally drop as it discharges, and you want to maintain a steady current flow to ensure controlled, safe energy extraction.

However, there's a significant concern I need to raise based on your power level requirements. You mentioned wanting 20A output current. If this is at 380V, that's 7,600 watts. Your current design with the 150-ohm resistor is sized for about 1,000 watts (380V divided by 150 ohms gives 2.53A, which matches your original calculation). Flyback converters are typically used in the range of 50 to 100 watts, and while special designs can push to a few hundred watts, they're generally not recommended beyond that. The literature consistently points out that flyback converters become impractical above about 60 watts for standard designs, with special multiphase designs potentially reaching a few hundred watts.

The reason flyback converters have this limitation is fundamental to how they work. Unlike other topologies that transfer energy continuously, a flyback stores all the energy in the magnetic field during the switch-on time and then releases it during the switch-off time. This means the transformer has to be sized to store the entire energy packet for each cycle, which makes it much larger and more expensive than transformers in other topologies at the same power level. The current stress is also much higher because all the power flows through a single switch that's only on part of the time.

For your constant current requirement of 20A at multi-kilowatt power levels, you really need to reconsider your topology. Looking at your three options, I would strongly recommend Option B: Flyback at constant current plus Boost at constant voltage plus Inverter to grid. Here's why this makes sense for your application.

The boost converter stage can efficiently handle the high current constant current regulation. Boost converters are excellent at this because they have continuous input current, which is exactly what you want when drawing from a battery. The inductor in a boost converter naturally limits and smooths the current, making constant current control much more straightforward than in a flyback. You would implement the boost stage with a PI controller that measures output current and adjusts the duty cycle to maintain 20A regardless of input voltage variations as the battery discharges.

The flyback or isolated converter stage then provides the voltage regulation and galvanic isolation you need for grid connection. This stage would operate in constant voltage mode at 380V, which is actually what flyback converters do well. The isolation is important for safety when connecting to the grid, and splitting the functionality this way allows each converter to operate in its optimal range.

For implementing constant current control in Simulink, you need to make several key changes to your existing model. First, change your reference from voltage to current. Instead of V_ref equals 380V, you need I_ref equals 20A. Second, redirect your feedback signal from the voltage measurement to the current measurement that you already have in your model. Third, and this is crucial, you'll need to retune your PI controller gains because current loop dynamics are completely different from voltage loop dynamics.

Current loops generally need higher bandwidth than voltage loops because current responds faster to duty cycle changes. The proportional gain typically needs to be lower than what you had for voltage control, while the integral gain might need to be higher to eliminate steady-state error. A good starting point for tuning would be to use the Frequency Response Estimator in Simulink to get the actual plant response, then design your compensator based on that measured frequency response rather than trying to linearize the model.

One thing that will actually work in your favor with constant current control is that you won't have the right-half-plane zero problems that plague flyback voltage control. The current loop is more direct and generally easier to stabilize. However, you still need to be careful about your output capacitor size. For constant current operation, you typically want a smaller output capacitor than for constant voltage operation because you're not trying to maintain a stiff voltage - the voltage is allowed to vary with the battery state of charge.

Regarding your PI controller parameters, the Kp of 0.0135 and Ki of 12.52 were tuned for voltage control and won't work for current control. You'll need to start fresh with the tuning. Since the Transfer Function Based approach failed due to linearization issues, I'd recommend using the Frequency Response Based tuning method, but you need to ensure your model is at a reasonable operating point first. Make sure the converter is running in steady state before attempting to extract frequency response data.

Looking at your block diagram, the structure is actually good. You have the sawtooth generator for PWM, the PI controller for feedback, and proper measurement points. The main changes needed are in the controller logic and reference values, not the overall structure. Keep the mutual inductance block approach since it's working for you now - there's no need to switch to the Linear Transformer block if the mutual inductance is giving you the control you need. For your specific application of battery discharge to grid, you need to carefully consider the battery voltage range. If your battery pack voltage varies from, say, 300V down to 200V as it discharges, your converter output voltage will also vary (in constant current mode). This is normal and expected. The grid-tie inverter on the output needs to be able to handle this variable DC bus voltage, so make sure your inverter specifications match your actual operating range. One more thing about the power level: if your battery pack is 48V as you mentioned, then 20A at 48V is only 960 watts, which is much more reasonable for your current design. However, this creates a huge turns ratio requirement if you're boosting to 380V. Make sure you've clearly defined your input voltage range, output voltage requirements, and actual power level because these fundamentally determine whether your approach is feasible.

The MathWorks documentation includes several relevant examples you should review. There's a battery charging and discharging example that shows constant current and constant voltage algorithms, which demonstrates exactly the control strategy you need. There are also current-controlled bidirectional converter examples that show how to implement PI-based current control, which would be directly applicable to your needs.

For debugging your current issues, I'd recommend these steps. First, verify your actual power requirements with your team because the 20A at 380V (7.6kW) seems inconsistent with a 48V input and the component values you've chosen. Second, if you're staying with the flyback approach for now, implement current-mode control with proper feedback from your current sensor rather than voltage. Third, use much more conservative PI gains initially - start with very small gains and slowly increase while monitoring stability. Fourth, add current limiting to your reference signal so you don't try to draw more current than your components can handle during transients.

If you decide to go with the two-stage approach (Option B), the design becomes cleaner. The first stage boost converter operates in constant current mode with the battery as input, outputting whatever voltage is needed to maintain 20A at the intermediate bus. The second stage flyback or LLC converter operates in constant voltage mode to regulate the 380V needed for your grid inverter. This separation of functions makes each stage simpler to design and control.

For simulation purposes, I'd suggest starting with lower power levels to verify your control strategy works, then scaling up once you've proven the concept. Simulink can absolutely handle the power levels you need, but you need to ensure your component values are realistic for those power levels. At multi-kilowatt power, you need inductances in the range of tens to hundreds of microhenries, capacitors in the hundreds of microfarads to millifarads, and switching frequencies typically in the 20-100kHz range.

Finally, regarding the plots you shared, the fact that your voltage reaches the target intermittently tells me the power stage is capable of delivering the energy, but the control system isn't maintaining regulation. This is actually good news because it means your hardware design is fundamentally sound. The solution is in the control strategy, which is much easier to fix than rebuilding the entire power stage.

Your journey from voltage mode to recognizing the need for current mode shows good engineering intuition. Many people would have kept forcing the voltage control approach to work without stepping back to ask whether they were solving the right problem. The fact that you caught this and are now asking the right questions about current control shows you're thinking like an engineer, not just following formulas.

I hope this helps clarify where you are, why things have behaved the way they have, and what your path forward should be. Don't hesitate to ask more specific questions about any aspect of the implementation. The transition from voltage to current control is absolutely doable, but it requires rethinking several aspects of your design, especially at the power levels you're targeting.

10 Comments

Hi @Umar,
Let me thank you a lot for your entire dedication to my query. But I think you switched option B and C and I am confused.
You said:
"I would strongly recommend Option B: Flyback at constant current plus Boost at constant voltage plus Inverter to grid."
But later on the answer you also said:
"The boost converter stage can efficiently handle the high current constant current regulation." (...) The first stage boost converter operates in constant current mode with the battery as input, outputting whatever voltage is needed to maintain 20A at the intermediate bus. The second stage flyback or LLC converter operates in constant voltage mode to regulate the 380V needed for your grid inverter." which is option C.
Please, have a look again and clarify if you meant Option B or Option C. I guess you meant Option C, so the flyback is in the middle but let me know.
Thanks once again.
Carlos

Hi @Carlos,

You're absolutely right to call this out - I apologize for the confusion. Yes, I meant Option C,not Option B. The technical description I gave clearly describes Option C: Boost at constant current, then Flyback at constant voltage, then Inverter to grid. I mislabeled it as Option B, which was my error.

Here's what I'm recommending: Your boost converter should be the first stage operating in constant current mode (20A) drawing from the battery. This stage outputs variable voltage to an intermediate bus. The flyback converter is the second stage operating in constant voltage mode (380V) and provides the galvanic isolation you need for grid safety. Finally, your grid-tie inverter takes the regulated 380V DC and converts it to AC.

The reason this makes sense is that boost converters excel at constant current regulation with their continuous input current characteristic, which is exactly what you want when drawing from a battery. The flyback is much better suited for voltage regulation and isolation, and by splitting these functions you keep each converter operating in its optimal range. Again, your single-stage flyback is already struggling because flybacks typically max out around 100-200W, and if you really need 20A at 380V, that's 7.6kW which is way beyond what a single flyback can handle.

Before we go further though, I need you to clarify your actual power requirements because there's a significant inconsistency: Are you pulling 20A from a 48V battery (960W), or do you need 20A at 380V output (7.6kW)? These are very different designs. Also confirm your battery voltage range as it discharges because this affects your boost stage design significantly.

If you want to stick with your current single-stage flyback just for learning purposes, you can convert it to current control by changing your reference from voltage to current, redirecting your feedback to the current sensor, and completely retuning your PI gains. But realistically, for any significant power level, you need the two-stage approach.

So yes - Option C is what I'm recommending. Sorry for the confusion with the labeling.

Hope this clarifies everything now.

Hi @Umar,
Thanks for clarifying it. I assumed you meant Option C and I was right now working on this design. I am pulling 20 A from a 48 V battery as an upper limit this voltage, it could be less. The input voltage lower limit I stated was 2 V but if possible I would go to almost 0. But I imagine that's not possible so I set this limit. Batteries won't be reused, so there is no risk of going beyond cut-off voltage.
The input current is 20 A but if the voltage has to be increased, the current will decrease. I decided to make it 7 A (D = 0.65). I hope I am doing right because I am calculating from the typical equations for a boost converter but I don't know if they apply when it's constant-current control.
Let me ask you a few more things:
I checked the documentation about charging and discharging algorithms but I am not sure if I need them. I saw the block "Discharger" but is not compatible with the rest of the blocks. And then, there is this block called "Battery Discharging Current Limit" which establishes a limit for undervoltage and once again, I don't think I will need it. As those two blocks can't go together, I thought maybe I can design the boost converter just as I was doing for the flyback and apply the current control (ACMC I expected). Is that a right choice? I was designing by the moment the first stage only and I will attach later the flyback as shown in the picture:
After that, I will design the control loop. I believe it's just one, the output current control which should remain 7 A, with a PI. Is that right?
And when that works, I will design the flyback at constant voltage control, with another PI.
I hope this is the path I should follow.
Thanks again! ;)
Carlos

Hi @Carlos,

Thanks for the detailed clarification — you’re definitely on the right track with the two-stage setup (Boost > Flyback > Inverter). A few important notes and confirmations:

  • Power level: 20 A @ 48 V = ~960 W. The 2 V lower limit isn’t practical — use something like 36–40 V min.

Boost stage: Operate in constant-current mode using a PI loop on battery current (7 A or 20 A target). The duty-cycle equations and component sizing still follow standard boost formulas; just replace voltage feedback with current feedback.

Flyback stage: Add next, in constant-voltage mode (380 V) with its own PI loop. Make sure it handles the variable intermediate bus from the boost.

  • You’ll end up with two independent PI loops: one regulating input current, one regulating output voltage.

Battery modeling: Don’t use both Discharger and Battery Discharging Current Limit blocks together — your converter already acts as the discharger. Use the current-limit block (or your own logic) for safety limits.

Design checks: Verify boost duty-cycle range, inductor sizing, and loop stability. Ensure flyback power rating matches boost output and that both loops interact stably. Here what I will recommend next steps:

1. Finalize battery voltage/current specs.

2. Implement and tune boost CC control.

3. Add flyback CV control and test under varying load/input.

4. Integrate with inverter and include protection logic.

This staged approach keeps each converter in its optimal mode and is far more scalable and stable than a single high-power flyback.

Hope this helps!

Hi @Umar,
But the intention is to deep discharge the batteries. I can't finish at 36 V... It should reach close to 0 V.
I have just tested the boost converter for a 48 V input voltage and it's reaching 20 A (well, almost, by decimals) with a fix D (0.65). But if I decrease that voltage, I have to change the load. In a real flyback converter, the load can't be changed dynamically (or can it?). So the purpose is to modify the duty cycle? With my calculations, D = 0.65. I calculated it from the input and output currents and with it, I calculated the output voltage for both input voltages (2 and 48 V). As it should be controlled by constant current, I supposed that D is calculated first by fixing the output current I want. Or am I doing it wrong? Please, correct me :)
After that, I will follow the next steps you told me.
Thank you!
Carlos

Hi @Carlos,

Please see my detailed response to your latest comments below — I’ve double-checked the relevant Simulink documentation to ensure accuracy.

Your comment: “But the intention is to deep discharge the batteries. I can’t finish at 36 V… It should reach close to 0 V.”

My feedback: The MathWorks documentation suggests modelling realistic battery behaviour and converter limits, rather than driving the input all the way to 0 V. Below a certain voltage, gate-drive circuits and switching devices lose proper bias, and the inductor current can rise uncontrollably.

In Simscape, converter blocks assume a non-zero, physically meaningful input voltage and require a defined electrical reference. There’s no native support for a “battery to 0 V” condition in the converter library.

So yes — while you can model a low-voltage cutoff, it’s best to design the boost stage to stop converting below about 20–36 V, as you previously suggested. Treat anything below that as an intentional shutdown rather than continuing to boost.

Your comment: “I have just tested the boost converter for a 48 V input voltage… it’s reaching 20 A… but if I decrease that voltage, I have to change the load. In a real flyback converter, the load can’t be changed dynamically (or can it?). So the purpose is to modify the duty cycle?… With my calculations, D = 0.65.”

My feedback: Exactly — in constant-current operation, you don’t fix the duty cycle. It will continuously vary as the input voltage or load changes to maintain the desired current.

According to the [Average-Value DC-DC Converter documentation][1]: “If you set the Control input parameter to ‘Current reference’, the converter sets the output current and computes the voltage.”

This means the converter (or your control loop) dynamically adjusts duty cycle to achieve the commanded current. Similarly, the [Boost Converter block][2] supports several modelling modes such as “Average model (D-controlled)”, allowing you to connect your PI controller output directly to the duty-cycle input.

So your idea of using a PI loop on the input current is exactly right — you use design calculations (like D ≈ 0.65) only for initial sizing, not as a fixed value during simulation.

As for varying the load: in your two-stage setup, the flyback converter and inverter together act as the “load” seen by the boost stage. The boost current-control loop adapts automatically to that, so there’s no need to manually adjust the load during operation (though it can be useful for testing).

Your comment: “I was designing the first stage only… and when that works, I’ll design the flyback at constant-voltage control, with another PI. I believe it’s just one [loop], the output current control…”

My feedback: You’re absolutely correct — this is a classic two-loop architecture.

The first stage (boost) regulates input current, and the second stage (flyback) regulates output voltage. As confirmed in the [Average-Value DC-DC Converter block documentation][1]: “If you set the Control input parameter to ‘Voltage reference’, the converter sets the output voltage and computes the current.”

So, configure the boost converter for current-reference mode and the flyback for voltage-reference mode. Each stage will have its own PI controller.

Be aware that because the intermediate DC bus connects both stages, transient coupling can occur when loads change or when the inverter starts drawing current. It’s worth running dynamic simulations to verify stability.

Your comment: “I calculated from the input and output currents and with it, I calculated the output voltage for both input voltages (2 V and 48 V)… As it should be controlled by constant current, I supposed that D is calculated first by fixing the output current I want. Or am I doing it wrong?”

My feedback: You’re on the right path for design calculations — using current, voltage, and duty-cycle relationships helps size components. However, once in simulation or hardware, the control loop manages D dynamically.

The [*Boost Converter* documentation][3] gives the familiar steady-state relationship for ideal operation:

     V_out = V_in / 1 - D

That equation is useful for sizing and estimating extremes, but in your constant-current design, the controller continuously adjusts D to hold the commanded current as V_in and load vary.

Keep in mind that if V_in drops too low (e.g., 2 V), D approaches 1, which is physically impractical. Device losses and saturation become dominant. Therefore, implement a realistic minimum voltage cutoff or derate the current as V_in decreases.

Implementation notes (based on Simulink documentation):

  • Boost stage:use Current reference mode.
  • Flyback stage: use Voltage reference mode.
  • Include current and * voltage sensors* (from Simscape > Foundation Library > Electrical Sensors) to feed the PI controllers.
  • For faster simulation, start with Average model (D-controlled) mode; switch to switch-level mode for detailed studies.
  • Include protection logic,e.g., undervoltage cutoff using Simulink logic or protection blocks.
  • Limit the duty-cycle command within a safe range (e.g., 0.05–0.85).
  • Test the full system with input-voltage and load transients to confirm loop interaction and stability.

In summary: You’re following the right design path, and the MathWorks documentation fully supports your two-stage control concept — boost converter in constant-current mode, flyback converter in constant-voltage mode, each with independent PI loops.

Just remember:

  • Don’t fix the duty cycle — let the current-loop control it.
  • Choose the correct control mode for each converter block.
  • Use a realistic minimum input voltage instead of 0 V.
  • Simulate dynamic events to verify stable behaviour.

References:

[1]: [ https://es.mathworks.com/help/sps/ref/averagevaluedcdcconverter.html ]

[2]: [ https://www.mathworks.com/help/sps/powersys/ref/boostconverter.html ]

[3]: [ https://www.mathworks.com/help/sps/ug/boost-converter.html ]

Hi @Umar,
I still have some doubts about the output current and the load. I tuned the PI for Vin= 48 V and to have a current of 7 A, R must be 19.59 ohm. Kp is 0.0081925 and Ki is 0.69759. If I change Vin to 40 V as it will happen in real life, to ensure a current of 7 A, R must be lower and Kp and Ki have to be changed too. So it's not possible to keep a constant output current of 7 A because Kp and Ki can't change dinamically and I guess R is also unchangeable (flyback and inverter have the load they have). In simulation is perfect but only by changing those values. So, is not a problem to have different output current along the discharging time? Take into account that I am measuring input current... I will have to change it later to a be a voltage measurement with a sensing resistor as it is done in real life.
About the minimum input voltage, I guess that by simulation I will find a limit, but I don' t know when to stop in the practice because the idea is to drain at its maximum the batteries to be safe for storage (20 V is still high four our purpose). If it's not 2 V as semiconductors can't work with such low voltages, then the value that ensures correct working.
I am building my own boost converter instead of using the predefined block as I want to be sure I can control all the parameters.
Thanks for everything. I am learning a lot with your explanations :)
Carlos

Hi @Carlos,

Let me address your concerns in order to wrap this up completely.

About the output current and load changing with varying input voltage - you're experiencing exactly what should happen, and it's actually not a problem. When you tune your PI for 48V with those specific Kp and Ki values, and then the voltage drops to 40V, the system dynamics change. You're right that in a real system the load (your flyback and inverter) can't change, and the PI gains don't change dynamically either. Here's the thing though: for battery discharge applications, you don't need perfect 7A tracking. If your current drifts between 6-8A as the battery voltage drops, that's completely acceptable. The battery discharges slowly enough that these variations won't cause any issues. If you really need tighter current regulation, you'd implement gain scheduling - basically a lookup table in Simulink that adjusts your Kp and Ki based on the measured input voltage. You'd tune the controller at maybe 5 different voltage points (48V, 44V, 40V, 36V, 32V) and interpolate between them. But honestly, for safe battery discharge and storage preparation, the simple approach with fixed gains tuned around 40V will work fine.

About measuring input current versus using a voltage sensing resistor - yes, in real hardware you'll use a small sense resistor (0.01-0.05 ohms) with a differential amplifier on the battery side. That's standard practice and what you should plan for in your final design.

Now for the minimum input voltage question - this is really important. You cannot discharge to 2V or "almost 0V" with a boost converter. It's physically impossible. Your MOSFETs need gate drive voltage to operate (typically 5-10V minimum), and below about 20-30V input, the whole control system breaks down. The duty cycle would need to approach 100%, which you can't actually achieve, and the converter would become unstable.

For a 48V battery pack, which I'm assuming is 13 cells in series, the safe minimum discharge voltage is around 2.5V per cell, giving you about 32.5V for the pack. Going to 20V like you mentioned would actually damage the cells - you'd be at about 1.5V per cell, which is way below the safe cutoff. For storage preparation, discharging to 32-36V is actually better and safer than trying to go lower.

If you absolutely need to remove all energy for recycling, the standard practice is to discharge with your converter down to 32V, then disconnect and short the battery through a low-value resistor to remove the remaining charge. This two-stage approach is how it's done in industry because power electronics can't handle the full 48V to 0V range.

Since you're building your own boost converter rather than using the predefined block, make sure you implement proper protection: duty cycle limiting between 0.05 and 0.85, undervoltage cutoff at 32V, overcurrent protection, and anti-windup on your PI controller. Test your boost stage thoroughly with a simple resistive load first, sweeping the input from 48V down to 32V, before you add the flyback stage.

Your two-stage approach is correct - boost in constant current mode feeding a flyback in constant voltage mode, each with its own PI controller. The boost regulates battery current at 7A, and the flyback regulates output voltage at 380V. The intermediate DC bus voltage between them will vary naturally based on power flow, and that's expected. Just make sure to verify stability when you connect them together by running dynamic simulations with voltage and load transients.

One last clarification on the duty cycle calculation - you're right that D=0.65 is what you calculate from the steady-state equations for initial component sizing. But once you implement current control, you don't fix D at 0.65. The PI controller continuously adjusts D to maintain 7A as conditions change. Your calculation was for design purposes, not for operation.

You've got a solid grasp of this now. Move forward with: boost stage first with current control from 48V to 32V minimum, accept some current variation as normal (+/-10-15%), add your protection logic, then integrate the flyback with voltage control, and finally test the complete system. You don't need perfect 7.000A tracking - good enough is actually good enough here.

Best of luck with your implementation. You're asking all the right questions and clearly understanding the concepts.

Time to build it and see it work.

Hi @Umar,
After all this advice, thank you so much. I am considering changing the flyback stage by a push-pull or full-bridge but don't worry, I will read about them. The reason is somebody told me it's too much power what I need and the best choice is another topology. 960 W is too much for a flyback...
For the rest of the comments, thank you, they will be very useful even if I change the topology.
Carlos

Hi @Carlos,

You’re welcome! Yes, for around 960 W, moving to a push-pull or full-bridge topology is a sensible step — it should give you better efficiency and manageable component stress compared to a flyback. Glad my comments helped!

Sign in to comment.

Hi @Carlos,

I went through your entire thread carefully, including all your updates and the changes you made along the way. I have good news: there's nothing wrong with your Simulink circuit topology or block connections. Your model is actually built correctly. The problem is a duty cycle calculation error.Let me walk through what happened based on your comments.

In your initial post, you mentioned trying both closed-loop control and a fixed duty cycle of 0.116564, which you calculated for 48V input to get 380V output. You were getting negative 1.428V output and near-zero negative current. You tried moving the current measurement block around, changing secondary connections, and reversing polarity measurements, but never got positive voltage and current at the magnitudes you expected.

When Antonino suggested placing the load in parallel with the output capacitor and checking your transformer connections, you responded explaining your thinking. You said you thought having a resistor in a different location would be beneficial for biasing, and since an inverter would follow the flyback, you weren't initially adding a load resistor. You decided to try a random value of 250 ohms. You also mentioned you thought it should work by measuring current before the diode without any load, which shows a misunderstanding of how flyback converters need to be loaded to operate properly.

Then you described several changes you made. You changed the PowerGUI step size so it wasn't the same as the switching period of one divided by 24000 seconds. You reduced the reference voltage from 380V down to 70V for testing. And here's the critical part: you said the fixed duty cycle is now 0.024 as you calculated for an input of 48V. You also changed the diode forward voltage from 2.1V, which is your actual spec, to 0.7V, and reduced the capacitor from 87 microfarads to 12.5 microfarads. Even running the simulation for 100 seconds, the output voltage remained too small and the output current was nearly zero, though you noted the output current was switching with an upper limit almost at zero, and the output voltage was increasing very slowly.

You also mentioned that the MathWorks example Antonino shared used the blue Simscape blocks, which were incompatible with your PID controller ports, so you had to stick with the black Simulink blocks.

Here's what I found after analyzing everything. Your circuit topology is completely correct. The transformer polarity with dots on opposite ends is exactly right for a flyback converter. Your diode orientation is correct, your load placement is correct, and all your block connections are proper. The problem is purely in the parameter values, specifically your duty cycle calculation.

When you said you calculated duty cycle equals 0.024 for a 48V input to get 380V output, this is where the error occurred. Let me show you the correct math.

Your transformer turns ratio is the square root of L2 divided by L1, which equals the square root of 0.036 divided by 0.00001, which equals 60.

For a flyback converter, the duty cycle formula is: duty cycle equals the sum of output voltage plus diode forward voltage, all divided by the sum of turns ratio times input voltage plus output voltage plus diode forward voltage.

For your original 380V target with 2.1V diode, the calculation is: duty cycle equals 380 plus 2.1, divided by 60 times 48 plus 380 plus 2.1, which equals 382.1 divided by 3262.1, which equals 0.117 or 11.7 percent.

This matches your very first calculation of 0.116564. That was correct! But when you recalculated and got duty cycle equals 0.024, you actually calculated the correct duty cycle for a 70V output, not 380V. The calculation is: duty cycle equals 70 plus 2.1, divided by 60 times 48 plus 70 plus 2.1, which equals 72.1 divided by 2952.1, which equals 0.024 or 2.4 percent.

So here's what happened. You calculated duty cycle equals 0.024 thinking it was for 380V output, but it's actually only correct for 70V output. You then reduced your reference voltage to 70V for testing, which would match that duty cycle, but you were still expecting much higher voltages and couldn't understand why the output was so small.

This explains everything you observed. With duty cycle equals 0.024, your switch is only on for 2.4 percent of each cycle. This stores very little energy in the primary inductance. When the switch opens, minimal energy transfers to the secondary. That's why you saw near-zero current and why the output voltage was increasing extremely slowly. The converter is actually working correctly, it's just operating with five times less energy than needed for 380V.

The 250 ohm load resistor made things worse. For 380V at 2.53A, which is your design spec, you need resistance equals 380V divided by 2.53A, which equals 150 ohms. With 250 ohms, even if the voltage reached 70V, you'd only draw 0.28A, which explains why you saw current values close to zero.

The reduced capacitor from 87 microfarads to 12.5 microfarads also compounds the problem. A smaller capacitor requires many more switching cycles to build up the DC voltage, especially when combined with insufficient energy transfer from the too-small duty cycle. This explains the very slowly increasing voltage you described.

To fix your circuit and achieve the original 380V output goal, make these changes. First, change duty cycle from 0.024 to 0.117, this is the critical fix, go back to your original calculation. Second, change load resistor from 250 ohms to 150 ohms to match your 2.53A design spec. Third, change capacitor back to 87 microfarads from the 12.5 microfarads you're using now. Fourth, set reference voltage back to 380V. Fifth, restore diode forward voltage to 2.1V, your actual component specification.

With these changes, your simulation should reach steady state in two to three seconds instead of requiring 100 plus seconds.

If you want to test at 70V first before attempting full 380V, you can keep duty cycle equals 0.024 since that's actually correct for 70V. But you must change the load resistor to about 28 ohms, which is 70V divided by 2.5A, to draw meaningful current and properly load the converter. With 250 ohms at 70V, you'll continue seeing near-zero current.

About the Simscape blocks issue you mentioned, you're absolutely right that the black Simulink blocks and blue Simscape blocks have incompatible ports. You made the correct choice sticking with Simulink blocks for your control system. Your block diagram structure is fine.

The reason this was so confusing is that you made multiple changes simultaneously. You reduced reference voltage to 70V, changed the capacitor, changed the diode forward voltage, picked a random load resistor value, and recalculated the duty cycle. These combined changes made it nearly impossible to isolate that the root cause was simply the duty cycle being wrong for your intended 380V output voltage.

Your original instinct with duty cycle equals 0.116564 was absolutely correct. That's the value you need for 380V. The confusion happened when you recalculated and accidentally computed the duty cycle for a different output voltage.

The slow voltage rise and near-zero current you observed are exactly what you'd expect from a correctly functioning flyback converter that's operating with a duty cycle five times too small for the desired output. The converter is working, it's just the parameters that need correction.

Let me know if you need clarification on any of these calculations or have questions about implementing the changes.

4 Comments

Hi @Umar,
First of all, let me thank you for your time. You are very kind :)
I made all those changes you stated (First, change duty cycle from 0.024 to 0.117, this is the critical fix, go back to your original calculation. Second, change load resistor from 250 ohms to 150 ohms to match your 2.53A design spec. Third, change capacitor back to 87 microfarads from the 12.5 microfarads you're using now. Fourth, set reference voltage back to 380V. Fifth, restore diode forward voltage to 2.1V, your actual component specification.) but in open-loop, so the duty cycle is fixed. However, this is what I obtained:
As you can see, I changed again the step in powergui (2.5 times the switching frequency, just in case it was an aliasing issue). I also added a current measurement block to the primary winding. It wasn't drawing current in my previous update because in the mutual inductance I had to select in "Measurements" > "Winding voltages and currents". Now it has high current values:
However, there is still something going on after the restoration of the changes. The current in the secondary is too small. Should it be 2.53 A according to my changes right? Also, the output voltage is switching near 0:
I also made "Measurements" > "Branch voltage and current" if it could work as it did in the mutual inductance but the result is the same (more or less I guess).
So, in summary, I believe there is still something regarding the parameters that make very small voltage and current in the secondary even in loop-control. After making it work like that, I would have to make it in close-loop, when the 380 V reference (V_ref) will be used. Check in the first screenshot that I have it disconnected and also there is a discrete PI controller with these configuration (not in the first screenshot because I deleted it accidentally):
I didn't calculate Kp and Ki by myself.
Also, please, have a look at the parameters in the mutual inductance:
Thank you so much @Umar, again, but I still need some help.
Carlos

Hi @Carlos,

Thanks again for sharing the updated screenshots and walking through all the changes. You've done a great job restoring the key parameters:

Duty cycle: 0.117 (11.7%)

Load resistor: 150 ohms

Output capacitor: 87 microfarads

Diode forward voltage: 2.1 volts

Reference voltage: 380 volts

Powergui sample time: 2.186 microseconds (which is 2.5× the switching period for 24 kHz)

Also, enabling “Winding voltages and currents” in the mutual inductance block was the right move—primary current now looks solid.

That said, I agree with your observation: the secondary current is still very low, and the output voltage is switching near zero. Based on your setup, you should be seeing around 2.53 amperes on the secondary side, so something is still limiting energy transfer.

Here are a few things to check next:

Mutual Inductance Parameters: You're using L1 = 10 microhenries and L2 = 36 millihenries, which is a huge mismatch. That weakens magnetic coupling. Try increasing L1 or switching to a transformer block with a coupling coefficient (e.g., k = 0.98).

Mutual Inductance Value (Lm): Lm is currently 9.99 microhenries, which is likely too low. A better estimate would be the geometric mean of L1 and L2:

So, Lm approx sqrt of 10 microheneries * 36 milliheneries Which equals approx 600 microheneries to improve coupling.

Transformer Polarity: Even though the dot convention looks correct, double-check that the secondary winding isn’t reversed. A polarity mismatch could cancel the induced voltage and explain the low current.

Diode Conduction: Confirm that the secondary voltage exceeds 2.1 volts during switching. If it doesn’t, the diode won’t conduct and the load won’t receive current.

Scope Signals: The output voltage plot looks saturated or flat—possibly a measurement artifact or a sign that the diode isn’t turning on.

Once these are addressed, the converter should deliver the expected output. After that, you can reconnect the PI controller and tune Kp = 0.0135 and Ki = 12.52 manually or with the PID Tuner App.

Let me know what you find—you're very close to resolving this.

Hi again @Umar,
I have a new update.
The Lm in the mutual inductance has been changed to be a bit less than the sqrt(L1*L2) --> Lm = 0.0005.
With that in mind, I see a V_out of around 90 V. It's still not 380 V, that I don't know why.
Also, measuring the current I find it's not 2.53 A. But at least is positive and not close to 0:
What else could be wrong?
I must comment that for my application, Vin would change so the duty cycle would change. For 2 V, which is the lower limit, I have a similar problem, the current and the voltage are not enough, even for the new load I calculated. Vo/Io=380/0.105 = 3610 ohms.
Carlos
Hi @Umar,
If I increase L1, I should change L2 and Lm being sqrt(L1*L2) too? Because I have to keep the relation with N12 as L2 depends on that. I believe the diode is working according to my previous update. Please, have a look at it. It's close to be working well but it's not reaching the 380 V and 2.53 A yet.
Update: it seems that if I decrease the inductance by a constant factor in L1, L2 and Lm, keeping L2 proportional to N21 and Lm to both L1 and L2, it gets even closer to the V_out I want but I don't know how I will ensure that I get 380 V by trial and error changing the inductances as I do it in open-loop. Will it work properly for close-loop? And as I say, I am decreasing the values, not increasing it... If I increased L1 while keeping constant L2 or even adjusting it to N21, V_out would decrease even more.
Thanks for your help.
Carlos

Sign in to comment.

Good day, @Carlos,
Thank you very much for your question and the figure.
As mentioned by @Antonino Riccobono earlier, if you do not have the load, you will have no output.
Second, you have placed the resistor in the wrong location. It must be parallel to the output capacitor. If you do not know the resistor value, it would be beneficial to use a range of values (e.g. using a slider).
Please refer to the link that @Antonino Riccobono has shared. It should give you a direction.
I hope the above information will help you with your project.

3 Comments

Hi,
I thought it would be beneficial to have a resistor in the place I put for biasing. As following the flyback there will be an inverter, I wasn't adding a resistor as I don't know the load, but I will try with a random value (250 ohms). I thought it should be working by measuring the current before the diode without any load. I made some changes after this. As you can see, I_out and V_out are still very small. I_out is switching but the upper limit is almost zero. V_out increases very slowly so it seems it's not working as expected.
I changed the step in powergui so it's not the same as the switching period (1/24000) s. I put a smaller voltage in the V_ref (70 V) although the idea is to have 380 V. The fixed duty cycle is now 0.024 as I calculated for an input of 48 V. With all those changes, V_out is too small as well as I_out. I am running a simulation of 100 s. No clue of why it's always getting a very small current. The load is in the place you mentioned. I also changed the VF from the diode being 0.7 V, but it's not the one I expect (mine is 2.1 V). And the capacitor is 1.25e-5 F.
The link that @Antonino Riccobono shared is using the other type of objects (those blue) which can't be applied to my circuit as I tried to connect a PID controller but the ports were incompatible. So I am using the black objects.
I still need help, please.
Thanks.
Carlos
Thanks for the suggestion but my team can't afford it.
Carlos

Sign in to comment.

Hi @Carlos, I was having technical difficulties while replying to your post. Please see attached.

7 Comments

Hi @Umar,
The input voltage at the beginning was 48 V. All calculations were done taking that into account. So D= 0.117 for Vin=48 V and D=0.76 for Vin= 2V. While I was waiting for your latest answer, I was decreasing until 7 times less L1, L2 and Lm. It could reach 380 V at some instants with these parameters (a bit shocking for me but it that works...):
I will probably try with the linear transformer after your next comment as I had some problems with that block in the past and that's why I moved to the mutual inductance.
Thanks.
Carlos

Hi @Carlos,

Let me explain what actually happened. With Vin = 48V and your target of 380V at D = 0.117, the required turns ratio works out to N2/N1 = 380 × (1-0.117) / (48 × 0.117) ≈ 60:1. Your original L1 = 10microheneries and L2 = 36milliheneries gave you exactly that since square root of (36milliheneries/10microheneries) = 60:1, so the turns ratio was never the problem.

The real issue was that the inductances were too large for your switching frequency. The energy simply couldn't fully transfer in each cycle, which is why you were stuck at 90V instead of 380V. When you divided everything by 7, you kept the same 60:1 turns ratio (since both L1 and L2 were divided equally), but the energy transfer dynamics completely changed. The smaller inductances allow faster current ramps, more complete energy transfer per cycle, and better matching to your switching frequency. Your practical approach beat the pure theory, which is exactly what good engineering looks like.

I do have a few questions to make sure we're completely sorted. Are you now getting stable 380V output, or just hitting it at some instants? If it's still transient, you might need more output capacitance or a slight duty cycle adjustment

Now that you mentioned you had problems with the Linear Transformer block in the past, which is why you moved to mutual inductance. Since the mutual inductance approach is working now with the divided-by-7 values, I'd say stick with what's working unless you run into issues. The mutual inductance block gives you more direct control over the individual inductances anyway, which can be helpful for fine-tuning.

Hope this helps.

Hi @Carlos, Hope you made some progress. Let me know if you need any further assistance or help with anything.

Hi @Umar,
Sorry for my late answer. I couldn't answer you since I didn't have access to the forum. About the stability of the output voltage, no, it just hits 380 V at some times as you can see in the graph:
However, I was considering this wrong since the beginning. What I need is a constant current at the output as the application is for discharging batteries. So, if it's OK for you, what should I change to make the current constant at the output instead of the voltage? Just discharging, no charging, so it won't have constant voltage step too.
Many thanks for your help :)
Update: I increased the capacitor until 330 uF. I got a better ripple with it:
But I am still hesitating with the constant current control. Firstly, with the equations needed to obtain the different data.
Carlos

Hi @Carlos,

Good to hear from you. Thanks for sharing the scope plots, in addition to these plots, could you please share screenshot of your block parameters GUI along with your updated Simulink block diagram, I want to see the scope setup and provide details of what have you exactly tried so far. Also, please provide details on what has worked for you so far based on my provided instructions and what has not worked for you.

Hi @Umar,
I am not sure what you mean by the "block parameters GUI"... Do you mean for each block (mutual inductance, diode, capacitor, transistor, ramp, etc. parameters)?
For the simulink block diagram, right now I have it like this:
It's not fine because the PI wasn't working properly for the values I proposed: Kp = 0.0135 and Ki = 12.52. I was trying to tune it first by the Transfer Function Based. But it said it was not possible to linearize the plant. After that, I decided to use the Frequency Response Based but I wasn't sure of the parameters I should set so I gave it up.
I think my design was taking the wrong path as I was doing it for constant voltage but my application needs a constant current, which means the output voltage would vary. So I have three options knowing that the application is to discharge batteries deeply:
A) Flyback at CC + Inverter to grid.
B) Flyback at CC + Boost at CV + Inverter to grid.
C) Boost at CC + Flyback at CV + Inverter to grid.
By the moment, I want to know if just one flyback (option A) before the inverter is possible and if so, if there are many changes to do in the design of the block diagram I did :) If not, I will move to option B or C. The input current would be 20 A and I would like to have 20 A in the output too.
So far, the values I have in my design are these:
C = 330 uF; R = 150 ohms. V_ref = 380 V (but I think it should be dependent on D as I want constant current). The ramp in the sawtooth comparator is 1/24000 s and the PI has this setup with Ts = 1.67e-5 s:
I think I'm not missing anything. But let me know if you need anything else :)
Thank you so much.
Carlos
once please check your transformer specificatiions ,turns ration from primary to secondary ... with the duty cycle .and check the transformer connectioncs are placed or you placed inductor in the place of transformer ???

Sign in to comment.

Communities

More Answers in the  Power Electronics Control

Categories

Find more on Simulink in Help Center and File Exchange

Asked:

on 30 Oct 2025

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!