How to use the graphic calculator control loop compensator
To use the calculator, select the type of compensator. Then enter the values of the circuit components. Press the 'Calculate' button or move the sliders to see the frequency response of the compensator as well as the location of the poles and zeros. The sliders will help you understand the impact of each component on the frequency response of the compensator.
Understanding the control loop compensator
Hello electronics enthusiast, so you're wandering the internet while your control circuit is not behaving, right? Well, you're lucky to have found this calculator. I've been in your shoes many times, so I think I can help you a bit. If you're like me and equations don't mean much to you, this page will help you develop intuition. If you already know about control, feedback... Stop reading and start playing with the calculator. If not, keep reading. By the way, while preparing the calculator I reviewed a well-read article (SLVA662 – July 2014 Demystifying Type II and Type III Compensators Using Op-Amp and OTA for DC/DC Converters), which is quite good if you like math. However, I warn you that there is an error in equation 29 that almost drove me crazy :D. In any case, I thank SW Lee and Texas Instruments for the article! Also, I'm sure there is potentially some error in this calculator, so if you see something strange, leave me a comment below so I can fix it! (I also appreciate if you tell me you liked it, eh🤪).
Many feedback systems can be unstable under certain conditions. In short, this means that the system in question will not behave as expected. Let's work with a familiar example. You step into an unknown shower and the water temperature fluctuates wildly: now it's hot (ouch!), you adjust the knobs, but now it's cold (brrr), now hot, now cold... Sounds familiar? Well, that's an unstable system. In this case, the system is the shower plus you touching it, and you are the controller. What happens is that, after a while, you start to understand the behavior of that shower and control it better. That's what a control loop compensator does: it controls the system to behave as we want. In a more 'engineering' way, we can say that the system has different elements:
- A process, which is what we want to control. In the case of the shower, the process is the regulation of the water temperature.
- A sensor, which tells us how the process is. In the shower, the sensor is you, who touch the water and decide if it's hot or cold.
- A controller, which realizes there is an error or, in other words, a difference in water temperature between the desired and the actual at that precise moment. The concept of error is very important. By observing this error, we can decide what to do to bring the system back to its desired working point. In the shower, the controller is you, who decide whether to adjust the knobs or not.
- An actuator, which is what makes the process change. In the shower, the actuator is your hand and the faucet.
- A control loop compensator, which is what ensures the system behaves as we want.
Control manages the system so that the output is as desired, even if conditions change. For example, there's always that careless person who starts washing dishes with hot water while you're showering. You start yelling but with the noise of the water, they don't hear you, and you resign yourself to solving the problem on your own. What do you do? You turn up the hot water. That is, you started from a correct working point and were happy. Someone disturbed the system, but you acted to bring it back to its working point. That's a control loop compensator.
This compensator can have different characteristics. For example, it can react faster or slower. Or it can react more aggressively or less. Following the shower example, this would be having more patience before starting to adjust the knobs or quickly turning them to the extremes to react faster at the risk of overshooting the desired temperature. In electronics, we achieve this by implementing the compensator with different topologies, and the characteristics of a compensator are seen in its transfer function. The transfer function is an equation (usually represented graphically) that tells us how the compensator behaves depending on the frequency. The left side of the graph indicates how the compensator reacts to slow changes, and the right side shows the behavior to fast stimuli. The vertical axis indicates how 'big' the compensator's response is. Normally, compensators react strongly to slow changes and lose their ability to react as the frequency of disturbances to the system increases. One very important thing you should know: the stability and behavior of a system are not defined solely by the compensator. The system itself has a huge influence. For example, no matter how expert you are at controlling showers, each shower has its dynamics and inertia. What you will do is adapt to those behaviors to improve the overall system response. Therefore, when we design a compensator, we do it based on the system we want to control. If the system changes, the compensator must also change.
Types of compensators
There are countless ways to implement a control loop compensator. However, some smart people have found some topologies that work well in most cases. The reasons they work well are because they use few components, which are also cheap and small, and are relatively easy to adjust (especially if you use this calculator 😜). These compensators have behaviors similar to classic PID controls, although mixed and difficult to see. I don't want to get into talking about PIDs because we would get into a mess that would distract us, but I recommend you read a lot about them if it's the first time you hear these concepts. With this introduction, let's look at the three types of compensators:
- Type 1: This compensator is the simplest of all. It is an integrator made with an operational amplifier with a resistor and a capacitor. This type of compensator aims to minimize steady-state error. That is, if the system has a constant error, this compensator will eliminate it. This characteristic is given by a pole at the origin. However, this compensator does not allow us to adjust the phase of the feedback loop. If you go to the calculator, you will see that it is constant no matter how you change the value of the components. Being able to adjust the phase is important to prevent the system from becoming unstable, we will see that a little later.
- Type 2: This compensator is a bit more complex. It maintains the good characteristics of Type 1 and also allows phase adjustments. Its transfer function includes an additional zero and pole. You can place them at any frequency you want to shape the frequency response, both in magnitude and phase. This compensator allows you to make phase adjustments of up to 90º if you separate the zero and pole enough.
- Type 3: This compensator is the most complex. It has two zeros and two poles, in addition to the pole at the origin. This gives it enormous flexibility to adjust the frequency response. You can compensate the phase up to 180º. This compensator is the most versatile of all, but also the most complex to adjust. Place the zeros where you want to start gaining phase and the poles where you want to start losing it.
But well, you may wonder why someone would use a type 1 or type 2 if type 3 is so versatile and allows gaining so much phase. Well, the answer is simple: because type 3 is more complex to adjust. If you have a system that behaves well with a type 1 or 2, don't complicate your life with a type 3. In general, apply the KISS principle (sing: Love Guuuuun... Ups, Keep It Simple, Stupid). Now, seriously, you need to know your system well before deciding on one type of controller or another. You need to ask yourself some questions: Is my system stable without a compensator? Do I know the transfer function of the feedback loop? Does it have phase jumps that are dangerous? If the answer to these questions justifies a type 3, go for it. If not, it's not necessary. Better a well-adjusted type 2 than a poorly adjusted type 3.
How to adjust a compensator
I will explain below what each component does in types 2 and 3 so you can see the mess it is to use type 3.
- Function of the components in a type 2 compensator
- R1: shifts the gain curve down (if R1 increases) or up (if R1 decreases).
- R2: moves the zero and pole to the left (if R2 increases) or to the right (if R2 decreases). Moves them in equal proportion.
- C1: moves the zero to the left (if C1 increases) or to the right (if C1 decreases).
- C3: moves the pole to the left (if C3 increases) or to the right (if C3 decreases).
As you can see, each component has a fairly predictable function. For example, if you want to increase the bandwidth of your system, you can decrease R1. That could reduce the system's stability, but you can easily correct it by decreasing R2 to move the phase 'boost' to the new cutoff frequency. With C1 and C3 you can easily shape your compensator. Now we will see that type 3, although it can give you a phase 'boost' of up to 180º, is more complicated to adjust. I will explain component by component and then make a drawing to make it clearer. Anyway, the best thing is to play with the calculator to better understand how each component behaves.
- Function of the components in a type 3 compensator
- R1: moves the zero to the left (if R1 increases) or to the right (if R1 decreases).
- R2: moves the other zero and one of the poles to the left (if R2 increases) or to the right (if R2 decreases). Moves them in equal proportion.
- R3: moves the other pole to the left (if R3 increases) or to the right (if R3 decreases).
- C1: moves the second zero to the left (if C1 increases) or to the right (if C1 decreases).
- C2: moves the first zero and the second pole to the left (if C2 increases) or to the right (if C2 decreases). Moves them in equal proportion.
- C3: moves the first pole to the left (if C3 increases) or to the right (if C3 decreases).
As you can see, in this case, some components affect more than one zero or pole. When that happens, a desired effect may be accompanied by an undesired one, which will motivate another change that may have the same problem and require several iterations. But well, with the calculator I make your life easier! In the following image, I leave you a drawing that clarifies a bit which components affect which parts of the function:
Well, with this we have finished this little introduction to compensators. I recommend you read about negative feedback and stability to complete your understanding. If you have any questions, leave me a comment below and I will answer as soon as possible. Oh! And if you liked the calculator, share it with your colleagues. See you next time!
Loop Compensator LTSpice Simulation
Download this LTSpice simulation to analyze the frequency response of your control loop compensator. You can use it as a starting point to create your own compensator designs and verify the stability of your control circuits. The file is provided for frequency response analysis and includes examples of Type 1, Type 2, and Type 3 compensators.
Frequently Asked Questions
-
What is loop compensation and why is it important?
Loop compensation shapes the frequency response of a power supply to ensure stability. Proper compensation prevents oscillations, reduces output impedance, increases rejection to noise coming from the line and improves transient response. -
When should I use a Type 2 vs Type 3 compensator?
Use Type 2 for current-mode control or when phase boost requirement is low (<90°). Use Type 3 for voltage-mode control or when you need a large phase boost (>90°). -
How do I choose the right crossover frequency?
Select a crossover frequency that is at about 10 times lower than the switching frequency to avoid that the control tries to compensate high frequency changes due to change of state in semiconductors. -
What causes instability in a control loop?
You want to avoid having positive feedback (avoiding right-hand plane poles in the denominator of your loop transfer function). A simple way of checking this is simulate your complete control loop and view BODE plot to ensure that the phase margin (PM) is greater than 45° and the gain margin (GM) is greater than 10 dB. -
How do I verify my compensator design?
You should verify it using a simulation (like LTSpice) to check the Bode plot for Phase Margin (PM) and Gain Margin (GM), and test the load transient response.