How to use PID controller
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Muhammad Ali
el 4 de Sept. de 2024
Comentada: Yifeng Tang
el 17 de Sept. de 2024
I have a control loop such that:
- The loop starts by calculating the error between the desired and measured temperature.
- The relay block turns the heating system on or off based on this error, with a hysteresis of ±5 degrees to prevent frequent switching.
- The output from the relay (on/off signal) is passed through a transfer function to simulate the dynamics of the system (introducing a delay or lag in the heating response).
- The scaled output from the transfer function (now a power signal) is converted into a physical signal.
- Finally, the physical signal controls the heat source, which in turn affects the system's temperature.
I want to use PID controller block instead of this, how can I achieve that?
4 comentarios
Yifeng Tang
el 17 de Sept. de 2024
I've done something similar to this. PID tuner does the job. It will first attempt to linearize the fluids systems, which is usually not that linear :p So it matters at which time you do the linearization (I think you can choose that in the tuner). Usually t=0 is NOT a good point to do the linearization. I've found that using a time where the system has stablized tends to give you a linearized system that's more useful.
Respuesta aceptada
Shivam Gothi
el 5 de Sept. de 2024
As mentioned by @Sam Chak, The most proper way to design a PID controller is by modelling of plant and making its linear model. You can then use an input-output transfer of this model to decide the PID controller gains that satisfies the required time or frequency domain specifications.
However, I was just searching across the MATLAB documentation and discovered that SIMULINK offers a convenient feature that might interest you.
The "PID Tuner App" in SIMULINK can automatically tune PID controller parameters to achieve your desired time or frequency domain response. It has an impressive graphical user interface, allowing the user to enter rise time, settling time, and other time domain specifications to be satisfied by the resultant closed loop system. When the "PID Tuner" launches, the software computes a linearized plant model seen by the controller. The software automatically identifies the plant input and output, and uses the current operating point for the linearization
For further information on the "PID Tuner App," you can refer to the following documentation:
I tried to reproduce the system, somewhat similiar to that demonstrated by you in the attached image. Below given figure demonstrates it. I have also attached the Simulink file along with this answer.
Properties of blocks:
System response with “on/off” relay:
I set a reference temperature of 305 kelvin, and the hysteresis of +-2 degrees. Below given is the response of temperature of the pipe with respect to time. You can see that it is between hysteresis band, but non-steady.
System response with PID controller:
Follow the following steps to use a PID controller:
- Add a “PID(s)” block (as shown in below image) to your model.
- Open the block parameters of "PID controller" by double clicking it. Go to the “main” tab, and click on “tune” button under the “Automated tuning” section.
- “PID tuner App” will open as shown below:
- Adjust the “rise time” and “transient behavior” from the sliding bars as per your requirements.
- To view the (“P”, “I”, and “D”) values computed by “PID tuner App, click on “show parameters” icon on the top menu bar.
- Click on ” Update Block” button on top menu bar to automatically set the parameters of PID controllers.
- Now close the “PID tuner App” and open the “block parameters” of “PID controller”. You will see the updated values of the controller gains.
- Run the model.
- The below given scope waveform shows the temperature of the pipe when PID controller is used.
Conclusions:
We can see that now temerature is controlled in very smooth way and steady state error is also zero.
This is the basic guidline to automatically tune the PID controller for your system. I have attached the simulink file. You can make changes to it according to your requirements, but repeat the above steps to tune your "PID" parameters again, as the plant is changed.
I hope this helps and is as per your expectation!
Más respuestas (1)
Shivam Gothi
el 16 de Sept. de 2024
I followed the same steps as suggested in above answer and got good results. I am attaching the modified simulink file.
You need to first connect the PID controller block in the network and then click on "tune" button. The tuner app will decide the gains best suitable to achieve the specified performance. Below given is the screenshot of "PID tuner app" I used in your attached model.
the screenshot from scope inside the "temperature control block" found inside "heating system" is shown below:
Please let me know whether this is correct and as per your expectation.
3 comentarios
Shivam Gothi
el 17 de Sept. de 2024
I have saved and attached the Simulink model files in the R2023a version. Please let me know if you are able to open them successfully. Additionally, if any of the responses meet your expectations and prove useful, I would appreciate your feedback or if you could mark the answer as accepted.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!