Author Topic: Building a PSU - Stuck with Compensator Values  (Read 4396 times)

0 Members and 3 Guests are viewing this topic.

Offline psydaddyTopic starter

  • Regular Contributor
  • *
  • Posts: 76
  • Country: pl
Building a PSU - Stuck with Compensator Values
« on: August 23, 2026, 06:55:38 pm »
I believe this is a very complex subject (Compensators). I’ve been diving into papers, videos, and other resources, but I’m still honestly lost about where to start. My PSU is working, but without the compensator, the output is a mess. I’ve attached the complete schematic. If you need any additional information about my PSU, please let me know.

Unfortunately, everything I find online seems to be written for people who already have a solid understanding of how this works. What I really need to understand is how to calculate the R and C values for a Type II and Type III compensator, and where to start.

I’ve heard about zeros, poles, and Bode plots, but I’m still not sure how to construct them or even where the zeros and poles are placed on a Bode plot. I also don’t know what to do with the poles and zeros once I’ve determined them in order to calculate the R and C values.

I would really appreciate some guidance. Is there an algorithm or step-by-step procedure I can follow, or perhaps a simulation tool that can help with this? I’ve also heard about the K-Factor Method, but I’m not sure how to apply it.

Thanks in advance for your help.
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 5355
  • Country: nl
Re: Building a PSU - Stuck with Compensator Values
« Reply #1 on: August 23, 2026, 11:31:21 pm »
I saw your very big schematic sheet full of disconnected puzzle rectangles, stared at it for a few minutes and  I just closed it again.

Control theory is a quite involved part of electronics design, and it's not something you can learn from a forum like this. Creating and interpreting bode plots is just a part of this, but it is an important part.

Simplified: A pole creates a bend downward in a bode plot, and a zero creates a bend upwards. All bends in a bode plot create a slope difference of 20dB/decade.

If you have an amplifier with feedback, then at higher frequencies, there are always phase shifts. If this phase shift becomes 180 degrees, and the amplification of that is equal or larger then one, then you have created an oscillator. So the goal is to ensure that the amplification factor is low enough that this never occurs (See: gain and phase margin).

A simple opamp, is often modeled with a DC gain of 100k (or thereabouts) and a single pole at 10Hz or so. (Draw the bode plot of that!) This results in a GBWP of 1MHz, and your surrounding circuit has to ensure that at 1MHz the total accumulated phase shift is still well below 180 degrees.

https://en.wikipedia.org/wiki/Control_theory
https://en.wikipedia.org/wiki/Bode_plot
 
The following users thanked this post: psydaddy

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 3352
  • Country: au
Re: Building a PSU - Stuck with Compensator Values
« Reply #2 on: August 23, 2026, 11:40:12 pm »
My PSU is working, but without the compensator, the output is a mess.
:-//
With information that vague, no one will be able to help.
Do you have a scope? Some means to apply a pulse load of varying amounts?

 
The following users thanked this post: psydaddy

Offline psydaddyTopic starter

  • Regular Contributor
  • *
  • Posts: 76
  • Country: pl
Re: Building a PSU - Stuck with Compensator Values
« Reply #3 on: August 24, 2026, 12:50:25 am »
I saw your very big schematic sheet full of disconnected puzzle rectangles, stared at it for a few minutes and  I just closed it again.

Control theory is a quite involved part of electronics design, and it's not something you can learn from a forum like this. Creating and interpreting bode plots is just a part of this, but it is an important part.

Simplified: A pole creates a bend downward in a bode plot, and a zero creates a bend upwards. All bends in a bode plot create a slope difference of 20dB/decade.

If you have an amplifier with feedback, then at higher frequencies, there are always phase shifts. If this phase shift becomes 180 degrees, and the amplification of that is equal or larger then one, then you have created an oscillator. So the goal is to ensure that the amplification factor is low enough that this never occurs (See: gain and phase margin).

A simple opamp, is often modeled with a DC gain of 100k (or thereabouts) and a single pole at 10Hz or so. (Draw the bode plot of that!) This results in a GBWP of 1MHz, and your surrounding circuit has to ensure that at 1MHz the total accumulated phase shift is still well below 180 degrees.

