Simulink Closed-Loop PID Autotuner生​成PLC代码不是完整​的功能块(FB)

Simulink Closed-Loop PID Autotuner通过PLC Coder使用TIA Portal生成PLC代码导入TIA Portal软件中,然后在编程软件中使用"从源生成块"自动生成PLC功能块(FB),是分散的小功能块(如下图所示),而不是完整的Closed-Loop PID Autotuner功能块(FB),请问Closed-Loop PID Autotuner模块如何生成的PLC代码导入PLC编程软件中才能生成完整的PLC功能块(FB),功能块接口和Simulink Closed-Loop PID Autotuner一样。

답변 (1개)

Maithili
Maithili 2026년 2월 23일 21:10

0 개 추천

Hi @rizhen,
Here are the steps to generate code for the Closed-Loop PID Autotuner block using PLC Coder:
  1. Put the PID Autotuner block into a "subsystem" block
  2. Set that "subsystem" block to be "atomic"
  3. With above two, it should generate one PLC FB
Hope this is helpful, thanks

댓글 수: 2

rizhen
rizhen 2026년 3월 2일 3:10
편집: rizhen 2026년 3월 2일 3:12
Hi,Maithili,
Thank you very much for your explanation. The Simulink model in my diagram is based on an Atomic Subsystem, and code was generated using PLC Coder. However, when importing it into a PLC IDE such as TIA Portal or TwinCAT 3, the blocks are scattered as individual FB blocks instead of appearing as a single, complete FB block like the Closed-Loop PID Autotuner block. If you have tried it, you should also find that this is the case.
Maithili
Maithili 대략 12시간 전
Hi @rizhen,
Thank you for the clarification. In addition to generating code for the top-level subsystem, there are also several other functions and function blocks (FBs) generated that serve as utility or helper functions. Together, these components implement the closed-loop PID autotuner subsystem algorithm specified by your model.
However, all you would need to call is the top-level FB, which has the same name as your subsystem. Based on your code, your subsystem is named 'Atomic Subsystem', so the corresponding FB is called 'Atomic'. This FB contains all the code required for the Closed-Loop PID Autotuner implementation.
You can also select the testbench option in the PLC configset option to generate testbench program, which shows how to call the top subsystem FB.
I hope this helps clarify your question.

댓글을 달려면 로그인하십시오.

제품

릴리스

R2025b

질문:

2026년 1월 23일

댓글:

대략 12시간 전

Community Treasure Hunt

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

Start Hunting!