How to execute subsystem once at startup
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to figure out how to do the Simulink equivalent of the Arduino 'void setup' in my program. For my program I want to have a startup mechanism to test my physical system, but it only needs to run once when the program is started. How would I go about doing this?
0 comentarios
Respuestas (1)
Madhu Govindarajan
el 30 de Oct. de 2017
Simulink works on time, so it looks like you need to 1) read the clock time of the simulation model using the clock block - https://www.mathworks.com/help/simulink/slref/clock.html. 2) Use this to enable an enabled subsystem at the appropriate time - https://www.mathworks.com/help/simulink/ug/enabled-subsystems.html 3) Put all your contents that can make the system startup inside this enabled subsystem. 4) Write logic that will disable the subsystem at the appropriate time.
Of course, there could be other possible workarounds.
2 comentarios
Andrew Tilmouth
el 16 de Oct. de 2018
If you have an atomic sub system which is set to a sample time of 0.02 and the clock is placed inside this system (connected to an If block checking for u1 == 0 and then to an If action subsystem containing the blocks that you want to run once) this will give the error shown below:- But it's not possible to change the clock sample time, there is no option to do that. How can this problem be solved, I am using 2013a so I do not have the new Initialize block although I am not sure if it is designed for that purpose anyway.
Any help would be appreciated, there is plenty of ECU code that needs to only run once at start up, this is a common requirement that needs to be modelled.
thanks
'ModelY/Clock' has an invalid sample time of [0, 0]. Periodic atomic subsystem 'ModelX' may contain only blocks that have constant (inf), inherited (-1), or periodic (0.02) sample times. To resolve this issue, try to change the sample time with one of the following: - Configuring the block 'ModelY/Clock' to inherit the sample time - Configuring the subsystem 'ModelX' to inherit the sample time. If you cannot change the block sample time, remove the problem block from the subsystem.
Madhu Govindarajan
el 16 de Oct. de 2018
Maybe you can share a simpler version of your model to help me understand the issue better and then I can help.
MathWorks Technical Support might be a better resource regardless :)
Ver también
Categorías
Más información sobre Modeling en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!