How to process CMEX S-Function blocks with variable steps until no signal changes? (Model is interacting with TwinCAT 3)

Hello, I'm working on a simulink model, which shall process and exchange data with TwinCAT to simulate an IO-Module. I'm using a variable step solver and trigger a reading access by each rising edge of a pulse generator. The received message is forwarded to a chain of cmex s-function blocks, which processes the data and generates an answer. This takes several model cycles, because (as far as I know) passing data from a s-function block to the next requires one cycle.
My expectation was, that simulink is calculating as long as it reconizes signal changes - i.e. it is performing simulation loops until the data is processed. But I can see, that each model cycle is initiated only by an edge of the pulse generator. My goal is to configure my model that it reads data from TwinCAT and process it in several cycles, which are not triggered by the pulse generator.

回答 (1 件)

Mark McBroom
Mark McBroom 2017 年 11 月 29 日
In your design, the s-function blocks will run only once each time a pulse occurs. If you want the s-function blocks to run N times for each each, you will need to put the blocks inside the rectangle into a while-iterator or a for-iterator subsystem.

この質問は閉じられています。

製品

質問済み:

2017 年 11 月 28 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by