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

3 个评论
回答(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.
8 个评论
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 @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 个评论
3 个评论
Hi @Carlos, I was having technical difficulties while replying to your post. Please see attached.
6 个评论
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.
社区
另请参阅
类别
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
















