Перейти к содержанию
    

Сгенерировать С код из Simulink модели

Открыл модель и следую инструкции

Open the model Configuration Parameters dialog, navigate to the Code Generation tab, and select the Generate code only check box, and click Apply.

Но у меня в Configuration Parameters dialog нет Code Generation tab. Кто нибудь может объяснить как сгенерировать код?

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

1 hour ago, Grizzly said:

Какая у вас модель используется? Инструкцию тоже кидайте.

я новичек в этом деле.  не очень понимаю. инструкцию чего?

модель прилагаю

Dimmer_w_softTune.slx

Изменено пользователем jenya7

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

1 hour ago, Grizzly said:

Которой следуете при кодогенерации.

да мне С код сгенерировать. желательно С99.

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

А с встроенных в Матлаб/симулинк примеров код генерируется? Вкладка Code Generation присутствует? 

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

1 hour ago, syoma said:

А с встроенных в Матлаб/симулинк примеров код генерируется? Вкладка Code Generation присутствует? 

даже не знаю. надо проверить. я не знал что там примеры имеются.

 

 

Товарищи а может кто у кого все инсталированно сгенерить код? А то  я только установил мне разбираться тут вечность. К тому же мой комп ужасно тормозит, еле тянет матлаб, у меня все виснет когда я загружаю модель.

Изменено пользователем jenya7

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Ну скажите хотя б версию Матлаба, в которой вам код нужен.

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

1 hour ago, syoma said:

Ну скажите хотя б версию Матлаба, в которой вам код нужен.

не важно. любая подойдет. мне С код нужен для микроконтролера.

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Важно. У вас модель создана в r2018b. У меня стоит 2016b и следовательно я ее открыть не могу. Экспортируйте модель в 2016b (File -> Export Model to -> Previous Version) - можно будет попробовать

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

1 hour ago, syoma said:

Важно. У вас модель создана в r2018b. У меня стоит 2016b и следовательно я ее открыть не могу. Экспортируйте модель в 2016b (File -> Export Model to -> Previous Version) - можно будет попробовать

спасибо. попробую.

 

экспортировал.

Dimmer_w_softTune_2016b.slx

Изменено пользователем jenya7

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Открыл вашу модель. Code Generation Tab есть. Поставил галочку Generate code only. В модели из ваших блоков выделил и сделал Subsystem и назвал ее Controller. То есть эта  Subsystem имеет три входа - от потенциометра и кнопок и один выход. Нажал на ней правой кнопкой и в контекстном меню выбрал C/C++ Code -> Build Subsystem.

Пара предупреждений и код сгенерился. Код для Controller внизу(step функция там основная), модель я приаттачил. У вас скорей всего не установлен Simulink Coder.

Остальные настройки для Code Generation там из GRT - то есть этот кодя для исполнения на intel-совместимых процессорах. Для встраиваемых используется ERT - ну то уж сами играйтесь. Для этого надо еще Embedded Coder устанавливать.

Spoiler

/*
 * Controller.c
 *
 * Code generation for model "Controller".
 *
 * Model version              : 1.11
 * Simulink Coder version : 8.11 (R2016b) 25-Aug-2016
 * C source code generated on : Wed May 08 19:53:22 2019
 *
 * Target selection: grt.tlc
 * Note: GRT includes extra infrastructure and instrumentation for prototyping
 * Embedded hardware selection: Intel->x86-64 (Windows64)
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "Controller.h"
#include "Controller_private.h"

/* Block states (auto storage) */
DW_Controller_T Controller_DW;

/* Previous zero-crossings (trigger) states */
PrevZCX_Controller_T Controller_PrevZCX;

/* External inputs (root inport signals with auto storage) */
ExtU_Controller_T Controller_U;

/* External outputs (root outports fed by signals with auto storage) */
ExtY_Controller_T Controller_Y;

/* Real-time model */
RT_MODEL_Controller_T Controller_M_;
RT_MODEL_Controller_T *const Controller_M = &Controller_M_;