https://en.wikipedia.org/wiki/Control_theory
https://en.wikipedia.org/wiki/Bode_plot

Thank you, I have it without that. I thought it would be easier to read  |O
I attached it.
 

Offline psydaddyTopic starter

  • Regular Contributor
  • *
  • Posts: 76
  • Country: pl
Re: Building a PSU - Stuck with Compensator Values
« Reply #4 on: August 24, 2026, 12:54:51 am »
My PSU is working, but without the compensator, the output is a mess.
:-//
With information that vague, no one will be able to help.
Do you have a scope? Some means to apply a pulse load of varying amounts?



Thank you.
I have a Scope, an LCR and Function Generator.
Let me know more about it. I saw some videos of people injecting a signal but it was made with a Frequency Response Analyzer, Can I do it manually? Where to connect and what to do?
 

Offline Someone

  • Super Contributor
  • ***
  • Posts: 6067
  • Country: au
    • send complaints here
Re: Building a PSU - Stuck with Compensator Values
« Reply #5 on: August 24, 2026, 01:00:52 am »
I would really appreciate some guidance. Is there an algorithm or step-by-step procedure I can follow, or perhaps a simulation tool that can help with this?
The steps are producing a (simplified) model of the entire system, or if you don't know what can be simplified then start with a model of the entire system. Simulation tool is whatever you find easiest to use.

There is no shortcut or equation with less than a dozen variables (even after simplification).
 

Offline psydaddyTopic starter

  • Regular Contributor
  • *
  • Posts: 76
  • Country: pl
Re: Building a PSU - Stuck with Compensator Values
« Reply #6 on: August 24, 2026, 01:10:56 am »
The steps are producing a (simplified) model of the entire system
Thank you.
By this, do you mean a Bode plot or something else? Once the Bode plot is built, what is the next step? Could you show me an example of a graph with poor stability and explain what you would do with it afterwards?
« Last Edit: August 24, 2026, 01:12:44 am by psydaddy »
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 3352
  • Country: au
Re: Building a PSU - Stuck with Compensator Values
« Reply #7 on: August 24, 2026, 01:20:22 am »
I attached it.

That is quite complex, do you have a known-good circuit you based that on?
At a quick glance, Q6, Q8 look to be reversed.
« Last Edit: August 24, 2026, 01:47:23 am by PCB.Wiz »
 

Offline Someone

  • Super Contributor
  • ***
  • Posts: 6067
  • Country: au
    • send complaints here
Re: Building a PSU - Stuck with Compensator Values
« Reply #8 on: August 24, 2026, 03:54:49 am »
The steps are producing a (simplified) model of the entire system
Thank you.
By this, do you mean a Bode plot or something else? Once the Bode plot is built, what is the next step? Could you show me an example of a graph with poor stability and explain what you would do with it afterwards?
...if you don't know what can be simplified then start with a model of the entire system. Simulation tool is whatever you find easiest to use.
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 5355
  • Country: nl
Re: Building a PSU - Stuck with Compensator Values
« Reply #9 on: August 24, 2026, 05:58:20 am »
The schematic with all the right parts connected is much easier to read. Basically, if you see a schematic cut in to little rectangular blocks, and you don't even have a system over view of the whole thing, then you just have to go searching for labels to see how the blocks fit together. And worse: Whether a label connects two or more blocks together. It's a horrible way of drawing schematics and it seems to have become popular in the last 5 years or so.

It's still only a partial schematic. Looks like rectified mains at 1kW, but no power factor correction. Then a bunch of stages for mosfet drivers, then it goes to an transformer that is not in the schematic, and the feedback comes back from "somewhere". Or is TR2 the main power transformer?

What's the history of this design? Did you create it yourself or are you reverse engineering / modifying an existing power supply?
The design of a 1kW power supply is not a beginner task, and it's a very bad way to attempt to learn control theory. A single wrongly routed track or missed parasitic behavior can completely mess up the stability.
 

Offline moffy

  • Super Contributor
  • ***
  • Posts: 3031
  • Country: au
