/* * 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 : 13.55 * Simulink Coder version : 24.1 (R2024a) 19-Nov-2023 * C/C++ source code generated on : Wed May 7 21:12:17 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 #include "ADM_Integrated_Logic_private.h" #include #include /* Named constants for Chart: '/Chart' */ #define ADM_Integrated_Logic_IN_HAC_OFF ((uint8_t)1U) #define ADM_Integrated_Logic_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 rate_scheduler(void); /* * This function updates active task flag for each subrate. * The function is called at model base rate, hence the * generated code self-manages all its subrates. */ static void rate_scheduler(void) { /* Compute which subrates run during the next base time step. Subrates * are an integer multiple of the base rate counter. Therefore, the subtask * counter is reset when it reaches its limit (zero means run). */ (ADM_Integrated_Logic_M->Timing.TaskCounters.TID[1])++; if ((ADM_Integrated_Logic_M->Timing.TaskCounters.TID[1]) > 499) {/* Sample time: [1.0s, 0.0s] */ ADM_Integrated_Logic_M->Timing.TaskCounters.TID[1] = 0; } } /* * Output and update for atomic system: * '/Calculate_F_c' * '/Calculate_F_c1' */ void ADM_Integrated_Lo_Calculate_F_c(double rtu_W, double rtu_theta, double *rty_F_c) { /* : F_c= W*sin(theta); */ *rty_F_c = rtu_W * sin(rtu_theta); } /* * Output and update for atomic system: * '/MATLAB Function1' * '/MATLAB Function5' */ void ADM_Integrated__MATLABFunction1(double rtu_u, double *rty_y) { *rty_y = rtu_u; /* : if u < 140 */ if (rtu_u < 140.0) { /* : u = 140; */ *rty_y = 140.0; } /* : y = u; */ } /* * Output and update for atomic system: * '/MATLAB Function2' * '/MATLAB Function6' */ void ADM_Integrated__MATLABFunction2(double rtu_u, double *rty_y) { *rty_y = rtu_u; /* : if u > -140 */ if (rtu_u > -140.0) { /* : u = -140; */ *rty_y = -140.0; } /* : y = u; */ } /* Model step function */ void ADM_Integrated_Logic_step(void) { double rtb_Add1; double rtb_Add1_tmp; double rtb_Add3; double rtb_Add_e; double rtb_Brake_Torque_Cmd; double rtb_Desired_Torque; double rtb_Error_m; double rtb_Gain_c; double rtb_Integrator_1; double rtb_Product1_e; double rtb_Product1_f; double rtb_Product1_iz; double rtb_Product1_m; double rtb_Product1_pd; double rtb_Sum1_aj; double rtb_Sum1_i2; double rtb_Sum1_lm; double rtb_Sum1_o1; double rtb_Sum1_p; double rtb_Sum_f; double rtb_Switch2; double rtb_UkYk1; double rtb_UkYk1_j; double rtb_Vx_Cmd_R; double rtb_Yk1_e; double rtb_Yk1_p; double rtb_deltafalllimit_m; double rtb_output_a; double rtb_output_p; double rtb_y_l; int32_t temp_gear; bool rtb_Compare; bool rtb_Compare_d; /* RelationalOperator: '/Compare' incorporates: * Constant: '/Constant' * Inport: '/GV_Operation_Mode' */ rtb_Compare = (ADM_Integrated_Logic_U.GV_Operation_Mode == 2.0); if (ADM_Integrated_Logic_M->Timing.TaskCounters.TID[1] == 0) { /* Step: '/Step' incorporates: * DigitalClock: '/Digital Clock' */ rtb_Add_e = ((ADM_Integrated_Logic_M->Timing.clockTick1) * 1.0); if (rtb_Add_e < 0.0) { temp_gear = 0; } else { temp_gear = 1000; } /* Product: '/Product' incorporates: * Step: '/Step' */ rtb_Integrator_1 = (double)temp_gear * rtb_Add_e; /* Saturate: '/Saturation' */ if (rtb_Integrator_1 > 1000.0) { /* Saturate: '/Saturation' */ ADM_Integrated_Logic_DW.Saturation = 1000.0; } else if (rtb_Integrator_1 < 0.0) { /* Saturate: '/Saturation' */ ADM_Integrated_Logic_DW.Saturation = 0.0; } else { /* Saturate: '/Saturation' */ ADM_Integrated_Logic_DW.Saturation = rtb_Integrator_1; } /* End of Saturate: '/Saturation' */ } /* Product: '/delta rise limit' incorporates: * Constant: '/Upper_Torq' * SampleTimeMath: '/sample time' * * About '/sample time': * y = K where K = ( w * Ts ) * */ rtb_Switch2 = 0.016; /* UnitDelay: '/Delay Input2' * * Block description for '/Delay Input2': * * Store in Global RAM */ rtb_Yk1_e = ADM_Integrated_Logic_DW.DelayInput2_DSTATE_m; /* Product: '/delta rise limit' incorporates: * SampleTimeMath: '/sample time' * * About '/sample time': * y = K where K = ( w * Ts ) * */ rtb_Integrator_1 = 0.002; /* Saturate: '/Pitch_Saturation' incorporates: * DiscreteIntegrator: '/Integrator_2' */ if (ADM_Integrated_Logic_DW.Integrator_2_DSTATE > 10.0) { rtb_Add_e = 10.0; } else if (ADM_Integrated_Logic_DW.Integrator_2_DSTATE < -10.0) { rtb_Add_e = -10.0; } else { rtb_Add_e = ADM_Integrated_Logic_DW.Integrator_2_DSTATE; } /* Sum: '/Difference Inputs1' incorporates: * Saturate: '/Pitch_Saturation' * * Block description for '/Difference Inputs1': * * Add in CPU */ rtb_UkYk1 = rtb_Add_e - rtb_Yk1_e; /* Switch: '/Switch2' incorporates: * RelationalOperator: '/LowerRelop1' */ if (rtb_UkYk1 <= 0.002) { /* Switch: '/Switch' incorporates: * RelationalOperator: '/UpperRelop' */ if (rtb_UkYk1 < -0.002) { rtb_Integrator_1 = -0.002; } else { rtb_Integrator_1 = rtb_UkYk1; } /* End of Switch: '/Switch' */ } /* End of Switch: '/Switch2' */ /* Sum: '/Difference Inputs2' * * Block description for '/Difference Inputs2': * * Add in CPU */ rtb_Yk1_e += rtb_Integrator_1; /* MATLAB Function: '/Calculate_F_c' incorporates: * Gain: '/Gain' */ ADM_Integrated_Lo_Calculate_F_c(ADM_Integrated_Logic_ConstB.W_value, 0.017453292519943295 * rtb_Yk1_e, &rtb_UkYk1); /* Gain: '/Gain2' incorporates: * Constant: '/Radius' * Product: '/Multiply3' * Sum: '/Required_Brake_Cal' */ /* : F_R= C_r*W*cos(theta); */ rtb_Integrator_1 = rtb_UkYk1 * 0.292 * 0.083822296730930432; /* Saturate: '/Saturation' */ if (rtb_Integrator_1 > 60.0) { rtb_Integrator_1 = 60.0; } else if (rtb_Integrator_1 < 0.0) { rtb_Integrator_1 = 0.0; } /* Sum: '/Difference Inputs1' incorporates: * Saturate: '/Saturation' * UnitDelay: '/Delay Input2' * * Block description for '/Difference Inputs1': * * Add in CPU * * Block description for '/Delay Input2': * * Store in Global RAM */ rtb_UkYk1 = rtb_Integrator_1 - ADM_Integrated_Logic_DW.DelayInput2_DSTATE; /* Switch: '/Switch2' incorporates: * RelationalOperator: '/LowerRelop1' */ if (rtb_UkYk1 <= 0.016) { /* Switch: '/Switch' incorporates: * RelationalOperator: '/UpperRelop' */ if (rtb_UkYk1 < -0.16) { rtb_Switch2 = -0.16; } else { rtb_Switch2 = rtb_UkYk1; } /* End of Switch: '/Switch' */ } /* End of Switch: '/Switch2' */ /* Sum: '/Difference Inputs2' incorporates: * UnitDelay: '/Delay Input2' * * Block description for '/Difference Inputs2': * * Add in CPU * * Block description for '/Delay Input2': * * Store in Global RAM */ rtb_UkYk1 = rtb_Switch2 + ADM_Integrated_Logic_DW.DelayInput2_DSTATE; /* Gain: '/Grade_GAIN' */ rtb_Desired_Torque = 0.8 * rtb_UkYk1; /* MATLAB Function: '/Vx_OutPut_Function' incorporates: * Constant: '/Constant' * Inport: '/GV_BrakeTorqueCommand' * Inport: '/GV_Vx_Command' * Inport: '/GV_Vx_Limit' * RelationalOperator: '/Compare' */ /* : if Brake_Input == 0 */ if (ADM_Integrated_Logic_U.GV_BrakeTorqueCommand < 50.0) { /* : if Vx_Limit <= Vx_Kph */ if (ADM_Integrated_Logic_U.GV_Vx_Limit <= ADM_Integrated_Logic_U.GV_Vx_Command) { /* : Vx_Output = Vx_Limit; */ rtb_deltafalllimit_m = ADM_Integrated_Logic_U.GV_Vx_Limit; } else { /* : else */ /* : Vx_Output = Vx_Kph; */ rtb_deltafalllimit_m = ADM_Integrated_Logic_U.GV_Vx_Command; } } else { /* : else */ /* : Vx_Output = 0; */ rtb_deltafalllimit_m = 0.0; } /* End of MATLAB Function: '/Vx_OutPut_Function' */ /* RateLimiter: '/Input_Vx_RateLimiter' */ rtb_output_a = rtb_deltafalllimit_m - ADM_Integrated_Logic_DW.PrevY; if (rtb_output_a > 0.004) { rtb_Vx_Cmd_R = ADM_Integrated_Logic_DW.PrevY + 0.004; } else if (rtb_output_a < -0.008) { rtb_Vx_Cmd_R = ADM_Integrated_Logic_DW.PrevY - 0.008; } else { rtb_Vx_Cmd_R = rtb_deltafalllimit_m; } ADM_Integrated_Logic_DW.PrevY = rtb_Vx_Cmd_R; /* End of RateLimiter: '/Input_Vx_RateLimiter' */ /* RelationalOperator: '/Compare' incorporates: * Constant: '/Constant' * Inport: '/GV_BrakeTorqueCommand' */ rtb_Compare_d = (ADM_Integrated_Logic_U.GV_BrakeTorqueCommand >= 100.0); /* Delay: '/Memory' */ rtb_deltafalllimit_m = ADM_Integrated_Logic_DW.Memory_DSTATE; /* MATLAB Function: '/Gear_FUNCTION1' incorporates: * Inport: '/GV_VCU_GearSelStat' * Inport: '/GV_Vx_Fbk' */ /* : SAFE_SPEED_THRESHOLD = 0; */ /* ¾ÈÀü ±â¾î º¯°æ ¼Óµµ(kph) */ /* ±âº»°ª: ÇöÀç ±â¾î À¯Áö */ /* : output = Current_Gear; */ /* 1. P´Ü ¿äûÀÌ ÀÖÀ» °æ¿ì: ¸ðµç »óÅ¿¡¼­ ¿ì¼± ó¸® */ /* : if Gear_Cmd == 0 */ if (ADM_Integrated_Logic_U.GV_VCU_GearSelStat == 0.0) { /* : if Vehicle_Speed <= SAFE_SPEED_THRESHOLD && Brake_Torque_Cmd == 1 */ if ((ADM_Integrated_Logic_U.GV_Vx_Fbk <= 0.0) && rtb_Compare_d) { /* : output = 0; */ rtb_deltafalllimit_m = 0.0; /* P´Ü ÁøÀÔ Çã¿ë */ } else { /* : else */ /* : output = Current_Gear; */ /* Á¶°Ç ºÒÃæÁ· ½Ã À¯Áö */ } } else { /* 2. ÇöÀç ±â¾î »óÅ¿¡ µû¶ó ó¸® */ /* : switch Current_Gear */ switch ((int32_t)rtb_deltafalllimit_m) { case 0: /* : case 0 */ /* P »óÅ */ /* : if Vehicle_Speed <= SAFE_SPEED_THRESHOLD */ 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))) { /* : if Gear_Cmd == 1 || Gear_Cmd == 3 || Gear_Cmd == 2 */ /* : output = 2; */ rtb_deltafalllimit_m = 2.0; /* P -> N (¸ðµç °æ¿ì NÀ» °ÅÃÄ¾ß ÇϹǷÎ) */ } break; case 1: /* : case 1 */ /* R »óÅ */ /* : if Gear_Cmd == 2 */ if (ADM_Integrated_Logic_U.GV_VCU_GearSelStat == 2.0) { /* : output = 2; */ rtb_deltafalllimit_m = 2.0; /* R -> N Çã¿ë */ } break; case 2: /* : case 2 */ /* N »óÅ */ /* : if Vehicle_Speed <= SAFE_SPEED_THRESHOLD && Brake_Torque_Cmd == 1 */ if ((ADM_Integrated_Logic_U.GV_Vx_Fbk <= 0.0) && rtb_Compare_d) { /* : if Gear_Cmd == 1 */ if (ADM_Integrated_Logic_U.GV_VCU_GearSelStat == 1.0) { /* : output = 1; */ rtb_deltafalllimit_m = 1.0; /* N -> R */ } else if (ADM_Integrated_Logic_U.GV_VCU_GearSelStat == 3.0) { /* : elseif Gear_Cmd == 3 */ /* : output = 3; */ rtb_deltafalllimit_m = 3.0; /* N -> D */ } } break; case 3: /* : case 3 */ /* D »óÅ */ /* : if Gear_Cmd == 2 */ if (ADM_Integrated_Logic_U.GV_VCU_GearSelStat == 2.0) { /* : output = 2; */ rtb_deltafalllimit_m = 2.0; /* D -> N Çã¿ë */ } break; } } /* End of MATLAB Function: '/Gear_FUNCTION1' */ /* Chart: '/Chart' incorporates: * Constant: '/Constant' * Constant: '/Constant1' * Inport: '/GV_MCU_RPM' */ if (ADM_Integrated_Logic_DW.is_active_c6_ADM_Integrated_Log == 0U) { ADM_Integrated_Logic_DW.is_active_c6_ADM_Integrated_Log = 1U; ADM_Integrated_Logic_DW.is_c6_ADM_Integrated_Logic = ADM_Integrated_Logic_IN_HAC_OFF; /* State HAC OFF */ } else if (ADM_Integrated_Logic_DW.is_c6_ADM_Integrated_Logic == ADM_Integrated_Logic_IN_HAC_OFF) { /* : sf_internal_predicateOutput = RPM_Input < rpm_threshold_low; */ if (ADM_Integrated_Logic_U.GV_MCU_RPM < -50.0) { ADM_Integrated_Logic_DW.is_c6_ADM_Integrated_Logic = ADM_Integrated_Logic_IN_HAC_ON; /* State HAC ON */ } else { /* Outport: '/Debug_HAC_RPM_Decision' */ /* : HAC_Output = 0; */ ADM_Integrated_Logic_Y.Debug_HAC_RPM_Decision = 0.0; } /* case IN_HAC_ON: */ /* : sf_internal_predicateOutput = RPM_Input > rpm_threshold_high; */ } else if (ADM_Integrated_Logic_U.GV_MCU_RPM > 150.0) { ADM_Integrated_Logic_DW.is_c6_ADM_Integrated_Logic = ADM_Integrated_Logic_IN_HAC_OFF; /* State HAC OFF */ } else { /* Outport: '/Debug_HAC_RPM_Decision' */ /* : HAC_Output = 1; */ ADM_Integrated_Logic_Y.Debug_HAC_RPM_Decision = 1.0; } /* End of Chart: '/Chart' */ /* MATLAB Function: '/HAC_OFF_OK_Func' */ /* Input Parameters: */ /* Desired_Brake_Torque_Cmd: Commanded brake torque when HAC is ON */ /* Desired_Torque: Required torque at the slope */ /* Feedback_Torque: Torque output from the motor */ /* HAC_Flag: Current HAC state flag */ /* Output Parameters: */ /* Brake_Torque_Cmd: Actual brake torque command */ /* HAC_ON_OFF_CHECK: Status of HAC (ON or OFF) */ /* Persistent variable to track if HAC has ever been ON */ /* Initialize HAC_ON_FLAG if it is empty */ /* : if isempty(HAC_ON_FLAG) */ /* Persistent variable for torque smoothing logic */ /* : if isempty(Smoothed_Torque) */ /* Persistent variable to store HAC ON Desired Torque */ /* : if isempty(HAC_Desired_Torque) */ /* Persistent variable to track HAC ON time */ /* : if isempty(HAC_ON_Timer) */ /* Initialize outputs */ /* : Brake_Torque_Cmd = 0; */ rtb_Brake_Torque_Cmd = 0.0; /* Outport: '/Debug_HAC_FLAG' incorporates: * MATLAB Function: '/HAC_OFF_OK_Func' */ /* : HAC_ON_OFF_CHECK = 0; */ ADM_Integrated_Logic_Y.Debug_HAC_FLAG = 0.0; /* MATLAB Function: '/HAC_OFF_OK_Func' incorporates: * Constant: '/Accel_Cmd ' * Constant: '/Brake_Cmd' * Constant: '/Gear_D' * Inport: '/GV_BrakeTorqueCommand' * Inport: '/GV_MCU_EstTrq' * Outport: '/Debug_HAC_RPM_Decision' * RelationalOperator: '/Relational Operator' * RelationalOperator: '/Relational Operator1' * RelationalOperator: '/Relational Operator2' * Sum: '/HAC_Flags_Add' */ /* Check if HAC is ON (HAC_Flag >= 4) */ /* : if HAC_Flag >= 4 */ if ((double)(((ADM_Integrated_Logic_U.GV_BrakeTorqueCommand <= 20.0) + (rtb_Vx_Cmd_R <= 2.0)) + (rtb_deltafalllimit_m == 3.0)) + ADM_Integrated_Logic_Y.Debug_HAC_RPM_Decision >= 4.0) { /* : if HAC_ON_FLAG == 0 */ if (ADM_Integrated_Logic_DW.HAC_ON_FLAG == 0.0) { /* : HAC_ON_Timer = 0; */ ADM_Integrated_Logic_DW.HAC_ON_Timer = 0.0; /* Reset timer when HAC turns ON */ } /* : HAC_ON_FLAG = 1; */ ADM_Integrated_Logic_DW.HAC_ON_FLAG = 1.0; /* : Brake_Torque_Cmd = Desired_Brake_Torque_Cmd; */ rtb_Brake_Torque_Cmd = ADM_Integrated_Logic_DW.Saturation; /* : Smoothed_Torque = Desired_Brake_Torque_Cmd; */ ADM_Integrated_Logic_DW.Smoothed_Torque = ADM_Integrated_Logic_DW.Saturation; /* : if HAC_ON_Timer < 3 */ if (ADM_Integrated_Logic_DW.HAC_ON_Timer < 3.0) { /* Update Desired Torque for the first 3 seconds */ /* : HAC_Desired_Torque = Desired_Torque; */ ADM_Integrated_Logic_DW.HAC_Desired_Torque = rtb_Desired_Torque; /* : HAC_ON_Timer = HAC_ON_Timer + 1/200; */ ADM_Integrated_Logic_DW.HAC_ON_Timer += 0.005; /* Assuming 200 Hz update rate */ } /* Outport: '/Debug_HAC_FLAG' */ /* : HAC_ON_OFF_CHECK = 1; */ ADM_Integrated_Logic_Y.Debug_HAC_FLAG = 1.0; /* : else */ /* If HAC has been ON and HAC_Flag drops below 4 */ /* : if HAC_ON_FLAG == 1 */ } else if (ADM_Integrated_Logic_DW.HAC_ON_FLAG == 1.0) { /* Check if Feedback Torque exceeds Desired Torque */ /* : if Feedback_Torque >= HAC_Desired_Torque */ if (ADM_Integrated_Logic_U.GV_MCU_EstTrq >= ADM_Integrated_Logic_DW.HAC_Desired_Torque) { /* : HAC_ON_OFF_CHECK = 0; */ /* Apply smoothing logic to reduce torque gradually */ /* : Smoothed_Torque = Smoothed_Torque - 0.05 * Smoothed_Torque; */ ADM_Integrated_Logic_DW.Smoothed_Torque -= 0.05 * ADM_Integrated_Logic_DW.Smoothed_Torque; /* Adjust smoothing factor as needed */ /* : if Smoothed_Torque < 0.01 */ if (ADM_Integrated_Logic_DW.Smoothed_Torque < 0.01) { /* Threshold to consider torque as zero */ /* : Smoothed_Torque = 0; */ ADM_Integrated_Logic_DW.Smoothed_Torque = 0.0; /* : HAC_ON_FLAG = 0; */ ADM_Integrated_Logic_DW.HAC_ON_FLAG = 0.0; /* Reset HAC_ON_FLAG if fully off */ /* : HAC_Desired_Torque = 0; */ ADM_Integrated_Logic_DW.HAC_Desired_Torque = 0.0; /* Reset Desired Torque when HAC is OFF */ /* : HAC_ON_Timer = 0; */ ADM_Integrated_Logic_DW.HAC_ON_Timer = 0.0; /* Reset Timer */ } /* : Brake_Torque_Cmd = Smoothed_Torque; */ rtb_Brake_Torque_Cmd = ADM_Integrated_Logic_DW.Smoothed_Torque; } else { /* : else */ /* Keep the brake torque command if torque condition is not met */ /* : Brake_Torque_Cmd = Desired_Brake_Torque_Cmd; */ rtb_Brake_Torque_Cmd = ADM_Integrated_Logic_DW.Saturation; /* : Smoothed_Torque = Desired_Brake_Torque_Cmd; */ ADM_Integrated_Logic_DW.Smoothed_Torque = ADM_Integrated_Logic_DW.Saturation; /* Outport: '/Debug_HAC_FLAG' */ /* : HAC_ON_OFF_CHECK = 1; */ ADM_Integrated_Logic_Y.Debug_HAC_FLAG = 1.0; } } /* MATLAB Function: '/GearCondition_Brake' */ /* : if data == 1 */ if (rtb_deltafalllimit_m == 1.0) { /* : output = -1; */ rtb_output_a = -1.0; } else if (rtb_deltafalllimit_m == 3.0) { /* : elseif data == 3 */ /* : output = 1; */ rtb_output_a = 1.0; } else { /* : else */ /* : output = 0; */ rtb_output_a = 0.0; } /* End of MATLAB Function: '/GearCondition_Brake' */ /* Gain: '/Brake_GAIN' incorporates: * DiscreteTransferFcn: '/Discrete Transfer Fcn' */ rtb_Integrator_1 = 0.0625 * ADM_Integrated_Logic_DW.DiscreteTransferFcn_states * -80.0; /* Saturate: '/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: '/Multiply2' incorporates: * Saturate: '/Saturation' */ rtb_Integrator_1 *= rtb_output_a; /* RateLimiter: '/Brake_Out_RateLimiter' */ rtb_output_a = rtb_Integrator_1 - ADM_Integrated_Logic_DW.PrevY_o; if (rtb_output_a > 3.0) { rtb_Integrator_1 = ADM_Integrated_Logic_DW.PrevY_o + 3.0; } else if (rtb_output_a < -3.0) { rtb_Integrator_1 = ADM_Integrated_Logic_DW.PrevY_o - 3.0; } ADM_Integrated_Logic_DW.PrevY_o = rtb_Integrator_1; /* End of RateLimiter: '/Brake_Out_RateLimiter' */ /* Saturate: '/Brake_Saturation' */ if (rtb_Integrator_1 > 1000.0) { rtb_Integrator_1 = 1000.0; } else if (rtb_Integrator_1 < 0.0) { rtb_Integrator_1 = 0.0; } /* End of Saturate: '/Brake_Saturation' */ /* MATLAB Function: '/Emergency_Brake_Func' incorporates: * Inport: '/GV_Vx_Fbk' * Sum: '/Add' */ /* : if Emergency_Flag == 1 */ if (rtb_Compare) { /* : Emergency_Brake_Output = Vehicle_Speed*100; */ rtb_output_a = ADM_Integrated_Logic_U.GV_Vx_Fbk * 100.0; } else { /* : else */ /* : Emergency_Brake_Output = Brake_Torque_Cmd; */ rtb_output_a = rtb_Brake_Torque_Cmd + rtb_Integrator_1; } /* End of MATLAB Function: '/Emergency_Brake_Func' */ /* Saturate: '/Brake_Saturation' */ if (rtb_output_a > 1500.0) { /* Outport: '/GV_Brake_Command' */ ADM_Integrated_Logic_Y.GV_Brake_Command = 1500.0; } else if (rtb_output_a < 0.0) { /* Outport: '/GV_Brake_Command' */ ADM_Integrated_Logic_Y.GV_Brake_Command = 0.0; } else { /* Outport: '/GV_Brake_Command' */ ADM_Integrated_Logic_Y.GV_Brake_Command = rtb_output_a; } /* End of Saturate: '/Brake_Saturation' */ /* Outport: '/Debug_CC_Brake_Output' */ ADM_Integrated_Logic_Y.Debug_CC_Brake_Output = rtb_Integrator_1; /* Outport: '/Debug_HAC_Brake_Output' */ ADM_Integrated_Logic_Y.Debug_HAC_Brake_Output = rtb_Brake_Torque_Cmd; /* MATLAB Function: '/Gear_pos_out' incorporates: * MATLAB Function: '/Target_RPM' */ /* Gear R ´Ü¿¡¼­ - target rpm °ª */ /* : if data == 0 */ if (rtb_deltafalllimit_m == 0.0) { /* : temp_gear = 0; */ rtb_output_p = 0.0; /* : temp_gear = 0; */ temp_gear = 0; } else { if (rtb_deltafalllimit_m == 2.0) { /* : elseif data == 2 */ /* : temp_gear = 0; */ rtb_output_p = 0.0; } else if (rtb_deltafalllimit_m == 1.0) { /* : elseif data == 1 */ /* : temp_gear = -1; */ rtb_output_p = -1.0; } else if (rtb_deltafalllimit_m == 3.0) { /* : elseif data == 3 */ /* : temp_gear = 1; */ rtb_output_p = 1.0; } else { /* : else */ /* : temp_gear = 0; */ rtb_output_p = 0.0; } if (rtb_deltafalllimit_m == 2.0) { /* : elseif data == 2 */ /* : temp_gear = 0; */ temp_gear = 0; } else if (rtb_deltafalllimit_m == 1.0) { /* : elseif data == 1 */ /* : temp_gear = -1; */ temp_gear = -1; } else if (rtb_deltafalllimit_m == 3.0) { /* : elseif data == 3 */ /* : temp_gear = 1; */ temp_gear = 1; } else { /* : else */ /* : temp_gear = 0; */ temp_gear = 0; } } /* End of MATLAB Function: '/Gear_pos_out' */ /* MATLAB Function: '/Target_RPM' */ /* : output = temp_gear; */ /* : gear_ratio = 11.93; */ /* : Radius = 0.270781; */ /* : engine_eff = 1; */ /* Gear R ´Ü¿¡¼­ - target rpm °ª */ /* : if data == 0 */ /* : speed_m_per_s = Vx_Kph * 1000/3600; */ /* : Target_RPM = (speed_m_per_s * gear_ratio * 60) / (Radius*2*pi)*engine_eff*temp_gear; */ rtb_Brake_Torque_Cmd = rtb_Vx_Cmd_R * 1000.0 / 3600.0 * 11.93 * 60.0 / 1.7013672006633955 * (double)temp_gear; /* RateLimiter: '/TargetSpd_RateLimiter' */ rtb_output_a = rtb_Brake_Torque_Cmd - ADM_Integrated_Logic_DW.PrevY_a; if (rtb_output_a > 0.4) { rtb_output_a = ADM_Integrated_Logic_DW.PrevY_a + 0.4; } else if (rtb_output_a < -0.8) { rtb_output_a = ADM_Integrated_Logic_DW.PrevY_a - 0.8; } else { rtb_output_a = rtb_Brake_Torque_Cmd; } ADM_Integrated_Logic_DW.PrevY_a = rtb_output_a; /* End of RateLimiter: '/TargetSpd_RateLimiter' */ /* Product: '/Product1' incorporates: * Constant: '/Constant' * Gain: '/gain' * Product: '/Product11' * Sum: '/Sum1' * Sum: '/Sum2' * Sum: '/Sum3' * Sum: '/Sum4' * UnitDelay: '/d' * UnitDelay: '/d1' */ rtb_Brake_Torque_Cmd = ((rtb_output_a + ADM_Integrated_Logic_DW.d1_DSTATE) * 0.002 + 0.1041032953945969 * ADM_Integrated_Logic_DW.d_DSTATE) / 0.1081032953945969; /* Sum: '/Sum1' incorporates: * Gain: '/gain' * Sum: '/Sum2' * UnitDelay: '/d' * UnitDelay: '/d1' */ rtb_Sum1_i2 = (rtb_Brake_Torque_Cmd - ADM_Integrated_Logic_DW.d_DSTATE_i) * 1000.0 - ADM_Integrated_Logic_DW.d1_DSTATE_p; /* Sum: '/Sum1' incorporates: * Gain: '/gain' * Sum: '/Sum2' * UnitDelay: '/d' * UnitDelay: '/d1' */ rtb_Sum1_o1 = (rtb_Sum1_i2 - ADM_Integrated_Logic_DW.d_DSTATE_c) * 1000.0 - ADM_Integrated_Logic_DW.d1_DSTATE_h; /* Sum: '/Sum1' incorporates: * Gain: '/gain' * Sum: '/Sum2' * UnitDelay: '/d' * UnitDelay: '/d1' */ rtb_Sum1_lm = (rtb_Sum1_o1 - ADM_Integrated_Logic_DW.d_DSTATE_d) * 1000.0 - ADM_Integrated_Logic_DW.d1_DSTATE_l; /* Gain: '/Gain' incorporates: * Constant: '/Constant3' * Constant: '/Constant4' * Constant: '/Constant5' * Product: '/Product' * Product: '/Product1' * Product: '/Product2' * Sum: '/Add5' */ rtb_Gain_c = (((156.8 * rtb_Brake_Torque_Cmd + 212.8 * rtb_Sum1_i2) + 21.8 * rtb_Sum1_o1) + rtb_Sum1_lm) * 9.44822373393802E-6; /* Product: '/Product1' incorporates: * Constant: '/Constant1' * Constant: '/Constant2' * Delay: '/Delay' * Delay: '/Delay1' * Delay: '/Delay2' * Delay: '/Delay3' * Gain: '/gain1' * Gain: '/gain3' * Product: '/x(n), x(n-1), x(n-2)' * Product: '/y(n-1)' * Product: '/y(n-2)' * Sum: '/Sum1' * Sum: '/Sum2' * Sum: '/Sum3' * Sum: '/Sum4' * Sum: '/Sum5' * Sum: '/Sum6' */ rtb_Product1_pd = ((((2.0 * ADM_Integrated_Logic_DW.Delay1_DSTATE + rtb_Gain_c) + ADM_Integrated_Logic_DW.Delay_DSTATE[0]) * 0.39478417604357435 - -7.2104316479128512 * ADM_Integrated_Logic_DW.Delay2_DSTATE) - 2.6178993711731877 * ADM_Integrated_Logic_DW.Delay3_DSTATE [0]) / 6.1716689809139611; /* Product: '/Product1' incorporates: * Constant: '/Constant' * Gain: '/gain' * Product: '/Product11' * Sum: '/Sum1' * Sum: '/Sum2' * Sum: '/Sum3' * Sum: '/Sum4' * UnitDelay: '/d' * UnitDelay: '/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: '/Subtract' incorporates: * Inport: '/GV_MCU_RPM' * MultiPortSwitch: '/Multiport Switch1' */ rtb_Error_m = rtb_Brake_Torque_Cmd - ADM_Integrated_Logic_U.GV_MCU_RPM; /* Saturate: '/Error_Saturation' incorporates: * MultiPortSwitch: '/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: '/Error_Saturation' */ /* DeadZone: '/Dead Zone' incorporates: * MultiPortSwitch: '/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: '/Sum1' incorporates: * Gain: '/gain' * Sum: '/Sum2' * UnitDelay: '/d' * UnitDelay: '/d1' */ rtb_Error_m = (rtb_Brake_Torque_Cmd - ADM_Integrated_Logic_DW.d_DSTATE_ir) * 1000.0 - ADM_Integrated_Logic_DW.d1_DSTATE_o; /* Sum: '/Sum1' incorporates: * Gain: '/gain' * Sum: '/Sum2' * UnitDelay: '/d' * UnitDelay: '/d1' */ rtb_Sum1_aj = (rtb_Error_m - ADM_Integrated_Logic_DW.d_DSTATE_m) * 1000.0 - ADM_Integrated_Logic_DW.d1_DSTATE_hm; /* Sum: '/Sum1' incorporates: * Gain: '/gain' * Sum: '/Sum2' * UnitDelay: '/d' * UnitDelay: '/d1' */ rtb_Sum1_p = (rtb_Sum1_aj - ADM_Integrated_Logic_DW.d_DSTATE_mw) * 1000.0 - ADM_Integrated_Logic_DW.d1_DSTATE_g; /* Sum: '/Add3' incorporates: * Constant: '/Constant3' * Constant: '/Constant4' * Constant: '/Constant5' * Gain: '/Gain' * Memory: '/Memory' * Product: '/Product2' * Product: '/Product3' * Product: '/Product4' * Sum: '/Add2' */ rtb_Add3 = (((156.8 * rtb_Brake_Torque_Cmd + 212.8 * rtb_Error_m) + 21.8 * rtb_Sum1_aj) + rtb_Sum1_p) * 9.44822373393802E-6 - ADM_Integrated_Logic_DW.Memory_PreviousInput; /* Product: '/Product1' incorporates: * Constant: '/Constant' * Gain: '/gain' * Product: '/Product11' * Sum: '/Sum1' * Sum: '/Sum2' * Sum: '/Sum3' * Sum: '/Sum4' * UnitDelay: '/d' * UnitDelay: '/d1' */ rtb_Product1_e = ((rtb_Add3 + ADM_Integrated_Logic_DW.d1_DSTATE_ej) * 0.002 + 0.029830988618379066 * ADM_Integrated_Logic_DW.d_DSTATE_j) / 0.03383098861837907; /* Product: '/Product1' incorporates: * Constant: '/Constant1' * Constant: '/Constant2' * Delay: '/Delay' * Delay: '/Delay1' * Delay: '/Delay2' * Delay: '/Delay3' * Gain: '/gain1' * Gain: '/gain3' * Product: '/x(n), x(n-1), x(n-2)' * Product: '/y(n-1)' * Product: '/y(n-2)' * Sum: '/Sum1' * Sum: '/Sum2' * Sum: '/Sum3' * Sum: '/Sum4' * Sum: '/Sum5' * Sum: '/Sum6' */ rtb_Product1_iz = ((((2.0 * ADM_Integrated_Logic_DW.Delay1_DSTATE_c + rtb_Product1_e) + 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: '/DOB_Gain' incorporates: * Inport: '/GV_Vx_Fbk' */ /* : if vx < 5 */ if (ADM_Integrated_Logic_U.GV_Vx_Fbk < 5.0) { /* : gain = 0; */ rtb_Switch2 = 0.0; } else { /* : else */ /* : gain = (vx-5) * 0.2; */ rtb_Switch2 = (ADM_Integrated_Logic_U.GV_Vx_Fbk - 5.0) * 0.2; } /* : if gain >=1 */ if (rtb_Switch2 >= 1.0) { /* : gain =1; */ rtb_Switch2 = 1.0; } /* End of MATLAB Function: '/DOB_Gain' */ /* Product: '/Product1' incorporates: * Constant: '/DOBFlag' * Product: '/Product' */ rtb_Integrator_1 = -(rtb_Product1_iz * 0.9); /* Saturate: '/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: '/Subtract2' incorporates: * DeadZone: '/Dead Zone' * MultiPortSwitch: '/Multiport Switch1' * Product: '/Product' * Product: '/Multiply1' * Saturate: '/DOB_Saturation' * Sum: '/Add' */ rtb_Add_e = (rtb_Add_e * 0.044648264844923756 + rtb_Product1_m) + rtb_Integrator_1 * rtb_Switch2; /* Saturate: '/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: '/Torq_Saturation' */ /* MATLAB Function: '/Emergency_Motor_Func' */ /* : if Emergency_Flag == 1 */ if (rtb_Compare) { /* Outport: '/GV_Motor_Torque_Cmd' */ /* : Emergency_Motor_Output = 0; */ ADM_Integrated_Logic_Y.GV_Motor_Torque_Cmd = 0.0; } else { /* Outport: '/GV_Motor_Torque_Cmd' incorporates: * Product: '/Multiply' */ /* : else */ /* : Emergency_Motor_Output = Motor_Torque_Cmd; */ ADM_Integrated_Logic_Y.GV_Motor_Torque_Cmd = rtb_output_p * rtb_Add_e; } /* End of MATLAB Function: '/Emergency_Motor_Func' */ /* Outport: '/GV_Gear_Postion_Out' */ ADM_Integrated_Logic_Y.GV_Gear_Postion_Out = rtb_deltafalllimit_m; /* Sum: '/Add2' incorporates: * Inport: '/GV_Vx_Fbk' */ rtb_Vx_Cmd_R -= ADM_Integrated_Logic_U.GV_Vx_Fbk; /* Outport: '/GV_Hill_Torque_Assist' */ ADM_Integrated_Logic_Y.GV_Hill_Torque_Assist = rtb_Desired_Torque; /* Outport: '/Debug_HAC_Pitch_angle' */ ADM_Integrated_Logic_Y.Debug_HAC_Pitch_angle = rtb_Yk1_e; /* MATLAB Function: '/Calculate_F_c1' incorporates: * Gain: '/Gain3' */ ADM_Integrated_Lo_Calculate_F_c(ADM_Integrated_Logic_ConstB.W_Value_for_Brake, 0.017453292519943295 * rtb_Yk1_e, &rtb_Switch2); /* Product: '/Product1' incorporates: * Constant: '/Constant' * Gain: '/gain' * Inport: '/GV_IMU_AX_Val' * Product: '/Product11' * Sum: '/Sum1' * Sum: '/Sum2' * Sum: '/Sum3' * Sum: '/Sum4' * UnitDelay: '/d' * UnitDelay: '/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: '/Product1' incorporates: * Constant: '/Constant' * Gain: '/gain' * Inport: '/GV_IMU_AY_Val' * Product: '/Product11' * Sum: '/Sum1' * Sum: '/Sum2' * Sum: '/Sum3' * Sum: '/Sum4' * UnitDelay: '/d' * UnitDelay: '/d1' */ rtb_output_p = ((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: '/Product1' incorporates: * Constant: '/Constant' * Gain: '/gain' * Inport: '/GV_IMU_AZ_Val' * Product: '/Product11' * Sum: '/Sum1' * Sum: '/Sum2' * Sum: '/Sum3' * Sum: '/Sum4' * UnitDelay: '/d' * UnitDelay: '/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: '/Pitch_calculate' */ /* This function calculates the pitch angle using accelerometer data. */ /* Inputs: */ /* ax - Acceleration in the x-axis */ /* ay - Acceleration in the y-axis */ /* az - Acceleration in the z-axis */ /* Output: */ /* pitch - Calculated pitch angle in degrees */ /* Step 1: Calculate the denominator (sqrt(ay^2 + az^2)) */ /* : denominator = sqrt(ay^2 + az^2); */ rtb_Switch2 = sqrt(rtb_output_p * rtb_output_p + rtb_Integrator_1 * rtb_Integrator_1); /* Step 2: Compute pitch in radians using arctan(ax / denominator) */ /* Protect against division by zero */ /* : if denominator == 0 */ if (rtb_Switch2 != 0.0) { /* : else */ /* : pitch = atan(ax / denominator); */ rtb_Switch2 = atan(rtb_Desired_Torque / rtb_Switch2); /* Calculate pitch in radians */ } else { /* : pitch = 0; */ /* If ay and az are both zero, pitch is set to 0 */ } /* Sum: '/Sum' incorporates: * DiscreteIntegrator: '/Integrator_2' * MATLAB Function: '/Pitch_calculate' */ /* Step 3: Convert radians to degrees */ /* : pitch = pitch * (180 / pi); */ /* Convert to degrees */ rtb_Sum_f = ADM_Integrated_Logic_DW.Integrator_2_DSTATE - rtb_Switch2 * 57.295779513082323; /* Product: '/Product1' incorporates: * Constant: '/Constant' * Gain: '/gain' * Inport: '/GV_IMU_PitchRtVal' * Product: '/Product11' * Sum: '/Sum1' * Sum: '/Sum2' * Sum: '/Sum3' * Sum: '/Sum4' * UnitDelay: '/d' * UnitDelay: '/d1' */ rtb_Product1_f = ((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: '/Add1' incorporates: * Constant: '/Constant' * Gain: '/Gain1' * Inport: '/GV_Vx_Fbk' * Sum: '/Add3' */ rtb_Add1_tmp = 400.0 - 6.5 * ADM_Integrated_Logic_U.GV_Vx_Fbk; /* MATLAB Function: '/MATLAB Function1' incorporates: * Sum: '/Add1' */ ADM_Integrated__MATLABFunction1(rtb_Add1_tmp, &rtb_y_l); /* Product: '/delta rise limit' incorporates: * SampleTimeMath: '/sample time' * * About '/sample time': * y = K where K = ( w * Ts ) * */ rtb_Switch2 = rtb_y_l * 0.002; /* UnitDelay: '/Delay Input2' * * Block description for '/Delay Input2': * * Store in Global RAM */ rtb_Yk1_p = ADM_Integrated_Logic_DW.DelayInput2_DSTATE_c; /* Sum: '/Difference Inputs1' incorporates: * Inport: '/GV_RWA_RackAngleCommand' * * Block description for '/Difference Inputs1': * * Add in CPU */ rtb_UkYk1_j = ADM_Integrated_Logic_U.GV_RWA_RackAngleCommand - rtb_Yk1_p; /* MATLAB Function: '/MATLAB Function2' incorporates: * Gain: '/Gain3' * Sum: '/Add1' */ ADM_Integrated__MATLABFunction2(-rtb_Add1_tmp, &rtb_y_l); /* Switch: '/Switch2' incorporates: * RelationalOperator: '/LowerRelop1' */ if (rtb_UkYk1_j <= rtb_Switch2) { /* Product: '/delta fall limit' incorporates: * SampleTimeMath: '/sample time' * * About '/sample time': * y = K where K = ( w * Ts ) * */ rtb_Switch2 = rtb_y_l * 0.002; /* Switch: '/Switch' incorporates: * RelationalOperator: '/UpperRelop' */ if (rtb_UkYk1_j >= rtb_Switch2) { rtb_Switch2 = rtb_UkYk1_j; } /* End of Switch: '/Switch' */ } /* End of Switch: '/Switch2' */ /* Sum: '/Difference Inputs2' * * Block description for '/Difference Inputs2': * * Add in CPU */ rtb_Yk1_p += rtb_Switch2; /* Outport: '/GV_Master_Rack_Angle_Cmd' */ ADM_Integrated_Logic_Y.GV_Master_Rack_Angle_Cmd = rtb_Yk1_p; /* MATLAB Function: '/MATLAB Function5' */ ADM_Integrated__MATLABFunction1(rtb_Add1_tmp, &rtb_y_l); /* Product: '/delta rise limit' incorporates: * SampleTimeMath: '/sample time' * * About '/sample time': * y = K where K = ( w * Ts ) * */ rtb_Switch2 = rtb_y_l * 0.002; /* UnitDelay: '/Delay Input2' * * Block description for '/Delay Input2': * * Store in Global RAM */ rtb_UkYk1_j = ADM_Integrated_Logic_DW.DelayInput2_DSTATE_i; /* Sum: '/Difference Inputs1' incorporates: * Inport: '/GV_RWS_RackAngleCommand' * * Block description for '/Difference Inputs1': * * Add in CPU */ rtb_Add1 = ADM_Integrated_Logic_U.GV_RWS_RackAngleCommand - rtb_UkYk1_j; /* MATLAB Function: '/MATLAB Function6' incorporates: * Gain: '/Gain5' */ ADM_Integrated__MATLABFunction2(-rtb_Add1_tmp, &rtb_y_l); /* Switch: '/Switch2' incorporates: * RelationalOperator: '/LowerRelop1' */ if (rtb_Add1 <= rtb_Switch2) { /* Product: '/delta fall limit' incorporates: * SampleTimeMath: '/sample time' * * About '/sample time': * y = K where K = ( w * Ts ) * */ rtb_Switch2 = rtb_y_l * 0.002; /* Switch: '/Switch' incorporates: * RelationalOperator: '/UpperRelop' */ if (rtb_Add1 >= rtb_Switch2) { rtb_Switch2 = rtb_Add1; } /* End of Switch: '/Switch' */ } /* End of Switch: '/Switch2' */ /* Sum: '/Difference Inputs2' * * Block description for '/Difference Inputs2': * * Add in CPU */ rtb_Switch2 += rtb_UkYk1_j; /* Outport: '/GV_RWS_RackAngleCmd1' */ ADM_Integrated_Logic_Y.GV_RWS_RackAngleCmd1 = rtb_Switch2; /* Update for UnitDelay: '/Delay Input2' * * Block description for '/Delay Input2': * * Store in Global RAM */ ADM_Integrated_Logic_DW.DelayInput2_DSTATE = rtb_UkYk1; /* Update for UnitDelay: '/Delay Input2' * * Block description for '/Delay Input2': * * Store in Global RAM */ ADM_Integrated_Logic_DW.DelayInput2_DSTATE_m = rtb_Yk1_e; /* Update for DiscreteIntegrator: '/Integrator_2' incorporates: * Constant: '/I_gain' * Constant: '/P_gain' * DiscreteIntegrator: '/Integrator_1' * Product: '/Product' * Product: '/Product1' * Sum: '/Sum1' * Sum: '/Sum2' */ ADM_Integrated_Logic_DW.Integrator_2_DSTATE += (rtb_Product1_f - (ADM_Integrated_Logic_DW.Integrator_1_DSTATE * 5.0 + rtb_Sum_f * 100.0)) * 0.002; /* Update for Delay: '/Memory' */ ADM_Integrated_Logic_DW.Memory_DSTATE = rtb_deltafalllimit_m; /* Update for DiscreteTransferFcn: '/Discrete Transfer Fcn' */ ADM_Integrated_Logic_DW.DiscreteTransferFcn_states = rtb_Vx_Cmd_R - -0.9375 * ADM_Integrated_Logic_DW.DiscreteTransferFcn_states; /* Update for UnitDelay: '/d1' */ ADM_Integrated_Logic_DW.d1_DSTATE = rtb_output_a; /* Update for UnitDelay: '/d' */ ADM_Integrated_Logic_DW.d_DSTATE = rtb_Brake_Torque_Cmd; /* Update for UnitDelay: '/d' */ ADM_Integrated_Logic_DW.d_DSTATE_i = rtb_Brake_Torque_Cmd; /* Update for UnitDelay: '/d1' */ ADM_Integrated_Logic_DW.d1_DSTATE_p = rtb_Sum1_i2; /* Update for UnitDelay: '/d' */ ADM_Integrated_Logic_DW.d_DSTATE_c = rtb_Sum1_i2; /* Update for UnitDelay: '/d1' */ ADM_Integrated_Logic_DW.d1_DSTATE_h = rtb_Sum1_o1; /* Update for UnitDelay: '/d' */ ADM_Integrated_Logic_DW.d_DSTATE_d = rtb_Sum1_o1; /* Update for UnitDelay: '/d1' */ ADM_Integrated_Logic_DW.d1_DSTATE_l = rtb_Sum1_lm; /* Update for Delay: '/Delay1' */ ADM_Integrated_Logic_DW.Delay1_DSTATE = rtb_Gain_c; /* Update for Delay: '/Delay' */ ADM_Integrated_Logic_DW.Delay_DSTATE[0] = ADM_Integrated_Logic_DW.Delay_DSTATE[1]; ADM_Integrated_Logic_DW.Delay_DSTATE[1] = rtb_Gain_c; /* Update for Delay: '/Delay2' */ ADM_Integrated_Logic_DW.Delay2_DSTATE = rtb_Product1_pd; /* Update for Delay: '/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: '/d1' */ ADM_Integrated_Logic_DW.d1_DSTATE_e = rtb_Product1_pd; /* Update for UnitDelay: '/d' */ ADM_Integrated_Logic_DW.d_DSTATE_ij = rtb_Product1_m; /* Update for Memory: '/Memory' */ ADM_Integrated_Logic_DW.Memory_PreviousInput = rtb_Add_e; /* Update for UnitDelay: '/d' */ ADM_Integrated_Logic_DW.d_DSTATE_ir = rtb_Brake_Torque_Cmd; /* Update for UnitDelay: '/d1' */ ADM_Integrated_Logic_DW.d1_DSTATE_o = rtb_Error_m; /* Update for UnitDelay: '/d' */ ADM_Integrated_Logic_DW.d_DSTATE_m = rtb_Error_m; /* Update for UnitDelay: '/d1' */ ADM_Integrated_Logic_DW.d1_DSTATE_hm = rtb_Sum1_aj; /* Update for UnitDelay: '/d' */ ADM_Integrated_Logic_DW.d_DSTATE_mw = rtb_Sum1_aj; /* Update for UnitDelay: '/d1' */ ADM_Integrated_Logic_DW.d1_DSTATE_g = rtb_Sum1_p; /* Update for UnitDelay: '/d1' */ ADM_Integrated_Logic_DW.d1_DSTATE_ej = rtb_Add3; /* Update for UnitDelay: '/d' */ ADM_Integrated_Logic_DW.d_DSTATE_j = rtb_Product1_e; /* Update for Delay: '/Delay1' */ ADM_Integrated_Logic_DW.Delay1_DSTATE_c = rtb_Product1_e; /* Update for Delay: '/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_e; /* Update for Delay: '/Delay2' */ ADM_Integrated_Logic_DW.Delay2_DSTATE_n = rtb_Product1_iz; /* Update for Delay: '/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_iz; /* Update for UnitDelay: '/d1' incorporates: * Inport: '/GV_IMU_AX_Val' */ ADM_Integrated_Logic_DW.d1_DSTATE_ob = ADM_Integrated_Logic_U.GV_IMU_AX_Val; /* Update for UnitDelay: '/d' */ ADM_Integrated_Logic_DW.d_DSTATE_e = rtb_Desired_Torque; /* Update for UnitDelay: '/d1' incorporates: * Inport: '/GV_IMU_AY_Val' */ ADM_Integrated_Logic_DW.d1_DSTATE_i = ADM_Integrated_Logic_U.GV_IMU_AY_Val; /* Update for UnitDelay: '/d' */ ADM_Integrated_Logic_DW.d_DSTATE_p = rtb_output_p; /* Update for UnitDelay: '/d1' incorporates: * Inport: '/GV_IMU_AZ_Val' */ ADM_Integrated_Logic_DW.d1_DSTATE_o1 = ADM_Integrated_Logic_U.GV_IMU_AZ_Val; /* Update for UnitDelay: '/d' */ ADM_Integrated_Logic_DW.d_DSTATE_n = rtb_Integrator_1; /* Update for DiscreteIntegrator: '/Integrator_1' */ ADM_Integrated_Logic_DW.Integrator_1_DSTATE += 0.002 * rtb_Sum_f; /* Update for UnitDelay: '/d1' incorporates: * Inport: '/GV_IMU_PitchRtVal' */ ADM_Integrated_Logic_DW.d1_DSTATE_a = ADM_Integrated_Logic_U.GV_IMU_PitchRtVal; /* Update for UnitDelay: '/d' */ ADM_Integrated_Logic_DW.d_DSTATE_d1 = rtb_Product1_f; /* Update for UnitDelay: '/Delay Input2' * * Block description for '/Delay Input2': * * Store in Global RAM */ ADM_Integrated_Logic_DW.DelayInput2_DSTATE_c = rtb_Yk1_p; /* Update for UnitDelay: '/Delay Input2' * * Block description for '/Delay Input2': * * Store in Global RAM */ ADM_Integrated_Logic_DW.DelayInput2_DSTATE_i = rtb_Switch2; if (ADM_Integrated_Logic_M->Timing.TaskCounters.TID[1] == 0) { /* Update absolute timer for sample time: [1.0s, 0.0s] */ /* The "clockTick1" counts the number of times the code of this task has * been executed. The resolution of this integer timer is 1.0, which is the step size * of the task. Size of "clockTick1" ensures timer will not overflow during the * application lifespan selected. */ ADM_Integrated_Logic_M->Timing.clockTick1++; } rate_scheduler(); } /* Model initialize function */ void ADM_Integrated_Logic_initialize(void) { /* : HAC_ON_FLAG = 0; */ /* : Smoothed_Torque = 0; */ /* : HAC_Desired_Torque = 0; */ /* : HAC_ON_Timer = 0; */ } /* Model terminate function */ void ADM_Integrated_Logic_terminate(void) { /* (no terminate code required) */ } /* * File trailer for generated code. * * [EOF] */