Real-time workshop - using external time management
이전 댓글 표시
I'm quite new to Matlab/Simulink. I am studying all the documentation but still can not find solution.
I am using Simulink to create a model and Real-Time Workshop to convert it to C++ code. Then, I have to integrate this code automatically generated, within other existing code. I can do it.
The existing C++ code can properly handle the inputs and outputs of the model. To do this I set the storage class of those signals such as ImportedExtern.
But now I need to use in the Simulink model an externally generated clock presented in the existing C++ code. I can do this? I'm trying to understand how time is handled in the simulation and which blocks can be involved.
Perhaps the question has a simple answer, most of what I think. I hope I was clear enough.
Thank you in advance.
답변 (2개)
Guy Rouleau
2011년 2월 18일
0 개 추천
RTW will generate a "step" function. You just need to use your external clock to call this "step" function in your C/C++ application at the right time.
Typically, you need to call the "step" function at the same rate as the one specified in the model. That way, the "step" function will automatically increase its time internally.
If you want to call the "step" function asynchrounously, or at non-constant intervals, you should ensure that your model is sample time independant, as explained here:
http://www.mathworks.com/help/toolbox/simulink/gui/bq7cmsp-1.html#bq990zm-1
댓글 수: 2
Luca Goldoni
2011년 2월 23일
Kaustubha Govind
2011년 2월 23일
The step function is generated as rt_OneStep, which you can tie in to your clock. I'm not sure what you mean by passing in a time variable - is this just something that the function must use as any other parameter, or do you want the model to somehow act upon this input by automatically running at the given frequency? AFAIK, the latter is not possible.
카테고리
도움말 센터 및 File Exchange에서 Simulink Coder에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!