Re: Building a PSU - Stuck with Compensator Values
« Reply #10 on: August 24, 2026, 08:27:14 am »
Just a note, the input common mode voltage range of the LM324 is (0V - Vcc-2V). With a 5V Vcc that means 0V to 3V and you have the 5V1 ref going into the CV controller, you might want to divide that down.
https://www.ti.com/lit/ds/symlink/lm324.pdf?ts=1787552102715&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FLM324
 

Offline MariuszD

  • Frequent Contributor
  • **
  • Posts: 685
  • Country: pl
Re: Building a PSU - Stuck with Compensator Values
« Reply #11 on: August 24, 2026, 08:52:39 am »
I’ve been diving into papers, videos, and other resources, but I’m still honestly lost about where to start.
What we discussed in the previous topic is still relevant. Start by determining what the Bode plot looks like for the power stage you built. It can be measured or simulated.

The small signal model of a given topology does not change, and the Bode plot will be similar, only the characteristic points will be in different places.

In the previous version, you used a very complicated capacitor arrangement at the output, and you didn't know the ESR of those capacitors. I wanted to run a simulation to show how it would look, but I couldn't due to unknown parameters.
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 5355
  • Country: nl
Re: Building a PSU - Stuck with Compensator Values
« Reply #12 on: August 24, 2026, 11:16:13 am »
What we discussed in the previous topic ...

Which one?
https://www.eevblog.com/forum/projects/help-with-compensator-circuit-halfbridge
https://www.eevblog.com/forum/projects/using-sg3525-cant-put-the-feedback-section-to-work
https://www.eevblog.com/forum/beginners/quick-question-smps-wave-shap

That's a lot of previous considerations. And I am actually not surprised by that. In your opening post in this thread you write:

I’ve heard about zeros, poles, and Bode plots, but I’m still not sure how to construct them or even where the zeros and poles are placed on a Bode plot. I also don’t know what to do with the poles and zeros once I’ve determined them in order to calculate the R and C values.

And there is simply no chance that you will learn that from reading forum posts. And attempting to learn this while working on a self designed 1kW powersupply also has very little chance of success. In your other threads (especially "help with half bridge") you've already been given a lot of advise about the feedback circuitry. Starting yet another thread is not going to give you many new insights. You first have to find a way to learn the basics of control loops, and then how to apply that theory.

For learning the basics of control theory and designing stable circuits with opamps, first get some good books. Then start with some hands-on work on much simpler circuits. Something like a linear power supply (20V 1A is a good starting point).  with both adjustable voltage and current limit seems a sensible choice. Or if you want to do SMPS, first design and build a few smaller ones.
 
The following users thanked this post: Someone

Offline mtwieg

  • Super Contributor
  • ***
  • Posts: 1790
  • Country: us
Re: Building a PSU - Stuck with Compensator Values
« Reply #13 on: August 24, 2026, 12:26:49 pm »
I have to agree with Doctorandus_P overall. If you're still intimidated by this stuff, then I think it's best you start with a simpler project. Just do a step-down buck converter, no high voltages and no transformer. Maybe also eliminate the current feedback and focus on voltage feedback. Once you get comfortable with that, you can add the other complexities back in.

Also, your schematic shows the SG3525 being powered from the secondary side. Where will its power come from initially...?
 
The following users thanked this post: psydaddy

Offline psydaddyTopic starter

  • Regular Contributor
  • *
  • Posts: 76
  • Country: pl
Re: Building a PSU - Stuck with Compensator Values
« Reply #14 on: August 24, 2026, 03:00:25 pm »
I attached it.

That is quite complex, do you have a known-good circuit you based that on?
At a quick glance, Q6, Q8 look to be reversed.

Thanks
Q6 and Q8 they are correct. They are connected to GND, they have to be the same type.

The steps are producing a (simplified) model of the entire system
Thank you.
By this, do you mean a Bode plot or something else? Once the Bode plot is built, what is the next step? Could you show me an example of a graph with poor stability and explain what you would do with it afterwards?
...if you don't know what can be simplified then start with a model of the entire system. Simulation tool is whatever you find easiest to use.

Why should I use a simulator if I can test it physically?
« Last Edit: August 24, 2026, 03:19:04 pm by psydaddy »
 

Offline psydaddyTopic starter

  • Regular Contributor
  • *
  • Posts: 76
  • Country: pl
