필터 지우기
필터 지우기

How can you generate a C code with embedded coder from a simulink model with a cycle time/period (sample time) shorter than 1 ms?

조회 수: 4 (최근 30일)
I have a simple simulink model same as the example rtwdemo_concurrent_execution (MathWorks Model Concurrent Execution for Symmetric Multicore CPU Platforms). When I change the sample time and the period time of this model from 1 (original value in the sample model) to 0.0001 and try to build the model and creat a C-Code, simulink shows the following error:
How can I make a smaller "Period" time?

채택된 답변

Qing Liu
Qing Liu 2019년 12월 4일
편집: Qing Liu 2019년 12월 17일
A tricky method : manually modify the tlc file( <MATLAB_ROOT>/rtw/c/tlc/mw/ertwinthread.tlc )
comment out lines 773-780 (as follow) from
773 %if ((period * 1000) < 1)
774 %if LibIsDeploymentDiagram()
775 %assign errormsg = "The periodic trigger %<LibGetTriggerName(ehIdx)> of model %<::CompiledModel.Name> has a base rate smaller than 1 ms. The current base rate is %<period> seconds. Increase the base rate of the periodic trigger by increasing the rate in the model."
776 %else
777 %assign errormsg = "%<::CompiledModel.Name> has a base rate smaller than 1 ms. The current base rate is %<period> seconds. Increase the base rate of the model."
778 %endif
779 %exit %<errormsg>
780 %endif
to this
773 /%%if ((period * 1000) < 1)
774 %if LibIsDeploymentDiagram()
775 %assign errormsg = "The periodic trigger %<LibGetTriggerName(ehIdx)> of model %<::CompiledModel.Name> has a base rate smaller than 1 ms. The current base rate is %<period> seconds. Increase the base rate of the periodic trigger by increasing the rate in the model."
776 %else
777 %assign errormsg = "%<::CompiledModel.Name> has a base rate smaller than 1 ms. The current base rate is %<period> seconds. Increase the base rate of the model."
778 %endif
779 %exit %<errormsg>
780 %endif%/
and the Code Generation process will skip the check of the time step greater than 1ms.

추가 답변 (1개)

Krishna Zanwar
Krishna Zanwar 2019년 2월 25일
The "base rate smaller than 1 ms" error message appears when the code generation target is set to GRT (Generic Real-Time) or ERT (Embedded Real-Time) in response to a Windows threading bug- when the base rate of the model is very fast, the timer in the generated code will not be able to issue an interrupt, and the generated executable will hang.
Since this issue only applies to GRT, ERT, and IDELINK targets, you should still be able to build an executable using SLRT. To change your model to use the SLRT target, please use the following steps:
1. Open the Configuration Parameters window in your model.
2. Select 'Code Generation' on the left, then for the 'System target file' parameter, click the 'Browse...' button.
3. In the pop-up that appears, select 'slrt.tlc (Simulink Real-Time)' and click OK.
4. Repeat steps 1-3 for each of the referenced models you are using.
After following these steps, your model will be set up to build for the SLRT target. Please note that for SLRT, you can only have one periodic trigger, so you will need to edit the concurrent execution options for your model to use one instead of two.
  댓글 수: 2
shi chen
shi chen 2019년 3월 21일
The code generated by slrt is not complete, there is no main function?
Qing Liu
Qing Liu 2019년 12월 3일
It does not make any sense to demand time step size bigger than 1ms. For many high-performance embeded system and RTOS, the minimum time step can be much smaller than 1ms.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Deployment, Integration, and Supported Hardware에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by