Thread Subject: Simulink: Pause in a while/for cycle

Subject: Simulink: Pause in a while/for cycle

From: Giacomo

Date: 18 Jun, 2009 07:19:01

Message: 1 of 4

Hello everyone, I have a serious problem with my project: I cant find a way to make Simulink wait a certain amount of seconds.
The project is about inflating an item in steps, so for example: inflate to 0.5 bar, pause for 30 seconds, inflate again to 1 bar, pause for 30 seconds, and so on.
I have a "do while" cycle inside a "for" cycle. The "for" cycle is set out to run for the number of inflating steps needed; inside the "do while" I have a condition that, while its verified, sends an analog output signal to open a valve and when the condition is false, the valve will be closed and the "do while" cycle ends. Now the problem is that, before the "do while" ends, I must have a pause, before the next inflating step begin.
I've tried in many ways:
- anything that involve simulink "clock" cannot be used cause it uses continous sample time and inside iteration cycles only (inf) or inherited (-1) can be used.
- I created a matlab script that works pretty well with "datestr(now)" command; in matlab command window runs perfectly, but if I put it in a Simulink Embedded Matlab Function block and try to built it gives me various incompatible errors.

Any ideas? I cant belive a so powerful software like Simulink cannot take a giving time pause during the simulation inside an iteration cycle...

Thank you

Subject: Simulink: Pause in a while/for cycle

From: Steven Lord

Date: 18 Jun, 2009 14:30:31

Message: 2 of 4


"Giacomo " <bigbig1982@hotmail.com> wrote in message
news:h1cpp5$6of$1@fred.mathworks.com...
> Hello everyone, I have a serious problem with my project: I cant find a
> way to make Simulink wait a certain amount of seconds.
> The project is about inflating an item in steps, so for example: inflate
> to 0.5 bar, pause for 30 seconds, inflate again to 1 bar, pause for 30
> seconds, and so on.
> I have a "do while" cycle inside a "for" cycle. The "for" cycle is set out
> to run for the number of inflating steps needed; inside the "do while" I
> have a condition that, while its verified, sends an analog output signal
> to open a valve and when the condition is false, the valve will be closed
> and the "do while" cycle ends. Now the problem is that, before the "do
> while" ends, I must have a pause, before the next inflating step begin.
> I've tried in many ways:
> - anything that involve simulink "clock" cannot be used cause it uses
> continous sample time and inside iteration cycles only (inf) or inherited
> (-1) can be used.
> - I created a matlab script that works pretty well with "datestr(now)"
> command; in matlab command window runs perfectly, but if I put it in a
> Simulink Embedded Matlab Function block and try to built it gives me
> various incompatible errors.
>
> Any ideas? I cant belive a so powerful software like Simulink cannot take
> a giving time pause during the simulation inside an iteration cycle...

So you're looking for your Simulink simulation to operate in real time?

http://www.mathworks.com/support/solutions/en/data/1-15JAW/

Or if you just need the simulation to delay a signal for 30 seconds of time
according to the simulation time, search the Block Reference page for Delay
blocks (like the continuous Transport Delay)

http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/slref/transportdelay.html

http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/slref/f4-4889.html

--
Steve Lord
slord@mathworks.com

Subject: Simulink: Pause in a while/for cycle

From: Giacomo

Date: 18 Jun, 2009 15:21:02

Message: 3 of 4

Thanks Steve, but the problem is that all those examples uses "clock", but in an iteration cycle like "for" or "while" I cannot put a clock or simulink gives error cause "clock" doesnt work with inherited (-1) or (inf) sample time :(

Subject: Simulink: Pause in a while/for cycle

From: Giacomo

Date: 24 Jun, 2009 17:57:01

Message: 4 of 4

Up, anyone?

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
simulink Giacomo 18 Jun, 2009 03:24:03
pause Giacomo 18 Jun, 2009 03:24:03
iteration Giacomo 18 Jun, 2009 03:24:03
while Giacomo 18 Jun, 2009 03:24:03
for Giacomo 18 Jun, 2009 03:24:03
rssFeed for this Thread

Contact us at files@mathworks.com