Re: Building a PSU - Stuck with Compensator Values
« Reply #15 on: August 24, 2026, 03:18:38 pm »
The schematic with all the right parts connected is much easier to read. Basically, if you see a schematic cut in to little rectangular blocks, and you don't even have a system over view of the whole thing, then you just have to go searching for labels to see how the blocks fit together. And worse: Whether a label connects two or more blocks together. It's a horrible way of drawing schematics and it seems to have become popular in the last 5 years or so.

Thanks. I thought about using buses to at least indicate where the connections go. Maybe I should do that.
Well, yes, it has become popular, but it also helps divide the project into modules, so in some ways it's better when you need to fix or adjust something afterwards.

It's still only a partial schematic. Looks like rectified mains at 1kW, but no power factor correction. Then a bunch of stages for mosfet drivers, then it goes to an transformer that is not in the schematic, and the feedback comes back from "somewhere". Or is TR2 the main power transformer?

There are two transformers. TR2 is the main transformer, while TR1 is the gate-driver transformer. The PWM and feedback loop are handled on the secondary side. The PWM controller (SG3525) is powered by a startup power supply (a small flyback module). Once the main power supply starts up, the auxiliary supply is shut down and the controller is powered from the secondary side.

What's the history of this design? Did you create it yourself or are you reverse engineering / modifying an existing power supply?

I'm designing it myself while studying the process. It's based on other DIY projects, videos, articles and PSU modules that I got my hands on.
I know that going big isn't necessarily the best approach, but building a flyback converter wasn't something I wanted to do because it comes with its own set of problems. The core air gap and compensating an optocoupler seemed like too much trouble.

The design of a 1kW power supply is not a beginner task, and it's a very bad way to attempt to learn control theory. A single wrongly routed track or missed parasitic behavior can completely mess up the stability.
I get you, but even if I build a step-down converter, I still have to learn control theory and deal with parasitic effects. Also, step-down converters have their own internal comparator. If I learn how to handle the feedback loop using an external comparator first, it will be easier than having to figure out how the internal comparator works and how it is connected internally.
At this stage, I’m not struggling with building the PSU itself. I’m struggling with compensating the feedback loop. So I don’t see how building a step-down converter would help me considering I might get myself into new challenges.
« Last Edit: August 24, 2026, 03:23:06 pm by psydaddy »
 

Offline temperance

  • Super Contributor
  • ***
  • Posts: 1609
  • Country: 00
Re: Building a PSU - Stuck with Compensator Values
« Reply #16 on: August 24, 2026, 03:24:36 pm »
The SMPS seems to use voltage mode control. You probably want current mode control to make the compensation matters substantially easier.

Current mode control, some general information
https://www.ti.com/lit/ab/sboa187e/sboa187e.pdf?ts=1787584895539&ref_url=https%253A%252F%252Fwww.google.com%252F
https://www.ti.com/lit/an/snva555/snva555.pdf?ts=1787584950036&ref_url=https%253A%252F%252Fwww.google.com%252F

Current mode control applied to a half bridge:
https://www.ti.com/lit/ds/symlink/lm5039.pdf?ts=1787585017196&ref_url=https%253A%252F%252Fwww.google.com%252F

This app note about balancing windings might also be of interest:
https://www.alldatasheet.com/datasheet-pdf/view/844193/FAIRCHILD/7531.html
 

Offline temperance

  • Super Contributor
  • ***
  • Posts: 1609
  • Country: 00
Re: Building a PSU - Stuck with Compensator Values
« Reply #17 on: August 24, 2026, 03:31:03 pm »
Quote
I know that going big isn't necessarily the best approach, but building a flyback converter wasn't something I wanted to do because it comes with its own set of problems. The core air gap and compensating an optocoupler seemed like too much trouble.

Are you sure about that? A 1 kW half bridge is going to be very difficult to tame. Past a few 100 W parasitics, cross talk and other matters will come to haunt you in your dreams.

The air gap is easy to solve with a diamond cutting wheel. (those hobby tools like cutting wheels).

Compensating the flyback converter (or any other converter):
https://www.onsemi.com/pub/Collateral/TND381-D.PDF
 