/* Model step function */
void Controller_step(void)
{
  real_T rtb_Gain1;
  boolean_T rtb_NotEqual1;
  real_T rtb_Sum2;
  real_T rtb_Gain1_0;

  /* RelationalOperator: '<S1>/NotEqual1' incorporates:
   *  Abs: '<S1>/Abs'
   *  Constant: '<S1>/Const3'
   *  Delay: '<S1>/Delay'
   *  Inport: '<Root>/In1'
   *  Sum: '<S1>/Sum1'
   */
  rtb_NotEqual1 = (fabs(Controller_U.In1 - Controller_DW.Delay_DSTATE) >
                   Controller_P.Const3_Value);

  /* DiscreteTransferFcn: '<S1>/Integr' */
  if (rtb_NotEqual1 && (Controller_PrevZCX.Integr_Reset_ZCE != POS_ZCSIG)) {
    Controller_DW.Integr_states = Controller_P.Integr_InitialStates;
  }

  Controller_PrevZCX.Integr_Reset_ZCE = rtb_NotEqual1;

  /* Sum: '<S1>/Sum2' incorporates:
   *  DiscreteTransferFcn: '<S1>/Integr'
   *  Inport: '<Root>/In1'
   */
  rtb_Sum2 = Controller_P.Integr_NumCoef * Controller_DW.Integr_states +
    Controller_U.In1;

  /* Switch: '<S3>/Switch2' incorporates:
   *  Constant: '<S1>/Lo_lim'
   *  Constant: '<S1>/Up_lim'
   *  RelationalOperator: '<S3>/LowerRelop1'
   *  RelationalOperator: '<S3>/UpperRelop'
   *  Switch: '<S3>/Switch'
   */
  if (rtb_Sum2 > Controller_P.Up_lim_Value) {
    /* Outport: '<Root>/Out1' */
    Controller_Y.Out1 = Controller_P.Up_lim_Value;
  } else if (rtb_Sum2 < Controller_P.Lo_lim_Value) {
    /* Switch: '<S3>/Switch' incorporates:
     *  Constant: '<S1>/Lo_lim'
     *  Outport: '<Root>/Out1'
     */
    Controller_Y.Out1 = Controller_P.Lo_lim_Value;
  } else {
    /* Outport: '<Root>/Out1' incorporates:
     *  Switch: '<S3>/Switch'
     */
    Controller_Y.Out1 = rtb_Sum2;
  }

  /* End of Switch: '<S3>/Switch2' */

  /* Switch: '<S2>/Switch' incorporates:
   *  Constant: '<S1>/Lo_lim'
   *  Constant: '<S1>/Up_lim'
   *  RelationalOperator: '<S2>/u_GTE_up'
   *  RelationalOperator: '<S2>/u_GT_lo'
   *  Switch: '<S2>/Switch1'
   */
  if (rtb_Sum2 >= Controller_P.Up_lim_Value) {
    rtb_Gain1 = Controller_P.Up_lim_Value;
  } else if (rtb_Sum2 > Controller_P.Lo_lim_Value) {
    /* Switch: '<S2>/Switch1' */
    rtb_Gain1 = rtb_Sum2;
  } else {
    rtb_Gain1 = Controller_P.Lo_lim_Value;
  }

  /* End of Switch: '<S2>/Switch' */

  /* Sum: '<S2>/Diff' */
  rtb_Gain1 = rtb_Sum2 - rtb_Gain1;

  /* RelationalOperator: '<S1>/NotEqual' incorporates:
   *  Constant: '<S1>/Const2'
   */
  rtb_NotEqual1 = (Controller_P.Const2_Value != rtb_Gain1);

  /* Signum: '<S1>/Sign1' */
  if (rtb_Gain1 < 0.0) {
    rtb_Sum2 = -1.0;
  } else if (rtb_Gain1 > 0.0) {
    rtb_Sum2 = 1.0;
  } else if (rtb_Gain1 == 0.0) {
    rtb_Sum2 = 0.0;
  } else {
    rtb_Sum2 = rtb_Gain1;
  }

  /* End of Signum: '<S1>/Sign1' */

  /* Gain: '<S1>/Gain1' incorporates:
   *  Gain: '<S1>/Gain'
   *  Inport: '<Root>/In2'
   *  Inport: '<Root>/In3'
   *  Sum: '<S1>/Sum'
   */
  rtb_Gain1 = (Controller_P.Gain_Gain * Controller_U.In3 + Controller_U.In2) *
    Controller_P.Gain1_Gain;

  /* Signum: '<S1>/Sign2' */
  if (rtb_Gain1 < 0.0) {
    rtb_Gain1_0 = -1.0;
  } else if (rtb_Gain1 > 0.0) {
    rtb_Gain1_0 = 1.0;
  } else if (rtb_Gain1 == 0.0) {
    rtb_Gain1_0 = 0.0;
  } else {
    rtb_Gain1_0 = rtb_Gain1;
  }

  /* End of Signum: '<S1>/Sign2' */

  /* Switch: '<S1>/Switch' incorporates:
   *  Constant: '<S1>/Const1'
   *  Logic: '<S1>/And'
   *  RelationalOperator: '<S1>/Equal1'
   */
  if (rtb_NotEqual1 && (rtb_Sum2 == rtb_Gain1_0)) {
    rtb_Gain1 = Controller_P.Const1_Value;
  }

  /* End of Switch: '<S1>/Switch' */

  /* Update for Delay: '<S1>/Delay' incorporates:
   *  Update for Inport: '<Root>/In1'
   */
  Controller_DW.Delay_DSTATE = Controller_U.In1;

  /* Update for DiscreteTransferFcn: '<S1>/Integr' */
  Controller_DW.Integr_states = (rtb_Gain1 - Controller_P.Integr_DenCoef[1] *
    Controller_DW.Integr_states) / Controller_P.Integr_DenCoef[0];

  /* Matfile logging */
  rt_UpdateTXYLogVars(Controller_M->rtwLogInfo, (&Controller_M->Timing.taskTime0));

  /* signal main to stop simulation */
  {                                    /* Sample time: [1.0s, 0.0s] */
    if ((rtmGetTFinal(Controller_M)!=-1) &&
        !((rtmGetTFinal(Controller_M)-Controller_M->Timing.taskTime0) >
          Controller_M->Timing.taskTime0 * (DBL_EPSILON))) {
      rtmSetErrorStatus(Controller_M, "Simulation finished");
    }
  }

  /* Update absolute time for base rate */
  /* The "clockTick0" counts the number of times the code of this task has
   * been executed. The absolute time is the multiplication of "clockTick0"
   * and "Timing.stepSize0". Size of "clockTick0" ensures timer will not
   * overflow during the application lifespan selected.
   * Timer of this task consists of two 32 bit unsigned integers.
   * The two integers represent the low bits Timing.clockTick0 and the high bits
   * Timing.clockTickH0. When the low bit overflows to 0, the high bits increment.
   */
  if (!(++Controller_M->Timing.clockTick0)) {
    ++Controller_M->Timing.clockTickH0;
  }

  Controller_M->Timing.taskTime0 = Controller_M->Timing.clockTick0 *
    Controller_M->Timing.stepSize0 + Controller_M->Timing.clockTickH0 *
    Controller_M->Timing.stepSize0 * 4294967296.0;
}

