Can i apply a series of values as Kp Ki and Kd values instead of just one single value. Like lets say it starts from 1,2,3.. and after the last value it stays at that value till end of simulation.

 採用された回答

Paul
Paul 2023 年 7 月 22 日

1 投票

Set the 'Source' parameter to 'external' as in doc for PID block. The you can calculate the gains external to the block as functions of time however is needed and feed the gain values into the block as inputs.

8 件のコメント

Manikanta Aditya
Manikanta Aditya 2023 年 7 月 22 日
Thanks Paul for your reply, but could you explain with more details of the steps to follow, please?
Paul
Paul 2023 年 7 月 22 日
Not without more information about what you don't understand. Do have a Simulink model? Does that model include the PID block? Is that Source parameter set to 'external'? Etc. Where are you getting stuck?
Manikanta Aditya
Manikanta Aditya 2023 年 7 月 22 日
編集済み: Manikanta Aditya 2023 年 7 月 22 日
I do have PID Controller block, and the parameter is set to external too, but My question is like how to apply a series of values as Kp Ki and Kd rather than a single value in the block parameters? Like lets say it starts from 1,2,3.. and after the last value it stays at that value till end of simulation.
Sam Chak
Sam Chak 2023 年 7 月 22 日
Hi Mani, I think you want to apply the time-varying gain function, Kp(t) = Staircase function, which can be easily constructed by visualizing how the gain jumps from one value to another, using a few Heaviside functions, kᵢ·θ(t – Tᵢ).
Paul
Paul 2023 年 7 月 22 日
Use the blocks available in Simulink to compute Kp (and the others) as whatever function of time is desired.
Do you really want the Kp gain to start at 1 and then keep increasing by 1 at a fixed rate? If so, what is that rate? If not, what is the actual function of time that is Kp(t)?
Manikanta Aditya
Manikanta Aditya 2023 年 7 月 23 日
I want to increase by a set of values instead of one value, so I want to know about this, like I want like the below mentioned
% Create a PID controller block.
pid_controller = pid(1, 1, 1);
% Create a list of KP values.
kp_values = [1, 2, 3, 4, 5];
% Create a list of KI values.
ki_values = [4, 5, 6, 7, 8];
% Create a list of KD values.
kd_values = [7, 8, 9, 10, 11];
Sam Chak
Sam Chak 2023 年 7 月 23 日
I see now, you are not using Simulink. So you want to hold the last value of each gain?
But I think that the pid() function does not accept time-varying parameters. However, you can possibly use the time-sampling approach or event-triggered method to update PID controller
kp_values = [1, 2, 3, 4, 5];
ki_values = [4, 5, 6, 7, 8];
kd_values = [7, 8, 9, 10, 11];
kp_values(end)
ans = 5
ki_values(end)
ans = 8
kd_values(end)
ans = 11
pid_controller = pid(kp_values(end), ki_values(end), kd_values(end))
pid_controller = 1 Kp + Ki * --- + Kd * s s with Kp = 5, Ki = 8, Kd = 11 Continuous-time PID controller in parallel form.
Manikanta Aditya
Manikanta Aditya 2023 年 7 月 23 日
Thanks @Sam Chak!, It was helpful

サインインしてコメントする。

その他の回答 (1 件)

Sam Chak
Sam Chak 2023 年 7 月 23 日

1 投票

If you set the PID controller block to have external inputs for the control gains as advised by @Paul, then the configuration should look like the following block diagram. However, I'm unsure how you intend to set up the filtered derivative, since yours has only Kd.

カテゴリ

製品

リリース

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by