Fixed-Step Discrete Timing

4 views (last 30 days)
Dana
Dana on 13 Dec 2013
Answered: Suneesh on 17 Dec 2013
How can I add a "Counter Limited" block in Simulink that only counts at a specific time interval, such as 1 second increments?
Looking at the Simulink Solver Pane Documentation, I understand that:
  • Simulation time is not the same as clock time. For example, running a simulation for 10 seconds usually does not take 10 seconds. Total simulation time depends on factors such as model complexity, solver step sizes, and computer speed.
Is there a way to slow it down so that 10 seconds does take 10 seconds to execute?
My test setup is a "Counter Limited" block and a "Display" sink block. The "Counter Limited" has an upper limit of 36 and I have set the sample time to 1 (naively assuming it would be 1 second)
In the configuration parameters I have set the following: Stop time: inf
Solver Options: Type: Fixed-Step Solver: discrete (no continuous states) Fixed-Step size: auto
Tasking and Sample time options: Periodic sample time constraint: Unconstrained Tasking mode for periodic sample times: Auto unchecked for the last two options.
Currently what this does is appears to be running at an extremely fast speed where the numbers look like they are jumping around all over the place (2,7,33,17,28,4).
My end goal is using the Vehicle Network Toolbox I have to send out a CAN message @245ms intervals where the data is different each send (it cycles through 36 sets of values) I have these values going through a multi-port switch into the CAN pack and am using the counter to drive the switch.
Thank you

Answers (1)

Suneesh
Suneesh on 17 Dec 2013
What you are trying to achieve is to have the simulation run in "real time". If you do not require hard (exact) real time constraints then consider:
MathWorks does have software for real time simulation. See:

Categories

Find more on General Applications in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!