/* Model initialize function */
void Controller_initialize(void)
{
  /* Registration code */

  /* initialize non-finites */
  rt_InitInfAndNaN(sizeof(real_T));

  /* initialize real-time model */
  (void) memset((void *)Controller_M, 0,
                sizeof(RT_MODEL_Controller_T));
  rtmSetTFinal(Controller_M, -1);
  Controller_M->Timing.stepSize0 = 1.0;

  /* Setup for data logging */
  {
    static RTWLogInfo rt_DataLoggingInfo;
    rt_DataLoggingInfo.loggingInterval = NULL;
    Controller_M->rtwLogInfo = &rt_DataLoggingInfo;
  }

  /* Setup for data logging */
  {
    rtliSetLogXSignalInfo(Controller_M->rtwLogInfo, (NULL));
    rtliSetLogXSignalPtrs(Controller_M->rtwLogInfo, (NULL));
    rtliSetLogT(Controller_M->rtwLogInfo, "tout");
    rtliSetLogX(Controller_M->rtwLogInfo, "");
    rtliSetLogXFinal(Controller_M->rtwLogInfo, "");
    rtliSetLogVarNameModifier(Controller_M->rtwLogInfo, "rt_");
    rtliSetLogFormat(Controller_M->rtwLogInfo, 4);
    rtliSetLogMaxRows(Controller_M->rtwLogInfo, 0);
    rtliSetLogDecimation(Controller_M->rtwLogInfo, 1);
    rtliSetLogY(Controller_M->rtwLogInfo, "");
    rtliSetLogYSignalInfo(Controller_M->rtwLogInfo, (NULL));
    rtliSetLogYSignalPtrs(Controller_M->rtwLogInfo, (NULL));
  }

  /* states (dwork) */
  (void) memset((void *)&Controller_DW, 0,
                sizeof(DW_Controller_T));

  /* external inputs */
  (void)memset((void *)&Controller_U, 0, sizeof(ExtU_Controller_T));

  /* external outputs */
  Controller_Y.Out1 = 0.0;

  /* Matfile logging */
  rt_StartDataLoggingWithStartTime(Controller_M->rtwLogInfo, 0.0, rtmGetTFinal
    (Controller_M), Controller_M->Timing.stepSize0, (&rtmGetErrorStatus
    (Controller_M)));
  Controller_PrevZCX.Integr_Reset_ZCE = POS_ZCSIG;

  /* InitializeConditions for Delay: '<S1>/Delay' */
  Controller_DW.Delay_DSTATE = Controller_P.Delay_InitialCondition;

  /* InitializeConditions for DiscreteTransferFcn: '<S1>/Integr' */
  Controller_DW.Integr_states = Controller_P.Integr_InitialStates;
}

