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?
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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?
0 Commenti
Risposta accettata
Qing Liu
il 4 Dic 2019
Modificato: Qing Liu
il 17 Dic 2019
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.
0 Commenti
Più risposte (1)
Krishna Zanwar
il 25 Feb 2019
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 Commenti
Qing Liu
il 3 Dic 2019
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.
Vedere anche
Categorie
Scopri di più su Deployment, Integration, and Supported Hardware in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!