From 4b8133e921a75863f423e87828caebf3afcbed64 Mon Sep 17 00:00:00 2001 From: cfif Date: Fri, 30 Jan 2026 17:14:14 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model_Task.c | 5 +- Model_Task.h | 2 + Model_actuator.c | 912 ++++++--------------------------------- Model_actuator.h | 133 ++---- Model_actuator_data.c | 127 ++++++ Model_actuator_private.h | 8 +- Model_actuator_types.h | 38 +- 7 files changed, 328 insertions(+), 897 deletions(-) create mode 100644 Model_actuator_data.c diff --git a/Model_Task.c b/Model_Task.c index db2ece7..91bd83d 100644 --- a/Model_Task.c +++ b/Model_Task.c @@ -21,7 +21,7 @@ void ModelTask_Init( } static bool setActuatorBusy(tModelTask *env) { - +/* for (uint8_t i = 0; i < 9; ++i) { if (rtY.Out1.COM[i] != 0) { #if (LOG_LIN_ACTUATOR == 1) @@ -37,7 +37,7 @@ static bool setActuatorBusy(tModelTask *env) { return true; } } - +*/ return false; } @@ -49,6 +49,7 @@ static _Noreturn void ModelTask_Thread(tModelTask *env) { Model_actuator_step(); setActuatorBusy(env); + env->isUpdate = true; osMutexRelease(env->access); } SystemDelayMs(250); diff --git a/Model_Task.h b/Model_Task.h index e855886..553862e 100644 --- a/Model_Task.h +++ b/Model_Task.h @@ -18,6 +18,8 @@ typedef struct { bool triggerCommand; uint8_t numCommand[9]; + bool isUpdate; + struct { osThreadId_t id; uint32_t stack[1024]; diff --git a/Model_actuator.c b/Model_actuator.c index a2cb023..2a50bd0 100644 --- a/Model_actuator.c +++ b/Model_actuator.c @@ -3,9 +3,9 @@ * * Code generated for Simulink model 'Model_actuator'. * - * Model version : 1.552 + * Model version : 1.572 * Simulink Coder version : 24.1 (R2024a) 19-Nov-2023 - * C/C++ source code generated on : Wed Dec 24 11:40:12 2025 + * C/C++ source code generated on : Fri Jan 30 16:05:13 2026 * * Target selection: ert.tlc * Embedded hardware selection: ARM Compatible->ARM Cortex-M @@ -16,835 +16,195 @@ */ #include "Model_actuator.h" +#include #include #include "Model_actuator_private.h" -#include -#include "Model_actuator_types.h" - -/* Exported block states */ -ActuatorCmdBus controllerData; /* '/Data Store Memory15' */ - -/* Block signals (default storage) */ -B rtB; /* Block states (default storage) */ DW rtDW; -/* External inputs (root inport signals with default storage) */ -ExtU rtU; - -/* External outputs (root outports fed by signals with default storage) */ -ExtY rtY; - /* Real-time model */ static RT_MODEL rtM_; RT_MODEL *const rtM = &rtM_; - -/* - * Output and update for action system: - * '/If Action Subsystem3' - * '/If Action Subsystem3' - * '/If Action Subsystem3' - * '/If Action Subsystem3' - * '/If Action Subsystem3' - * '/If Action Subsystem3' - * '/If Action Subsystem3' - */ -void IfActionSubsystem3(int8_t rtu_stepIn, int8_t *rty_step, uint8_t - rtd_com_loc[9]) +double look1_binlx(double u0, const double bp0[], const double table[], uint32_t +maxIndex) { - int32_t i; + double frac; + double yL_0d0; + uint32_t iLeft; - /* DataStoreWrite: '/Data Store Write3' */ - for (i = 0; i < 9; i++) { - rtd_com_loc[i] = 0U; - } + /* Column-major Lookup 1-D + Search method: 'binary' + Use previous index: 'off' + Interpolation method: 'Linear point-slope' + Extrapolation method: 'Linear' + Use last breakpoint for index at or above upper limit: 'off' + Remove protection against out-of-range input in generated code: 'off' + */ + /* Prelookup - Index and Fraction + Index Search method: 'binary' + Extrapolation method: 'Linear' + Use previous index: 'off' + Use last breakpoint for index at or above upper limit: 'off' + Remove protection against out-of-range input in generated code: 'off' + */ + if (u0 <= bp0[0U]) { + iLeft = 0U; + frac = (u0 - bp0[0U]) / (bp0[1U] - bp0[0U]); + } else if (u0 < bp0[maxIndex]) { + uint32_t bpIdx; + uint32_t iRght; - /* End of DataStoreWrite: '/Data Store Write3' */ + /* Binary Search */ + bpIdx = maxIndex >> 1U; + iLeft = 0U; + iRght = maxIndex; + while (iRght - iLeft > 1U) { + if (u0 < bp0[bpIdx]) { + iRght = bpIdx; + } else { + iLeft = bpIdx; + } - /* SignalConversion generated from: '/stepIn' */ - *rty_step = rtu_stepIn; -} + bpIdx = (iRght + iLeft) >> 1U; + } -/* - * Output and update for atomic system: - * '/MAX POSITION' - * '/MAX POSITION' - */ -void MAXPOSITION(const int16_t rtu_step[9], int16_t rty_y[9]) -{ - int32_t i; + frac = (u0 - bp0[iLeft]) / (bp0[iLeft + 1U] - bp0[iLeft]); + } else { + iLeft = maxIndex - 1U; + frac = (u0 - bp0[maxIndex - 1U]) / (bp0[maxIndex] - bp0[maxIndex - 1U]); + } - /* : y = step; */ - for (i = 0; i < 9; i++) { - rty_y[i] = rtu_step[i]; - } - - /* : fprintf('SIMULINK POSITION '); */ - printf("SIMULINK POSITION "); - fflush(stdout); - - /* : for i = 1:numel(step) */ - for (i = 0; i < 9; i++) { - /* : fprintf('%d ', int16(step(i))); */ - printf("%d ", rtu_step[i]); - fflush(stdout); - } - - /* : fprintf('\n'); */ - printf("\n"); - fflush(stdout); -} - -/* - * Output and update for atomic system: - * '/MAX POSITION1' - * '/MAX POSITION1' - */ -void MAXPOSITION1(const int8_t rtu_step[9], int8_t rty_y[9]) -{ - int32_t i; - - /* : y = step; */ - for (i = 0; i < 9; i++) { - rty_y[i] = rtu_step[i]; - } - - /* : fprintf('SIMULINK Stall_Slave '); */ - printf("SIMULINK Stall_Slave "); - fflush(stdout); - - /* : for i = 1:numel(step) */ - for (i = 0; i < 9; i++) { - /* : fprintf('%d ', int16(step(i))); */ - printf("%d ", (int16_t)rtu_step[i]); - fflush(stdout); - } - - /* : fprintf('\n'); */ - printf("\n"); - fflush(stdout); + /* Column-major Interpolation 1-D + Interpolation method: 'Linear point-slope' + Use last breakpoint for index at or above upper limit: 'off' + Overflow mode: 'wrapping' + */ + yL_0d0 = table[iLeft]; + return (table[iLeft + 1U] - yL_0d0) * frac + yL_0d0; } /* Model step function */ void Model_actuator_step(void) { - int32_t i; - int16_t rtb_y_ff[9]; - int8_t rtb_y_b[9]; - bool rtb_RelationalOperator_j[9]; - bool tmp; - bool tmp_0; + double IncarFL; + double rtb_Divide1; + uint32_t rtb_dt; + bool IncarFLErr; + bool rtb_FailCond; - /* Switch: '/Switch' incorporates: - * DataStoreRead: '/Data Store Read' - */ - if (rtDW.stepSig < 1) { - /* Switch: '/Switch' incorporates: - * Constant: '/Constant1' + /* Product: '/Divide1' incorporates: + * Constant: '/Constant' + * Constant: '/Constant1' + * DataStoreRead: '/Data Store Read1' + * Product: '/Divide' */ - rtDW.UnitDelay_DSTATE = 1; - } + rtb_Divide1 = (double)rtDW.controllerDataIncarInput.InIncarFL / 4095.0 * 5.0; - /* End of Switch: '/Switch' */ - - /* SwitchCase: '/Switch Case' */ - switch (rtDW.UnitDelay_DSTATE) { - case 1: - /* Outputs for IfAction SubSystem: '/Stop Mode' incorporates: - * ActionPort: '/Action Port' + /* Logic: '/Logical Operator' incorporates: + * Constant: '/Constant' + * RelationalOperator: '/Compare' */ - /* If: '/If1' incorporates: - * Inport: '/in_Busy_Ch0' - * Inport: '/in_Error_Connect_Ch0' + rtb_FailCond = (rtb_Divide1 < 15.0); + + /* Switch: '/Switch' incorporates: + * DataStoreRead: '/Data Store Read4' + * DataStoreWrite: '/Data Store Write' + * Logic: '/Logical Operator3' + * Logic: '/Logical Operator4' + * UnitDelay: '/Unit Delay' */ - if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0)) { - /* Outputs for IfAction SubSystem: '/If Action Subsystem2' incorporates: - * ActionPort: '/Action Port' - */ - for (i = 0; i < 9; i++) { - /* DataStoreWrite: '/Data Store Write2' */ - rtDW.mode_loc[i] = 2U; + if (rtb_FailCond && (!rtDW.UnitDelay_DSTATE)) { + rtDW.UnitDelay1_DSTATE = rtDW.t_now; + } - /* DataStoreWrite: '/Data Store Write3' */ - rtDW.com_loc[i] = 1U; - } + /* End of Switch: '/Switch' */ - /* Merge: '/Merge' incorporates: - * Constant: '/Constant' - * Merge: '/Merge' - * SignalConversion generated from: '/step' - * Sum: '/step inc' - */ - rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1); + /* Sum: '/Subtract' incorporates: + * DataStoreRead: '/Data Store Read4' + * DataStoreWrite: '/Data Store Write' + */ + rtb_dt = rtDW.t_now - rtDW.UnitDelay1_DSTATE; - /* MATLAB Function: '/stop mode' */ - /* : y = step; */ - /* : fprintf('SIMULINK Stop Mode\n'); */ - printf("SIMULINK Stop Mode\n"); - fflush(stdout); - printf("SIMULINK Stop Mode2\n"); - fflush(stdout); - /* End of Outputs for SubSystem: '/If Action Subsystem2' */ + /* Logic: '/Logical Operator1' incorporates: + * Constant: '/Constant' + * DataStoreWrite: '/Data Store Write1' + * RelationalOperator: '/Compare' + */ + IncarFLErr = (rtb_FailCond && (rtb_dt >= 3000U)); + + /* Switch: '/Switch' incorporates: + * Constant: '/Constant2' + * DataStoreWrite: '/Data Store Write' + * DataStoreWrite: '/Data Store Write1' + * Lookup_n-D: '/1-D Lookup Table' + * Product: '/Divide1' + */ + if (IncarFLErr) { + IncarFL = 200.0; } else { - /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: - * ActionPort: '/Action Port' - */ - /* Merge: '/Merge' */ - IfActionSubsystem3(rtDW.UnitDelay_DSTATE, &rtB.Merge, rtDW.com_loc); - - /* End of Outputs for SubSystem: '/If Action Subsystem3' */ + IncarFL = look1_binlx(rtb_Divide1, rtConstP.uDLookupTable_bp01Data, + rtConstP.uDLookupTable_tableData, 475U); } - /* End of If: '/If1' */ - /* End of Outputs for SubSystem: '/Stop Mode' */ - break; + /* End of Switch: '/Switch' */ - case 2: - /* Outputs for IfAction SubSystem: '/Initial CPOS Min' incorporates: - * ActionPort: '/Action Port' - */ - /* If: '/If' incorporates: - * Inport: '/in_Busy_Ch0' - * Inport: '/in_Error_Connect_Ch0' - */ - if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0)) { - /* Outputs for IfAction SubSystem: '/If Action Subsystem' incorporates: - * ActionPort: '/Action Port' - */ - for (i = 0; i < 9; i++) { - /* DataStoreWrite: '/Data Store Write' */ - rtDW.pos_loc[i] = 6000U; - - /* DataStoreWrite: '/Data Store Write1' */ - rtDW.com_loc[i] = 2U; - } - - /* MATLAB Function: '/Initial CPOS Min' */ - /* : y = step; */ - /* : fprintf('SIMULINK Initial CPOS Min - 6000\n'); */ - printf("SIMULINK Initial CPOS Min - 6000\n"); - fflush(stdout); - - /* Merge: '/Merge' incorporates: - * Constant: '/Constant' - * Merge: '/Merge' - * SignalConversion generated from: '/step' - * Sum: '/step inc' - */ - rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1); - - /* End of Outputs for SubSystem: '/If Action Subsystem' */ - } else { - /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: - * ActionPort: '/Action Port' - */ - /* DataStoreWrite: '/Data Store Write3' */ - for (i = 0; i < 9; i++) { - rtDW.com_loc[i] = 0U; - } - - /* End of DataStoreWrite: '/Data Store Write3' */ - - /* Merge: '/Merge' incorporates: - * Merge: '/Merge' - * SignalConversion generated from: '/stepIn1' - */ - rtB.Merge = rtDW.UnitDelay_DSTATE; - - /* End of Outputs for SubSystem: '/If Action Subsystem3' */ + /* MATLAB Function: '/Normal Mode2' */ + /* : y = dt ; */ + /* : fprintf('int16 %d\n',int16(dt)); */ + if (rtb_dt > 32767U) { + rtb_dt = 32767U; } - /* End of If: '/If' */ - /* End of Outputs for SubSystem: '/Initial CPOS Min' */ - break; - - case 3: - /* Outputs for IfAction SubSystem: '/Normal Mode' incorporates: - * ActionPort: '/Action Port' - */ - /* If: '/If1' incorporates: - * Inport: '/in_Busy_Ch0' - * Inport: '/in_Error_Connect_Ch0' - */ - if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0)) { - /* Outputs for IfAction SubSystem: '/If Action Subsystem2' incorporates: - * ActionPort: '/Action Port' - */ - for (i = 0; i < 9; i++) { - /* DataStoreWrite: '/Data Store Write' */ - rtDW.mode_loc[i] = 0U; - - /* DataStoreWrite: '/Data Store Write2' */ - rtDW.com_loc[i] = 1U; - } - - /* MATLAB Function: '/Normal Mode' */ - /* : y = step; */ - /* : fprintf('SIMULINK Normal Mode\n'); */ - printf("SIMULINK Normal Mode\n"); - fflush(stdout); - - /* Merge: '/Merge' incorporates: - * Constant: '/Constant' - * SignalConversion generated from: '/step' - * Sum: '/step inc' - */ - rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1); - - /* End of Outputs for SubSystem: '/If Action Subsystem2' */ - } else { - /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: - * ActionPort: '/Action Port' - */ - IfActionSubsystem3(rtDW.UnitDelay_DSTATE, &rtB.Merge, rtDW.com_loc); - - /* End of Outputs for SubSystem: '/If Action Subsystem3' */ - } - - /* End of If: '/If1' */ - /* End of Outputs for SubSystem: '/Normal Mode' */ - break; - - case 4: - /* Outputs for IfAction SubSystem: '/Move to position Min' incorporates: - * ActionPort: '/Action Port' - */ - /* If: '/If1' incorporates: - * Inport: '/in_Busy_Ch0' - * Inport: '/in_Error_Connect_Ch0' - */ - if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0)) { - /* Outputs for IfAction SubSystem: '/If Action Subsystem2' incorporates: - * ActionPort: '/Action Port' - */ - for (i = 0; i < 9; i++) { - /* DataStoreWrite: '/Data Store Write1' */ - rtDW.stall_set_loc[i] = 1U; - - /* DataStoreWrite: '/Data Store Write3' incorporates: - * Constant: '/Constant2' - */ - rtDW.lnoise_set_loc[i] = 0U; - - /* DataStoreWrite: '/Data Store Write2' */ - rtDW.com_loc[i] = 3U; - - /* DataStoreWrite: '/Data Store Write4' incorporates: - * Constant: '/Constant4' - */ - rtDW.autos_set_loc[i] = 0U; - - /* DataStoreWrite: '/Data Store Write5' incorporates: - * Constant: '/Constant5' - */ - rtDW.speed_set_loc[i] = 0U; - - /* DataStoreWrite: '/Data Store Write6' incorporates: - * Constant: '/Constant6' - */ - rtDW.coils_stop_set_loc[i] = 0U; - - /* DataStoreWrite: '/Data Store Write' */ - rtDW.pos_loc[i] = 1U; - } - - /* MATLAB Function: '/Move to position Min' */ - /* : y = step; */ - /* : fprintf('SIMULINK Move to position Min - 1\n'); */ - printf("SIMULINK Move to position Min - 1\n"); - fflush(stdout); - - /* Merge: '/Merge' incorporates: - * Constant: '/Constant' - * SignalConversion generated from: '/step' - * Sum: '/step inc' - */ - rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1); - - /* End of Outputs for SubSystem: '/If Action Subsystem2' */ - } else { - /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: - * ActionPort: '/Action Port' - */ - IfActionSubsystem3(rtDW.UnitDelay_DSTATE, &rtB.Merge, rtDW.com_loc); - - /* End of Outputs for SubSystem: '/If Action Subsystem3' */ - } - - /* End of If: '/If1' */ - /* End of Outputs for SubSystem: '/Move to position Min' */ - break; - - case 5: - /* Outputs for IfAction SubSystem: '/Check Stall Min' incorporates: - * ActionPort: '/Action Port' - */ - /* RelationalOperator: '/Relational Operator1' incorporates: - * DataStoreWrite: '/Data Store Write4' - * Inport: '/in_Act_Stall_Slave_Ch0' - */ - for (i = 0; i < 9; i++) { - rtb_RelationalOperator_j[i] = (rtU.in_Act_Stall_Slave_Ch0[i] == 1); - } - - /* End of RelationalOperator: '/Relational Operator1' */ - - /* Logic: '/Logical Operator2' */ - tmp = rtb_RelationalOperator_j[0]; - for (i = 0; i < 8; i++) { - tmp = (tmp || rtb_RelationalOperator_j[i + 1]); - } - - /* RelationalOperator: '/Relational Operator' incorporates: - * DataStoreWrite: '/Data Store Write1' - * Inport: '/in_CPOS_ALL_Ch0' - */ - for (i = 0; i < 9; i++) { - rtb_RelationalOperator_j[i] = (rtU.in_CPOS_ALL_Ch0[i] == 1); - } - - /* End of RelationalOperator: '/Relational Operator' */ - - /* Logic: '/Logical Operator1' */ - tmp_0 = rtb_RelationalOperator_j[0]; - for (i = 0; i < 8; i++) { - tmp_0 = (tmp_0 || rtb_RelationalOperator_j[i + 1]); - } - - /* If: '/If2' incorporates: - * DataTypeConversion: '/Data Type Conversion' - * DataTypeConversion: '/Data Type Conversion1' - * Inport: '/in_Busy_Ch0' - * Inport: '/in_Error_Connect_Ch0' - * Logic: '/Logical Operator' - * Logic: '/Logical Operator1' - * Logic: '/Logical Operator2' - */ - if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0) && (tmp || - tmp_0)) { - /* Outputs for IfAction SubSystem: '/If Action Subsystem2' incorporates: - * ActionPort: '/Action Port' - */ - /* DataStoreWrite: '/Data Store Write1' incorporates: - * DataStoreWrite: '/Data Store Write1' - * Inport: '/in_CPOS_ALL_Ch0' - */ - for (i = 0; i < 9; i++) { - rtDW.Min_position_Ch0[i] = rtU.in_CPOS_ALL_Ch0[i]; - } - - /* End of DataStoreWrite: '/Data Store Write1' */ - - /* Merge: '/Merge' incorporates: - * Constant: '/Constant' - * Sum: '/step inc' - */ - rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1); - - /* MATLAB Function: '/MIN POSITION' incorporates: - * DataStoreWrite: '/Data Store Write1' - * Inport: '/in_CPOS_ALL_Ch0' - */ - /* : y = step; */ - /* : fprintf('SIMULINK Min_position_Ch0 '); */ - printf("SIMULINK Min_position_Ch0 "); - fflush(stdout); - - /* : for i = 1:numel(step) */ - for (i = 0; i < 9; i++) { - /* : fprintf('%d ', int16(step(i))); */ - printf("%d ", rtU.in_CPOS_ALL_Ch0[i]); - fflush(stdout); - } - - /* : fprintf('\n'); */ - printf("\n"); - fflush(stdout); - - /* End of MATLAB Function: '/MIN POSITION' */ - /* End of Outputs for SubSystem: '/If Action Subsystem2' */ - } else { - /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: - * ActionPort: '/Action Port' - */ - IfActionSubsystem3(rtDW.UnitDelay_DSTATE, &rtB.Merge, rtDW.com_loc); - - /* End of Outputs for SubSystem: '/If Action Subsystem3' */ - } - - /* End of If: '/If2' */ - - /* MATLAB Function: '/MAX POSITION' incorporates: - * Inport: '/in_CPOS_ALL_Ch0' - */ - MAXPOSITION(rtU.in_CPOS_ALL_Ch0, rtb_y_ff); - - /* MATLAB Function: '/MAX POSITION1' incorporates: - * Inport: '/in_Act_Stall_Slave_Ch0' - */ - MAXPOSITION1(rtU.in_Act_Stall_Slave_Ch0, rtb_y_b); - - /* End of Outputs for SubSystem: '/Check Stall Min' */ - break; - - case 6: - /* Outputs for IfAction SubSystem: '/Initial CPOS Max' incorporates: - * ActionPort: '/Action Port' - */ - /* If: '/If1' incorporates: - * Inport: '/in_Busy_Ch0' - * Inport: '/in_Error_Connect_Ch0' - */ - if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0)) { - /* Outputs for IfAction SubSystem: '/If Action Subsystem2' incorporates: - * ActionPort: '/Action Port' - */ - for (i = 0; i < 9; i++) { - /* DataStoreWrite: '/Data Store Write' */ - rtDW.pos_loc[i] = 1U; - - /* DataStoreWrite: '/Data Store Write1' */ - rtDW.com_loc[i] = 2U; - } - - /* MATLAB Function: '/Initial CPOS Max' */ - /* : y = step; */ - /* : fprintf('SIMULINK Initial CPOS Max - 1\n'); */ - printf("SIMULINK Initial CPOS Max - 1\n"); - fflush(stdout); - - /* Merge: '/Merge' incorporates: - * Constant: '/Constant' - * SignalConversion generated from: '/step' - * Sum: '/step inc' - */ - rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1); - - /* End of Outputs for SubSystem: '/If Action Subsystem2' */ - } else { - /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: - * ActionPort: '/Action Port' - */ - IfActionSubsystem3(rtDW.UnitDelay_DSTATE, &rtB.Merge, rtDW.com_loc); - - /* End of Outputs for SubSystem: '/If Action Subsystem3' */ - } - - /* End of If: '/If1' */ - /* End of Outputs for SubSystem: '/Initial CPOS Max' */ - break; - - case 7: - /* Outputs for IfAction SubSystem: '/Move to position Max' incorporates: - * ActionPort: '/Action Port' - */ - /* If: '/If1' incorporates: - * Inport: '/in_Busy_Ch0' - * Inport: '/in_Error_Connect_Ch0' - */ - if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0)) { - /* Outputs for IfAction SubSystem: '/If Action Subsystem2' incorporates: - * ActionPort: '/Action Port' - */ - for (i = 0; i < 9; i++) { - /* DataStoreWrite: '/Data Store Write1' */ - rtDW.stall_set_loc[i] = 1U; - - /* DataStoreWrite: '/Data Store Write3' incorporates: - * Constant: '/Constant2' - */ - rtDW.lnoise_set_loc[i] = 0U; - - /* DataStoreWrite: '/Data Store Write2' */ - rtDW.com_loc[i] = 3U; - - /* DataStoreWrite: '/Data Store Write4' incorporates: - * Constant: '/Constant4' - */ - rtDW.autos_set_loc[i] = 0U; - - /* DataStoreWrite: '/Data Store Write5' incorporates: - * Constant: '/Constant5' - */ - rtDW.speed_set_loc[i] = 0U; - - /* DataStoreWrite: '/Data Store Write6' incorporates: - * Constant: '/Constant6' - */ - rtDW.coils_stop_set_loc[i] = 0U; - - /* DataStoreWrite: '/Data Store Write' */ - rtDW.pos_loc[i] = 6000U; - } - - /* MATLAB Function: '/Move to position Max' */ - /* : y = step; */ - /* : fprintf('SIMULINK Move to position Max - 6000\n'); */ - printf("SIMULINK Move to position Max - 6000\n"); - fflush(stdout); - - /* Merge: '/Merge' incorporates: - * Constant: '/Constant' - * SignalConversion generated from: '/step' - * Sum: '/step inc' - */ - rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1); - - /* End of Outputs for SubSystem: '/If Action Subsystem2' */ - } else { - /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: - * ActionPort: '/Action Port' - */ - IfActionSubsystem3(rtDW.UnitDelay_DSTATE, &rtB.Merge, rtDW.com_loc); - - /* End of Outputs for SubSystem: '/If Action Subsystem3' */ - } - - /* End of If: '/If1' */ - /* End of Outputs for SubSystem: '/Move to position Max' */ - break; - - case 8: - /* Outputs for IfAction SubSystem: '/Check Stall Max' incorporates: - * ActionPort: '/Action Port' - */ - /* RelationalOperator: '/Relational Operator1' incorporates: - * DataStoreWrite: '/Data Store Write4' - * Inport: '/in_Act_Stall_Slave_Ch0' - */ - for (i = 0; i < 9; i++) { - rtb_RelationalOperator_j[i] = (rtU.in_Act_Stall_Slave_Ch0[i] == 1); - } - - /* End of RelationalOperator: '/Relational Operator1' */ - - /* Logic: '/Logical Operator2' */ - tmp = rtb_RelationalOperator_j[0]; - for (i = 0; i < 8; i++) { - tmp = (tmp || rtb_RelationalOperator_j[i + 1]); - } - - /* RelationalOperator: '/Relational Operator' incorporates: - * DataStoreWrite: '/Data Store Write1' - * Inport: '/in_CPOS_ALL_Ch0' - */ - for (i = 0; i < 9; i++) { - rtb_RelationalOperator_j[i] = (rtU.in_CPOS_ALL_Ch0[i] == 6000); - } - - /* End of RelationalOperator: '/Relational Operator' */ - - /* Logic: '/Logical Operator1' */ - tmp_0 = rtb_RelationalOperator_j[0]; - for (i = 0; i < 8; i++) { - tmp_0 = (tmp_0 || rtb_RelationalOperator_j[i + 1]); - } - - /* If: '/If2' incorporates: - * DataTypeConversion: '/Data Type Conversion' - * DataTypeConversion: '/Data Type Conversion1' - * Inport: '/in_Busy_Ch0' - * Inport: '/in_Error_Connect_Ch0' - * Logic: '/Logical Operator' - * Logic: '/Logical Operator1' - * Logic: '/Logical Operator2' - */ - if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0) && (tmp || - tmp_0)) { - /* Outputs for IfAction SubSystem: '/If Action Subsystem2' incorporates: - * ActionPort: '/Action Port' - */ - /* DataStoreWrite: '/Data Store Write1' incorporates: - * DataStoreWrite: '/Data Store Write1' - * Inport: '/in_CPOS_ALL_Ch0' - */ - for (i = 0; i < 9; i++) { - rtDW.Max_position_Ch0[i] = rtU.in_CPOS_ALL_Ch0[i]; - } - - /* End of DataStoreWrite: '/Data Store Write1' */ - - /* Merge: '/Merge' incorporates: - * Constant: '/Constant' - * Sum: '/step inc' - */ - rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1); - - /* MATLAB Function: '/MIN POSITION' incorporates: - * DataStoreWrite: '/Data Store Write1' - * Inport: '/in_CPOS_ALL_Ch0' - */ - /* : y = step; */ - /* : fprintf('SIMULINK Max_position_Ch0 '); */ - printf("SIMULINK Max_position_Ch0 "); - fflush(stdout); - - /* : for i = 1:numel(step) */ - for (i = 0; i < 9; i++) { - /* : fprintf('%d ', int16(step(i))); */ - printf("%d ", rtU.in_CPOS_ALL_Ch0[i]); - fflush(stdout); - } - - /* : fprintf('\n'); */ - printf("\n"); - fflush(stdout); - - /* End of MATLAB Function: '/MIN POSITION' */ - /* End of Outputs for SubSystem: '/If Action Subsystem2' */ - } else { - /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: - * ActionPort: '/Action Port' - */ - IfActionSubsystem3(rtDW.UnitDelay_DSTATE, &rtB.Merge, rtDW.com_loc); - - /* End of Outputs for SubSystem: '/If Action Subsystem3' */ - } - - /* End of If: '/If2' */ - - /* MATLAB Function: '/MAX POSITION' incorporates: - * Inport: '/in_CPOS_ALL_Ch0' - */ - MAXPOSITION(rtU.in_CPOS_ALL_Ch0, rtb_y_ff); - - /* MATLAB Function: '/MAX POSITION1' incorporates: - * Inport: '/in_Act_Stall_Slave_Ch0' - */ - MAXPOSITION1(rtU.in_Act_Stall_Slave_Ch0, rtb_y_b); - - /* End of Outputs for SubSystem: '/Check Stall Max' */ - break; - - case 9: - /* Outputs for IfAction SubSystem: '/Homing' incorporates: - * ActionPort: '/Action Port' - */ - /* DataStoreWrite: '/Data Store Write3' */ - for (i = 0; i < 9; i++) { - rtDW.com_loc[i] = 0U; - } - - /* End of DataStoreWrite: '/Data Store Write3' */ - - /* Merge: '/Merge' incorporates: - * Constant: '/Constant2' - * SignalConversion generated from: '/step' - */ - rtB.Merge = 1; - - /* MATLAB Function: '/MAX POSITION' incorporates: - * DataStoreRead: '/Data Store Read2' - */ - /* : y = step; */ - /* : fprintf('SIMULINK MAX POSITION '); */ - printf("SIMULINK MAX POSITION "); + printf("int16 %d\n", (int16_t)rtb_dt); fflush(stdout); - /* : for i = 1:numel(step) */ - for (i = 0; i < 9; i++) { - /* : fprintf('%d ', int16(step(i))); */ - printf("%d ", rtDW.Max_position_Ch0[i]); - fflush(stdout); - } + /* End of MATLAB Function: '/Normal Mode2' */ - /* : fprintf('\n'); */ - printf("\n"); + /* MATLAB Function: '/Normal Mode' incorporates: + * DataStoreRead: '/Data Store Read1' + */ + /* : y = IncarFL; */ + /* : fprintf('IncarFL %u \n',IncarFL); */ + printf("IncarFL %u \n", rtDW.controllerDataIncarInput.InIncarFL); fflush(stdout); - /* End of MATLAB Function: '/MAX POSITION' */ - - /* MATLAB Function: '/MIN POSITION' incorporates: - * DataStoreRead: '/Data Store Read3' - */ - /* : y = step; */ - /* : fprintf('SIMULINK MIN POSITION '); */ - printf("SIMULINK MIN POSITION "); + /* MATLAB Function: '/Normal Mode1' */ + /* : y = IncarFL_VIN ; */ + /* : fprintf('IncarFL_VIN %f\n',IncarFL_VIN); */ + printf("IncarFL_VIN %f\n", rtb_Divide1); fflush(stdout); - /* : for i = 1:numel(step) */ - for (i = 0; i < 9; i++) { - /* : fprintf('%d ', int16(step(i))); */ - printf("%d ", rtDW.Min_position_Ch0[i]); - fflush(stdout); - } - - /* : fprintf('\n'); */ - printf("\n"); + /* MATLAB Function: '/Normal Mode2' incorporates: + * DataStoreWrite: '/Data Store Write1' + */ + /* : y = IncarFLErr ; */ + /* : fprintf('IncarFLErr %d\n',int8(IncarFLErr)); */ + printf("IncarFLErr %d\n", (int8_t)IncarFLErr); fflush(stdout); - /* End of MATLAB Function: '/MIN POSITION' */ - /* End of Outputs for SubSystem: '/Homing' */ - break; - - case 0: - /* Outputs for IfAction SubSystem: '/Homing1' incorporates: - * ActionPort: '/Action Port' + /* MATLAB Function: '/Normal Mode3' incorporates: + * DataStoreWrite: '/Data Store Write' */ - /* Merge: '/Merge' incorporates: - * SignalConversion generated from: '/stepIn' - */ - rtB.Merge = rtDW.UnitDelay_DSTATE; + /* : y = IncarFLOut ; */ + /* : fprintf('IncarFLOut %f\n',IncarFLOut); */ + printf("IncarFLOut %f\n", IncarFL); + fflush(stdout); - /* End of Outputs for SubSystem: '/Homing1' */ - break; - } - - /* End of SwitchCase: '/Switch Case' */ - - /* DataStoreWrite: '/Start write stepSig' incorporates: - * Constant: '/Constant1' - */ - rtDW.stepSig = 1; - - /* BusCreator: '/Bus Creator' incorporates: - * DataStoreRead: '/Data Store Read1' - * DataStoreRead: '/Data Store Read2' - * DataStoreRead: '/Data Store Read3' - * DataStoreRead: '/Data Store Read4' - * DataStoreRead: '/Data Store Read5' - * DataStoreRead: '/Data Store Read6' - * DataStoreRead: '/Data Store Read7' - * DataStoreRead: '/Data Store Read8' - * DataStoreRead: '/Data Store Read9' - * DataStoreWrite: '/Data Store Write' - */ - for (i = 0; i < 9; i++) { - controllerData.POS[i] = rtDW.pos_loc[i]; - controllerData.BUS_ADR[i] = rtDW.busAdr_loc[i]; - controllerData.MODE[i] = rtDW.mode_loc[i]; - controllerData.COM[i] = rtDW.com_loc[i]; - controllerData.Stall_SET[i] = rtDW.stall_set_loc[i]; - controllerData.Lnoise_SET[i] = rtDW.lnoise_set_loc[i]; - controllerData.Autos_SET[i] = rtDW.autos_set_loc[i]; - controllerData.Speed_SET[i] = rtDW.speed_set_loc[i]; - controllerData.Coils_Stop_SET[i] = rtDW.coils_stop_set_loc[i]; - } - - /* End of BusCreator: '/Bus Creator' */ - - /* Outport: '/Out1' incorporates: - * DataStoreRead: '/Data Store Read10' - */ - rtY.Out1 = controllerData; - - /* Update for Switch: '/Switch' incorporates: - * UnitDelay: '/Unit Delay' - */ - rtDW.UnitDelay_DSTATE = rtB.Merge; + /* Update for UnitDelay: '/Unit Delay' */ + rtDW.UnitDelay_DSTATE = rtb_FailCond; } /* Model initialize function */ void Model_actuator_initialize(void) { - /* (no initialization code required) */ + /* (no initialization code required) */ } /* Model terminate function */ void Model_actuator_terminate(void) { - /* (no terminate code required) */ + /* (no terminate code required) */ } /* diff --git a/Model_actuator.h b/Model_actuator.h index df98196..885bc91 100644 --- a/Model_actuator.h +++ b/Model_actuator.h @@ -3,9 +3,9 @@ * * Code generated for Simulink model 'Model_actuator'. * - * Model version : 1.550 + * Model version : 1.571 * Simulink Coder version : 24.1 (R2024a) 19-Nov-2023 - * C/C++ source code generated on : Tue Dec 23 15:12:50 2025 + * C/C++ source code generated on : Fri Jan 30 15:55:23 2026 * * Target selection: ert.tlc * Embedded hardware selection: ARM Compatible->ARM Cortex-M @@ -38,77 +38,38 @@ /* user code (top of header file) */ #include -/* Block signals (default storage) */ -typedef struct { - int8_t Merge; /* '/Merge' */ -} B; - /* Block states (default storage) for system '' */ typedef struct { - int16_t Min_position_Ch0[9]; /* '/Data Store Memory12' */ - int16_t Max_position_Ch0[9]; /* '/Data Store Memory13' */ - uint16_t pos_loc[9]; /* '/Data Store Memory4' */ - int8_t UnitDelay_DSTATE; /* '/Unit Delay' */ - int8_t stepSig; /* '/Data Store Memory' */ - uint8_t mode_loc[9]; /* '/Data Store Memory1' */ - uint8_t com_loc[9]; /* '/Data Store Memory2' */ - uint8_t busAdr_loc[9]; /* '/Data Store Memory3' */ - uint8_t stall_set_loc[9]; /* '/Data Store Memory5' */ - uint8_t lnoise_set_loc[9]; /* '/Data Store Memory6' */ - uint8_t autos_set_loc[9]; /* '/Data Store Memory7' */ - uint8_t speed_set_loc[9]; /* '/Data Store Memory8' */ - uint8_t coils_stop_set_loc[9]; /* '/Data Store Memory9' */ + IncarCmdBusInput controllerDataIncarInput;/* '/Data Store Memory' */ + uint32_t UnitDelay1_DSTATE; /* '/Unit Delay1' */ + uint32_t t_now; /* '/Data Store Memory5' */ + bool UnitDelay_DSTATE; /* '/Unit Delay' */ } DW; -/* External inputs (root inport signals with default storage) */ +/* Constant parameters (default storage) */ typedef struct { - int16_t in_CPOS_ALL_Ch0[9]; /* '/in_CPOS_ALL_Ch0' */ - int8_t in_Act_Emrf_Slave_Ch0[9]; /* '/in_Act_Emrf_Slave_Ch0' */ - int8_t in_Mode_Slave_Ch0[9]; /* '/in_Mode_Slave_Ch0' */ - int8_t in_Act_Err1_Supply_Ch0[9]; /* '/in_Act_Err1_Supply_Ch0' */ - int8_t in_Act_Err2_Communication_Ch0[9]; - /* '/in_Act_Err2_Communication_Ch0' */ - int8_t in_Act_Err3_Temperature_Ch0[9]; - /* '/in_Act_Err3_Temperature_Ch0' */ - int8_t in_Act_Err4_Permanent_Electrical_Ch0[9]; - /* '/in_Act_Err4_Permanent_Electrical_Ch0' */ - int8_t in_Act_Stall_Slave_Ch0[9]; /* '/in_Act_Stall_Slave_Ch0' */ - int8_t in_Act_Reset_Ch0[9]; /* '/in_Act_Reset_Ch0' */ - uint8_t in_Busy_Ch0; /* '/in_Busy_Ch0' */ - uint8_t in_Error_Connect_Ch0; /* '/in_Error_Connect_Ch0' */ -} ExtU; + /* Expression: [2202 2202 2164 2129 2096 2065 2037 2010 1984 1960 1937 1916 1895 1875 1857 1839 1821 1805 1789 1774 1759 1744 1731 1717 1704 1692 1680 1668 1657 1645 1635 1624 1614 1604 1594 1585 1576 1567 1558 1549 1541 1533 1524 1517 1509 1501 1494 1487 14791472 1466 1459 1452 1446 1439 1433 1427 1421 1415 1409 1403 1398 1392 1387 1381 1376 1371 1365 1360 1355 1350 1345 1341 1336 1331 1327 1322 1317 1313 1309 1304 1300 1296 1292 1287 1283 1279 1275 1271 1268 1264 1260 1256 1252 1249 1245 1241 1238 1234 1231 1227 1224 1221 1217 1214 1211 1207 1204 1201 1198 1195 1192 1189 1186 1182 1179 1177 1174 1171 1168 1165 1162 1159 1157 1154 1151 1148 1146 1143 1140 1138 1135 1132 1130 1127 1125 1122 1120 1117 1115 1112 1110 1108 1105 1103 1101 1098 1096 1094 1091 1089 1087 1085 1082 1080 1078 1076 1074 1072 1069 1067 1065 1063 1061 1059 1057 1055 1053 1051 1049 1047 1045 1043 1041 1039 1037 1035 1033 1032 1030 1028 1026 1024 1022 1020 1019 1017 1015 1013 1011 1010 1008 1006 1005 1003 1001 999 998 996 994 993 991 989 988 986 984 983 981 980 978 976 975 973 972 970 969 967 966 964 963 961 960 958 957 955 954 952 951 949 948 946 945 944 942 941 939 938 937 935 934 932 931 930 928 927 926 924 923 922 920 919 918 916 915 914 912 911 910 909 907 906 905 904 902 901 900 899 897 896 895 894 893 891 890 889 888 887 885 884 883 882 881 880 878 877 876 875 874 873 872 871 869 868 867 866 865 864 863 862 861 860 858 857 856 855 854 853 852 851 850 849 848 847 846 845 844 843 842 841 840 839 838 837 836 835 834 833 832 831 830 829 828 827 826 825 824 823 822 821 820 819 818 817 816 815 814 813 813 812 811 810 809 808 807 806 805 804 803 802 802 801 800 799 798 797 796 795 795 794 793 792 791 790 789 789 788 787 786 785 784 783 783 782 781 780 779 778 778 777 776 775 774 774 773 772 771 770 769 769 768 767 766 766 765 764 763 762 762 761 760 759 758 758 757 756 755 755 754 753 752 752 751 750 749 749 748 747 746 746 745 744 743 743 742 741 740 740 739 738 737 737 736 735 735 734 733 732 732 731 730 730 729 728 727 727 726 725 725 724 723 723 722 721 721 720 719 718 718 717 716 716 715 714 714 713 712 712 ] -/* External outputs (root outports fed by signals with default storage) */ -typedef struct { - ActuatorCmdBus Out1; /* '/Out1' */ -} ExtY; + * Referenced by: '/1-D Lookup Table' + */ + double uDLookupTable_tableData[476]; + + /* Expression: [15:490] + * Referenced by: '/1-D Lookup Table' + */ + double uDLookupTable_bp01Data[476]; +} ConstP; /* Real-time Model Data Structure */ struct tag_RTM { const char * volatile errorStatus; }; -/* Block signals (default storage) */ -extern B rtB; - /* Block states (default storage) */ extern DW rtDW; -/* External inputs (root inport signals with default storage) */ -extern ExtU rtU; - -/* External outputs (root outports fed by signals with default storage) */ -extern ExtY rtY; - -/* - * Exported States - * - * Note: Exported states are block states with an exported global - * storage class designation. Code generation will declare the memory for these - * states and exports their symbols. - * - */ -extern ActuatorCmdBus controllerData; /* '/Data Store Memory15' */ +/* Constant parameters (default storage) */ +extern const ConstP rtConstP; /* Model entry point functions */ extern void Model_actuator_initialize(void); @@ -121,10 +82,7 @@ extern RT_MODEL *const rtM; /*- * These blocks were eliminated from the model due to optimizations: * - * Block '/Display1' : Unused code path elimination - * Block '/Display2' : Unused code path elimination - * Block '/Display3' : Unused code path elimination - * Block '/Display3' : Unused code path elimination + * Block '/Display' : Unused code path elimination */ /*- @@ -142,45 +100,18 @@ extern RT_MODEL *const rtM; * Here is the system hierarchy for this model * * '' : 'Model_actuator' - * '' : 'Model_actuator/Check Stall Max' - * '' : 'Model_actuator/Check Stall Min' - * '' : 'Model_actuator/Finish case' - * '' : 'Model_actuator/Homing' - * '' : 'Model_actuator/Homing1' - * '' : 'Model_actuator/Initial CPOS Max' - * '' : 'Model_actuator/Initial CPOS Min' - * '' : 'Model_actuator/Move to position Max' - * '' : 'Model_actuator/Move to position Min' - * '' : 'Model_actuator/Normal Mode' - * '' : 'Model_actuator/Start case' - * '' : 'Model_actuator/Stop Mode' - * '' : 'Model_actuator/Subsystem' - * '' : 'Model_actuator/Check Stall Max/Check Stall Max' - * '' : 'Model_actuator/Check Stall Max/If Action Subsystem2' - * '' : 'Model_actuator/Check Stall Max/If Action Subsystem3' - * '' : 'Model_actuator/Check Stall Min/Check Stall Min' - * '' : 'Model_actuator/Check Stall Min/If Action Subsystem2' - * '' : 'Model_actuator/Check Stall Min/If Action Subsystem3' - * '' : 'Model_actuator/Homing/MAX POSITION' - * '' : 'Model_actuator/Homing/MIN POSITION' - * '' : 'Model_actuator/Initial CPOS Max/If Action Subsystem2' - * '' : 'Model_actuator/Initial CPOS Max/If Action Subsystem3' - * '' : 'Model_actuator/Initial CPOS Max/Initial CPOS Max' - * '' : 'Model_actuator/Initial CPOS Min/If Action Subsystem' - * '' : 'Model_actuator/Initial CPOS Min/If Action Subsystem3' - * '' : 'Model_actuator/Initial CPOS Min/Initial CPOS Min' - * '' : 'Model_actuator/Move to position Max/If Action Subsystem2' - * '' : 'Model_actuator/Move to position Max/If Action Subsystem3' - * '' : 'Model_actuator/Move to position Max/Move to position Max' - * '' : 'Model_actuator/Move to position Min/If Action Subsystem2' - * '' : 'Model_actuator/Move to position Min/If Action Subsystem3' - * '' : 'Model_actuator/Move to position Min/Move to position Min' - * '' : 'Model_actuator/Normal Mode/If Action Subsystem2' - * '' : 'Model_actuator/Normal Mode/If Action Subsystem3' - * '' : 'Model_actuator/Normal Mode/Normal Mode' - * '' : 'Model_actuator/Stop Mode/If Action Subsystem2' - * '' : 'Model_actuator/Stop Mode/If Action Subsystem3' - * '' : 'Model_actuator/Stop Mode/stop mode' + * '' : 'Model_actuator/ACP' + * '' : 'Model_actuator/ACP/Incar' + * '' : 'Model_actuator/ACP/Incar/Compare To Constant' + * '' : 'Model_actuator/ACP/Incar/Compare To Constant1' + * '' : 'Model_actuator/ACP/Incar/Compare To Constant2' + * '' : 'Model_actuator/ACP/Incar/Normal Mode' + * '' : 'Model_actuator/ACP/Incar/Normal Mode1' + * '' : 'Model_actuator/ACP/Incar/Normal Mode2' + * '' : 'Model_actuator/ACP/Incar/Normal Mode3' + * '' : 'Model_actuator/ACP/Incar/RealTime_Timer' + * '' : 'Model_actuator/ACP/Incar/Subsystem' + * '' : 'Model_actuator/ACP/Incar/RealTime_Timer/Normal Mode2' */ #endif /* Model_actuator_h_ */ diff --git a/Model_actuator_data.c b/Model_actuator_data.c new file mode 100644 index 0000000..c82c8c8 --- /dev/null +++ b/Model_actuator_data.c @@ -0,0 +1,127 @@ +/* + * File: Model_actuator_data.c + * + * Code generated for Simulink model 'Model_actuator'. + * + * Model version : 1.571 + * Simulink Coder version : 24.1 (R2024a) 19-Nov-2023 + * C/C++ source code generated on : Fri Jan 30 15:55:23 2026 + * + * Target selection: ert.tlc + * Embedded hardware selection: ARM Compatible->ARM Cortex-M + * Emulation hardware selection: + * Differs from embedded hardware (MATLAB Host) + * Code generation objectives: Unspecified + * Validation result: Not run + */ + +#include "Model_actuator.h" + +/* Constant parameters (default storage) */ +const ConstP rtConstP = { + /* Expression: [2202 2202 2164 2129 2096 2065 2037 2010 1984 1960 1937 1916 1895 1875 1857 1839 1821 1805 1789 1774 1759 1744 1731 1717 1704 1692 1680 1668 1657 1645 1635 1624 1614 1604 1594 1585 1576 1567 1558 1549 1541 1533 1524 1517 1509 1501 1494 1487 14791472 1466 1459 1452 1446 1439 1433 1427 1421 1415 1409 1403 1398 1392 1387 1381 1376 1371 1365 1360 1355 1350 1345 1341 1336 1331 1327 1322 1317 1313 1309 1304 1300 1296 1292 1287 1283 1279 1275 1271 1268 1264 1260 1256 1252 1249 1245 1241 1238 1234 1231 1227 1224 1221 1217 1214 1211 1207 1204 1201 1198 1195 1192 1189 1186 1182 1179 1177 1174 1171 1168 1165 1162 1159 1157 1154 1151 1148 1146 1143 1140 1138 1135 1132 1130 1127 1125 1122 1120 1117 1115 1112 1110 1108 1105 1103 1101 1098 1096 1094 1091 1089 1087 1085 1082 1080 1078 1076 1074 1072 1069 1067 1065 1063 1061 1059 1057 1055 1053 1051 1049 1047 1045 1043 1041 1039 1037 1035 1033 1032 1030 1028 1026 1024 1022 1020 1019 1017 1015 1013 1011 1010 1008 1006 1005 1003 1001 999 998 996 994 993 991 989 988 986 984 983 981 980 978 976 975 973 972 970 969 967 966 964 963 961 960 958 957 955 954 952 951 949 948 946 945 944 942 941 939 938 937 935 934 932 931 930 928 927 926 924 923 922 920 919 918 916 915 914 912 911 910 909 907 906 905 904 902 901 900 899 897 896 895 894 893 891 890 889 888 887 885 884 883 882 881 880 878 877 876 875 874 873 872 871 869 868 867 866 865 864 863 862 861 860 858 857 856 855 854 853 852 851 850 849 848 847 846 845 844 843 842 841 840 839 838 837 836 835 834 833 832 831 830 829 828 827 826 825 824 823 822 821 820 819 818 817 816 815 814 813 813 812 811 810 809 808 807 806 805 804 803 802 802 801 800 799 798 797 796 795 795 794 793 792 791 790 789 789 788 787 786 785 784 783 783 782 781 780 779 778 778 777 776 775 774 774 773 772 771 770 769 769 768 767 766 766 765 764 763 762 762 761 760 759 758 758 757 756 755 755 754 753 752 752 751 750 749 749 748 747 746 746 745 744 743 743 742 741 740 740 739 738 737 737 736 735 735 734 733 732 732 731 730 730 729 728 727 727 726 725 725 724 723 723 722 721 721 720 719 718 718 717 716 716 715 714 714 713 712 712 ] + + * Referenced by: '/1-D Lookup Table' + */ + { 2202.0, 2202.0, 2164.0, 2129.0, 2096.0, 2065.0, 2037.0, 2010.0, 1984.0, + 1960.0, 1937.0, 1916.0, 1895.0, 1875.0, 1857.0, 1839.0, 1821.0, 1805.0, + 1789.0, 1774.0, 1759.0, 1744.0, 1731.0, 1717.0, 1704.0, 1692.0, 1680.0, + 1668.0, 1657.0, 1645.0, 1635.0, 1624.0, 1614.0, 1604.0, 1594.0, 1585.0, + 1576.0, 1567.0, 1558.0, 1549.0, 1541.0, 1533.0, 1524.0, 1517.0, 1509.0, + 1501.0, 1494.0, 1487.0, 1.4791472E+7, 1466.0, 1459.0, 1452.0, 1446.0, 1439.0, + 1433.0, 1427.0, 1421.0, 1415.0, 1409.0, 1403.0, 1398.0, 1392.0, 1387.0, + 1381.0, 1376.0, 1371.0, 1365.0, 1360.0, 1355.0, 1350.0, 1345.0, 1341.0, + 1336.0, 1331.0, 1327.0, 1322.0, 1317.0, 1313.0, 1309.0, 1304.0, 1300.0, + 1296.0, 1292.0, 1287.0, 1283.0, 1279.0, 1275.0, 1271.0, 1268.0, 1264.0, + 1260.0, 1256.0, 1252.0, 1249.0, 1245.0, 1241.0, 1238.0, 1234.0, 1231.0, + 1227.0, 1224.0, 1221.0, 1217.0, 1214.0, 1211.0, 1207.0, 1204.0, 1201.0, + 1198.0, 1195.0, 1192.0, 1189.0, 1186.0, 1182.0, 1179.0, 1177.0, 1174.0, + 1171.0, 1168.0, 1165.0, 1162.0, 1159.0, 1157.0, 1154.0, 1151.0, 1148.0, + 1146.0, 1143.0, 1140.0, 1138.0, 1135.0, 1132.0, 1130.0, 1127.0, 1125.0, + 1122.0, 1120.0, 1117.0, 1115.0, 1112.0, 1110.0, 1108.0, 1105.0, 1103.0, + 1101.0, 1098.0, 1096.0, 1094.0, 1091.0, 1089.0, 1087.0, 1085.0, 1082.0, + 1080.0, 1078.0, 1076.0, 1074.0, 1072.0, 1069.0, 1067.0, 1065.0, 1063.0, + 1061.0, 1059.0, 1057.0, 1055.0, 1053.0, 1051.0, 1049.0, 1047.0, 1045.0, + 1043.0, 1041.0, 1039.0, 1037.0, 1035.0, 1033.0, 1032.0, 1030.0, 1028.0, + 1026.0, 1024.0, 1022.0, 1020.0, 1019.0, 1017.0, 1015.0, 1013.0, 1011.0, + 1010.0, 1008.0, 1006.0, 1005.0, 1003.0, 1001.0, 999.0, 998.0, 996.0, 994.0, + 993.0, 991.0, 989.0, 988.0, 986.0, 984.0, 983.0, 981.0, 980.0, 978.0, 976.0, + 975.0, 973.0, 972.0, 970.0, 969.0, 967.0, 966.0, 964.0, 963.0, 961.0, 960.0, + 958.0, 957.0, 955.0, 954.0, 952.0, 951.0, 949.0, 948.0, 946.0, 945.0, 944.0, + 942.0, 941.0, 939.0, 938.0, 937.0, 935.0, 934.0, 932.0, 931.0, 930.0, 928.0, + 927.0, 926.0, 924.0, 923.0, 922.0, 920.0, 919.0, 918.0, 916.0, 915.0, 914.0, + 912.0, 911.0, 910.0, 909.0, 907.0, 906.0, 905.0, 904.0, 902.0, 901.0, 900.0, + 899.0, 897.0, 896.0, 895.0, 894.0, 893.0, 891.0, 890.0, 889.0, 888.0, 887.0, + 885.0, 884.0, 883.0, 882.0, 881.0, 880.0, 878.0, 877.0, 876.0, 875.0, 874.0, + 873.0, 872.0, 871.0, 869.0, 868.0, 867.0, 866.0, 865.0, 864.0, 863.0, 862.0, + 861.0, 860.0, 858.0, 857.0, 856.0, 855.0, 854.0, 853.0, 852.0, 851.0, 850.0, + 849.0, 848.0, 847.0, 846.0, 845.0, 844.0, 843.0, 842.0, 841.0, 840.0, 839.0, + 838.0, 837.0, 836.0, 835.0, 834.0, 833.0, 832.0, 831.0, 830.0, 829.0, 828.0, + 827.0, 826.0, 825.0, 824.0, 823.0, 822.0, 821.0, 820.0, 819.0, 818.0, 817.0, + 816.0, 815.0, 814.0, 813.0, 813.0, 812.0, 811.0, 810.0, 809.0, 808.0, 807.0, + 806.0, 805.0, 804.0, 803.0, 802.0, 802.0, 801.0, 800.0, 799.0, 798.0, 797.0, + 796.0, 795.0, 795.0, 794.0, 793.0, 792.0, 791.0, 790.0, 789.0, 789.0, 788.0, + 787.0, 786.0, 785.0, 784.0, 783.0, 783.0, 782.0, 781.0, 780.0, 779.0, 778.0, + 778.0, 777.0, 776.0, 775.0, 774.0, 774.0, 773.0, 772.0, 771.0, 770.0, 769.0, + 769.0, 768.0, 767.0, 766.0, 766.0, 765.0, 764.0, 763.0, 762.0, 762.0, 761.0, + 760.0, 759.0, 758.0, 758.0, 757.0, 756.0, 755.0, 755.0, 754.0, 753.0, 752.0, + 752.0, 751.0, 750.0, 749.0, 749.0, 748.0, 747.0, 746.0, 746.0, 745.0, 744.0, + 743.0, 743.0, 742.0, 741.0, 740.0, 740.0, 739.0, 738.0, 737.0, 737.0, 736.0, + 735.0, 735.0, 734.0, 733.0, 732.0, 732.0, 731.0, 730.0, 730.0, 729.0, 728.0, + 727.0, 727.0, 726.0, 725.0, 725.0, 724.0, 723.0, 723.0, 722.0, 721.0, 721.0, + 720.0, 719.0, 718.0, 718.0, 717.0, 716.0, 716.0, 715.0, 714.0, 714.0, 713.0, + 712.0, 712.0 }, + + /* Expression: [15:490] + * Referenced by: '/1-D Lookup Table' + */ + { 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, + 28.0, 29.0, 30.0, 31.0, 32.0, 33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, 40.0, + 41.0, 42.0, 43.0, 44.0, 45.0, 46.0, 47.0, 48.0, 49.0, 50.0, 51.0, 52.0, 53.0, + 54.0, 55.0, 56.0, 57.0, 58.0, 59.0, 60.0, 61.0, 62.0, 63.0, 64.0, 65.0, 66.0, + 67.0, 68.0, 69.0, 70.0, 71.0, 72.0, 73.0, 74.0, 75.0, 76.0, 77.0, 78.0, 79.0, + 80.0, 81.0, 82.0, 83.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0, 90.0, 91.0, 92.0, + 93.0, 94.0, 95.0, 96.0, 97.0, 98.0, 99.0, 100.0, 101.0, 102.0, 103.0, 104.0, + 105.0, 106.0, 107.0, 108.0, 109.0, 110.0, 111.0, 112.0, 113.0, 114.0, 115.0, + 116.0, 117.0, 118.0, 119.0, 120.0, 121.0, 122.0, 123.0, 124.0, 125.0, 126.0, + 127.0, 128.0, 129.0, 130.0, 131.0, 132.0, 133.0, 134.0, 135.0, 136.0, 137.0, + 138.0, 139.0, 140.0, 141.0, 142.0, 143.0, 144.0, 145.0, 146.0, 147.0, 148.0, + 149.0, 150.0, 151.0, 152.0, 153.0, 154.0, 155.0, 156.0, 157.0, 158.0, 159.0, + 160.0, 161.0, 162.0, 163.0, 164.0, 165.0, 166.0, 167.0, 168.0, 169.0, 170.0, + 171.0, 172.0, 173.0, 174.0, 175.0, 176.0, 177.0, 178.0, 179.0, 180.0, 181.0, + 182.0, 183.0, 184.0, 185.0, 186.0, 187.0, 188.0, 189.0, 190.0, 191.0, 192.0, + 193.0, 194.0, 195.0, 196.0, 197.0, 198.0, 199.0, 200.0, 201.0, 202.0, 203.0, + 204.0, 205.0, 206.0, 207.0, 208.0, 209.0, 210.0, 211.0, 212.0, 213.0, 214.0, + 215.0, 216.0, 217.0, 218.0, 219.0, 220.0, 221.0, 222.0, 223.0, 224.0, 225.0, + 226.0, 227.0, 228.0, 229.0, 230.0, 231.0, 232.0, 233.0, 234.0, 235.0, 236.0, + 237.0, 238.0, 239.0, 240.0, 241.0, 242.0, 243.0, 244.0, 245.0, 246.0, 247.0, + 248.0, 249.0, 250.0, 251.0, 252.0, 253.0, 254.0, 255.0, 256.0, 257.0, 258.0, + 259.0, 260.0, 261.0, 262.0, 263.0, 264.0, 265.0, 266.0, 267.0, 268.0, 269.0, + 270.0, 271.0, 272.0, 273.0, 274.0, 275.0, 276.0, 277.0, 278.0, 279.0, 280.0, + 281.0, 282.0, 283.0, 284.0, 285.0, 286.0, 287.0, 288.0, 289.0, 290.0, 291.0, + 292.0, 293.0, 294.0, 295.0, 296.0, 297.0, 298.0, 299.0, 300.0, 301.0, 302.0, + 303.0, 304.0, 305.0, 306.0, 307.0, 308.0, 309.0, 310.0, 311.0, 312.0, 313.0, + 314.0, 315.0, 316.0, 317.0, 318.0, 319.0, 320.0, 321.0, 322.0, 323.0, 324.0, + 325.0, 326.0, 327.0, 328.0, 329.0, 330.0, 331.0, 332.0, 333.0, 334.0, 335.0, + 336.0, 337.0, 338.0, 339.0, 340.0, 341.0, 342.0, 343.0, 344.0, 345.0, 346.0, + 347.0, 348.0, 349.0, 350.0, 351.0, 352.0, 353.0, 354.0, 355.0, 356.0, 357.0, + 358.0, 359.0, 360.0, 361.0, 362.0, 363.0, 364.0, 365.0, 366.0, 367.0, 368.0, + 369.0, 370.0, 371.0, 372.0, 373.0, 374.0, 375.0, 376.0, 377.0, 378.0, 379.0, + 380.0, 381.0, 382.0, 383.0, 384.0, 385.0, 386.0, 387.0, 388.0, 389.0, 390.0, + 391.0, 392.0, 393.0, 394.0, 395.0, 396.0, 397.0, 398.0, 399.0, 400.0, 401.0, + 402.0, 403.0, 404.0, 405.0, 406.0, 407.0, 408.0, 409.0, 410.0, 411.0, 412.0, + 413.0, 414.0, 415.0, 416.0, 417.0, 418.0, 419.0, 420.0, 421.0, 422.0, 423.0, + 424.0, 425.0, 426.0, 427.0, 428.0, 429.0, 430.0, 431.0, 432.0, 433.0, 434.0, + 435.0, 436.0, 437.0, 438.0, 439.0, 440.0, 441.0, 442.0, 443.0, 444.0, 445.0, + 446.0, 447.0, 448.0, 449.0, 450.0, 451.0, 452.0, 453.0, 454.0, 455.0, 456.0, + 457.0, 458.0, 459.0, 460.0, 461.0, 462.0, 463.0, 464.0, 465.0, 466.0, 467.0, + 468.0, 469.0, 470.0, 471.0, 472.0, 473.0, 474.0, 475.0, 476.0, 477.0, 478.0, + 479.0, 480.0, 481.0, 482.0, 483.0, 484.0, 485.0, 486.0, 487.0, 488.0, 489.0, + 490.0 } +}; + +/* + * File trailer for generated code. + * + * [EOF] + */ diff --git a/Model_actuator_private.h b/Model_actuator_private.h index 487fecc..f921934 100644 --- a/Model_actuator_private.h +++ b/Model_actuator_private.h @@ -3,9 +3,9 @@ * * Code generated for Simulink model 'Model_actuator'. * - * Model version : 1.550 + * Model version : 1.571 * Simulink Coder version : 24.1 (R2024a) 19-Nov-2023 - * C/C++ source code generated on : Tue Dec 23 15:12:50 2025 + * C/C++ source code generated on : Fri Jan 30 15:55:23 2026 * * Target selection: ert.tlc * Embedded hardware selection: ARM Compatible->ARM Cortex-M @@ -22,8 +22,8 @@ #include "Model_actuator_types.h" #include "Model_actuator.h" -extern void IfActionSubsystem3(int8_t rtu_stepIn, int8_t *rty_step, uint8_t - rtd_com_loc[9]); +extern double look1_binlx(double u0, const double bp0[], const double table[], + uint32_t maxIndex); #endif /* Model_actuator_private_h_ */ diff --git a/Model_actuator_types.h b/Model_actuator_types.h index bbd4855..52685d3 100644 --- a/Model_actuator_types.h +++ b/Model_actuator_types.h @@ -3,9 +3,9 @@ * * Code generated for Simulink model 'Model_actuator'. * - * Model version : 1.550 + * Model version : 1.571 * Simulink Coder version : 24.1 (R2024a) 19-Nov-2023 - * C/C++ source code generated on : Tue Dec 23 15:12:50 2025 + * C/C++ source code generated on : Fri Jan 30 15:55:23 2026 * * Target selection: ert.tlc * Embedded hardware selection: ARM Compatible->ARM Cortex-M @@ -18,20 +18,30 @@ #ifndef Model_actuator_types_h_ #define Model_actuator_types_h_ #include -#ifndef DEFINED_TYPEDEF_FOR_ActuatorCmdBus_ -#define DEFINED_TYPEDEF_FOR_ActuatorCmdBus_ +#include +#ifndef DEFINED_TYPEDEF_FOR_IncarCmdBusInput_ +#define DEFINED_TYPEDEF_FOR_IncarCmdBusInput_ typedef struct { - uint16_t POS[9]; - uint8_t BUS_ADR[9]; - uint8_t MODE[9]; - uint8_t COM[9]; - uint8_t Stall_SET[9]; - uint8_t Lnoise_SET[9]; - uint8_t Autos_SET[9]; - uint8_t Speed_SET[9]; - uint8_t Coils_Stop_SET[9]; -} ActuatorCmdBus; + uint16_t InIncarFL; + uint16_t InIncarFR; + uint16_t InIncarRL; + uint16_t InIncarRR; +} IncarCmdBusInput; + +#endif + +#ifndef DEFINED_TYPEDEF_FOR_IncarCmdBusError_ +#define DEFINED_TYPEDEF_FOR_IncarCmdBusError_ + +typedef struct { + bool IncarFLErr; + bool IncarFRErr; + bool IncarRLErr; + bool IncarRRErr; + bool CANIncarTempErrF; + bool CANIncarTempErrR; +} IncarCmdBusError; #endif