/* Model terminate function */
void Controller_terminate(void)
{
  /* (no terminate code required) */
}

 

 

Dimmer_w_softTune_2016b.slx

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

А этим сгенерированным кодом точно пользоваться можно?

Я никогда не пробовал такое. Сначала использовал матлаб, а потом - октаву, когда понял, что нет смысла искать кряки на линуксовый матлаб в торрентах, когда октава вообще ничем ему не уступает. Когда модель получалась, переносил алгоритм на С. Руками. И все отлично работало. Где надо, использовал openmp, где была возможность нормально распараллелить — CUDA.

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

15 hours ago, Ques said:

А этим сгенерированным кодом точно пользоваться можно?

А почему нельзя? У нас сотни тысяч строк такого кода гигаваттами электричества управляют, у Airbusа самолеты на нем летают, да и в вашей машине такого кода полно. Не уверены - можете легко запустить верификацию и убедиться, что он рабочий. Лицензионную чистоту уж сами определяйте своей совестью.

15 hours ago, Ques said:

Когда модель получалась, переносил алгоритм на С. Руками. И все отлично работало.

Дык этого никто не отрицает - вы использовали модель для проверки алгоритма и если она заработала, начинали кодить. Конечно, оно будет работать, так как теория верна и уже проверена. Автоматическая генерация кода нужна только для того, чтобы вы не писали код руками и не вносили ошибки на этом этапе, так как ловить баги в коде будет намного сложнее, чем в модели и они появятся позже в цикле разработки, делая их поиск и устранение дороже.

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

On 5/8/2019 at 9:03 PM, syoma said:

Открыл вашу модель. Code Generation Tab есть. Поставил галочку Generate code only. В модели из ваших блоков выделил и сделал Subsystem и назвал ее Controller. То есть эта  Subsystem имеет три входа - от потенциометра и кнопок и один выход. Нажал на ней правой кнопкой и в контекстном меню выбрал C/C++ Code -> Build Subsystem.

Пара предупреждений и код сгенерился. Код для Controller внизу(step функция там основная), модель я приаттачил. У вас скорей всего не установлен Simulink Coder.

Остальные настройки для Code Generation там из GRT - то есть этот кодя для исполнения на intel-совместимых процессорах. Для встраиваемых используется ERT - ну то уж сами играйтесь. Для этого надо еще Embedded Coder устанавливать.

  Reveal hidden contents


