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.

Answers (1)

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.

This question is closed.

Products

Asked:

on 28 Nov 2017

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!