working with Real-time windows target by M-file

1 Ansicht (letzte 30 Tage)
study
study am 27 Dez. 2013
Kommentiert: study am 8 Jan. 2014
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!

Akzeptierte Antwort

Jan Houska
Jan Houska am 6 Jan. 2014
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 Kommentar
study
study am 8 Jan. 2014
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by