Offline temperance

  • Super Contributor
  • ***
  • Posts: 1609
  • Country: 00
Re: Building a PSU - Stuck with Compensator Values
« Reply #18 on: August 24, 2026, 03:33:51 pm »
Quote
Also, step-down converters have their own internal comparator. If I learn how to handle the feedback loop using an external comparator first, it will be easier than having to figure out how the internal comparator works and how it is connected internally.

Which comparator? The one you are probably pointing at is probably the current mode control circuit which makes taming the SMPS much easier.
 

Offline psydaddyTopic starter

  • Regular Contributor
  • *
  • Posts: 76
  • Country: pl
Re: Building a PSU - Stuck with Compensator Values
« Reply #19 on: August 24, 2026, 03:36:20 pm »
Just a note, the input common mode voltage range of the LM324 is (0V - Vcc-2V). With a 5V Vcc that means 0V to 3V and you have the 5V1 ref going into the CV controller, you might want to divide that down.
https://www.ti.com/lit/ds/symlink/lm324.pdf?ts=1787552102715&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FLM324

Oh that's a great point! Thank you.
I'm powering it with 5V but the reference voltage is divided into 2.5V. This is still 0.5V margin. I'm worrying about going lower in the reference voltage to avoid false triggering. What do you think? Should i go lower in the comparator or should use a rail-to-rail opamp instead?
 

Offline temperance

  • Super Contributor
  • ***
  • Posts: 1609
  • Country: 00
Re: Building a PSU - Stuck with Compensator Values
« Reply #20 on: August 24, 2026, 03:45:49 pm »
Those are not comparators but (error) amplifiers.

I think yo should try and build a 10...30 W flyback first if you don't know the difference between a comparator and an amplifier.
 
The following users thanked this post: Someone

Offline psydaddyTopic starter

  • Regular Contributor
  • *
  • Posts: 76
  • Country: pl
Re: Building a PSU - Stuck with Compensator Values
« Reply #21 on: August 24, 2026, 03:51:16 pm »
I’ve been diving into papers, videos, and other resources, but I’m still honestly lost about where to start.
What we discussed in the previous topic is still relevant. Start by determining what the Bode plot looks like for the power stage you built. It can be measured or simulated.

The small signal model of a given topology does not change, and the Bode plot will be similar, only the characteristic points will be in different places.

In the previous version, you used a very complicated capacitor arrangement at the output, and you didn't know the ESR of those capacitors. I wanted to run a simulation to show how it would look, but I couldn't due to unknown parameters.

Is there a way to build a bode plot of my built without a Frequency Response Analyzer? I read about using a function generator and an oscilloscope but i don't know how to connect it. I saw someone connecting a resistor in series with the negative feedback but he didn't explain how to do it. Then he read the phase and the a amplitude, done a few calculus and then plot it with excel.

I'll try to create as simulation based on your previous post, i'll leave it here so you can check if i'm going in the right direction. I tried it once but I lost my LTspice file.

But after i have the Bode Plot built, how do I convert it into the resistors and capacitors of my Type 2 and 3 compensator?
 

Offline psydaddyTopic starter

  • Regular Contributor
  • *
  • Posts: 76
  • Country: pl
Re: Building a PSU - Stuck with Compensator Values
« Reply #22 on: August 24, 2026, 04:45:52 pm »
Which one?
https://www.eevblog.com/forum/projects/help-with-compensator-circuit-halfbridge
https://www.eevblog.com/forum/projects/using-sg3525-cant-put-the-feedback-section-to-work
https://www.eevblog.com/forum/beginners/quick-question-smps-wave-shap

That's a lot of previous considerations. And I am actually not surprised by that. In your opening post in this thread you write:

You are considering my previous threads where I was asking about things I didn’t know, but you’re not taking into account the progress I’ve made so far and the things I’ve learned since then. Most of that progress was based on the answers I received from those threads.

And there is simply no chance that you will learn that from reading forum posts. And attempting to learn this while working on a self designed 1kW powersupply also has very little chance of success. In your other threads (especially "help with half bridge") you've already been given a lot of advise about the feedback circuitry. Starting yet another thread is not going to give you many new insights. You first have to find a way to learn the basics of control loops, and then how to apply that theory.

