working with Real-time windows target by M-file

1 vue (au cours des 30 derniers jours)
study
study le 27 Déc 2013
Commenté : study le 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!

Réponse acceptée

Jan Houska
Jan Houska le 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 commentaire
study
study le 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

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by