working with Real-time windows target by M-file
조회 수: 1 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
채택된 답변
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Target Computer Setup에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!