PID Controller - non-adjustable parameters
20 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I am using PI controller (original library name "PID Controller") component.
Customized, it looks like on the following picture:
Project requirements are that all the "parameters" are customizable, and changeable during the runtime.
Most of them, I succeeded to configure as "inputs", and that works.
Issue comes with certain parameters, which become hardcoded in the model, and therefore hardcoded also in the generated C code. These parameters are: Integrator saturation limits (Upper limit, Lower limit)
Is there a way to feed these parameters also externally? Or, is there a better common practice to handle these situations? Reason for doing so is the project maintenance. Different users could code their parameters in external memory regions, without need to reflash an MCU and touch the control-loop algorithms.
4 件のコメント
Aquatris
2024 年 10 月 23 日
Then my next question is there a specific reasong to set the integrator saturation level independently then the output saturation value?
The output saturation value already disables the integrator via clamping (as selected by the drop down menu). So unless you put an integrator saturation value that is lower than the output saturation value (which I cannot think of a solid reason), the integrator saturation value would not do anything.
採用された回答
その他の回答 (1 件)
Aravind
2024 年 10 月 29 日 5:07
It seems like you want to configure the saturation limits of the integrator externally during code generation. You can accomplish this by setting the storage class of the parameters representing the saturation limits to "ImportedExtern." This approach will make the generated code declare the parameter as a global variable using the "extern" keyword in C. You can then define the value of this variable in a separate header file, allowing users to adjust the parameters without altering the MCU firmware or control algorithms.
To change the storage class of a parameter in Simulink, you can follow these steps:
- Open your Simulink model, go to the "Modeling" tab, and click on "Model Explorer."
- In "Model Explorer," navigate to the "Base Workspace" or the specific model workspace. Find and select the parameter you want to modify.
- Double-click on the parameter to open its properties dialog. Locate the "Storage Class" field and select the needed storage class from the dropdown menu.
- Click "OK" or "Apply" to save the changes. Update your model by clicking the "Update Model" button or pressing Ctrl+D.
- Regenerate the code to ensure the changes are applied.
You can also use the "Code Mappings Editor" to achieve this. For more details, you can refer to the documentation here: https://www.mathworks.com/help/releases/R2024a/rtw/ref/codemappingseditorc.html.
Here are some additional resources to help you with choosing storage classes for parameters in your Simulink model:
- Choosing storage class for controlling data representation in generated code: https://www.mathworks.com/help/releases/R2024a/rtw/ug/choose-a-built-in-storage-class-for-controlling-data-representation-in-the-generated-code.html
- Configuring parameters for Code generation: https://www.mathworks.com/help/releases/R2024a/rtw/ug/configure-parameters-for-code-generation.html
- Different storage classes available for code generation: https://www.mathworks.com/help/releases/R2024a/ecoder/ug/storage-classes-for-code-generation-from-matlab-code.html
- An example on changing storage classes and their effect on the generated code: https://www.mathworks.com/help/releases/R2024a/rtw/ug/configure-model-data-for-c-code-generation.html
I hope this helps resolve your query!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Deployment, Integration, and Supported Hardware についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!