Sending PID gain values from Simulink PID block to Matlab workspace
4 次查看(过去 30 天)
显示 更早的评论
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)
0 个评论
采纳的回答
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 个)
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
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!