Sending PID gain values from Simulink PID block to Matlab workspace

11 ビュー (過去 30 日間)
Emmanuel
Emmanuel 2012 年 5 月 6 日
回答済み: Mohit Bhatia 2019 年 2 月 13 日
Hey Guys
Im in the process of tuning a PID controller. I have written a processing script to analyse the step and frequency response of the system. But I don't want to manually enter the PID gain values in the .m file every time I tune the PID using Simulink.
Is there any way to send the PID gain values from the PID block in Simulink to the Matlab workspace automatically after tuning manually?
I really appreciate any help as this would help me speed up tuning now and in the future.
Thanks E Sunil (TU Delft)

採用された回答

TAB
TAB 2012 年 5 月 7 日
You can retrieve the gain values of PID block in your m-script. See below piece of code.
% Get the values from block
P_str = get_param('PID_Block_Path','P');
I_str = get_param('PID_Block_Path','I');
D_str = get_param('PID_Block_Path','D');
% Convert string to values
P_val = str2double(P_str);
I_val = str2double(I_str);
D_val = str2double(D_str);
% If required send values to base workspace
assignin('base','P_val_base',P_val);
assignin('base','I_val_base',I_val);
assignin('base','D_val_base',D_val);
  1 件のコメント
Emmanuel
Emmanuel 2012 年 5 月 10 日
Thanks a lot. This worked. My life will be a lot simpler now !!

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

その他の回答 (1 件)

Mohit Bhatia
Mohit Bhatia 2019 年 2 月 13 日
Hello
I want to tune the PID controller. For that how can i connect my model to .m file
Thank you

Community Treasure Hunt

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

Start Hunting!

Translated by