pause to control pumping time

start(p1.t);
pause(pumptime1)
stop(p1.t);
start(p2.t);
pause(pumptime2)
stop(p2.t);
these are my pumping code that i can run very well. However there is still a problem that when I make the pumptime1 smaller than pumptime2, the pumps would stop same time when the pause(pumptime2) is over. while the opposite way can work well. Please help me to figure out whats wrong. Very Thanks!

6 件のコメント

Walter Roberson
Walter Roberson 2018 年 8 月 9 日
I would have expected a structure more like
start(p1.t);
start(p2.t);
pause( max(pumptime1, pumptime2) );
stop(p1.t);
stop(p2.t);
?
Kuang-Yu WANG
Kuang-Yu WANG 2018 年 8 月 9 日
編集済み: Kuang-Yu WANG 2018 年 8 月 9 日
I would like the 2 pumptime run separately. for example
pumptime1=5
pumptime2=10
when open the pump2 first and then pump1 in 10 sec. pump2 can work 10sec and pump1 can work 5sec. however open pump1 first, they would both stop at 10 sec. i don't know how to deal with the later condition. so the structure looks not as same as yours.
Walter Roberson
Walter Roberson 2018 年 8 月 9 日
What is p1.t ? Is it a timer() object?
Kuang-Yu WANG
Kuang-Yu WANG 2018 年 8 月 9 日
yes, but i think p1.t only effect the time in each pumping sequence. if i take off _ pause_. the pumps would just pump once.
Walter Roberson
Walter Roberson 2018 年 8 月 9 日
I suspect we will need to see the functions associated with the timers.
Kuang-Yu WANG
Kuang-Yu WANG 2018 年 8 月 9 日
values=[1 0 0 1 0 0; 1 1 0 1 1 0; 0 1 0 0 1 0; 0 1 1 0 1 1; 0 0 1 0 0 1; 1 0 1 1 0 1]; % perestalitic pump sequence
vleng=length(values); % perestalitic pump sequence
p1.t = timer('TimerFcn',{@pump1_timer, values, vleng},...
'StartDelay',.05,'ExecutionMode','fixedRate');
function pump1_timer(~, ~, values, vleng)
global vc p1
p1.ts = p1.ts +1;
if p1.ts > vleng
p1.ts = 1;
end
vc = vc_set_bits_ac(vc, p1.num, values(p1.ts,:));
end

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSimulink についてさらに検索

質問済み:

2018 年 8 月 9 日

コメント済み:

2018 年 8 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by