Remove default block names from auto generated Code using embedded coder

조회 수: 7 (최근 30일)
Hello,
i am autogenerating a PID code from simulink, but in the generated code i get some variable name which correponds to its root level block name.
How can i replace these root level block names by some meaning full names in generated code. For example ,
rtb_DeadZone_0 = rtb_Sum * rtb_Saturation + rtb_DeadZone * rtb_PID_Y_Out_Ratelimited;
OR
if (Select_OL) {
rtb_Sum = (real32_T)OL_X_Command;
rtb_DeadZone = (real32_T)OL_Y_Command;
}
i get above lines of code when i autogenerate it and bit hard to read and understand. How can i replace those autogenerated name like rtb_DeadZone_0 , rtb_Sum etc.
Thank you.

채택된 답변

Fangjun Jiang
Fangjun Jiang 2020년 6월 27일
If you want a particular variable name for a signal line in the model, double click the signal line, give it a name "MySignal", right click, select properties, chck "signal name must resolve to Simulink object". In base workspace, create a Simulink.Signal object, MySignal=Simulink.Signal. Then, set properties.
open MySignal
  댓글 수: 2
creative
creative 2020년 6월 28일
Thanks Fangjun,
But i see the name of the sub blocks appearing in the code, these blocks are inside PID block which is available in simulink. Inside these built-in block i cant change the signal name. Do you any siggestion?
Thank you.
Fangjun Jiang
Fangjun Jiang 2020년 6월 28일
The place to change is Ctrl+E, Code Generation, Identifiers. Change Local block output variables from rtb_$N$M to something else. But you don't have specifiic control, just one type of auto naming to another. Right click, select "what's this?" to see the meaning of those $ symbols.
There should be no problem if you break the link of the PID controller and label the signals inside, especially if you want to control the generated signal names.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by