How to solve "invalid setting for parameter 'Gain' " while trying to simulate with only integral gain of a PID controller?
100 views (last 30 days)
Show older comments
Hi,
I am trying to add an 'integral action' into a wind turbine model to remove steady state traking error. I only need to use the integral gain. I have used MATLAB sprict to calculate the integral gain 'Ki', and used the PID controller in the Simulink with having 'I' controller selected. When I run the simulation, It gives this error:
Error using DAC (line 251)
Invalid setting in 'DAC_si/IPC/DAC/Integral action 'Ki'/I Gain/Internal Parameters/Integral Gain' for parameter 'Gain'.
I would appriciate if anyone couldn help me on solving this. Thank you.
Best regards
3 Comments
Answers (1)
Daniel
on 10 Jul 2023
Although there's not a lot that can be said without seeing the actual model and script involved, the error "Invalid setting ... for parameter 'Gain'" would seem to indicate that you're trying to set the Gain parameter to something invalid for that parameter. You have to set the Gain parameter for a block to a string or character array. So, for instance, to set the gain to 3, you would have to execute set_param(gcb,'Gain','3'), not set_param(gcb,'Gain',3).
You might also consider setting the Gain parameter to a variable which you define in the MATLAB workspace or in the model workspace. The Simulink Onramp gives some examples of how to pass variables from MATLAB to Simulink in the "Simulink and MATLAB" module, if that's helpful to you. If you go that route, you can just set that variable in your DAC script, without needing to worry about interfacing directly into the Simulink model and getting the set_param syntax correct.
2 Comments
Daniel
on 10 Jul 2023
I'm not familiar with tunable parameters and realp, so I won't be able to help with that error without a model to run. Perhaps someone else has more experience.
That being said, do you need to modify the parameter value during a single simulation? Or do you only need to modify it between simulations?
If the parameter can remain constant over the course of a simulation, you shouldn't need to use tunable parameters at all. Just set Ki to whatever value you want the gain to take, in the MATLAB script, and set the value of the gain block to Ki in the model.
If the parameter needs to update over the course of the simulation, you can adjust the value in MATLAB during simulation. Running set_param(<model>,'SimulationCommand','update') should update the Simulink model to use the new value from the MATLAB workspace.
See Also
Categories
Find more on Naming Conventions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!