/* * File: Mount_Drv_FDR2023.c * * Code generated for Simulink model 'Mount_Drv_FDR2023'. * * Model version : 9.78 * Simulink Coder version : 9.8 (R2022b) 13-May-2022 * C/C++ source code generated on : Mon Apr 1 12:53:27 2024 * * Target selection: ert.tlc * Embedded hardware selection: Intel->x86-64 (Linux 64) * Code generation objective: Execution efficiency * Validation result: All passed */ #include "Mount_Drv_FDR2023.h" #include "rtwtypes.h" #include "Mount_Drv_FDR2023_private.h" #include #include #include real_T look1_binlx(real_T u0, const real_T bp0[], const real_T table[], uint32_T maxIndex) { real_T frac; real_T yL_0d0; uint32_T iLeft; /* 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; /* Binary Search */ bpIdx = maxIndex >> 1U; iLeft = 0U; iRght = maxIndex; while (iRght - iLeft > 1U) { if (u0 < bp0[bpIdx]) { iRght = bpIdx; } else { iLeft = bpIdx; } bpIdx = (iRght + iLeft) >> 1U; } frac = (u0 - bp0[iLeft]) / (bp0[iLeft + 1U] - bp0[iLeft]); } else { iLeft = maxIndex - 1U; frac = (u0 - bp0[maxIndex - 1U]) / (bp0[maxIndex] - bp0[maxIndex - 1U]); } /* 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; } /* * Output and update for enable system: * '/gs' * '/gs' * '/gs' */ void Mount_Drv_FDR2023_gs(real_T rtu_Enable, real_T rtu_v, real_T *rty_gsv, real_T rtp_vs, real_T rtp_Ts, real_T rtp_Tc, real_T rtp_sigma0) { /* Outputs for Enabled SubSystem: '/gs' incorporates: * EnablePort: '/Enable' */ if (rtu_Enable > 0.0) { real_T rtb_Gain_j; /* Gain: '/Gain' */ rtb_Gain_j = 1.0 / rtp_vs * rtu_v; /* Product: '/Divide' incorporates: * Constant: '/gs' * Math: '/Math Function' * Math: '/Math Function1' * UnaryMinus: '/Unary Minus' * * About '/Math Function': * Operator: exp * * About '/Math Function1': * Operator: magnitude^2 */ *rty_gsv = (rtp_Ts - rtp_Tc) / rtp_sigma0 * exp(-(rtb_Gain_j * rtb_Gain_j)); } /* End of Outputs for SubSystem: '/gs' */ } /* * Output and update for enable system: * '/AZ DT Lugre Fr mode' * '/EL DT Lugre Fr model' */ void Mount_Drv_FDR20_AZDTLugreFrmode(real_T rtu_Enable, real_T rtu_v, real_T *rty_Tfr, real_T rtp_vs, real_T rtp_Ts, real_T rtp_Tc, real_T rtp_sigma0, real_T rtp_iIsSig01Active, real_T rtp_sigma1, real_T rtp_sigmav, DW_AZDTLugreFrmode_Mount_Drv__T *localDW) { /* Outputs for Enabled SubSystem: '/AZ DT Lugre Fr mode' incorporates: * EnablePort: '/Enable' */ if (rtu_Enable > 0.0) { /* Outputs for Enabled SubSystem: '/v2z' incorporates: * EnablePort: '/Enable' */ /* Outputs for Enabled SubSystem: '/g(v)' incorporates: * EnablePort: '/Enable' */ /* Constant: '/Constant' */ if (rtp_iIsSig01Active > 0.0) { /* Outputs for Enabled SubSystem: '/gs' */ /* Constant: '/Constant' */ Mount_Drv_FDR2023_gs(0.0, rtu_v, &localDW->Divide, rtp_vs, rtp_Ts, rtp_Tc, rtp_sigma0); /* End of Outputs for SubSystem: '/gs' */ /* Sum: '/Sum' incorporates: * Constant: '/gc' */ localDW->Sum_i = rtp_Tc / rtp_sigma0 + localDW->Divide; /* Sum: '/Sum' incorporates: * Abs: '/Abs' * DiscreteIntegrator: '/Discrete-Time Integrator' * Product: '/Divide' */ localDW->Sum = rtu_v - fabs(rtu_v) / localDW->Sum_i * localDW->DiscreteTimeIntegrator_DSTATE; } /* End of Constant: '/Constant' */ /* End of Outputs for SubSystem: '/g(v)' */ /* End of Outputs for SubSystem: '/v2z' */ /* Sum: '/Sum' incorporates: * DiscreteIntegrator: '/Discrete-Time Integrator' * Gain: '/sigma_0' * Gain: '/sigma_1' * Gain: '/sigma_v' */ *rty_Tfr = (rtp_sigma1 * localDW->Sum + rtp_sigma0 * localDW->DiscreteTimeIntegrator_DSTATE) + rtp_sigmav * rtu_v; /* Update for DiscreteIntegrator: '/Discrete-Time Integrator' */ localDW->DiscreteTimeIntegrator_DSTATE += 0.000125 * localDW->Sum; } /* End of Outputs for SubSystem: '/AZ DT Lugre Fr mode' */ } /* * Output and update for iterator system: * '/For Each Subsystem' * '/For Each Subsystem' */ void Mount_Drv_FDR2_ForEachSubsystem(int32_T NumIters, const real_T rtu_In1[8], real_T rty_Out1[8]) { /* local scratch DWork variables */ int32_T ForEach_itr; int32_T i; /* Outputs for Iterator SubSystem: '/For Each Subsystem' incorporates: * ForEach: '/For Each' */ for (ForEach_itr = 0; ForEach_itr < NumIters; ForEach_itr++) { real_T rtb_Out1_CoreSubsysCanOut_k; /* Sum: '/Sum of Elements2' */ rtb_Out1_CoreSubsysCanOut_k = -0.0; for (i = 0; i < 6; i++) { /* Sum: '/Sum of Elements2' incorporates: * ForEachSliceSelector generated from: '/In1' * Sin: '/EMF Spatial Pattern (N//A)' */ rtb_Out1_CoreSubsysCanOut_k += sin(Mount_Drv_FDR2023_ConstP.pooled6[i] * rtu_In1[ForEach_itr] + Mount_Drv_FDR2023_ConstP.pooled7[i]) * Mount_Drv_FDR2023_ConstP.pooled5[i]; } /* ForEachSliceAssignment generated from: '/Out1' */ rty_Out1[ForEach_itr] = rtb_Out1_CoreSubsysCanOut_k; } /* End of Outputs for SubSystem: '/For Each Subsystem' */ } /* * Output and update for iterator system: * '/For Each Subsystem1' * '/For Each Subsystem1' */ void Mount_Drv_FDR_ForEachSubsystem1(int32_T NumIters, const real_T rtu_In1[8], real_T rty_Out1[8]) { /* local scratch DWork variables */ int32_T ForEach_itr; /* Outputs for Iterator SubSystem: '/For Each Subsystem1' incorporates: * ForEach: '/For Each' */ for (ForEach_itr = 0; ForEach_itr < NumIters; ForEach_itr++) { /* ForEachSliceAssignment generated from: '/Out1' incorporates: * ForEachSliceSelector generated from: '/In1' * Sin: '/Cogging Spatial Pattern (N)' * Sum: '/Sum of Elements2' */ rty_Out1[ForEach_itr] = (sin(0.033300882128051809 * rtu_In1[ForEach_itr] + 0.8799) * 0.4854 + sin(0.067230082786821563 * rtu_In1[ForEach_itr] - 1.9742) * 5.4809) + sin(0.13446016557364313 * rtu_In1[ForEach_itr] + 2.2989) * 1.7897; } /* End of Outputs for SubSystem: '/For Each Subsystem1' */ } real_T rt_roundd(real_T u) { real_T y; if (fabs(u) < 4.503599627370496E+15) { if (u >= 0.5) { y = floor(u + 0.5); } else if (u > -0.5) { y = 0.0; } else { y = ceil(u - 0.5); } } else { y = u; } return y; } real_T rt_remd(real_T u0, real_T u1) { real_T y; if ((u1 != 0.0) && (u1 != trunc(u1))) { real_T q; q = fabs(u0 / u1); if (fabs(q - floor(q + 0.5)) <= DBL_EPSILON * q) { y = 0.0; } else { y = fmod(u0, u1); } } else { y = fmod(u0, u1); } return y; } /* Model step function */ void Mount_Drv_FDR2023_step(RT_MODEL_Mount_Drv_FDR2023_T *const Mount_Drv_FDR2023_M, ExtU_Mount_Drv_FDR2023_T *Mount_Drv_FDR2023_U, ExtY_Mount_Drv_FDR2023_T *Mount_Drv_FDR2023_Y) { DW_Mount_Drv_FDR2023_T *Mount_Drv_FDR2023_DW = Mount_Drv_FDR2023_M->dwork; /* local block i/o variables */ real_T rtb_ImpAsg_InsertedFor_Out1__ke[4]; real_T rtb_ImpAsg_InsertedFor_Out1_ke3[4]; real_T rtb_ImpAsg_InsertedFor_Out_ke3s[8]; real_T rtb_ImpAsg_InsertedFor_Ou_ke3sc[8]; real_T rtb_Bias[8]; real_T rtb_VectorConcatenate_b[8]; real_T rtb_ImpAsg_InsertedFor_Out1_a_d[4]; real_T rtb_ImpAsg_InsertedFor_Out1_at_[4]; real_T rtb_VectorConcatenate_m[4]; real_T rtb_Diff[3]; real_T rtb_Drv_Pos_avg[3]; real_T rtb_TSamp[3]; real_T rtb_CoggingSpatialPatternN[2]; real_T DiscreteTransferFcn_tmp; real_T rtb_Sum1_cj; real_T rtb_Sum1_e; real_T rtb_Sum1_hs; real_T rtb_Sum1_o; real_T rtb_Sum1_pw; real_T rtb_iIsSig01Active; int32_T i; int32_T i_0; int32_T i_1; for (i = 0; i < 3; i++) { /* Gain: '/Drv_Pos_avg' */ rtb_Drv_Pos_avg[i] = 0.0; i_1 = 0; for (i_0 = 0; i_0 < 14; i_0++) { rtb_Drv_Pos_avg[i] += Mount_Drv_FDR2023_ConstP.Drv_Pos_avg_Gain[i_1 + i] * Mount_Drv_FDR2023_U->Mount_drv_Po[i_0]; i_1 += 3; } /* SampleTimeMath: '/TSamp' incorporates: * Gain: '/Drv_Pos_avg' * * About '/TSamp': * y = u * K where K = 1 / ( w * Ts ) */ DiscreteTransferFcn_tmp = rtb_Drv_Pos_avg[i] * 8000.0; /* Sum: '/Diff' incorporates: * Gain: '/Drv_Pos_avg' * UnitDelay: '/UD' * * Block description for '/Diff': * * Add in CPU * * Block description for '/UD': * * Store in Global RAM */ rtb_Diff[i] = DiscreteTransferFcn_tmp - Mount_Drv_FDR2023_DW->UD_DSTATE[i]; /* SampleTimeMath: '/TSamp' incorporates: * Gain: '/Drv_Pos_avg' * * About '/TSamp': * y = u * K where K = 1 / ( w * Ts ) */ rtb_TSamp[i] = DiscreteTransferFcn_tmp; } /* Outputs for Enabled SubSystem: '/AZ DT Lugre Fr mode' */ /* Constant: '/Constant' */ Mount_Drv_FDR20_AZDTLugreFrmode(1.0, rtb_Diff[0], &Mount_Drv_FDR2023_DW->Sum_d, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 203113.71617142862, &Mount_Drv_FDR2023_DW->AZDTLugreFrmode); /* End of Outputs for SubSystem: '/AZ DT Lugre Fr mode' */ /* Outputs for Enabled SubSystem: '/EL DT Lugre Fr model' */ /* Constant: '/Constant1' */ Mount_Drv_FDR20_AZDTLugreFrmode(1.0, rtb_Diff[1], &Mount_Drv_FDR2023_DW->Sum_i, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 215619.25285978024, &Mount_Drv_FDR2023_DW->ELDTLugreFrmodel); /* End of Outputs for SubSystem: '/EL DT Lugre Fr model' */ /* Outputs for Enabled SubSystem: '/GIR DT Lugre Fr model' incorporates: * EnablePort: '/Enable' */ /* Outputs for Enabled SubSystem: '/gs' */ /* Constant: '/Constant' incorporates: * Gain: '/iIsSig01Active' */ Mount_Drv_FDR2023_gs(0.0, rtb_Diff[2], &Mount_Drv_FDR2023_DW->Divide, 0.00012396694214876033, 21309.20352, 17757.6696, 2.34256E+9); /* End of Outputs for SubSystem: '/gs' */ /* Sum: '/Sum' incorporates: * Abs: '/Abs' * Constant: '/gc' * DiscreteIntegrator: '/Discrete-Time Integrator' * Gain: '/iIsSig01Active' * Product: '/Divide' * Sum: '/Sum' */ rtb_iIsSig01Active = rtb_Diff[2] - fabs(rtb_Diff[2]) / (Mount_Drv_FDR2023_DW->Divide + 7.5804545454545461E-6) * Mount_Drv_FDR2023_DW->DiscreteTimeIntegrator_DSTATE; /* DiscreteTransferFcn: '/Discrete Transfer Fcn' */ DiscreteTransferFcn_tmp = (rtb_iIsSig01Active - -126.32395447351627 * Mount_Drv_FDR2023_DW->DiscreteTransferFcn_states) / 128.32395447351627; /* Sum: '/Sum' incorporates: * DiscreteIntegrator: '/Discrete-Time Integrator' * DiscreteTransferFcn: '/Discrete Transfer Fcn' * Gain: '/sigma_0' * Gain: '/sigma_1' * Gain: '/sigma_v' */ Mount_Drv_FDR2023_DW->Sum = ((DiscreteTransferFcn_tmp + Mount_Drv_FDR2023_DW->DiscreteTransferFcn_states) * 3.8634489257387631E+7 + 2.34256E+9 * Mount_Drv_FDR2023_DW->DiscreteTimeIntegrator_DSTATE) + 4450.864 * rtb_Diff[2]; /* Update for DiscreteIntegrator: '/Discrete-Time Integrator' */ Mount_Drv_FDR2023_DW->DiscreteTimeIntegrator_DSTATE += 0.000125 * rtb_iIsSig01Active; /* Update for DiscreteTransferFcn: '/Discrete Transfer Fcn' */ Mount_Drv_FDR2023_DW->DiscreteTransferFcn_states = DiscreteTransferFcn_tmp; /* End of Outputs for SubSystem: '/GIR DT Lugre Fr model' */ /* Delay: '/DRV delay' */ i_1 = (int32_T)Mount_Drv_FDR2023_DW->CircBufIdx * 3; /* DiscreteTransferFcn: '/DRV_dyn' incorporates: * Delay: '/DRV delay' * Quantizer: '/DRV_quant' */ DiscreteTransferFcn_tmp = rt_roundd(Mount_Drv_FDR2023_DW->DRVdelay_DSTATE[i_1] / 24.4140625) * 24.4140625 - -0.88235294117647056 * Mount_Drv_FDR2023_DW->DRV_dyn_states[0]; rtb_Sum1_o = 0.058823529411764705 * DiscreteTransferFcn_tmp + 0.058823529411764705 * Mount_Drv_FDR2023_DW->DRV_dyn_states[0]; /* Saturate: '/AZ_drv_sat' incorporates: * DiscreteTransferFcn: '/DRV_dyn' * Quantizer: '/DRV_quant' */ if (rtb_Sum1_o > 800000.0) { rtb_Sum1_o = 800000.0; } else if (rtb_Sum1_o < -800000.0) { rtb_Sum1_o = -800000.0; } /* DiscreteTransferFcn: '/DRV_dyn' incorporates: * Delay: '/DRV delay' * Quantizer: '/DRV_quant' */ rtb_Sum1_pw = rt_roundd(Mount_Drv_FDR2023_DW->DRVdelay_DSTATE[i_1 + 1] / 12.20703125) * 12.20703125 - -0.88235294117647056 * Mount_Drv_FDR2023_DW->DRV_dyn_states[1]; rtb_Sum1_e = 0.058823529411764705 * rtb_Sum1_pw + 0.058823529411764705 * Mount_Drv_FDR2023_DW->DRV_dyn_states[1]; /* Saturate: '/AZ_drv_sat' incorporates: * DiscreteTransferFcn: '/DRV_dyn' * Quantizer: '/DRV_quant' */ if (rtb_Sum1_e > 400000.0) { rtb_Sum1_e = 400000.0; } else if (rtb_Sum1_e < -400000.0) { rtb_Sum1_e = -400000.0; } /* DiscreteTransferFcn: '/DRV_dyn' incorporates: * Delay: '/DRV delay' * Quantizer: '/DRV_quant' */ rtb_Sum1_cj = rt_roundd(Mount_Drv_FDR2023_DW->DRVdelay_DSTATE[i_1 + 2] / 5.7330322265625) * 5.7330322265625 - -0.88235294117647056 * Mount_Drv_FDR2023_DW->DRV_dyn_states[2]; rtb_Sum1_hs = 0.058823529411764705 * rtb_Sum1_cj + 0.058823529411764705 * Mount_Drv_FDR2023_DW->DRV_dyn_states[2]; /* Saturate: '/AZ_drv_sat' incorporates: * DiscreteTransferFcn: '/DRV_dyn' * Quantizer: '/DRV_quant' */ if (rtb_Sum1_hs > 175740.0) { rtb_Sum1_hs = 175740.0; } else if (rtb_Sum1_hs < -175740.0) { rtb_Sum1_hs = -175740.0; } /* Update for DiscreteTransferFcn: '/DRV_dyn' */ Mount_Drv_FDR2023_DW->DRV_dyn_states[2] = rtb_Sum1_cj; /* Outputs for Enabled SubSystem: '/Parasitic AZ' incorporates: * EnablePort: '/Enable' */ /* Gain: '/deg2mm' incorporates: * Gain: '/Gain' */ rtb_Sum1_cj = 57.295779513082323 * rtb_Drv_Pos_avg[0] * 163.51989761934874; /* Bias: '/Bias' */ for (i = 0; i < 8; i++) { rtb_Bias[i] = rtb_Sum1_cj + Mount_Drv_FDR2023_ConstP.Bias_Bias[i]; } /* End of Bias: '/Bias' */ /* SignalConversion generated from: '/Vector Concatenate' */ memcpy(&rtb_VectorConcatenate_b[0], &rtb_Bias[0], sizeof(real_T) << 3U); /* Outputs for Iterator SubSystem: '/For Each Subsystem' */ Mount_Drv_FDR2_ForEachSubsystem(8, rtb_VectorConcatenate_b, rtb_ImpAsg_InsertedFor_Ou_ke3sc); /* End of Outputs for SubSystem: '/For Each Subsystem' */ /* Gain: '/1//Kt' incorporates: * Abs: '/Abs' * Gain: '/1//N_segm' */ rtb_iIsSig01Active = 0.125 * fabs(rtb_Sum1_o) * 0.00047014574518100609; /* Product: '/Divide' */ for (i = 0; i < 8; i++) { rtb_Bias[i] = rtb_iIsSig01Active * rtb_ImpAsg_InsertedFor_Ou_ke3sc[i]; } /* End of Product: '/Divide' */ /* Outputs for Iterator SubSystem: '/For Each Subsystem1' */ Mount_Drv_FDR_ForEachSubsystem1(8, rtb_VectorConcatenate_b, rtb_ImpAsg_InsertedFor_Out_ke3s); /* End of Outputs for SubSystem: '/For Each Subsystem1' */ /* Sum: '/Sum of Elements1' incorporates: * Sum: '/Sum of Elements' * Sum: '/Sum of Elements' * Sum: '/Sum of Elements1' * Sum: '/Sum of Elements' * Sum: '/Sum of Elements1' * Sum: '/Sum of Elements2' * Sum: '/Sum of Elements2' * Sum: '/Sum of Elements' * Sum: '/Sum of Elements' */ rtb_Sum1_cj = -0.0; for (i_1 = 0; i_1 < 8; i_1++) { rtb_Sum1_cj += rtb_ImpAsg_InsertedFor_Out_ke3s[i_1]; } /* Gain: '/R ' */ rtb_iIsSig01Active = 9.369 * rtb_Sum1_cj; /* Sum: '/Sum of Elements' incorporates: * Sum: '/Sum of Elements1' * Sum: '/Sum of Elements' * Sum: '/Sum of Elements1' * Sum: '/Sum of Elements' * Sum: '/Sum of Elements1' * Sum: '/Sum of Elements2' * Sum: '/Sum of Elements2' * Sum: '/Sum of Elements' * Sum: '/Sum of Elements' */ rtb_Sum1_cj = -0.0; for (i_1 = 0; i_1 < 8; i_1++) { rtb_Sum1_cj += rtb_Bias[i_1]; } real_T rtb_SumofElements1; /* Sum: '/Sum2' incorporates: * Gain: '/R' */ Mount_Drv_FDR2023_DW->Sum2_i = 9.369 * rtb_Sum1_cj + rtb_iIsSig01Active; /* End of Outputs for SubSystem: '/Parasitic AZ' */ /* Outputs for Enabled SubSystem: '/Parasitic EL' incorporates: * EnablePort: '/Enable' */ /* Gain: '/deg2mm' incorporates: * Gain: '/Gain' */ rtb_Sum1_cj = 57.295779513082323 * rtb_Drv_Pos_avg[1] * 180.76375062905271; /* SignalConversion generated from: '/Vector Concatenate' incorporates: * Bias: '/Bias' */ rtb_VectorConcatenate_m[0] = rtb_Sum1_cj; /* SignalConversion generated from: '/Vector Concatenate' incorporates: * Bias: '/Bias' */ rtb_VectorConcatenate_m[1] = rtb_Sum1_cj + 24.3; /* SignalConversion generated from: '/Vector Concatenate' incorporates: * Bias: '/Bias' */ rtb_VectorConcatenate_m[2] = rtb_Sum1_cj; /* SignalConversion generated from: '/Vector Concatenate' incorporates: * Bias: '/Bias' */ rtb_VectorConcatenate_m[3] = rtb_Sum1_cj + 24.3; /* Outputs for Iterator SubSystem: '/For Each Subsystem' */ Mount_Drv_FDR2_ForEachSubsystem(4, rtb_VectorConcatenate_m, rtb_ImpAsg_InsertedFor_Out1_ke3); /* End of Outputs for SubSystem: '/For Each Subsystem' */ /* Gain: '/1//Kt' incorporates: * Abs: '/Abs' * Gain: '/1//N_segm' */ rtb_Sum1_cj = 0.25 * fabs(rtb_Sum1_e) * 0.00047014574518100609; /* Outputs for Iterator SubSystem: '/For Each Subsystem1' */ Mount_Drv_FDR_ForEachSubsystem1(4, rtb_VectorConcatenate_m, rtb_ImpAsg_InsertedFor_Out1__ke); /* End of Outputs for SubSystem: '/For Each Subsystem1' */ /* Sum: '/Sum2' incorporates: * Gain: '/R' * Gain: '/R ' * Product: '/Divide' * Sum: '/Sum of Elements' * Sum: '/Sum of Elements1' */ Mount_Drv_FDR2023_DW->Sum2_m = (((rtb_Sum1_cj * rtb_ImpAsg_InsertedFor_Out1_ke3[0] + rtb_Sum1_cj * rtb_ImpAsg_InsertedFor_Out1_ke3[1]) + rtb_Sum1_cj * rtb_ImpAsg_InsertedFor_Out1_ke3[2]) + rtb_Sum1_cj * rtb_ImpAsg_InsertedFor_Out1_ke3[3]) * 10.357 + (((rtb_ImpAsg_InsertedFor_Out1__ke[0] + rtb_ImpAsg_InsertedFor_Out1__ke[1]) + rtb_ImpAsg_InsertedFor_Out1__ke[2]) + rtb_ImpAsg_InsertedFor_Out1__ke[3]) * 10.357; /* End of Outputs for SubSystem: '/Parasitic EL' */ /* Outputs for Enabled SubSystem: '/Parasitic GIR' incorporates: * EnablePort: '/Enable' */ /* Gain: '/ratio' incorporates: * Gain: '/Gain' */ rtb_Sum1_cj = 57.295779513082323 * rtb_Drv_Pos_avg[2] * 20.0; /* SignalConversion generated from: '/Vector Concatenate' incorporates: * Bias: '/Bias' */ rtb_VectorConcatenate_m[0] = rtb_Sum1_cj; /* SignalConversion generated from: '/Vector Concatenate' incorporates: * Bias: '/Bias' */ rtb_VectorConcatenate_m[1] = rtb_Sum1_cj + 0.95; /* SignalConversion generated from: '/Vector Concatenate' incorporates: * Bias: '/Bias' */ rtb_VectorConcatenate_m[2] = rtb_Sum1_cj; /* SignalConversion generated from: '/Vector Concatenate' incorporates: * Bias: '/Bias' */ rtb_VectorConcatenate_m[3] = rtb_Sum1_cj + 0.95; /* Gain: '/1//Kt' incorporates: * Abs: '/Abs' * Constant: '/PretentionTotal' * Gain: '/1//N_segm' * Gain: '/1//ratio ' * Sum: '/Sum1' * UnitDelay: '/Unit Delay2' */ rtb_Sum1_cj = (fabs(Mount_Drv_FDR2023_DW->UnitDelay2_DSTATE) + 12120.0) * 0.25 * 0.05 * 0.0097854060454238556; /* Outputs for Iterator SubSystem: '/For Each Subsystem' incorporates: * ForEach: '/For Each' */ /* ForEachSliceAssignment generated from: '/Out1' incorporates: * ForEachSliceSelector generated from: '/In1' * Sin: '/(N//A)' * Sum: '/Sum of Elements2' */ rtb_ImpAsg_InsertedFor_Out1_a_d[0] = (sin(0.83126541613985927 * rtb_VectorConcatenate_m[0] + 2.4103) * 0.2285 + sin(1.6625308322797185 * rtb_VectorConcatenate_m[0] + 0.0983) * 1.3459) + sin(2.494424566950296 * rtb_VectorConcatenate_m[0] - 0.1834) * 0.1234; /* End of Outputs for SubSystem: '/For Each Subsystem' */ /* Product: '/Divide' */ rtb_ImpAsg_InsertedFor_Out1_a_d[0] *= rtb_Sum1_cj; /* Outputs for Iterator SubSystem: '/For Each Subsystem' incorporates: * ForEach: '/For Each' */ /* ForEachSliceAssignment generated from: '/Out1' incorporates: * ForEachSliceSelector generated from: '/In1' * Sin: '/(N//A)' * Sum: '/Sum of Elements2' */ rtb_ImpAsg_InsertedFor_Out1_a_d[1] = (sin(0.83126541613985927 * rtb_VectorConcatenate_m[1] + 2.4103) * 0.2285 + sin(1.6625308322797185 * rtb_VectorConcatenate_m[1] + 0.0983) * 1.3459) + sin(2.494424566950296 * rtb_VectorConcatenate_m[1] - 0.1834) * 0.1234; /* End of Outputs for SubSystem: '/For Each Subsystem' */ /* Product: '/Divide' */ rtb_ImpAsg_InsertedFor_Out1_a_d[1] *= rtb_Sum1_cj; /* Outputs for Iterator SubSystem: '/For Each Subsystem' incorporates: * ForEach: '/For Each' */ /* ForEachSliceAssignment generated from: '/Out1' incorporates: * ForEachSliceSelector generated from: '/In1' * Sin: '/(N//A)' * Sum: '/Sum of Elements2' */ rtb_ImpAsg_InsertedFor_Out1_a_d[2] = (sin(0.83126541613985927 * rtb_VectorConcatenate_m[2] + 2.4103) * 0.2285 + sin(1.6625308322797185 * rtb_VectorConcatenate_m[2] + 0.0983) * 1.3459) + sin(2.494424566950296 * rtb_VectorConcatenate_m[2] - 0.1834) * 0.1234; /* End of Outputs for SubSystem: '/For Each Subsystem' */ /* Product: '/Divide' */ rtb_ImpAsg_InsertedFor_Out1_a_d[2] *= rtb_Sum1_cj; /* Outputs for Iterator SubSystem: '/For Each Subsystem' incorporates: * ForEach: '/For Each' */ /* ForEachSliceAssignment generated from: '/Out1' incorporates: * ForEachSliceSelector generated from: '/In1' * Sin: '/(N//A)' * Sum: '/Sum of Elements2' */ rtb_ImpAsg_InsertedFor_Out1_a_d[3] = (sin(0.83126541613985927 * rtb_VectorConcatenate_m[3] + 2.4103) * 0.2285 + sin(1.6625308322797185 * rtb_VectorConcatenate_m[3] + 0.0983) * 1.3459) + sin(2.494424566950296 * rtb_VectorConcatenate_m[3] - 0.1834) * 0.1234; /* End of Outputs for SubSystem: '/For Each Subsystem' */ /* Product: '/Divide' */ rtb_ImpAsg_InsertedFor_Out1_a_d[3] *= rtb_Sum1_cj; /* Outputs for Iterator SubSystem: '/For Each Subsystem1' incorporates: * ForEach: '/For Each' */ /* Sin: '/Cogging Spatial Pattern (N)' incorporates: * ForEachSliceSelector generated from: '/In1' */ rtb_CoggingSpatialPatternN[0] = sin(1.105840614063607 * rtb_VectorConcatenate_m[0] + 1.1997) * 0.0053; rtb_CoggingSpatialPatternN[1] = sin(2.494424566950296 * rtb_VectorConcatenate_m[0] - 1.5093) * 0.0481; /* Sum: '/Sum of Elements2' */ rtb_iIsSig01Active = rtb_CoggingSpatialPatternN[0] + rtb_CoggingSpatialPatternN[1]; /* ForEachSliceAssignment generated from: '/Out1' */ rtb_ImpAsg_InsertedFor_Out1_at_[0] = rtb_iIsSig01Active; /* Sin: '/Cogging Spatial Pattern (N)' incorporates: * ForEachSliceSelector generated from: '/In1' */ rtb_CoggingSpatialPatternN[0] = sin(1.105840614063607 * rtb_VectorConcatenate_m[1] + 1.1997) * 0.0053; rtb_CoggingSpatialPatternN[1] = sin(2.494424566950296 * rtb_VectorConcatenate_m[1] - 1.5093) * 0.0481; /* Sum: '/Sum of Elements2' */ rtb_iIsSig01Active = rtb_CoggingSpatialPatternN[0] + rtb_CoggingSpatialPatternN[1]; /* ForEachSliceAssignment generated from: '/Out1' */ rtb_ImpAsg_InsertedFor_Out1_at_[1] = rtb_iIsSig01Active; /* Sin: '/Cogging Spatial Pattern (N)' incorporates: * ForEachSliceSelector generated from: '/In1' */ rtb_CoggingSpatialPatternN[0] = sin(1.105840614063607 * rtb_VectorConcatenate_m[2] + 1.1997) * 0.0053; rtb_CoggingSpatialPatternN[1] = sin(2.494424566950296 * rtb_VectorConcatenate_m[2] - 1.5093) * 0.0481; /* Sum: '/Sum of Elements2' */ rtb_iIsSig01Active = rtb_CoggingSpatialPatternN[0] + rtb_CoggingSpatialPatternN[1]; /* ForEachSliceAssignment generated from: '/Out1' */ rtb_ImpAsg_InsertedFor_Out1_at_[2] = rtb_iIsSig01Active; /* Sin: '/Cogging Spatial Pattern (N)' incorporates: * ForEachSliceSelector generated from: '/In1' */ rtb_CoggingSpatialPatternN[0] = sin(1.105840614063607 * rtb_VectorConcatenate_m[3] + 1.1997) * 0.0053; rtb_CoggingSpatialPatternN[1] = sin(2.494424566950296 * rtb_VectorConcatenate_m[3] - 1.5093) * 0.0481; /* Sum: '/Sum of Elements2' */ rtb_iIsSig01Active = rtb_CoggingSpatialPatternN[0] + rtb_CoggingSpatialPatternN[1]; /* ForEachSliceAssignment generated from: '/Out1' */ rtb_ImpAsg_InsertedFor_Out1_at_[3] = rtb_iIsSig01Active; /* End of Outputs for SubSystem: '/For Each Subsystem1' */ /* Sum: '/Sum2' incorporates: * Gain: '/ratio ' * Gain: '/ratio ' * Sum: '/Sum of Elements' * Sum: '/Sum of Elements1' */ Mount_Drv_FDR2023_DW->Sum2 = (((rtb_ImpAsg_InsertedFor_Out1_a_d[0] + rtb_ImpAsg_InsertedFor_Out1_a_d[1]) + rtb_ImpAsg_InsertedFor_Out1_a_d[2]) + rtb_ImpAsg_InsertedFor_Out1_a_d[3]) * 20.0 + (((rtb_ImpAsg_InsertedFor_Out1_at_[0] + rtb_ImpAsg_InsertedFor_Out1_at_[1]) + rtb_ImpAsg_InsertedFor_Out1_at_[2]) + rtb_ImpAsg_InsertedFor_Out1_at_[3]) * 20.0; /* Update for UnitDelay: '/Unit Delay2' */ Mount_Drv_FDR2023_DW->UnitDelay2_DSTATE = rtb_Sum1_hs; /* End of Outputs for SubSystem: '/Parasitic GIR' */ /* Gain: '/Gain' incorporates: * Abs: '/Abs' * Constant: '/PretensionTotal' * Gain: '/Gain' * Sum: '/Sum1' */ rtb_iIsSig01Active = (fabs(rtb_Sum1_hs) + 12120.0) * 0.25; /* Gain: '/Gain' */ rtb_SumofElements1 = 57.295779513082323 * rtb_Drv_Pos_avg[2]; /* Product: '/Product1' incorporates: * Constant: '/Max Position' * Gain: '/Gain' * Lookup_n-D: '/1-D Lookup Table' * Math: '/Rem' * Sum: '/Sum2' */ rtb_Sum1_cj = look1_binlx(rt_remd(rtb_SumofElements1, 0.76595698841698845), Mount_Drv_FDR2023_ConstP.uDLookupTable_bp01Data, Mount_Drv_FDR2023_ConstP.uDLookupTable_tableData, 520U) * rtb_iIsSig01Active; /* Product: '/Product1' incorporates: * Constant: '/Max Position' * Lookup_n-D: '/1-D Lookup Table' * Math: '/Rem' * Sum: '/Sum2' */ rtb_iIsSig01Active *= look1_binlx(rt_remd(rtb_SumofElements1, 0.382978992248062), Mount_Drv_FDR2023_ConstP.uDLookupTable_bp01Data_p, Mount_Drv_FDR2023_ConstP.uDLookupTable_tableData_c, 260U); /* Sum: '/Sum1' incorporates: * Product: '/Product1' * Product: '/Product1' * Sum: '/Sum of Elements' * Sum: '/Sum of Elements' */ rtb_Sum1_cj = (((rtb_iIsSig01Active + rtb_iIsSig01Active) + rtb_iIsSig01Active) + rtb_iIsSig01Active) + (((rtb_Sum1_cj + rtb_Sum1_cj) + rtb_Sum1_cj) + rtb_Sum1_cj); /* Sum: '/Sum' */ rtb_Sum1_o += Mount_Drv_FDR2023_DW->Sum2_i - Mount_Drv_FDR2023_DW->Sum_d; rtb_Sum1_e += Mount_Drv_FDR2023_DW->Sum2_m - Mount_Drv_FDR2023_DW->Sum_i; rtb_Sum1_hs += (Mount_Drv_FDR2023_DW->Sum2 - Mount_Drv_FDR2023_DW->Sum) + rtb_Sum1_cj; /* Outport: '/Mount_T' incorporates: * Gain: '/Split_Drv_To' */ for (i_1 = 0; i_1 < 16; i_1++) { Mount_Drv_FDR2023_Y->Mount_T[i_1] = 0.0; Mount_Drv_FDR2023_Y->Mount_T[i_1] += Mount_Drv_FDR2023_ConstP.Split_Drv_To_Gain[i_1] * rtb_Sum1_o; Mount_Drv_FDR2023_Y->Mount_T[i_1] += Mount_Drv_FDR2023_ConstP.Split_Drv_To_Gain[i_1 + 16] * rtb_Sum1_e; Mount_Drv_FDR2023_Y->Mount_T[i_1] += Mount_Drv_FDR2023_ConstP.Split_Drv_To_Gain[i_1 + 32] * rtb_Sum1_hs; } /* End of Outport: '/Mount_T' */ /* Outport: '/ToothCAxialFo' incorporates: * Gain: '/factAxial' */ Mount_Drv_FDR2023_Y->ToothCAxialFo = 0.070376984126984135 * rtb_Sum1_cj; /* Update for UnitDelay: '/UD' * * Block description for '/UD': * * Store in Global RAM */ Mount_Drv_FDR2023_DW->UD_DSTATE[0] = rtb_TSamp[0]; /* Update for Delay: '/DRV delay' */ Mount_Drv_FDR2023_DW->DRVdelay_DSTATE[(int32_T) Mount_Drv_FDR2023_DW->CircBufIdx * 3] = Mount_Drv_FDR2023_U->Mount_cmd[0]; /* Update for DiscreteTransferFcn: '/DRV_dyn' */ Mount_Drv_FDR2023_DW->DRV_dyn_states[0] = DiscreteTransferFcn_tmp; /* Update for UnitDelay: '/UD' * * Block description for '/UD': * * Store in Global RAM */ Mount_Drv_FDR2023_DW->UD_DSTATE[1] = rtb_TSamp[1]; /* Update for Delay: '/DRV delay' */ Mount_Drv_FDR2023_DW->DRVdelay_DSTATE[(int32_T) Mount_Drv_FDR2023_DW->CircBufIdx * 3 + 1] = Mount_Drv_FDR2023_U->Mount_cmd[1]; /* Update for DiscreteTransferFcn: '/DRV_dyn' */ Mount_Drv_FDR2023_DW->DRV_dyn_states[1] = rtb_Sum1_pw; /* Update for UnitDelay: '/UD' * * Block description for '/UD': * * Store in Global RAM */ Mount_Drv_FDR2023_DW->UD_DSTATE[2] = rtb_TSamp[2]; /* Update for Delay: '/DRV delay' */ Mount_Drv_FDR2023_DW->DRVdelay_DSTATE[(int32_T) Mount_Drv_FDR2023_DW->CircBufIdx * 3 + 2] = Mount_Drv_FDR2023_U->Mount_cmd[2]; if (Mount_Drv_FDR2023_DW->CircBufIdx < 31U) { Mount_Drv_FDR2023_DW->CircBufIdx++; } else { Mount_Drv_FDR2023_DW->CircBufIdx = 0U; } } /* Model initialize function */ void Mount_Drv_FDR2023_initialize(RT_MODEL_Mount_Drv_FDR2023_T *const Mount_Drv_FDR2023_M) { /* (no initialization code required) */ UNUSED_PARAMETER(Mount_Drv_FDR2023_M); } /* Model terminate function */ void Mount_Drv_FDR2023_terminate(RT_MODEL_Mount_Drv_FDR2023_T *const Mount_Drv_FDR2023_M) { /* (no terminate code required) */ UNUSED_PARAMETER(Mount_Drv_FDR2023_M); } /* * File trailer for generated code. * * [EOF] */