mirror of
https://github.com/Dev-KATECH/ADM.git
synced 2026-05-17 01:43:59 +09:00
- LongitudinalCtrlMode 함수 비활성화 - Param match에서 가속도 관련 변수 0으로 비활성화 - Drive_ACC_Cmd 오프셋 적용 - GV_RC_Drive_ACC_Cmd 변수 생성 - Fault 시 명령 0으로 설정하는 조건 수정 - 속도 - 가속도 제어 전환 조건 추가 - 통합 로직 수정 : 가속도 제어 로직 적용 : 가속도 명령을 처리하는 Pre-processing 과정에 문제가 있어 해당 부분 재검토 필요 : 가속도 제어 로직이 동작하지 않도록 AccCmd_Out, AccControlFlag 0으로 설정
1653 lines
50 KiB
C
1653 lines
50 KiB
C
/*
|
|
* Academic License - for use in teaching, academic research, and meeting
|
|
* course requirements at degree granting institutions only. Not for
|
|
* government, commercial, or other organizational use.
|
|
*
|
|
* File: ADM_Integrated_Logic.c
|
|
*
|
|
* Code generated for Simulink model 'ADM_Integrated_Logic'.
|
|
*
|
|
* Model version : 14.98
|
|
* Simulink Coder version : 24.2 (R2024b) 21-Jun-2024
|
|
* C/C++ source code generated on : Tue Oct 21 13:14:18 2025
|
|
*
|
|
* Target selection: ert.tlc
|
|
* Embedded hardware selection: NXP->Cortex-M4
|
|
* Code generation objectives:
|
|
* 1. Execution efficiency
|
|
* 2. RAM efficiency
|
|
* 3. Debugging
|
|
* Validation result: Not run
|
|
*/
|
|
|
|
#include "ADM_Integrated_Logic.h"
|
|
#include <stdint.h>
|
|
#include <math.h>
|
|
#include <stdbool.h>
|
|
|
|
/* Named constants for Chart: '<S11>/Chart' */
|
|
#define IN_HAC_OFF ((uint8_t)1U)
|
|
#define IN_HAC_ON ((uint8_t)2U)
|
|
|
|
/* Block signals and states (default storage) */
|
|
DW_ADM_Integrated_Logic_T ADM_Integrated_Logic_DW;
|
|
|
|
/* External inputs (root inport signals with default storage) */
|
|
ExtU_ADM_Integrated_Logic_T ADM_Integrated_Logic_U;
|
|
|
|
/* External outputs (root outports fed by signals with default storage) */
|
|
ExtY_ADM_Integrated_Logic_T ADM_Integrated_Logic_Y;
|
|
|
|
/* Real-time model */
|
|
static RT_MODEL_ADM_Integrated_Logic_T ADM_Integrated_Logic_M_;
|
|
RT_MODEL_ADM_Integrated_Logic_T *const ADM_Integrated_Logic_M =
|
|
&ADM_Integrated_Logic_M_;
|
|
static void ADM_Integrated_Lo_Calculate_F_c(double rtu_W, double rtu_theta,
|
|
double *rty_F_c);
|
|
static void ADM_Integrated__MATLABFunction1(double rtu_u, double *rty_y);
|
|
static void ADM_Integrated__MATLABFunction2(double rtu_u, double *rty_y);
|
|
|
|
/*
|
|
* Output and update for atomic system:
|
|
* '<S58>/Calculate_F_c'
|
|
* '<S58>/Calculate_F_c1'
|
|
*/
|
|
static void ADM_Integrated_Lo_Calculate_F_c(double rtu_W, double rtu_theta,
|
|
double *rty_F_c)
|
|
{
|
|
*rty_F_c = rtu_W * sin(rtu_theta);
|
|
}
|
|
|
|
/*
|
|
* Output and update for atomic system:
|
|
* '<S1>/MATLAB Function1'
|
|
* '<S1>/MATLAB Function5'
|
|
*/
|
|
static void ADM_Integrated__MATLABFunction1(double rtu_u, double *rty_y)
|
|
{
|
|
*rty_y = rtu_u;
|
|
if (rtu_u < 140.0) {
|
|
*rty_y = 140.0;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Output and update for atomic system:
|
|
* '<S1>/MATLAB Function2'
|
|
* '<S1>/MATLAB Function6'
|
|
*/
|
|
static void ADM_Integrated__MATLABFunction2(double rtu_u, double *rty_y)
|
|
{
|
|
*rty_y = rtu_u;
|
|
if (rtu_u > -140.0) {
|
|
*rty_y = -140.0;
|
|
}
|
|
}
|
|
|
|
/* Model step function */
|
|
void ADM_Integrated_Logic_step(void)
|
|
{
|
|
double tmp[9];
|
|
double x_hat_pred[3];
|
|
double tmp_0[2];
|
|
double tmp_1[2];
|
|
double rtb_AccFlag;
|
|
double rtb_Add1;
|
|
double rtb_Add3;
|
|
double rtb_Add_e;
|
|
double rtb_Brake_Saturation;
|
|
double rtb_Brake_Torque_Cmd;
|
|
double rtb_Desired_Torque;
|
|
double rtb_Error_m;
|
|
double rtb_F_PI;
|
|
double rtb_Gain_c;
|
|
double rtb_Integrator_1;
|
|
double rtb_Memory;
|
|
double rtb_Pitch_Angle;
|
|
double rtb_Product1;
|
|
double rtb_Product1_gg;
|
|
double rtb_Product1_h;
|
|
double rtb_Product1_k3;
|
|
double rtb_Product1_m;
|
|
double rtb_Product1_pd;
|
|
double rtb_Product2_a;
|
|
double rtb_Saturation;
|
|
double rtb_Sum1_cr;
|
|
double rtb_Sum1_d;
|
|
double rtb_Sum1_f;
|
|
double rtb_Sum1_j1;
|
|
double rtb_Sum_f;
|
|
double rtb_Switch2_k;
|
|
double rtb_TSamp;
|
|
double rtb_Trig;
|
|
double rtb_Vx_Cmd_R;
|
|
double rtb_y;
|
|
double rtb_y_k;
|
|
int32_t i;
|
|
bool rtb_Compare_l;
|
|
bool rtb_Compare_p;
|
|
static const int8_t a[6] = { 1, 0, 0, 1, 0, 0 };
|
|
|
|
static const double b_a[6] = { 0.2997, 0.0, -0.0842, 0.01, 0.9981, 0.0 };
|
|
|
|
double rtb_Add1_tmp;
|
|
|
|
/* Product: '<S13>/Product1' incorporates:
|
|
* Constant: '<S13>/Constant'
|
|
* Gain: '<S13>/gain'
|
|
* Inport: '<Root>/GV_IMU_AX_Val'
|
|
* Product: '<S13>/Product11'
|
|
* Sum: '<S13>/Sum1'
|
|
* Sum: '<S13>/Sum2'
|
|
* Sum: '<S13>/Sum3'
|
|
* Sum: '<S13>/Sum4'
|
|
* UnitDelay: '<S13>/d'
|
|
* UnitDelay: '<S13>/d1'
|
|
*/
|
|
rtb_Product1 = ((ADM_Integrated_Logic_U.GV_IMU_AX_Val +
|
|
ADM_Integrated_Logic_DW.d1_DSTATE) * 0.002 +
|
|
0.63461977236758138 * ADM_Integrated_Logic_DW.d_DSTATE) /
|
|
0.63861977236758138;
|
|
|
|
/* MATLAB Function: '<S1>/MATLAB Function' incorporates:
|
|
* Constant: '<S1>/Constant1'
|
|
* Constant: '<S1>/Constant2'
|
|
*/
|
|
tmp[0] = 1.0;
|
|
tmp[3] = 0.002;
|
|
tmp[6] = -0.019620000000000002;
|
|
tmp[1] = 0.0;
|
|
tmp[2] = 0.0;
|
|
tmp[4] = 1.0;
|
|
tmp[5] = 0.0;
|
|
tmp[7] = 0.0;
|
|
tmp[8] = 1.0;
|
|
rtb_Pitch_Angle = ADM_Integrated_Logic_DW.x_hat[1];
|
|
rtb_Brake_Saturation = ADM_Integrated_Logic_DW.x_hat[0];
|
|
rtb_Vx_Cmd_R = ADM_Integrated_Logic_DW.x_hat[2];
|
|
for (i = 0; i < 3; i++) {
|
|
x_hat_pred[i] = (tmp[i + 3] * rtb_Pitch_Angle + tmp[i] *
|
|
rtb_Brake_Saturation) + tmp[i + 6] * rtb_Vx_Cmd_R;
|
|
}
|
|
|
|
/* SignalConversion generated from: '<S14>/ SFunction ' incorporates:
|
|
* Inport: '<Root>/GV_Vx_Fbk'
|
|
* MATLAB Function: '<S1>/MATLAB Function'
|
|
*/
|
|
tmp_0[0] = ADM_Integrated_Logic_U.GV_Vx_Fbk;
|
|
tmp_0[1] = rtb_Product1;
|
|
|
|
/* MATLAB Function: '<S1>/MATLAB Function' */
|
|
rtb_Pitch_Angle = x_hat_pred[1];
|
|
rtb_Brake_Saturation = x_hat_pred[0];
|
|
rtb_Vx_Cmd_R = x_hat_pred[2];
|
|
for (i = 0; i < 2; i++) {
|
|
tmp_1[i] = tmp_0[i] - (((double)a[i + 2] * rtb_Pitch_Angle + (double)a[i] *
|
|
rtb_Brake_Saturation) + 0.0 * rtb_Vx_Cmd_R);
|
|
}
|
|
|
|
rtb_Add_e = tmp_1[1];
|
|
rtb_Pitch_Angle = tmp_1[0];
|
|
for (i = 0; i < 3; i++) {
|
|
ADM_Integrated_Logic_DW.x_hat[i] = (b_a[i + 3] * rtb_Add_e + b_a[i] *
|
|
rtb_Pitch_Angle) + x_hat_pred[i];
|
|
}
|
|
|
|
/* RelationalOperator: '<S5>/Compare' incorporates:
|
|
* Constant: '<S5>/Constant'
|
|
* Inport: '<Root>/GV_Drive_Mode'
|
|
*/
|
|
rtb_Compare_l = (ADM_Integrated_Logic_U.GV_Drive_Mode == 2.0);
|
|
|
|
/* MATLAB Function: '<S25>/Vx_OutPut_Function' incorporates:
|
|
* Constant: '<S73>/Constant'
|
|
* Inport: '<Root>/GV_BrakeTorqueCommand'
|
|
* Inport: '<Root>/GV_Vx_Command'
|
|
* Inport: '<Root>/GV_Vx_Limit'
|
|
* RelationalOperator: '<S73>/Compare'
|
|
*/
|
|
if (!(ADM_Integrated_Logic_U.GV_BrakeTorqueCommand >= 50.0)) {
|
|
if (ADM_Integrated_Logic_U.GV_Vx_Limit <=
|
|
ADM_Integrated_Logic_U.GV_Vx_Command) {
|
|
rtb_Add_e = ADM_Integrated_Logic_U.GV_Vx_Limit;
|
|
} else {
|
|
rtb_Add_e = ADM_Integrated_Logic_U.GV_Vx_Command;
|
|
}
|
|
} else {
|
|
rtb_Add_e = 0.0;
|
|
}
|
|
|
|
/* Product: '<S25>/Product' incorporates:
|
|
* MATLAB Function: '<S25>/Vx_OutPut_Function'
|
|
* Switch: '<S25>/Switch'
|
|
*/
|
|
rtb_Pitch_Angle = rtb_Add_e * (double)!rtb_Compare_l;
|
|
|
|
/* RateLimiter: '<S25>/Input_Vx_RateLimiter' */
|
|
rtb_Brake_Saturation = rtb_Pitch_Angle - ADM_Integrated_Logic_DW.PrevY;
|
|
if (rtb_Brake_Saturation > 0.004) {
|
|
rtb_Vx_Cmd_R = ADM_Integrated_Logic_DW.PrevY + 0.004;
|
|
} else if (rtb_Brake_Saturation < -0.008) {
|
|
rtb_Vx_Cmd_R = ADM_Integrated_Logic_DW.PrevY - 0.008;
|
|
} else {
|
|
rtb_Vx_Cmd_R = rtb_Pitch_Angle;
|
|
}
|
|
|
|
ADM_Integrated_Logic_DW.PrevY = rtb_Vx_Cmd_R;
|
|
|
|
/* End of RateLimiter: '<S25>/Input_Vx_RateLimiter' */
|
|
|
|
/* Saturate: '<S11>/Pitch_Saturation' incorporates:
|
|
* DiscreteIntegrator: '<S11>/Integrator_2'
|
|
*/
|
|
if (ADM_Integrated_Logic_DW.Integrator_2_DSTATE > 8.0) {
|
|
rtb_Pitch_Angle = 8.0;
|
|
} else if (ADM_Integrated_Logic_DW.Integrator_2_DSTATE < -8.0) {
|
|
rtb_Pitch_Angle = -8.0;
|
|
} else {
|
|
rtb_Pitch_Angle = ADM_Integrated_Logic_DW.Integrator_2_DSTATE;
|
|
}
|
|
|
|
/* End of Saturate: '<S11>/Pitch_Saturation' */
|
|
|
|
/* Delay: '<S65>/Delay' */
|
|
if (ADM_Integrated_Logic_DW.icLoad) {
|
|
ADM_Integrated_Logic_DW.Delay_DSTATE = rtb_Pitch_Angle;
|
|
}
|
|
|
|
/* Product: '<S65>/delta rise limit' incorporates:
|
|
* Constant: '<S11>/Angle_Upper'
|
|
* SampleTimeMath: '<S65>/sample time'
|
|
*
|
|
* About '<S65>/sample time':
|
|
* y = K where K = ( w * Ts )
|
|
* */
|
|
rtb_Product2_a = 0.002;
|
|
|
|
/* Sum: '<S65>/Difference Inputs1' incorporates:
|
|
* Delay: '<S65>/Delay'
|
|
*
|
|
* Block description for '<S65>/Difference Inputs1':
|
|
*
|
|
* Add in CPU
|
|
*/
|
|
rtb_Pitch_Angle -= ADM_Integrated_Logic_DW.Delay_DSTATE;
|
|
|
|
/* Switch: '<S70>/Switch2' incorporates:
|
|
* RelationalOperator: '<S70>/LowerRelop1'
|
|
*/
|
|
if (!(rtb_Pitch_Angle > 0.002)) {
|
|
/* Switch: '<S70>/Switch' incorporates:
|
|
* RelationalOperator: '<S70>/UpperRelop'
|
|
*/
|
|
if (rtb_Pitch_Angle < -0.002) {
|
|
rtb_Product2_a = -0.002;
|
|
} else {
|
|
rtb_Product2_a = rtb_Pitch_Angle;
|
|
}
|
|
|
|
/* End of Switch: '<S70>/Switch' */
|
|
}
|
|
|
|
/* End of Switch: '<S70>/Switch2' */
|
|
|
|
/* Sum: '<S65>/Difference Inputs2' incorporates:
|
|
* Delay: '<S65>/Delay'
|
|
*
|
|
* Block description for '<S65>/Difference Inputs2':
|
|
*
|
|
* Add in CPU
|
|
*/
|
|
rtb_Pitch_Angle = rtb_Product2_a + ADM_Integrated_Logic_DW.Delay_DSTATE;
|
|
|
|
/* MATLAB Function: '<S58>/Calculate_F_c' incorporates:
|
|
* Gain: '<S58>/Gain'
|
|
*/
|
|
ADM_Integrated_Lo_Calculate_F_c(ADM_Integrated_Logic_ConstB.W_value,
|
|
0.017453292519943295 * rtb_Pitch_Angle, &rtb_Product2_a);
|
|
|
|
/* Gain: '<S58>/Gain2' incorporates:
|
|
* Constant: '<S58>/Radius'
|
|
* Gain: '<S58>/Gain1'
|
|
* Gain: '<S58>/Rolling_Gain'
|
|
* MATLAB Function: '<S58>/Calculate_F_R'
|
|
* Product: '<S58>/Multiply3'
|
|
* Sum: '<S58>/Required_Brake_Cal'
|
|
*/
|
|
rtb_Saturation = (cos(0.017453292519943295 * rtb_Pitch_Angle) *
|
|
436.7465753424658 * 0.0 + rtb_Product2_a) * 0.292 *
|
|
0.083822296730930432;
|
|
|
|
/* Saturate: '<S58>/Saturation' */
|
|
if (rtb_Saturation > 60.0) {
|
|
rtb_Saturation = 60.0;
|
|
} else if (rtb_Saturation < 0.0) {
|
|
rtb_Saturation = 0.0;
|
|
}
|
|
|
|
/* End of Saturate: '<S58>/Saturation' */
|
|
|
|
/* Delay: '<S64>/Delay' */
|
|
if (ADM_Integrated_Logic_DW.icLoad_e) {
|
|
ADM_Integrated_Logic_DW.Delay_DSTATE_i = rtb_Saturation;
|
|
}
|
|
|
|
/* Product: '<S64>/delta rise limit' incorporates:
|
|
* Constant: '<S11>/Upper_Torq'
|
|
* SampleTimeMath: '<S64>/sample time'
|
|
*
|
|
* About '<S64>/sample time':
|
|
* y = K where K = ( w * Ts )
|
|
* */
|
|
rtb_Product2_a = 0.016;
|
|
|
|
/* Sum: '<S64>/Difference Inputs1' incorporates:
|
|
* Delay: '<S64>/Delay'
|
|
*
|
|
* Block description for '<S64>/Difference Inputs1':
|
|
*
|
|
* Add in CPU
|
|
*/
|
|
rtb_Saturation -= ADM_Integrated_Logic_DW.Delay_DSTATE_i;
|
|
|
|
/* Switch: '<S69>/Switch2' incorporates:
|
|
* RelationalOperator: '<S69>/LowerRelop1'
|
|
*/
|
|
if (!(rtb_Saturation > 0.016)) {
|
|
/* Switch: '<S69>/Switch' incorporates:
|
|
* RelationalOperator: '<S69>/UpperRelop'
|
|
*/
|
|
if (rtb_Saturation < -0.16) {
|
|
rtb_Product2_a = -0.16;
|
|
} else {
|
|
rtb_Product2_a = rtb_Saturation;
|
|
}
|
|
|
|
/* End of Switch: '<S69>/Switch' */
|
|
}
|
|
|
|
/* End of Switch: '<S69>/Switch2' */
|
|
|
|
/* Sum: '<S64>/Difference Inputs2' incorporates:
|
|
* Delay: '<S64>/Delay'
|
|
*
|
|
* Block description for '<S64>/Difference Inputs2':
|
|
*
|
|
* Add in CPU
|
|
*/
|
|
rtb_Saturation = rtb_Product2_a + ADM_Integrated_Logic_DW.Delay_DSTATE_i;
|
|
|
|
/* Gain: '<S11>/Grade_GAIN' */
|
|
rtb_Desired_Torque = 0.8 * rtb_Saturation;
|
|
|
|
/* RelationalOperator: '<S54>/Compare' incorporates:
|
|
* Constant: '<S54>/Constant'
|
|
* Inport: '<Root>/GV_BrakeTorqueCommand'
|
|
*/
|
|
rtb_Compare_p = (ADM_Integrated_Logic_U.GV_BrakeTorqueCommand >= 100.0);
|
|
|
|
/* Delay: '<S10>/Memory' */
|
|
rtb_Memory = ADM_Integrated_Logic_DW.Memory_DSTATE;
|
|
|
|
/* MATLAB Function: '<S10>/Gear_FUNCTION1' incorporates:
|
|
* Inport: '<Root>/GV_VCU_GearSelStat'
|
|
* Inport: '<Root>/GV_Vx_Fbk'
|
|
*/
|
|
if (ADM_Integrated_Logic_U.GV_VCU_GearSelStat == 0.0) {
|
|
if ((ADM_Integrated_Logic_U.GV_Vx_Fbk <= 0.0) && rtb_Compare_p) {
|
|
rtb_Memory = 0.0;
|
|
}
|
|
} else {
|
|
switch ((int32_t)rtb_Memory) {
|
|
case 0:
|
|
if ((ADM_Integrated_Logic_U.GV_Vx_Fbk <= 0.0) &&
|
|
((ADM_Integrated_Logic_U.GV_VCU_GearSelStat == 1.0) ||
|
|
(ADM_Integrated_Logic_U.GV_VCU_GearSelStat == 3.0) ||
|
|
(ADM_Integrated_Logic_U.GV_VCU_GearSelStat == 2.0))) {
|
|
rtb_Memory = 2.0;
|
|
}
|
|
break;
|
|
|
|
case 1:
|
|
if (ADM_Integrated_Logic_U.GV_VCU_GearSelStat == 2.0) {
|
|
rtb_Memory = 2.0;
|
|
}
|
|
break;
|
|
|
|
case 2:
|
|
if ((ADM_Integrated_Logic_U.GV_Vx_Fbk <= 0.0) && rtb_Compare_p) {
|
|
if (ADM_Integrated_Logic_U.GV_VCU_GearSelStat == 1.0) {
|
|
rtb_Memory = 1.0;
|
|
} else if (ADM_Integrated_Logic_U.GV_VCU_GearSelStat == 3.0) {
|
|
rtb_Memory = 3.0;
|
|
}
|
|
}
|
|
break;
|
|
|
|
case 3:
|
|
if (ADM_Integrated_Logic_U.GV_VCU_GearSelStat == 2.0) {
|
|
rtb_Memory = 2.0;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
/* End of MATLAB Function: '<S10>/Gear_FUNCTION1' */
|
|
|
|
/* Chart: '<S11>/Chart' incorporates:
|
|
* Constant: '<S11>/Constant'
|
|
* Constant: '<S11>/Constant1'
|
|
* Inport: '<Root>/GV_MCU_RPM'
|
|
*/
|
|
if (ADM_Integrated_Logic_DW.is_active_c6_ADM_Integrated_Log == 0) {
|
|
ADM_Integrated_Logic_DW.is_active_c6_ADM_Integrated_Log = 1U;
|
|
ADM_Integrated_Logic_DW.is_c6_ADM_Integrated_Logic = IN_HAC_OFF;
|
|
} else if (ADM_Integrated_Logic_DW.is_c6_ADM_Integrated_Logic == IN_HAC_OFF) {
|
|
if (ADM_Integrated_Logic_U.GV_MCU_RPM < -50.0) {
|
|
ADM_Integrated_Logic_DW.is_c6_ADM_Integrated_Logic = IN_HAC_ON;
|
|
} else {
|
|
/* Outport: '<Root>/Debug_HAC_RPM_Decision' */
|
|
ADM_Integrated_Logic_Y.Debug_HAC_RPM_Decision = 0.0;
|
|
}
|
|
|
|
/* case IN_HAC_ON: */
|
|
} else if (ADM_Integrated_Logic_U.GV_MCU_RPM > 150.0) {
|
|
ADM_Integrated_Logic_DW.is_c6_ADM_Integrated_Logic = IN_HAC_OFF;
|
|
} else {
|
|
/* Outport: '<Root>/Debug_HAC_RPM_Decision' */
|
|
ADM_Integrated_Logic_Y.Debug_HAC_RPM_Decision = 1.0;
|
|
}
|
|
|
|
/* End of Chart: '<S11>/Chart' */
|
|
|
|
/* MATLAB Function: '<S11>/HAC_OFF_OK_Func' */
|
|
rtb_Brake_Torque_Cmd = 0.0;
|
|
|
|
/* Outport: '<Root>/Debug_HAC_FLAG' incorporates:
|
|
* MATLAB Function: '<S11>/HAC_OFF_OK_Func'
|
|
*/
|
|
ADM_Integrated_Logic_Y.Debug_HAC_FLAG = 0.0;
|
|
|
|
/* MATLAB Function: '<S11>/HAC_OFF_OK_Func' incorporates:
|
|
* Constant: '<S11>/Accel_Cmd '
|
|
* Constant: '<S11>/Brake_Cmd'
|
|
* Constant: '<S11>/Gear_D'
|
|
* Inport: '<Root>/GV_BrakeTorqueCommand'
|
|
* Inport: '<Root>/GV_MCU_EstTrq'
|
|
* Outport: '<Root>/Debug_HAC_RPM_Decision'
|
|
* RelationalOperator: '<S11>/Relational Operator'
|
|
* RelationalOperator: '<S11>/Relational Operator1'
|
|
* RelationalOperator: '<S11>/Relational Operator2'
|
|
* Sum: '<S11>/HAC_Flags_Add'
|
|
*/
|
|
if (((double)(((ADM_Integrated_Logic_U.GV_BrakeTorqueCommand <= 20.0) +
|
|
(rtb_Vx_Cmd_R <= 2.0)) + (rtb_Memory == 3.0)) + 1.0) +
|
|
ADM_Integrated_Logic_Y.Debug_HAC_RPM_Decision >= 5.0) {
|
|
if (ADM_Integrated_Logic_DW.HAC_ON_FLAG == 0.0) {
|
|
ADM_Integrated_Logic_DW.HAC_ON_Timer = 0.0;
|
|
}
|
|
|
|
ADM_Integrated_Logic_DW.HAC_ON_FLAG = 1.0;
|
|
rtb_Brake_Torque_Cmd = 1000.0;
|
|
ADM_Integrated_Logic_DW.Smoothed_Torque = 1000.0;
|
|
if (ADM_Integrated_Logic_DW.HAC_ON_Timer < 3.0) {
|
|
ADM_Integrated_Logic_DW.HAC_Desired_Torque = rtb_Desired_Torque;
|
|
ADM_Integrated_Logic_DW.HAC_ON_Timer += 0.005;
|
|
}
|
|
|
|
/* Outport: '<Root>/Debug_HAC_FLAG' */
|
|
ADM_Integrated_Logic_Y.Debug_HAC_FLAG = 1.0;
|
|
} else if (ADM_Integrated_Logic_DW.HAC_ON_FLAG == 1.0) {
|
|
if (ADM_Integrated_Logic_U.GV_MCU_EstTrq >=
|
|
ADM_Integrated_Logic_DW.HAC_Desired_Torque) {
|
|
ADM_Integrated_Logic_DW.Smoothed_Torque -= 0.05 *
|
|
ADM_Integrated_Logic_DW.Smoothed_Torque;
|
|
if (ADM_Integrated_Logic_DW.Smoothed_Torque < 0.01) {
|
|
ADM_Integrated_Logic_DW.Smoothed_Torque = 0.0;
|
|
ADM_Integrated_Logic_DW.HAC_ON_FLAG = 0.0;
|
|
ADM_Integrated_Logic_DW.HAC_Desired_Torque = 0.0;
|
|
ADM_Integrated_Logic_DW.HAC_ON_Timer = 0.0;
|
|
}
|
|
|
|
rtb_Brake_Torque_Cmd = ADM_Integrated_Logic_DW.Smoothed_Torque;
|
|
} else {
|
|
rtb_Brake_Torque_Cmd = 1000.0;
|
|
ADM_Integrated_Logic_DW.Smoothed_Torque = 1000.0;
|
|
|
|
/* Outport: '<Root>/Debug_HAC_FLAG' */
|
|
ADM_Integrated_Logic_Y.Debug_HAC_FLAG = 1.0;
|
|
}
|
|
}
|
|
|
|
/* MATLAB Function: '<S28>/MATLAB Function' incorporates:
|
|
* Inport: '<Root>/GV_Vx_Fbk'
|
|
*/
|
|
if (fabs(ADM_Integrated_Logic_U.GV_Vx_Fbk) < 0.1) {
|
|
rtb_AccFlag = 0.0;
|
|
} else {
|
|
rtb_AccFlag = 1.0;
|
|
}
|
|
|
|
/* End of MATLAB Function: '<S28>/MATLAB Function' */
|
|
|
|
/* Product: '<S28>/Product2' incorporates:
|
|
* Constant: '<S1>/Constant3'
|
|
* Product: '<S28>/Product'
|
|
* Product: '<S28>/Product1'
|
|
* Sum: '<S28>/Subtract'
|
|
*/
|
|
rtb_Product2_a = (0.0 - rtb_Product1 * 1500.0) * rtb_AccFlag;
|
|
|
|
/* SampleTimeMath: '<S31>/TSamp'
|
|
*
|
|
* About '<S31>/TSamp':
|
|
* y = u * K where K = 1 / ( w * Ts )
|
|
* */
|
|
rtb_TSamp = rtb_Product2_a * 500.0;
|
|
|
|
/* Sum: '<S28>/Subtract1' incorporates:
|
|
* Constant: '<S1>/Constant10'
|
|
* Constant: '<S1>/Constant11'
|
|
* Constant: '<S1>/Constant13'
|
|
* DiscreteIntegrator: '<S28>/Discrete-Time Integrator'
|
|
* Product: '<S28>/D controller'
|
|
* Product: '<S28>/I controller'
|
|
* Product: '<S28>/P controller'
|
|
* Sum: '<S31>/Diff'
|
|
* UnitDelay: '<S31>/UD'
|
|
*
|
|
* Block description for '<S31>/Diff':
|
|
*
|
|
* Add in CPU
|
|
*
|
|
* Block description for '<S31>/UD':
|
|
*
|
|
* Store in Global RAM
|
|
*/
|
|
rtb_F_PI = (0.07 * rtb_Product2_a +
|
|
ADM_Integrated_Logic_DW.DiscreteTimeIntegrator_DSTATE * 0.2) +
|
|
(rtb_TSamp - ADM_Integrated_Logic_DW.UD_DSTATE) * 0.0;
|
|
|
|
/* Saturate: '<S28>/Saturation' */
|
|
if (rtb_F_PI > 3525.0) {
|
|
rtb_y = 3525.0;
|
|
} else if (rtb_F_PI < -2500.0) {
|
|
rtb_y = -2500.0;
|
|
} else {
|
|
rtb_y = rtb_F_PI;
|
|
}
|
|
|
|
/* End of Saturate: '<S28>/Saturation' */
|
|
|
|
/* Product: '<S28>/Product3' */
|
|
rtb_y_k = rtb_AccFlag * rtb_y;
|
|
|
|
/* RateLimiter: '<S3>/Rate Limiter' */
|
|
rtb_Brake_Saturation = rtb_y_k - ADM_Integrated_Logic_DW.PrevY_b;
|
|
if (rtb_Brake_Saturation > 2.0) {
|
|
rtb_y_k = ADM_Integrated_Logic_DW.PrevY_b + 2.0;
|
|
} else if (rtb_Brake_Saturation < -2.0) {
|
|
rtb_y_k = ADM_Integrated_Logic_DW.PrevY_b - 2.0;
|
|
}
|
|
|
|
ADM_Integrated_Logic_DW.PrevY_b = rtb_y_k;
|
|
|
|
/* End of RateLimiter: '<S3>/Rate Limiter' */
|
|
|
|
/* Product: '<S3>/Product' incorporates:
|
|
* MATLAB Function: '<S3>/MATLAB Function1'
|
|
*/
|
|
rtb_AccFlag = (double)(rtb_Memory == 3.0) * rtb_y_k;
|
|
|
|
/* MATLAB Function: '<S3>/MATLAB Function' */
|
|
if (!(rtb_AccFlag >= 0.0)) {
|
|
rtb_AccFlag = 0.0;
|
|
}
|
|
|
|
/* End of MATLAB Function: '<S3>/MATLAB Function' */
|
|
|
|
/* Gain: '<S6>/Brake_GAIN' incorporates:
|
|
* DiscreteTransferFcn: '<S1>/Discrete Transfer Fcn'
|
|
*/
|
|
rtb_Integrator_1 = 0.0625 * ADM_Integrated_Logic_DW.DiscreteTransferFcn_states
|
|
* -80.0;
|
|
|
|
/* MATLAB Function: '<S6>/GearCondition_Brake' */
|
|
if (rtb_Memory == 1.0) {
|
|
i = -1;
|
|
} else {
|
|
i = (rtb_Memory == 3.0);
|
|
}
|
|
|
|
/* Saturate: '<S6>/Saturation' */
|
|
if (rtb_Integrator_1 > 1000.0) {
|
|
rtb_Integrator_1 = 1000.0;
|
|
} else if (rtb_Integrator_1 < 0.0) {
|
|
rtb_Integrator_1 = 0.0;
|
|
}
|
|
|
|
/* Product: '<S6>/Multiply2' incorporates:
|
|
* MATLAB Function: '<S6>/GearCondition_Brake'
|
|
* Saturate: '<S6>/Saturation'
|
|
*/
|
|
rtb_y_k = (double)i * rtb_Integrator_1;
|
|
|
|
/* RateLimiter: '<S6>/Brake_Out_RateLimiter' */
|
|
rtb_Brake_Saturation = rtb_y_k - ADM_Integrated_Logic_DW.PrevY_o;
|
|
if (rtb_Brake_Saturation > 3.0) {
|
|
rtb_y_k = ADM_Integrated_Logic_DW.PrevY_o + 3.0;
|
|
} else if (rtb_Brake_Saturation < -3.0) {
|
|
rtb_y_k = ADM_Integrated_Logic_DW.PrevY_o - 3.0;
|
|
}
|
|
|
|
ADM_Integrated_Logic_DW.PrevY_o = rtb_y_k;
|
|
|
|
/* End of RateLimiter: '<S6>/Brake_Out_RateLimiter' */
|
|
|
|
/* Saturate: '<S6>/Brake_Saturation' */
|
|
if (rtb_y_k > 1000.0) {
|
|
rtb_y_k = 1000.0;
|
|
} else if (rtb_y_k < 0.0) {
|
|
rtb_y_k = 0.0;
|
|
}
|
|
|
|
/* End of Saturate: '<S6>/Brake_Saturation' */
|
|
|
|
/* MATLAB Function: '<S1>/Emergency_Brake_Func' incorporates:
|
|
* Inport: '<Root>/GV_Vx_Fbk'
|
|
* Sum: '<S1>/Add'
|
|
* Switch: '<S1>/Switch2'
|
|
*/
|
|
if (rtb_Compare_l) {
|
|
rtb_Brake_Saturation = ADM_Integrated_Logic_U.GV_Vx_Fbk * 100.0;
|
|
} else {
|
|
rtb_Brake_Saturation = rtb_Brake_Torque_Cmd + rtb_y_k;
|
|
}
|
|
|
|
/* Saturate: '<S1>/Brake_Saturation' incorporates:
|
|
* MATLAB Function: '<S1>/Emergency_Brake_Func'
|
|
*/
|
|
if (rtb_Brake_Saturation > 2500.0) {
|
|
rtb_Brake_Saturation = 2500.0;
|
|
} else if (rtb_Brake_Saturation < 0.0) {
|
|
rtb_Brake_Saturation = 0.0;
|
|
}
|
|
|
|
/* End of Saturate: '<S1>/Brake_Saturation' */
|
|
|
|
/* Outputs for Enabled SubSystem: '<S1>/Enabled Subsystem' incorporates:
|
|
* EnablePort: '<S9>/Enable'
|
|
*/
|
|
/* MATLAB Function: '<S1>/MATLAB Function4' incorporates:
|
|
* Inport: '<Root>/GV_Drive_ACC_Cmd'
|
|
* Inport: '<Root>/GV_MCU_EstTrq'
|
|
* Inport: '<Root>/GV_Vx_Fbk'
|
|
* MATLAB Function: '<S1>/IDB_Fault_Injection'
|
|
*/
|
|
if (((rtb_Vx_Cmd_R >= 1.0) || (ADM_Integrated_Logic_U.GV_Drive_ACC_Cmd >= 0.01))
|
|
&& (ADM_Integrated_Logic_U.GV_MCU_EstTrq >= 10.0) && (rtb_Product1 >= 0.2)
|
|
&& (ADM_Integrated_Logic_U.GV_Vx_Fbk >= 1.5) && (rtb_Brake_Saturation <=
|
|
10.0)) {
|
|
/* MATLAB Function: '<S9>/MATLAB Function' incorporates:
|
|
* Constant: '<S1>/Constant9'
|
|
* Inport: '<Root>/GV_IMU_AZ_Val'
|
|
* MATLAB Function: '<S1>/MATLAB Function'
|
|
*/
|
|
ADM_Integrated_Logic_DW.M = ADM_Integrated_Logic_U.GV_MCU_EstTrq / ((0.01 *
|
|
ADM_Integrated_Logic_U.GV_IMU_AZ_Val + ADM_Integrated_Logic_DW.x_hat[1]) *
|
|
0.022698910310142498);
|
|
|
|
/* MATLAB Function: '<S1>/MATLAB Function3' */
|
|
if ((ADM_Integrated_Logic_DW.M > 500.0) && (ADM_Integrated_Logic_DW.M <
|
|
2000.0)) {
|
|
if (fabs(ADM_Integrated_Logic_DW.M -
|
|
ADM_Integrated_Logic_DW.currentEstMass) /
|
|
ADM_Integrated_Logic_DW.currentEstMass < 0.2) {
|
|
rtb_Trig = ADM_Integrated_Logic_DW.currentEstMass;
|
|
ADM_Integrated_Logic_DW.currentEstMass = 0.98 *
|
|
ADM_Integrated_Logic_DW.currentEstMass + 0.02 *
|
|
ADM_Integrated_Logic_DW.M;
|
|
ADM_Integrated_Logic_DW.isConverged = ((fabs
|
|
(ADM_Integrated_Logic_DW.currentEstMass - rtb_Trig) < 5.0) ||
|
|
ADM_Integrated_Logic_DW.isConverged);
|
|
if (ADM_Integrated_Logic_DW.isConverged) {
|
|
/* Outport: '<Root>/GV_VCU_EstMassFlag' */
|
|
ADM_Integrated_Logic_Y.GV_VCU_EstMassFlag = 2.0;
|
|
} else {
|
|
/* Outport: '<Root>/GV_VCU_EstMassFlag' */
|
|
ADM_Integrated_Logic_Y.GV_VCU_EstMassFlag = 1.0;
|
|
}
|
|
} else {
|
|
ADM_Integrated_Logic_DW.isConverged = false;
|
|
|
|
/* Outport: '<Root>/GV_VCU_EstMassFlag' */
|
|
ADM_Integrated_Logic_Y.GV_VCU_EstMassFlag = 1.0;
|
|
}
|
|
} else {
|
|
ADM_Integrated_Logic_DW.isConverged = false;
|
|
|
|
/* Outport: '<Root>/GV_VCU_EstMassFlag' */
|
|
ADM_Integrated_Logic_Y.GV_VCU_EstMassFlag = 1.0;
|
|
}
|
|
} else {
|
|
/* MATLAB Function: '<S1>/MATLAB Function3' */
|
|
ADM_Integrated_Logic_DW.isConverged = false;
|
|
|
|
/* Outport: '<Root>/GV_VCU_EstMassFlag' incorporates:
|
|
* MATLAB Function: '<S1>/MATLAB Function3'
|
|
*/
|
|
ADM_Integrated_Logic_Y.GV_VCU_EstMassFlag = 0.0;
|
|
}
|
|
|
|
/* End of MATLAB Function: '<S1>/MATLAB Function4' */
|
|
/* End of Outputs for SubSystem: '<S1>/Enabled Subsystem' */
|
|
|
|
/* Outport: '<Root>/GV_VCU_EstMass' incorporates:
|
|
* MATLAB Function: '<S1>/MATLAB Function3'
|
|
*/
|
|
ADM_Integrated_Logic_Y.GV_VCU_EstMass = ADM_Integrated_Logic_DW.currentEstMass;
|
|
|
|
/* Outport: '<Root>/GV_Brake_Command' incorporates:
|
|
* MATLAB Function: '<S1>/IDB_Fault_Injection'
|
|
*/
|
|
ADM_Integrated_Logic_Y.GV_Brake_Command = rtb_Brake_Saturation;
|
|
|
|
/* Outport: '<Root>/Target_IDB_Out' incorporates:
|
|
* MATLAB Function: '<S1>/IDB_Fault_Injection'
|
|
*/
|
|
ADM_Integrated_Logic_Y.Target_IDB_Out = rtb_Brake_Saturation;
|
|
|
|
/* Outport: '<Root>/Debug_CC_Brake_Output' */
|
|
ADM_Integrated_Logic_Y.Debug_CC_Brake_Output = rtb_y_k;
|
|
|
|
/* Outport: '<Root>/Debug_AccControl_TorqueCmd' incorporates:
|
|
* Constant: '<S3>/Constant'
|
|
* Constant: '<S3>/Constant1'
|
|
* Product: '<S3>/Product1'
|
|
* Product: '<S3>/Product2'
|
|
*/
|
|
ADM_Integrated_Logic_Y.Debug_AccControl_TorqueCmd = rtb_AccFlag * 0.270798 /
|
|
11.93;
|
|
|
|
/* MATLAB Function: '<S6>/Target_RPM' */
|
|
if (rtb_Memory == 0.0) {
|
|
i = 0;
|
|
} else if (rtb_Memory == 2.0) {
|
|
i = 0;
|
|
} else if (rtb_Memory == 1.0) {
|
|
i = -1;
|
|
} else {
|
|
i = (rtb_Memory == 3.0);
|
|
}
|
|
|
|
rtb_AccFlag = rtb_Vx_Cmd_R * 1000.0 / 3600.0 * 11.93 * 60.0 /
|
|
1.7013672006633955 * (double)i;
|
|
|
|
/* End of MATLAB Function: '<S6>/Target_RPM' */
|
|
|
|
/* RateLimiter: '<S6>/TargetSpd_RateLimiter' */
|
|
rtb_Brake_Saturation = rtb_AccFlag - ADM_Integrated_Logic_DW.PrevY_a;
|
|
if (rtb_Brake_Saturation > 0.4) {
|
|
rtb_AccFlag = ADM_Integrated_Logic_DW.PrevY_a + 0.4;
|
|
} else if (rtb_Brake_Saturation < -0.8) {
|
|
rtb_AccFlag = ADM_Integrated_Logic_DW.PrevY_a - 0.8;
|
|
}
|
|
|
|
ADM_Integrated_Logic_DW.PrevY_a = rtb_AccFlag;
|
|
|
|
/* End of RateLimiter: '<S6>/TargetSpd_RateLimiter' */
|
|
|
|
/* Product: '<S38>/Product1' incorporates:
|
|
* Constant: '<S38>/Constant'
|
|
* Gain: '<S38>/gain'
|
|
* Product: '<S38>/Product11'
|
|
* Sum: '<S38>/Sum1'
|
|
* Sum: '<S38>/Sum2'
|
|
* Sum: '<S38>/Sum3'
|
|
* Sum: '<S38>/Sum4'
|
|
* UnitDelay: '<S38>/d'
|
|
* UnitDelay: '<S38>/d1'
|
|
*/
|
|
rtb_Brake_Saturation = ((rtb_AccFlag + ADM_Integrated_Logic_DW.d1_DSTATE_c) *
|
|
0.002 + 0.1041032953945969 * ADM_Integrated_Logic_DW.d_DSTATE_l) /
|
|
0.1081032953945969;
|
|
|
|
/* Sum: '<S48>/Sum1' incorporates:
|
|
* Gain: '<S48>/gain'
|
|
* Sum: '<S48>/Sum2'
|
|
* UnitDelay: '<S48>/d'
|
|
* UnitDelay: '<S48>/d1'
|
|
*/
|
|
rtb_Trig = (rtb_Brake_Saturation - ADM_Integrated_Logic_DW.d_DSTATE_i) *
|
|
1000.0 - ADM_Integrated_Logic_DW.d1_DSTATE_p;
|
|
|
|
/* Sum: '<S49>/Sum1' incorporates:
|
|
* Gain: '<S49>/gain'
|
|
* Sum: '<S49>/Sum2'
|
|
* UnitDelay: '<S49>/d'
|
|
* UnitDelay: '<S49>/d1'
|
|
*/
|
|
rtb_Sum1_j1 = (rtb_Trig - ADM_Integrated_Logic_DW.d_DSTATE_c) * 1000.0 -
|
|
ADM_Integrated_Logic_DW.d1_DSTATE_h;
|
|
|
|
/* Sum: '<S50>/Sum1' incorporates:
|
|
* Gain: '<S50>/gain'
|
|
* Sum: '<S50>/Sum2'
|
|
* UnitDelay: '<S50>/d'
|
|
* UnitDelay: '<S50>/d1'
|
|
*/
|
|
rtb_Sum1_d = (rtb_Sum1_j1 - ADM_Integrated_Logic_DW.d_DSTATE_d) * 1000.0 -
|
|
ADM_Integrated_Logic_DW.d1_DSTATE_l;
|
|
|
|
/* Gain: '<S46>/Gain' incorporates:
|
|
* Constant: '<S46>/Constant3'
|
|
* Constant: '<S46>/Constant4'
|
|
* Constant: '<S46>/Constant5'
|
|
* Product: '<S46>/Product'
|
|
* Product: '<S46>/Product1'
|
|
* Product: '<S46>/Product2'
|
|
* Sum: '<S46>/Add5'
|
|
*/
|
|
rtb_Gain_c = (((156.8 * rtb_Brake_Saturation + 212.8 * rtb_Trig) + 21.8 *
|
|
rtb_Sum1_j1) + rtb_Sum1_d) * 9.44822373393802E-6;
|
|
|
|
/* Product: '<S52>/Product1' incorporates:
|
|
* Constant: '<S52>/Constant1'
|
|
* Constant: '<S52>/Constant2'
|
|
* Delay: '<S52>/Delay'
|
|
* Delay: '<S52>/Delay1'
|
|
* Delay: '<S52>/Delay2'
|
|
* Delay: '<S52>/Delay3'
|
|
* Gain: '<S52>/gain1'
|
|
* Gain: '<S52>/gain3'
|
|
* Product: '<S52>/x(n), x(n-1), x(n-2)'
|
|
* Product: '<S52>/y(n-1)'
|
|
* Product: '<S52>/y(n-2)'
|
|
* Sum: '<S52>/Sum1'
|
|
* Sum: '<S52>/Sum2'
|
|
* Sum: '<S52>/Sum3'
|
|
* Sum: '<S52>/Sum4'
|
|
* Sum: '<S52>/Sum5'
|
|
* Sum: '<S52>/Sum6'
|
|
*/
|
|
rtb_Product1_pd = ((((2.0 * ADM_Integrated_Logic_DW.Delay1_DSTATE + rtb_Gain_c)
|
|
+ ADM_Integrated_Logic_DW.Delay_DSTATE_c[0]) *
|
|
0.39478417604357435 - -7.2104316479128512 *
|
|
ADM_Integrated_Logic_DW.Delay2_DSTATE) -
|
|
2.6178993711731877 * ADM_Integrated_Logic_DW.Delay3_DSTATE
|
|
[0]) / 6.1716689809139611;
|
|
|
|
/* Product: '<S51>/Product1' incorporates:
|
|
* Constant: '<S51>/Constant'
|
|
* Gain: '<S51>/gain'
|
|
* Product: '<S51>/Product11'
|
|
* Sum: '<S51>/Sum1'
|
|
* Sum: '<S51>/Sum2'
|
|
* Sum: '<S51>/Sum3'
|
|
* Sum: '<S51>/Sum4'
|
|
* UnitDelay: '<S51>/d'
|
|
* UnitDelay: '<S51>/d1'
|
|
*/
|
|
rtb_Product1_m = ((rtb_Product1_pd + ADM_Integrated_Logic_DW.d1_DSTATE_e) *
|
|
0.002 + 0.00861032953945969 *
|
|
ADM_Integrated_Logic_DW.d_DSTATE_ij) / 0.01261032953945969;
|
|
|
|
/* Sum: '<S6>/Subtract' incorporates:
|
|
* Inport: '<Root>/GV_MCU_RPM'
|
|
* MultiPortSwitch: '<S45>/Multiport Switch1'
|
|
*/
|
|
rtb_Error_m = rtb_Brake_Saturation - ADM_Integrated_Logic_U.GV_MCU_RPM;
|
|
|
|
/* Saturate: '<S6>/Error_Saturation' incorporates:
|
|
* MultiPortSwitch: '<S45>/Multiport Switch1'
|
|
*/
|
|
if (rtb_Error_m > 2000.0) {
|
|
rtb_Error_m = 2000.0;
|
|
} else if (rtb_Error_m < -2000.0) {
|
|
rtb_Error_m = -2000.0;
|
|
}
|
|
|
|
/* End of Saturate: '<S6>/Error_Saturation' */
|
|
|
|
/* DeadZone: '<S35>/Dead Zone' incorporates:
|
|
* MultiPortSwitch: '<S45>/Multiport Switch1'
|
|
*/
|
|
if (rtb_Error_m > 50.0) {
|
|
rtb_Add_e = rtb_Error_m - 50.0;
|
|
} else if (rtb_Error_m >= -50.0) {
|
|
rtb_Add_e = 0.0;
|
|
} else {
|
|
rtb_Add_e = rtb_Error_m - -50.0;
|
|
}
|
|
|
|
/* Sum: '<S40>/Sum1' incorporates:
|
|
* Gain: '<S40>/gain'
|
|
* Sum: '<S40>/Sum2'
|
|
* UnitDelay: '<S40>/d'
|
|
* UnitDelay: '<S40>/d1'
|
|
*/
|
|
rtb_Error_m = (rtb_Brake_Saturation - ADM_Integrated_Logic_DW.d_DSTATE_ir) *
|
|
1000.0 - ADM_Integrated_Logic_DW.d1_DSTATE_o;
|
|
|
|
/* Sum: '<S41>/Sum1' incorporates:
|
|
* Gain: '<S41>/gain'
|
|
* Sum: '<S41>/Sum2'
|
|
* UnitDelay: '<S41>/d'
|
|
* UnitDelay: '<S41>/d1'
|
|
*/
|
|
rtb_Sum1_f = (rtb_Error_m - ADM_Integrated_Logic_DW.d_DSTATE_m) * 1000.0 -
|
|
ADM_Integrated_Logic_DW.d1_DSTATE_hm;
|
|
|
|
/* Sum: '<S42>/Sum1' incorporates:
|
|
* Gain: '<S42>/gain'
|
|
* Sum: '<S42>/Sum2'
|
|
* UnitDelay: '<S42>/d'
|
|
* UnitDelay: '<S42>/d1'
|
|
*/
|
|
rtb_Sum1_cr = (rtb_Sum1_f - ADM_Integrated_Logic_DW.d_DSTATE_mw) * 1000.0 -
|
|
ADM_Integrated_Logic_DW.d1_DSTATE_g;
|
|
|
|
/* Sum: '<S33>/Add3' incorporates:
|
|
* Constant: '<S33>/Constant3'
|
|
* Constant: '<S33>/Constant4'
|
|
* Constant: '<S33>/Constant5'
|
|
* Gain: '<S33>/Gain'
|
|
* Memory: '<S6>/Memory'
|
|
* Product: '<S33>/Product2'
|
|
* Product: '<S33>/Product3'
|
|
* Product: '<S33>/Product4'
|
|
* Sum: '<S33>/Add2'
|
|
*/
|
|
rtb_Add3 = (((156.8 * rtb_Brake_Saturation + 212.8 * rtb_Error_m) + 21.8 *
|
|
rtb_Sum1_f) + rtb_Sum1_cr) * 9.44822373393802E-6 -
|
|
ADM_Integrated_Logic_DW.Memory_PreviousInput;
|
|
|
|
/* Product: '<S43>/Product1' incorporates:
|
|
* Constant: '<S43>/Constant'
|
|
* Gain: '<S43>/gain'
|
|
* Product: '<S43>/Product11'
|
|
* Sum: '<S43>/Sum1'
|
|
* Sum: '<S43>/Sum2'
|
|
* Sum: '<S43>/Sum3'
|
|
* Sum: '<S43>/Sum4'
|
|
* UnitDelay: '<S43>/d'
|
|
* UnitDelay: '<S43>/d1'
|
|
*/
|
|
rtb_Product1_k3 = ((rtb_Add3 + ADM_Integrated_Logic_DW.d1_DSTATE_ej) * 0.002 +
|
|
0.029830988618379066 * ADM_Integrated_Logic_DW.d_DSTATE_j) /
|
|
0.03383098861837907;
|
|
|
|
/* Product: '<S44>/Product1' incorporates:
|
|
* Constant: '<S44>/Constant1'
|
|
* Constant: '<S44>/Constant2'
|
|
* Delay: '<S44>/Delay'
|
|
* Delay: '<S44>/Delay1'
|
|
* Delay: '<S44>/Delay2'
|
|
* Delay: '<S44>/Delay3'
|
|
* Gain: '<S44>/gain1'
|
|
* Gain: '<S44>/gain3'
|
|
* Product: '<S44>/x(n), x(n-1), x(n-2)'
|
|
* Product: '<S44>/y(n-1)'
|
|
* Product: '<S44>/y(n-2)'
|
|
* Sum: '<S44>/Sum1'
|
|
* Sum: '<S44>/Sum2'
|
|
* Sum: '<S44>/Sum3'
|
|
* Sum: '<S44>/Sum4'
|
|
* Sum: '<S44>/Sum5'
|
|
* Sum: '<S44>/Sum6'
|
|
*/
|
|
rtb_Product1_h = ((((2.0 * ADM_Integrated_Logic_DW.Delay1_DSTATE_c +
|
|
rtb_Product1_k3) +
|
|
ADM_Integrated_Logic_DW.Delay_DSTATE_p[0]) *
|
|
0.00035530575843921691 - -7.9992893884831213 *
|
|
ADM_Integrated_Logic_DW.Delay2_DSTATE_n) -
|
|
3.9470487616123275 *
|
|
ADM_Integrated_Logic_DW.Delay3_DSTATE_h[0]) /
|
|
4.0536618499045511;
|
|
|
|
/* MATLAB Function: '<S6>/DOB_Gain' incorporates:
|
|
* Inport: '<Root>/GV_Vx_Fbk'
|
|
*/
|
|
if (ADM_Integrated_Logic_U.GV_Vx_Fbk < 5.0) {
|
|
rtb_y_k = 0.0;
|
|
} else {
|
|
rtb_y_k = (ADM_Integrated_Logic_U.GV_Vx_Fbk - 5.0) * 0.2;
|
|
}
|
|
|
|
if (rtb_y_k >= 1.0) {
|
|
rtb_y_k = 1.0;
|
|
}
|
|
|
|
/* End of MATLAB Function: '<S6>/DOB_Gain' */
|
|
|
|
/* Product: '<S6>/Product1' incorporates:
|
|
* Constant: '<S6>/DOBFlag'
|
|
* Product: '<S6>/Product'
|
|
*/
|
|
rtb_Integrator_1 = -(rtb_Product1_h * 0.9);
|
|
|
|
/* Saturate: '<S6>/DOB_Saturation' */
|
|
if (rtb_Integrator_1 > 30.0) {
|
|
rtb_Integrator_1 = 30.0;
|
|
} else if (rtb_Integrator_1 < -30.0) {
|
|
rtb_Integrator_1 = -30.0;
|
|
}
|
|
|
|
/* Sum: '<S6>/Subtract2' incorporates:
|
|
* DeadZone: '<S35>/Dead Zone'
|
|
* MultiPortSwitch: '<S45>/Multiport Switch1'
|
|
* Product: '<S47>/Product'
|
|
* Product: '<S6>/Multiply1'
|
|
* Saturate: '<S6>/DOB_Saturation'
|
|
* Sum: '<S35>/Add'
|
|
*/
|
|
rtb_Add_e = (rtb_Add_e * 0.044648264844923756 + rtb_Product1_m) +
|
|
rtb_Integrator_1 * rtb_y_k;
|
|
|
|
/* Saturate: '<S6>/Torq_Saturation' */
|
|
if (rtb_Add_e > 80.0) {
|
|
rtb_Add_e = 80.0;
|
|
} else if (rtb_Add_e < -80.0) {
|
|
rtb_Add_e = -80.0;
|
|
}
|
|
|
|
/* End of Saturate: '<S6>/Torq_Saturation' */
|
|
|
|
/* MATLAB Function: '<S1>/Emergency_Motor_Func' incorporates:
|
|
* Inport: '<Root>/GV_IDB_ECU_Fault_Flag'
|
|
* Inport: '<Root>/GV_RCU_ECU_Fault_Flag'
|
|
* Inport: '<Root>/GV_Vx_Fbk'
|
|
* MATLAB Function: '<S6>/Gear_pos_out'
|
|
*/
|
|
if (rtb_Compare_l) {
|
|
if ((ADM_Integrated_Logic_U.GV_IDB_ECU_Fault_Flag == 1.0) &&
|
|
(ADM_Integrated_Logic_U.GV_RCU_ECU_Fault_Flag == 1.0)) {
|
|
if (ADM_Integrated_Logic_U.GV_Vx_Fbk / 3.6 > 0.5) {
|
|
rtb_y_k = -80.0;
|
|
} else {
|
|
rtb_y_k = 0.0;
|
|
}
|
|
} else {
|
|
rtb_y_k = 0.0;
|
|
}
|
|
} else {
|
|
if (rtb_Memory == 0.0) {
|
|
/* MATLAB Function: '<S6>/Gear_pos_out' */
|
|
i = 0;
|
|
} else if (rtb_Memory == 2.0) {
|
|
/* MATLAB Function: '<S6>/Gear_pos_out' */
|
|
i = 0;
|
|
} else if (rtb_Memory == 1.0) {
|
|
/* MATLAB Function: '<S6>/Gear_pos_out' */
|
|
i = -1;
|
|
} else {
|
|
/* MATLAB Function: '<S6>/Gear_pos_out' */
|
|
i = (rtb_Memory == 3.0);
|
|
}
|
|
|
|
/* Product: '<S6>/Multiply' incorporates:
|
|
* MATLAB Function: '<S6>/Gear_pos_out'
|
|
*/
|
|
rtb_y_k = (double)i * rtb_Add_e;
|
|
|
|
/* Saturate: '<S1>/Saturation' */
|
|
if (rtb_y_k < 0.0) {
|
|
rtb_y_k = 0.0;
|
|
}
|
|
|
|
/* End of Saturate: '<S1>/Saturation' */
|
|
}
|
|
|
|
/* End of MATLAB Function: '<S1>/Emergency_Motor_Func' */
|
|
|
|
/* MATLAB Function: '<S1>/MCU_Fault_Injection' incorporates:
|
|
* Inport: '<Root>/GV_MCU_Actuator_Fault_Flag'
|
|
*/
|
|
if (ADM_Integrated_Logic_U.GV_MCU_Actuator_Fault_Flag == 1.0) {
|
|
/* Outport: '<Root>/GV_Motor_Torque_Cmd' */
|
|
ADM_Integrated_Logic_Y.GV_Motor_Torque_Cmd = 0.0;
|
|
} else {
|
|
/* Outport: '<Root>/GV_Motor_Torque_Cmd' */
|
|
ADM_Integrated_Logic_Y.GV_Motor_Torque_Cmd = rtb_y_k;
|
|
}
|
|
|
|
/* Outport: '<Root>/Target_MCU_Out' incorporates:
|
|
* MATLAB Function: '<S1>/MCU_Fault_Injection'
|
|
*/
|
|
ADM_Integrated_Logic_Y.Target_MCU_Out = rtb_y_k;
|
|
|
|
/* Sum: '<S28>/Sum' */
|
|
rtb_F_PI -= rtb_y;
|
|
|
|
/* Outport: '<Root>/Debug_HAC_Brake_Output' */
|
|
ADM_Integrated_Logic_Y.Debug_HAC_Brake_Output = rtb_Brake_Torque_Cmd;
|
|
|
|
/* Outport: '<Root>/GV_Gear_Postion_Out' */
|
|
ADM_Integrated_Logic_Y.GV_Gear_Postion_Out = rtb_Memory;
|
|
|
|
/* Outport: '<Root>/GV_Hill_Torque_Assist' */
|
|
ADM_Integrated_Logic_Y.GV_Hill_Torque_Assist = rtb_Desired_Torque;
|
|
|
|
/* Outport: '<Root>/Debug_HAC_Pitch_angle' */
|
|
ADM_Integrated_Logic_Y.Debug_HAC_Pitch_angle = rtb_Pitch_Angle;
|
|
|
|
/* MATLAB Function: '<S58>/Calculate_F_c1' incorporates:
|
|
* Gain: '<S58>/Gain3'
|
|
*/
|
|
ADM_Integrated_Lo_Calculate_F_c(ADM_Integrated_Logic_ConstB.W_Value_for_Brake,
|
|
0.017453292519943295 * rtb_Pitch_Angle, &rtb_y);
|
|
|
|
/* Product: '<S59>/Product1' incorporates:
|
|
* Constant: '<S59>/Constant'
|
|
* Gain: '<S59>/gain'
|
|
* Inport: '<Root>/GV_IMU_AX_Val'
|
|
* Product: '<S59>/Product11'
|
|
* Sum: '<S59>/Sum1'
|
|
* Sum: '<S59>/Sum2'
|
|
* Sum: '<S59>/Sum3'
|
|
* Sum: '<S59>/Sum4'
|
|
* UnitDelay: '<S59>/d'
|
|
* UnitDelay: '<S59>/d1'
|
|
*/
|
|
rtb_Desired_Torque = ((ADM_Integrated_Logic_U.GV_IMU_AX_Val +
|
|
ADM_Integrated_Logic_DW.d1_DSTATE_ob) * 0.002 + 0.061661977236758134 *
|
|
ADM_Integrated_Logic_DW.d_DSTATE_e) /
|
|
0.065661977236758137;
|
|
|
|
/* Product: '<S60>/Product1' incorporates:
|
|
* Constant: '<S60>/Constant'
|
|
* Gain: '<S60>/gain'
|
|
* Inport: '<Root>/GV_IMU_AY_Val'
|
|
* Product: '<S60>/Product11'
|
|
* Sum: '<S60>/Sum1'
|
|
* Sum: '<S60>/Sum2'
|
|
* Sum: '<S60>/Sum3'
|
|
* Sum: '<S60>/Sum4'
|
|
* UnitDelay: '<S60>/d'
|
|
* UnitDelay: '<S60>/d1'
|
|
*/
|
|
rtb_Brake_Torque_Cmd = ((ADM_Integrated_Logic_U.GV_IMU_AY_Val +
|
|
ADM_Integrated_Logic_DW.d1_DSTATE_i) * 0.002 + 0.061661977236758134 *
|
|
ADM_Integrated_Logic_DW.d_DSTATE_p) / 0.065661977236758137;
|
|
|
|
/* Product: '<S61>/Product1' incorporates:
|
|
* Constant: '<S61>/Constant'
|
|
* Gain: '<S61>/gain'
|
|
* Inport: '<Root>/GV_IMU_AZ_Val'
|
|
* Product: '<S61>/Product11'
|
|
* Sum: '<S61>/Sum1'
|
|
* Sum: '<S61>/Sum2'
|
|
* Sum: '<S61>/Sum3'
|
|
* Sum: '<S61>/Sum4'
|
|
* UnitDelay: '<S61>/d'
|
|
* UnitDelay: '<S61>/d1'
|
|
*/
|
|
rtb_Integrator_1 = ((ADM_Integrated_Logic_U.GV_IMU_AZ_Val +
|
|
ADM_Integrated_Logic_DW.d1_DSTATE_o1) * 0.002 +
|
|
0.061661977236758134 * ADM_Integrated_Logic_DW.d_DSTATE_n)
|
|
/ 0.065661977236758137;
|
|
|
|
/* MATLAB Function: '<S11>/Pitch_calculate' */
|
|
rtb_y = sqrt(rtb_Brake_Torque_Cmd * rtb_Brake_Torque_Cmd + rtb_Integrator_1 *
|
|
rtb_Integrator_1);
|
|
if (!(rtb_y == 0.0)) {
|
|
rtb_y = atan(rtb_Desired_Torque / rtb_y);
|
|
}
|
|
|
|
/* Sum: '<S11>/Sum' incorporates:
|
|
* DiscreteIntegrator: '<S11>/Integrator_2'
|
|
* MATLAB Function: '<S11>/Pitch_calculate'
|
|
*/
|
|
rtb_Sum_f = ADM_Integrated_Logic_DW.Integrator_2_DSTATE - rtb_y *
|
|
57.295779513082323;
|
|
|
|
/* Gain: '<S62>/gain1' incorporates:
|
|
* Constant: '<S62>/Constant1'
|
|
* Product: '<S62>/Product2'
|
|
*/
|
|
rtb_Switch2_k = 0.063661977236758135;
|
|
|
|
/* Product: '<S62>/Product1' incorporates:
|
|
* Constant: '<S62>/Constant'
|
|
* Gain: '<S62>/gain'
|
|
* Inport: '<Root>/GV_IMU_PitchRtVal'
|
|
* Product: '<S62>/Product11'
|
|
* Sum: '<S62>/Sum1'
|
|
* Sum: '<S62>/Sum2'
|
|
* Sum: '<S62>/Sum3'
|
|
* Sum: '<S62>/Sum4'
|
|
* UnitDelay: '<S62>/d'
|
|
* UnitDelay: '<S62>/d1'
|
|
*/
|
|
rtb_Product1_gg = ((ADM_Integrated_Logic_U.GV_IMU_PitchRtVal +
|
|
ADM_Integrated_Logic_DW.d1_DSTATE_a) * 0.002 +
|
|
0.061661977236758134 * ADM_Integrated_Logic_DW.d_DSTATE_d1)
|
|
/ 0.065661977236758137;
|
|
|
|
/* Sum: '<S1>/Add2' incorporates:
|
|
* Inport: '<Root>/GV_Vx_Fbk'
|
|
*/
|
|
rtb_Vx_Cmd_R -= ADM_Integrated_Logic_U.GV_Vx_Fbk;
|
|
|
|
/* Sum: '<S1>/Add1' incorporates:
|
|
* Constant: '<S1>/Constant'
|
|
* Gain: '<S1>/Gain1'
|
|
* Inport: '<Root>/GV_Vx_Fbk'
|
|
* Sum: '<S1>/Add3'
|
|
*/
|
|
rtb_Add1_tmp = 400.0 - 6.5 * ADM_Integrated_Logic_U.GV_Vx_Fbk;
|
|
|
|
/* MATLAB Function: '<S1>/MATLAB Function1' incorporates:
|
|
* Sum: '<S1>/Add1'
|
|
*/
|
|
ADM_Integrated__MATLABFunction1(rtb_Add1_tmp, &rtb_Switch2_k);
|
|
|
|
/* Product: '<S23>/delta rise limit' incorporates:
|
|
* SampleTimeMath: '<S23>/sample time'
|
|
*
|
|
* About '<S23>/sample time':
|
|
* y = K where K = ( w * Ts )
|
|
* */
|
|
rtb_Switch2_k *= 0.002;
|
|
|
|
/* Delay: '<S23>/Delay' incorporates:
|
|
* Inport: '<Root>/GV_RWA_RackAngleCommand'
|
|
*/
|
|
if (ADM_Integrated_Logic_DW.icLoad_l) {
|
|
ADM_Integrated_Logic_DW.Delay_DSTATE_c4 =
|
|
ADM_Integrated_Logic_U.GV_RWA_RackAngleCommand;
|
|
}
|
|
|
|
/* Sum: '<S23>/Difference Inputs1' incorporates:
|
|
* Delay: '<S23>/Delay'
|
|
* Inport: '<Root>/GV_RWA_RackAngleCommand'
|
|
*
|
|
* Block description for '<S23>/Difference Inputs1':
|
|
*
|
|
* Add in CPU
|
|
*/
|
|
rtb_y_k = ADM_Integrated_Logic_U.GV_RWA_RackAngleCommand -
|
|
ADM_Integrated_Logic_DW.Delay_DSTATE_c4;
|
|
|
|
/* MATLAB Function: '<S1>/MATLAB Function2' incorporates:
|
|
* Gain: '<S1>/Gain3'
|
|
* Sum: '<S1>/Add1'
|
|
*/
|
|
ADM_Integrated__MATLABFunction2(-rtb_Add1_tmp, &rtb_y);
|
|
|
|
/* Switch: '<S71>/Switch2' incorporates:
|
|
* RelationalOperator: '<S71>/LowerRelop1'
|
|
*/
|
|
if (!(rtb_y_k > rtb_Switch2_k)) {
|
|
/* Product: '<S23>/delta fall limit' incorporates:
|
|
* SampleTimeMath: '<S23>/sample time'
|
|
*
|
|
* About '<S23>/sample time':
|
|
* y = K where K = ( w * Ts )
|
|
* */
|
|
rtb_y *= 0.002;
|
|
|
|
/* Switch: '<S71>/Switch' incorporates:
|
|
* RelationalOperator: '<S71>/UpperRelop'
|
|
*/
|
|
if (rtb_y_k < rtb_y) {
|
|
rtb_Switch2_k = rtb_y;
|
|
} else {
|
|
rtb_Switch2_k = rtb_y_k;
|
|
}
|
|
|
|
/* End of Switch: '<S71>/Switch' */
|
|
}
|
|
|
|
/* End of Switch: '<S71>/Switch2' */
|
|
|
|
/* Sum: '<S23>/Difference Inputs2' incorporates:
|
|
* Delay: '<S23>/Delay'
|
|
*
|
|
* Block description for '<S23>/Difference Inputs2':
|
|
*
|
|
* Add in CPU
|
|
*/
|
|
rtb_y = rtb_Switch2_k + ADM_Integrated_Logic_DW.Delay_DSTATE_c4;
|
|
|
|
/* Outport: '<Root>/GV_Master_Rack_Angle_Cmd' incorporates:
|
|
* MATLAB Function: '<S1>/RWA_Actuator_Fault_Injection'
|
|
*/
|
|
ADM_Integrated_Logic_Y.GV_Master_Rack_Angle_Cmd = rtb_y;
|
|
|
|
/* Outport: '<Root>/Target_RWA_Out' incorporates:
|
|
* MATLAB Function: '<S1>/RWA_Actuator_Fault_Injection'
|
|
*/
|
|
ADM_Integrated_Logic_Y.Target_RWA_Out = rtb_y;
|
|
|
|
/* MATLAB Function: '<S1>/MATLAB Function5' */
|
|
ADM_Integrated__MATLABFunction1(rtb_Add1_tmp, &rtb_Switch2_k);
|
|
|
|
/* Product: '<S24>/delta rise limit' incorporates:
|
|
* SampleTimeMath: '<S24>/sample time'
|
|
*
|
|
* About '<S24>/sample time':
|
|
* y = K where K = ( w * Ts )
|
|
* */
|
|
rtb_Switch2_k *= 0.002;
|
|
|
|
/* Delay: '<S24>/Delay' incorporates:
|
|
* Inport: '<Root>/GV_RWS_RackAngleCommand'
|
|
*/
|
|
if (ADM_Integrated_Logic_DW.icLoad_d) {
|
|
ADM_Integrated_Logic_DW.Delay_DSTATE_i1 =
|
|
ADM_Integrated_Logic_U.GV_RWS_RackAngleCommand;
|
|
}
|
|
|
|
/* Sum: '<S24>/Difference Inputs1' incorporates:
|
|
* Delay: '<S24>/Delay'
|
|
* Inport: '<Root>/GV_RWS_RackAngleCommand'
|
|
*
|
|
* Block description for '<S24>/Difference Inputs1':
|
|
*
|
|
* Add in CPU
|
|
*/
|
|
rtb_Add1 = ADM_Integrated_Logic_U.GV_RWS_RackAngleCommand -
|
|
ADM_Integrated_Logic_DW.Delay_DSTATE_i1;
|
|
|
|
/* MATLAB Function: '<S1>/MATLAB Function6' incorporates:
|
|
* Gain: '<S1>/Gain5'
|
|
*/
|
|
ADM_Integrated__MATLABFunction2(-rtb_Add1_tmp, &rtb_y_k);
|
|
|
|
/* Switch: '<S72>/Switch2' incorporates:
|
|
* RelationalOperator: '<S72>/LowerRelop1'
|
|
*/
|
|
if (!(rtb_Add1 > rtb_Switch2_k)) {
|
|
/* Product: '<S24>/delta fall limit' incorporates:
|
|
* SampleTimeMath: '<S24>/sample time'
|
|
*
|
|
* About '<S24>/sample time':
|
|
* y = K where K = ( w * Ts )
|
|
* */
|
|
rtb_y_k *= 0.002;
|
|
|
|
/* Switch: '<S72>/Switch' incorporates:
|
|
* RelationalOperator: '<S72>/UpperRelop'
|
|
*/
|
|
if (rtb_Add1 < rtb_y_k) {
|
|
rtb_Switch2_k = rtb_y_k;
|
|
} else {
|
|
rtb_Switch2_k = rtb_Add1;
|
|
}
|
|
|
|
/* End of Switch: '<S72>/Switch' */
|
|
}
|
|
|
|
/* End of Switch: '<S72>/Switch2' */
|
|
|
|
/* Sum: '<S24>/Difference Inputs2' incorporates:
|
|
* Delay: '<S24>/Delay'
|
|
*
|
|
* Block description for '<S24>/Difference Inputs2':
|
|
*
|
|
* Add in CPU
|
|
*/
|
|
rtb_y_k = rtb_Switch2_k + ADM_Integrated_Logic_DW.Delay_DSTATE_i1;
|
|
|
|
/* Outport: '<Root>/GV_RWS_RackAngleCmd1' */
|
|
ADM_Integrated_Logic_Y.GV_RWS_RackAngleCmd1 = rtb_y_k;
|
|
|
|
/* Outport: '<Root>/Act_Fault_Exist' incorporates:
|
|
* MATLAB Function: '<S1>/Actuator_Fault_Decision'
|
|
*/
|
|
ADM_Integrated_Logic_Y.Act_Fault_Exist = 0.0;
|
|
|
|
/* MATLAB Function: '<S1>/Actuator_Fault_Decision' incorporates:
|
|
* Inport: '<Root>/GV_ACU_ECU_Fault_Flag'
|
|
* Inport: '<Root>/GV_ACU_ECU_Fault_Flag1'
|
|
* Inport: '<Root>/GV_ACU_ECU_Fault_Flag2'
|
|
* Inport: '<Root>/GV_ACU_ECU_Fault_Flag3'
|
|
* Inport: '<Root>/GV_ACU_Fault_Flag'
|
|
* Inport: '<Root>/GV_Drive_Mode'
|
|
* Inport: '<Root>/GV_IDB_ECU_Fault_Flag'
|
|
* Inport: '<Root>/GV_MCU_Actuator_Fault_Flag'
|
|
* Inport: '<Root>/GV_RCU_ECU_Fault_Flag'
|
|
* Inport: '<Root>/GV_RWA1_ECU_Fault_Flag'
|
|
* Inport: '<Root>/GV_RWA2_ECU_Fault_Flag'
|
|
* Inport: '<Root>/GV_RWA_Actuator_Fault'
|
|
*/
|
|
if ((ADM_Integrated_Logic_U.GV_ACU_Fault_Flag == 1.0) ||
|
|
(ADM_Integrated_Logic_U.GV_MCU_Actuator_Fault_Flag == 1.0) ||
|
|
(ADM_Integrated_Logic_U.GV_RWA_Actuator_Fault == 1.0)) {
|
|
/* Outport: '<Root>/Act_Fault_Exist' */
|
|
ADM_Integrated_Logic_Y.Act_Fault_Exist = 1.0;
|
|
}
|
|
|
|
if (((ADM_Integrated_Logic_U.GV_ACU_ECU_Fault_Flag == 1.0) ||
|
|
(ADM_Integrated_Logic_U.GV_ACU_ECU_Fault_Flag1 == 1.0) ||
|
|
(ADM_Integrated_Logic_U.GV_ACU_ECU_Fault_Flag2 == 1.0) ||
|
|
(ADM_Integrated_Logic_U.GV_ACU_ECU_Fault_Flag3 == 1.0)) &&
|
|
((ADM_Integrated_Logic_U.GV_Drive_Mode == 0.0) ||
|
|
(ADM_Integrated_Logic_U.GV_Drive_Mode == 2.0))) {
|
|
/* Outport: '<Root>/Act_Fault_Exist' */
|
|
ADM_Integrated_Logic_Y.Act_Fault_Exist = 1.0;
|
|
}
|
|
|
|
if ((ADM_Integrated_Logic_U.GV_IDB_ECU_Fault_Flag == 1.0) ||
|
|
(ADM_Integrated_Logic_U.GV_RCU_ECU_Fault_Flag == 1.0)) {
|
|
/* Outport: '<Root>/Act_Fault_Exist' */
|
|
ADM_Integrated_Logic_Y.Act_Fault_Exist = 1.0;
|
|
} else if ((ADM_Integrated_Logic_U.GV_RWA1_ECU_Fault_Flag == 1.0) &&
|
|
(ADM_Integrated_Logic_U.GV_RWA2_ECU_Fault_Flag == 1.0)) {
|
|
/* Outport: '<Root>/Act_Fault_Exist' */
|
|
ADM_Integrated_Logic_Y.Act_Fault_Exist = 1.0;
|
|
}
|
|
|
|
/* Update for UnitDelay: '<S13>/d1' incorporates:
|
|
* Inport: '<Root>/GV_IMU_AX_Val'
|
|
*/
|
|
ADM_Integrated_Logic_DW.d1_DSTATE = ADM_Integrated_Logic_U.GV_IMU_AX_Val;
|
|
|
|
/* Update for UnitDelay: '<S13>/d' */
|
|
ADM_Integrated_Logic_DW.d_DSTATE = rtb_Product1;
|
|
|
|
/* Update for DiscreteIntegrator: '<S11>/Integrator_2' incorporates:
|
|
* Constant: '<S11>/I_gain'
|
|
* Constant: '<S11>/P_gain'
|
|
* DiscreteIntegrator: '<S11>/Integrator_1'
|
|
* Product: '<S11>/Product'
|
|
* Product: '<S11>/Product1'
|
|
* Sum: '<S11>/Sum1'
|
|
* Sum: '<S11>/Sum2'
|
|
*/
|
|
ADM_Integrated_Logic_DW.Integrator_2_DSTATE += (rtb_Product1_gg -
|
|
(ADM_Integrated_Logic_DW.Integrator_1_DSTATE * 5.0 + rtb_Sum_f * 100.0)) *
|
|
0.002;
|
|
|
|
/* Update for Delay: '<S65>/Delay' */
|
|
ADM_Integrated_Logic_DW.icLoad = false;
|
|
ADM_Integrated_Logic_DW.Delay_DSTATE = rtb_Pitch_Angle;
|
|
|
|
/* Update for Delay: '<S64>/Delay' */
|
|
ADM_Integrated_Logic_DW.icLoad_e = false;
|
|
ADM_Integrated_Logic_DW.Delay_DSTATE_i = rtb_Saturation;
|
|
|
|
/* Update for Delay: '<S10>/Memory' */
|
|
ADM_Integrated_Logic_DW.Memory_DSTATE = rtb_Memory;
|
|
|
|
/* Update for DiscreteIntegrator: '<S28>/Discrete-Time Integrator' incorporates:
|
|
* Memory: '<S28>/Memory'
|
|
* Sum: '<S28>/Sum1'
|
|
*/
|
|
ADM_Integrated_Logic_DW.DiscreteTimeIntegrator_DSTATE += (rtb_Product2_a -
|
|
ADM_Integrated_Logic_DW.Memory_PreviousInput_f) * 0.002;
|
|
|
|
/* Update for UnitDelay: '<S31>/UD'
|
|
*
|
|
* Block description for '<S31>/UD':
|
|
*
|
|
* Store in Global RAM
|
|
*/
|
|
ADM_Integrated_Logic_DW.UD_DSTATE = rtb_TSamp;
|
|
|
|
/* Update for DiscreteTransferFcn: '<S1>/Discrete Transfer Fcn' */
|
|
ADM_Integrated_Logic_DW.DiscreteTransferFcn_states = rtb_Vx_Cmd_R - -0.9375 *
|
|
ADM_Integrated_Logic_DW.DiscreteTransferFcn_states;
|
|
|
|
/* Update for UnitDelay: '<S38>/d1' */
|
|
ADM_Integrated_Logic_DW.d1_DSTATE_c = rtb_AccFlag;
|
|
|
|
/* Update for UnitDelay: '<S38>/d' */
|
|
ADM_Integrated_Logic_DW.d_DSTATE_l = rtb_Brake_Saturation;
|
|
|
|
/* Update for UnitDelay: '<S48>/d' */
|
|
ADM_Integrated_Logic_DW.d_DSTATE_i = rtb_Brake_Saturation;
|
|
|
|
/* Update for UnitDelay: '<S48>/d1' */
|
|
ADM_Integrated_Logic_DW.d1_DSTATE_p = rtb_Trig;
|
|
|
|
/* Update for UnitDelay: '<S49>/d' */
|
|
ADM_Integrated_Logic_DW.d_DSTATE_c = rtb_Trig;
|
|
|
|
/* Update for UnitDelay: '<S49>/d1' */
|
|
ADM_Integrated_Logic_DW.d1_DSTATE_h = rtb_Sum1_j1;
|
|
|
|
/* Update for UnitDelay: '<S50>/d' */
|
|
ADM_Integrated_Logic_DW.d_DSTATE_d = rtb_Sum1_j1;
|
|
|
|
/* Update for UnitDelay: '<S50>/d1' */
|
|
ADM_Integrated_Logic_DW.d1_DSTATE_l = rtb_Sum1_d;
|
|
|
|
/* Update for Delay: '<S52>/Delay1' */
|
|
ADM_Integrated_Logic_DW.Delay1_DSTATE = rtb_Gain_c;
|
|
|
|
/* Update for Delay: '<S52>/Delay' */
|
|
ADM_Integrated_Logic_DW.Delay_DSTATE_c[0] =
|
|
ADM_Integrated_Logic_DW.Delay_DSTATE_c[1];
|
|
ADM_Integrated_Logic_DW.Delay_DSTATE_c[1] = rtb_Gain_c;
|
|
|
|
/* Update for Delay: '<S52>/Delay2' */
|
|
ADM_Integrated_Logic_DW.Delay2_DSTATE = rtb_Product1_pd;
|
|
|
|
/* Update for Delay: '<S52>/Delay3' */
|
|
ADM_Integrated_Logic_DW.Delay3_DSTATE[0] =
|
|
ADM_Integrated_Logic_DW.Delay3_DSTATE[1];
|
|
ADM_Integrated_Logic_DW.Delay3_DSTATE[1] = rtb_Product1_pd;
|
|
|
|
/* Update for UnitDelay: '<S51>/d1' */
|
|
ADM_Integrated_Logic_DW.d1_DSTATE_e = rtb_Product1_pd;
|
|
|
|
/* Update for UnitDelay: '<S51>/d' */
|
|
ADM_Integrated_Logic_DW.d_DSTATE_ij = rtb_Product1_m;
|
|
|
|
/* Update for Memory: '<S6>/Memory' */
|
|
ADM_Integrated_Logic_DW.Memory_PreviousInput = rtb_Add_e;
|
|
|
|
/* Update for UnitDelay: '<S40>/d' */
|
|
ADM_Integrated_Logic_DW.d_DSTATE_ir = rtb_Brake_Saturation;
|
|
|
|
/* Update for UnitDelay: '<S40>/d1' */
|
|
ADM_Integrated_Logic_DW.d1_DSTATE_o = rtb_Error_m;
|
|
|
|
/* Update for UnitDelay: '<S41>/d' */
|
|
ADM_Integrated_Logic_DW.d_DSTATE_m = rtb_Error_m;
|
|
|
|
/* Update for UnitDelay: '<S41>/d1' */
|
|
ADM_Integrated_Logic_DW.d1_DSTATE_hm = rtb_Sum1_f;
|
|
|
|
/* Update for UnitDelay: '<S42>/d' */
|
|
ADM_Integrated_Logic_DW.d_DSTATE_mw = rtb_Sum1_f;
|
|
|
|
/* Update for UnitDelay: '<S42>/d1' */
|
|
ADM_Integrated_Logic_DW.d1_DSTATE_g = rtb_Sum1_cr;
|
|
|
|
/* Update for UnitDelay: '<S43>/d1' */
|
|
ADM_Integrated_Logic_DW.d1_DSTATE_ej = rtb_Add3;
|
|
|
|
/* Update for UnitDelay: '<S43>/d' */
|
|
ADM_Integrated_Logic_DW.d_DSTATE_j = rtb_Product1_k3;
|
|
|
|
/* Update for Delay: '<S44>/Delay1' */
|
|
ADM_Integrated_Logic_DW.Delay1_DSTATE_c = rtb_Product1_k3;
|
|
|
|
/* Update for Delay: '<S44>/Delay' */
|
|
ADM_Integrated_Logic_DW.Delay_DSTATE_p[0] =
|
|
ADM_Integrated_Logic_DW.Delay_DSTATE_p[1];
|
|
ADM_Integrated_Logic_DW.Delay_DSTATE_p[1] = rtb_Product1_k3;
|
|
|
|
/* Update for Delay: '<S44>/Delay2' */
|
|
ADM_Integrated_Logic_DW.Delay2_DSTATE_n = rtb_Product1_h;
|
|
|
|
/* Update for Delay: '<S44>/Delay3' */
|
|
ADM_Integrated_Logic_DW.Delay3_DSTATE_h[0] =
|
|
ADM_Integrated_Logic_DW.Delay3_DSTATE_h[1];
|
|
ADM_Integrated_Logic_DW.Delay3_DSTATE_h[1] = rtb_Product1_h;
|
|
|
|
/* Update for Memory: '<S28>/Memory' */
|
|
ADM_Integrated_Logic_DW.Memory_PreviousInput_f = rtb_F_PI;
|
|
|
|
/* Update for UnitDelay: '<S59>/d1' incorporates:
|
|
* Inport: '<Root>/GV_IMU_AX_Val'
|
|
*/
|
|
ADM_Integrated_Logic_DW.d1_DSTATE_ob = ADM_Integrated_Logic_U.GV_IMU_AX_Val;
|
|
|
|
/* Update for UnitDelay: '<S59>/d' */
|
|
ADM_Integrated_Logic_DW.d_DSTATE_e = rtb_Desired_Torque;
|
|
|
|
/* Update for UnitDelay: '<S60>/d1' incorporates:
|
|
* Inport: '<Root>/GV_IMU_AY_Val'
|
|
*/
|
|
ADM_Integrated_Logic_DW.d1_DSTATE_i = ADM_Integrated_Logic_U.GV_IMU_AY_Val;
|
|
|
|
/* Update for UnitDelay: '<S60>/d' */
|
|
ADM_Integrated_Logic_DW.d_DSTATE_p = rtb_Brake_Torque_Cmd;
|
|
|
|
/* Update for UnitDelay: '<S61>/d1' incorporates:
|
|
* Inport: '<Root>/GV_IMU_AZ_Val'
|
|
*/
|
|
ADM_Integrated_Logic_DW.d1_DSTATE_o1 = ADM_Integrated_Logic_U.GV_IMU_AZ_Val;
|
|
|
|
/* Update for UnitDelay: '<S61>/d' */
|
|
ADM_Integrated_Logic_DW.d_DSTATE_n = rtb_Integrator_1;
|
|
|
|
/* Update for DiscreteIntegrator: '<S11>/Integrator_1' */
|
|
ADM_Integrated_Logic_DW.Integrator_1_DSTATE += 0.002 * rtb_Sum_f;
|
|
|
|
/* Update for UnitDelay: '<S62>/d1' incorporates:
|
|
* Inport: '<Root>/GV_IMU_PitchRtVal'
|
|
*/
|
|
ADM_Integrated_Logic_DW.d1_DSTATE_a = ADM_Integrated_Logic_U.GV_IMU_PitchRtVal;
|
|
|
|
/* Update for UnitDelay: '<S62>/d' */
|
|
ADM_Integrated_Logic_DW.d_DSTATE_d1 = rtb_Product1_gg;
|
|
|
|
/* Update for Delay: '<S23>/Delay' */
|
|
ADM_Integrated_Logic_DW.icLoad_l = false;
|
|
ADM_Integrated_Logic_DW.Delay_DSTATE_c4 = rtb_y;
|
|
|
|
/* Update for Delay: '<S24>/Delay' */
|
|
ADM_Integrated_Logic_DW.icLoad_d = false;
|
|
ADM_Integrated_Logic_DW.Delay_DSTATE_i1 = rtb_y_k;
|
|
}
|
|
|
|
/* Model initialize function */
|
|
void ADM_Integrated_Logic_initialize(void)
|
|
{
|
|
/* InitializeConditions for Delay: '<S65>/Delay' */
|
|
ADM_Integrated_Logic_DW.icLoad = true;
|
|
|
|
/* InitializeConditions for Delay: '<S64>/Delay' */
|
|
ADM_Integrated_Logic_DW.icLoad_e = true;
|
|
|
|
/* InitializeConditions for Delay: '<S23>/Delay' */
|
|
ADM_Integrated_Logic_DW.icLoad_l = true;
|
|
|
|
/* InitializeConditions for Delay: '<S24>/Delay' */
|
|
ADM_Integrated_Logic_DW.icLoad_d = true;
|
|
|
|
/* SystemInitialize for MATLAB Function: '<S1>/MATLAB Function3' */
|
|
ADM_Integrated_Logic_DW.currentEstMass = 1500.0;
|
|
}
|
|
|
|
/*
|
|
* File trailer for generated code.
|
|
*
|
|
* [EOF]
|
|
*/
|