Who has never dealt with tedious calibration of a control loop? When it comes to controlling a system so that it follows a target, the first idea might be to use the widespread Proportional-Integral-Derivative (PID) controller. This general purpose controller has several assets: it fits in many cases, it has just 3 parameters and it doesn’t require deep controls background to be set up. It is used successfully in more than 90% of actual industrial applications, most of them being just PI controllers, without derivative action.
However, calibrating those 3 gains is sometimes a cumbersome process. That’s where Simcenter Amesim’s PID tuner helps. In just a few clicks, the controller can be easily calibrated. This article will guide you through the different steps to quickly calibrate a PID loop.
What is a PID? A PID is a feedback controller: it compares the desired setpoint (SP) with the actual value (AV, the feedback loop). The difference between those two is called the error value. From this error, the PID computes three actions:
While individual effects can be easily guessed, cross-effects are less intuitive. Furthermore, there are limits to increasing gains to keep the system stable; we talk about stability margins. That’s why finding a good set of P, I and D gains that fulfills both performance and stability objectives requires some methodology.
There are many ways to calibrate a PID. The famous ones, such as Ziegler-Nichols or Cohen-Coon, are rather experimental: it’s about changing the gains iteratively until the system starts reacting in a certain manner, from which a rule-based method gives the gains. This fits well with “blind calibration”, meaning when the system’s characteristics are not easily reachable. However, when the system is known (for instance when designed in Simcenter Amesim), direct synthesis methods are more attractive. The PID tuner of Simcenter Amesim implements one of them.
In a nutshell, the principle is the following:
- First, extract the “signature” of the system.
- Second, define a target “signature”, for instance, a first order type.
- From those two inputs, a controller can be synthetized automatically with a bit a linear algebra.
Of course, there are limits to this process; a PID can’t handle all types of systems (see for which systems a PID is best in the table below). But with reasonable assumptions and tricks, most of the typical cases can be managed this way. The PID tuner wraps this approach and makes all calculations in the back stage. Let’s illustrate this with an example.
Let’s consider a double mass-spring system where two masses are linked by different springs and dampers. Our objective is to control the position of the middle mass by applying a force on the outer mass. The system with its PID controller looks as follows:
Step 1. System linearization
After running a first simulation with default PID settings, let’s open the PID tuner. What we previously called the “signature” of the system shows up as plots on the right-hand side with the open-loop frequency response and the step response. If you are familiar with linear analysis, you can observe two eigen-frequencies from gain and phase curves around 0.8 Hz and 3.7 Hz. If you are not, that doesn’t really matter. The step response is simpler to understand. Here we observe a 2nd order type response with a rather low damping and low frequency, and a static gain close to 0.025 (e.g. final value). This being said, there is not much to do here; let’s move to the next step.
Tip #1: Adjust the plot axis to the system for the best performance of the tool. The 1st eigen-frequency should be roughly centered on the Bode diagram and the step response should cover a complete transient. Check Options for adjustment.
Step 2. Model estimate
This numerical “signature” must be reformulated into an analytical model from which gains can be derived. The PID tuner offers an auto-fit feature to do this. By default, it tries to fit simultaneously the gain curve and the step response.
Here comes Tip #2: focus on the dominant dynamic, not on higher frequency ones. A PID can only compensate for one eigen-frequency, so it must be selected carefully. In our case, the 0.7 Hz mode is obviously making most of the time response. Therefore, we’d better fit only the step response and let the high frequency part of the gain curve out of scope. This is simply done by changing the fitting target of the tool to “step response”.
With this setting, the tool converges to a second order model at 0.8 Hz and 13% damping. Visually, the gain curve nicely fits for the DC gain (left-hand side of the curve, see in orange) and for the first peak. The second peak and associated damping are not captured. However, the step response is 97.7% correct, so this simplification looks perfectly fine.
Step 3. PID tuning
Let’s proceed with tuning by moving to the second tab. Tuning is as simple as moving the slider bar and checking step response preview in the plot.
Here, the target response is set to 0.5 Hz. The tool indicates that stability margins are good (91.4 degrees and 12.1 dB). The expected step response is shown in blue; the orange dotted curve depicts the theoretical response if the system was exactly matching the 2nd order model from which gains were computed. After applying those gains and updating the simulation, we got confirmation that this tuning behaves as expected.The system is now calibrated! Compared to the open-loop response, the static error is canceled, response time is much faster and upon specification (0.5 Hz) and low frequency mode is drastically damped. Faster or slower response can be easily adjusted by moving the slider bar within acceptable stability margins (check for green lights).
See how it works in this demo:
Saturation and anti-windup
Additionally, the output of the PID controller can be limited to comply with actuator power limits. If saturation is not properly managed, a combination of integral effect and saturation typically leads to windup issues. What is this? Assume that error is continuously increasing. The output of the PID will increase as well and eventually exceed the upper limit of the saturation. This accumulation has no effect until the error starts decreasing again. The integrator output will start decreasing as well, but since its actual value is above the upper limit, it won't reflect on the PID output until it passes below that threshold. That’s the windup effect.
Several anti-windup techniques are available in the PID submodel to avoid this pitfall and synchronize integral action whit output saturation.
The PID gains can be freely edited for fine-tuning. Just toggle the "Manual tuning" button and change proposed gains.
Response preview immediately updates after each change.
Stability margins are displayed in the tool interface with color lights.
They can also be visualized from the “More plots” menu:
For motion control, one classical approach consists in cascading a velocity and a position loop. This scheme has several benefits: faster compensation of perturbation thanks to the inner loop, independent calibration of speed and position response as well as of their limits amongst others.
The PID tuner is fully compatible with this approach and the same process applies: first, tune the inner loop, then outer one after toggling the linearization option of the inner one to “normal” to ensure proper scanning of the inner loop “signature” from the outer one.
The PID tuner in Simcenter Amesim offers an easy way to calibrate a PID loop without prior control knowledge in just a few steps. Whether you are a control expert interested in stability margins or a system designer who just want to make it work quickly, this tool extends control capabilities of Simcenter Amesim and allows for increased efficiency in simulating mechatronic systems.
- Any questions? Feel free to contact me at firstname.lastname@example.org or post your question on our Simcenter Amesim forum.
- To learn more how system simulation helps frontload control validation, register for our on-demand webinar.