Well, i would say that the problem is not how and where you ask people for help but how people answer you back.
You are right about learning the basics. And you are right about the feedback I got back then. But there is still some questions remaining. I didn't feel right to open the same thread because the project has evolved and changed some direction.

For learning the basics of control theory and designing stable circuits with opamps, first get some good books. Then start with some hands-on work on much simpler circuits. Something like a linear power supply (20V 1A is a good starting point).  with both adjustable voltage and current limit seems a sensible choice. Or if you want to do SMPS, first design and build a few smaller ones.

This is a new subject for me. How can I tell whether a book is good or not?
On a side note: I’m a teacher. I teach programming languages. My students are always asking me for book recommendations, but I don’t recommend books to them. Of course, there are excellent books out there, but I’m their best book. Why? Because when they need me, I know where they are in terms of their knowledge and can give them the right direction based on that. Books can’t do that. And this is what I'm asking, not for books, but directions on: I got lost, how can i keep going?
Of course I appreciate if you could recommend me good books, but if you could give me direction, that would be excellent.

As for the linear power supply: using transistors to dissipate power as heat in order to regulate the output is a fundamentally different approach. How would building a linear power supply benefit me before moving on to an SMPS?
« Last Edit: August 24, 2026, 04:52:17 pm by psydaddy »
 

Offline psydaddyTopic starter

  • Regular Contributor
  • *
  • Posts: 76
  • Country: pl
Re: Building a PSU - Stuck with Compensator Values
« Reply #23 on: August 24, 2026, 04:58:40 pm »
I have to agree with Doctorandus_P overall. If you're still intimidated by this stuff, then I think it's best you start with a simpler project. Just do a step-down buck converter, no high voltages and no transformer. Maybe also eliminate the current feedback and focus on voltage feedback. Once you get comfortable with that, you can add the other complexities back in.

Also, your schematic shows the SG3525 being powered from the secondary side. Where will its power come from initially...?
Thank you.
I can ignore the Current feedback by canceling it in my circuit because CV leads.
By creating a step-down converter I still need to get create a good compensator. So I would be stuck in the same subject again.
Yes, SG3525 is powered from the sec side. Firstly powered by an auxiliary flyback module and then it gets power from the secondary side to keep working.
 

Offline psydaddyTopic starter

  • Regular Contributor
  • *
  • Posts: 76
  • Country: pl
Re: Building a PSU - Stuck with Compensator Values
« Reply #24 on: August 24, 2026, 05:23:17 pm »
The SMPS seems to use voltage mode control. You probably want current mode control to make the compensation matters substantially easier.

Current mode control, some general information
https://www.ti.com/lit/ab/sboa187e/sboa187e.pdf?ts=1787584895539&ref_url=https%253A%252F%252Fwww.google.com%252F
https://www.ti.com/lit/an/snva555/snva555.pdf?ts=1787584950036&ref_url=https%253A%252F%252Fwww.google.com%252F

Current mode control applied to a half bridge:
https://www.ti.com/lit/ds/symlink/lm5039.pdf?ts=1787585017196&ref_url=https%253A%252F%252Fwww.google.com%252F

This app note about balancing windings might also be of interest:
https://www.alldatasheet.com/datasheet-pdf/view/844193/FAIRCHILD/7531.html

Thank you for the links. The PCBs are already made and ordering new components from china with EU taxation is a crazy move at the moment. So I can't change it all this time.

Quote
Are you sure about that? A 1 kW half bridge is going to be very difficult to tame. Past a few 100 W parasitics, cross talk and other matters will come to haunt you in your dreams.
I read that Optocoupler are not linear and it creates you other issues. The onsemi presentation you shared also get into compensation, so even If i get to find the right air gap size, the right RCD,  the driver and so on, I’ll get back to the same problem. I still have to manage how to build a compensator type 2/3.

Quote
Those are not comparators but (error) amplifiers.
You're right, thanks for pointing that out.
I said “comparators” because they compare whether i− is greater than i+. Since there’s still no compensation added to the PCB (it’s only present in the schematic), they’re not error amplifiers yet :P
« Last Edit: August 24, 2026, 07:06:38 pm by psydaddy »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->