/*
 * Controller.c
 *
 * Code generation for model "Controller".
 *
 * Model version              : 1.11
 * Simulink Coder version : 8.11 (R2016b) 25-Aug-2016
 * C source code generated on : Wed May 08 19:53:22 2019
 *
 * Target selection: grt.tlc
 * Note: GRT includes extra infrastructure and instrumentation for prototyping
 * Embedded hardware selection: Intel->x86-64 (Windows64)
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "Controller.h"
#include "Controller_private.h"

/* Block states (auto storage) */
DW_Controller_T Controller_DW;

/* Previous zero-crossings (trigger) states */
PrevZCX_Controller_T Controller_PrevZCX;

/* External inputs (root inport signals with auto storage) */
ExtU_Controller_T Controller_U;

/* External outputs (root outports fed by signals with auto storage) */
ExtY_Controller_T Controller_Y;

/* Real-time model */
RT_MODEL_Controller_T Controller_M_;
RT_MODEL_Controller_T *const Controller_M = &Controller_M_;

/* Model step function */
void Controller_step(void)
{
  real_T rtb_Gain1;
  boolean_T rtb_NotEqual1;
  real_T rtb_Sum2;
  real_T rtb_Gain1_0;

  /* RelationalOperator: '<S1>/NotEqual1' incorporates:
   *  Abs: '<S1>/Abs'
   *  Constant: '<S1>/Const3'
   *  Delay: '<S1>/Delay'
   *  Inport: '<Root>/In1'
   *  Sum: '<S1>/Sum1'
   */
  rtb_NotEqual1 = (fabs(Controller_U.In1 - Controller_DW.Delay_DSTATE) >
                   Controller_P.Const3_Value);

  /* DiscreteTransferFcn: '<S1>/Integr' */
  if (rtb_NotEqual1 && (Controller_PrevZCX.Integr_Reset_ZCE != POS_ZCSIG)) {
    Controller_DW.Integr_states = Controller_P.Integr_InitialStates;
  }

  Controller_PrevZCX.Integr_Reset_ZCE = rtb_NotEqual1;

  /* Sum: '<S1>/Sum2' incorporates:
   *  DiscreteTransferFcn: '<S1>/Integr'
   *  Inport: '<Root>/In1'
   */
  rtb_Sum2 = Controller_P.Integr_NumCoef * Controller_DW.Integr_states +
    Controller_U.In1;

  /* Switch: '<S3>/Switch2' incorporates:
   *  Constant: '<S1>/Lo_lim'
   *  Constant: '<S1>/Up_lim'
   *  RelationalOperator: '<S3>/LowerRelop1'
   *  RelationalOperator: '<S3>/UpperRelop'
   *  Switch: '<S3>/Switch'
   */
  if (rtb_Sum2 > Controller_P.Up_lim_Value) {
    /* Outport: '<Root>/Out1' */
    Controller_Y.Out1 = Controller_P.Up_lim_Value;
  } else if (rtb_Sum2 < Controller_P.Lo_lim_Value) {
    /* Switch: '<S3>/Switch' incorporates:
     *  Constant: '<S1>/Lo_lim'
     *  Outport: '<Root>/Out1'
     */
    Controller_Y.Out1 = Controller_P.Lo_lim_Value;
  } else {
    /* Outport: '<Root>/Out1' incorporates:
     *  Switch: '<S3>/Switch'
     */
    Controller_Y.Out1 = rtb_Sum2;
  }

  /* End of Switch: '<S3>/Switch2' */

  /* Switch: '<S2>/Switch' incorporates:
   *  Constant: '<S1>/Lo_lim'
   *  Constant: '<S1>/Up_lim'
   *  RelationalOperator: '<S2>/u_GTE_up'
   *  RelationalOperator: '<S2>/u_GT_lo'
   *  Switch: '<S2>/Switch1'
   */
  if (rtb_Sum2 >= Controller_P.Up_lim_Value) {
    rtb_Gain1 = Controller_P.Up_lim_Value;
  } else if (rtb_Sum2 > Controller_P.Lo_lim_Value) {
    /* Switch: '<S2>/Switch1' */
    rtb_Gain1 = rtb_Sum2;
  } else {
    rtb_Gain1 = Controller_P.Lo_lim_Value;
  }

  /* End of Switch: '<S2>/Switch' */

  /* Sum: '<S2>/Diff' */
  rtb_Gain1 = rtb_Sum2 - rtb_Gain1;

  /* RelationalOperator: '<S1>/NotEqual' incorporates:
   *  Constant: '<S1>/Const2'
   */
  rtb_NotEqual1 = (Controller_P.Const2_Value != rtb_Gain1);

  /* Signum: '<S1>/Sign1' */
  if (rtb_Gain1 < 0.0) {
    rtb_Sum2 = -1.0;
  } else if (rtb_Gain1 > 0.0) {
    rtb_Sum2 = 1.0;
  } else if (rtb_Gain1 == 0.0) {
    rtb_Sum2 = 0.0;
  } else {
    rtb_Sum2 = rtb_Gain1;
  }

  /* End of Signum: '<S1>/Sign1' */

  /* Gain: '<S1>/Gain1' incorporates:
   *  Gain: '<S1>/Gain'
   *  Inport: '<Root>/In2'
   *  Inport: '<Root>/In3'
   *  Sum: '<S1>/Sum'
   */
  rtb_Gain1 = (Controller_P.Gain_Gain * Controller_U.In3 + Controller_U.In2) *
    Controller_P.Gain1_Gain;

  /* Signum: '<S1>/Sign2' */
  if (rtb_Gain1 < 0.0) {
    rtb_Gain1_0 = -1.0;
  } else if (rtb_Gain1 > 0.0) {
    rtb_Gain1_0 = 1.0;
  } else if (rtb_Gain1 == 0.0) {
    rtb_Gain1_0 = 0.0;
  } else {
    rtb_Gain1_0 = rtb_Gain1;
  }

  /* End of Signum: '<S1>/Sign2' */

  /* Switch: '<S1>/Switch' incorporates:
   *  Constant: '<S1>/Const1'
   *  Logic: '<S1>/And'
   *  RelationalOperator: '<S1>/Equal1'
   */
  if (rtb_NotEqual1 && (rtb_Sum2 == rtb_Gain1_0)) {
    rtb_Gain1 = Controller_P.Const1_Value;
  }

  /* End of Switch: '<S1>/Switch' */

  /* Update for Delay: '<S1>/Delay' incorporates:
   *  Update for Inport: '<Root>/In1'
   */
  Controller_DW.Delay_DSTATE = Controller_U.In1;

  /* Update for DiscreteTransferFcn: '<S1>/Integr' */
  Controller_DW.Integr_states = (rtb_Gain1 - Controller_P.Integr_DenCoef[1] *
    Controller_DW.Integr_states) / Controller_P.Integr_DenCoef[0];

  /* Matfile logging */
  rt_UpdateTXYLogVars(Controller_M->rtwLogInfo, (&Controller_M->Timing.taskTime0));

  /* signal main to stop simulation */
  {                                    /* Sample time: [1.0s, 0.0s] */
    if ((rtmGetTFinal(Controller_M)!=-1) &&
        !((rtmGetTFinal(Controller_M)-Controller_M->Timing.taskTime0) >
          Controller_M->Timing.taskTime0 * (DBL_EPSILON))) {
      rtmSetErrorStatus(Controller_M, "Simulation finished");
    }
  }

  /* Update absolute time for base rate */
  /* The "clockTick0" counts the number of times the code of this task has
   * been executed. The absolute time is the multiplication of "clockTick0"
   * and "Timing.stepSize0". Size of "clockTick0" ensures timer will not
   * overflow during the application lifespan selected.
   * Timer of this task consists of two 32 bit unsigned integers.
   * The two integers represent the low bits Timing.clockTick0 and the high bits
   * Timing.clockTickH0. When the low bit overflows to 0, the high bits increment.
   */
  if (!(++Controller_M->Timing.clockTick0)) {
    ++Controller_M->Timing.clockTickH0;
  }

  Controller_M->Timing.taskTime0 = Controller_M->Timing.clockTick0 *
    Controller_M->Timing.stepSize0 + Controller_M->Timing.clockTickH0 *
    Controller_M->Timing.stepSize0 * 4294967296.0;
}

