working with Real-time windows target by M-file

1 回表示 (過去 30 日間)
study
study 2013 年 12 月 27 日
コメント済み: study 2014 年 1 月 8 日
I'm just getting to know and develop a simple control with MATLAB's real-time windows target.
Basically, the tool supports real-time application developed with Simulink block diagram with just a interface card.
My control application is fairly simple. The pseudo-code can be described shortly as:
while (1)
{
if (flg)
{
valve.open();
}
if (pressure > thres_pressure_B) && (flg)
{
valve.off();
wait(5s);
valve.reverse();
flg=0;
}
if (pressure < thres_pressure_A) && (!flg)
{
prog.exit();
}
}
with pressure: real-time sensor feedback reading valve: value transmitted to I/O card
where the aim of the control is to vary the pressure (in a container) up from thres_pressure_A to thres_pressure_B and down back to A (similar to a trapezoidal trajectory)
However, I feel difficulty implementing this algorithm in Simulink which is required by the toolbox (real-time windows target)
Is there any way-around this e.g. I can program it with M-file (preferred)? or any Simulink toolbox that can perform the same logic
Thank you and Merry Christmas!

採用された回答

Jan Houska
Jan Houska 2014 年 1 月 6 日
You need a Simulink model to work with Real-Time Windows Target. However, there are several possibilities how to implement your algorithm in a Simulink model.
The closest way to a M-file would be the MATLAB Function block. Although you can try to implement the whole algorithm as MATLAB Function block, I would not recommend doing so. Instead, it looks like your model needs to do a control action every 5 seconds. That would indicate a 5s sample rate. Then, in each sample, you perform one pass of your while loop. You can model the "if" condition e.g. by a conditional "If" subsystem. You can model the exit() by the Stop Simulation block.
  1 件のコメント
study
study 2014 年 1 月 8 日
the answer resolves to a MUST in Simulink model in order to work with Real-time Windows Target. That is also what I did in the last few days. Thank you

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTarget Computer Setup についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by