/* Model initialize function */
void Controller_initialize(void)
{
  /* Registration code */

  /* initialize non-finites */
  rt_InitInfAndNaN(sizeof(real_T));

  /* initialize real-time model */
  (void) memset((void *)Controller_M, 0,
                sizeof(RT_MODEL_Controller_T));
  rtmSetTFinal(Controller_M, -1);
  Controller_M->Timing.stepSize0 = 1.0;

  /* Setup for data logging */
  {
    static RTWLogInfo rt_DataLoggingInfo;
    rt_DataLoggingInfo.loggingInterval = NULL;
    Controller_M->rtwLogInfo = &rt_DataLoggingInfo;
  }

  /* Setup for data logging */
  {
    rtliSetLogXSignalInfo(Controller_M->rtwLogInfo, (NULL));
    rtliSetLogXSignalPtrs(Controller_M->rtwLogInfo, (NULL));
    rtliSetLogT(Controller_M->rtwLogInfo, "tout");
    rtliSetLogX(Controller_M->rtwLogInfo, "");
    rtliSetLogXFinal(Controller_M->rtwLogInfo, "");
    rtliSetLogVarNameModifier(Controller_M->rtwLogInfo, "rt_");
    rtliSetLogFormat(Controller_M->rtwLogInfo, 4);
    rtliSetLogMaxRows(Controller_M->rtwLogInfo, 0);
    rtliSetLogDecimation(Controller_M->rtwLogInfo, 1);
    rtliSetLogY(Controller_M->rtwLogInfo, "");
    rtliSetLogYSignalInfo(Controller_M->rtwLogInfo, (NULL));
    rtliSetLogYSignalPtrs(Controller_M->rtwLogInfo, (NULL));
  }

  /* states (dwork) */
  (void) memset((void *)&Controller_DW, 0,
                sizeof(DW_Controller_T));

  /* external inputs */
  (void)memset((void *)&Controller_U, 0, sizeof(ExtU_Controller_T));

  /* external outputs */
  Controller_Y.Out1 = 0.0;

  /* Matfile logging */
  rt_StartDataLoggingWithStartTime(Controller_M->rtwLogInfo, 0.0, rtmGetTFinal
    (Controller_M), Controller_M->Timing.stepSize0, (&rtmGetErrorStatus
    (Controller_M)));
  Controller_PrevZCX.Integr_Reset_ZCE = POS_ZCSIG;

  /* InitializeConditions for Delay: '<S1>/Delay' */
  Controller_DW.Delay_DSTATE = Controller_P.Delay_InitialCondition;

  /* InitializeConditions for DiscreteTransferFcn: '<S1>/Integr' */
  Controller_DW.Integr_states = Controller_P.Integr_InitialStates;
}

/* Model terminate function */
void Controller_terminate(void)
{
  /* (no terminate code required) */
}

 

 

Dimmer_w_softTune_2016b.slx

Спасибо большое!

а хидеры

#include "Controller.h"

#include "Controller_private.h"

там есть что то нужное?

там наверное определения структур DW_Controller_T и PrevZCX_Controller_T

Изменено пользователем jenya7

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Присоединяйтесь к обсуждению

Вы можете написать сейчас и зарегистрироваться позже. Если у вас есть аккаунт, авторизуйтесь, чтобы опубликовать от имени своего аккаунта.

Гость
Ответить в этой теме...

×   Вставлено с форматированием.   Вставить как обычный текст

  Разрешено использовать не более 75 эмодзи.

×   Ваша ссылка была автоматически встроена.   Отображать как обычную ссылку

×   Ваш предыдущий контент был восстановлен.   Очистить редактор

×   Вы не можете вставлять изображения напрямую. Загружайте или вставляйте изображения по ссылке.

×
×
  • Создать...