diff --git a/01_Matlab/01_Libraries/01_Controller/BLDC_controller_Lib.slx b/01_Matlab/01_Libraries/01_Controller/BLDC_controller_Lib.slx index 68d4e86..50475e2 100644 Binary files a/01_Matlab/01_Libraries/01_Controller/BLDC_controller_Lib.slx and b/01_Matlab/01_Libraries/01_Controller/BLDC_controller_Lib.slx differ diff --git a/01_Matlab/01_Libraries/01_Controller/BLDC_controller_Lib_old.slx b/01_Matlab/01_Libraries/01_Controller/BLDC_controller_Lib_old.slx deleted file mode 100644 index 8eb05b7..0000000 Binary files a/01_Matlab/01_Libraries/01_Controller/BLDC_controller_Lib_old.slx and /dev/null differ diff --git a/01_Matlab/BLDC_controller_ert_rtw/BLDC_controller.c b/01_Matlab/BLDC_controller_ert_rtw/BLDC_controller.c index 9111d29..9f96c3d 100644 --- a/01_Matlab/BLDC_controller_ert_rtw/BLDC_controller.c +++ b/01_Matlab/BLDC_controller_ert_rtw/BLDC_controller.c @@ -7,9 +7,9 @@ * * Code generated for Simulink model 'BLDC_controller'. * - * Model version : 1.800 + * Model version : 1.817 * Simulink Coder version : 8.13 (R2017b) 24-Jul-2017 - * C/C++ source code generated on : Sat May 25 21:42:39 2019 + * C/C++ source code generated on : Tue May 28 19:55:33 2019 * * Target selection: ert.tlc * Embedded hardware selection: ARM Compatible->ARM Cortex @@ -108,11 +108,9 @@ static void Edge_counter_Reset(DW_Edge_counter *localDW); static void Edge_counter_Disable(uint8_T *rty_cnt, DW_Edge_counter *localDW); static void Edge_counter(boolean_T rtu_Enable, boolean_T rtu_b_edge, int8_T rtu_z_dir, int8_T rtu_z_dirPrev, uint8_T *rty_cnt, DW_Edge_counter *localDW); -static void Moving_Average_Filter(boolean_T rtu_Trigger, int32_T rtu_n_motRaw, - int32_T *rty_n_mot, DW_Moving_Average_Filter *localDW, - ZCE_Moving_Average_Filter *localZCE); -static void Raw_Speed_calculation(boolean_T rtu_Trigger, int16_T rtu_z_counter, - int8_T rtu_z_dir, int32_T *rty_n_motRaw, ZCE_Raw_Speed_calculation *localZCE); +static void Motor_Speed_Calculation(boolean_T rtu_Trigger, int16_T rtu_z_counter, + int8_T rtu_z_dir, int32_T *rty_n_mot, DW_Motor_Speed_Calculation *localDW, + ZCE_Motor_Speed_Calculation *localZCE); static void F03_01_Pure_Trapezoidal_Method(int32_T rtu_a_elecAngleAdv, int16_T *rty_r_phaA_Trap, int16_T *rty_r_phaB_Trap, int16_T *rty_r_phaC_Trap); static void F03_02_Sinusoidal_Method(int32_T rtu_a_elecAngleAdv, int16_T @@ -124,7 +122,9 @@ static void F02_Electrical_Angle_Ca_Disable(int32_T *rty_a_elecAngleAdv, int32_T static void F02_Electrical_Angle_Calculatio(int32_T rtu_r_DC, uint8_T rtu_z_pos, int8_T rtu_z_dir, int16_T rtu_z_counter, int16_T rtu_z_counterRaw, int32_T *rty_a_elecAngleAdv, int32_T *rty_a_elecAngle); +static void falling_edge2(void); static void rising_edge(void); +static void falling_edge2_b(void); static void rising_edge_f(void); static uint8_T plook_u8s32u32n31_evenc_s(int32_T u, int32_T bp0, uint32_T bpSpace, uint32_T maxIndex, uint32_T *fraction) @@ -185,7 +185,7 @@ static int32_T div_nde_s32_floor(int32_T numerator, int32_T denominator) /* * Output and update for enable system: * '/F01_03_Direction_Detection' - * '/F01_03_Direction_Detection' + * '/F01_03_Direction_Detection' */ static void F01_03_Direction_Detection(boolean_T rtu_Enable, uint8_T rtu_z_pos, uint8_T rtu_z_posPrev, int8_T *rty_z_dir, int8_T *rty_z_dirPrev, @@ -233,18 +233,18 @@ static void F01_03_Direction_Detection(boolean_T rtu_Enable, uint8_T rtu_z_pos, /* * System reset for enable system: * '/Edge_counter' - * '/Edge_counter' + * '/Edge_counter' */ static void Edge_counter_Reset(DW_Edge_counter *localDW) { - /* InitializeConditions for UnitDelay: '/UnitDelay1' */ + /* InitializeConditions for UnitDelay: '/UnitDelay1' */ localDW->UnitDelay1_DSTATE = 0U; } /* * Disable for enable system: * '/Edge_counter' - * '/Edge_counter' + * '/Edge_counter' */ static void Edge_counter_Disable(uint8_T *rty_cnt, DW_Edge_counter *localDW) { @@ -261,7 +261,7 @@ static void Edge_counter_Disable(uint8_T *rty_cnt, DW_Edge_counter *localDW) /* * Output and update for enable system: * '/Edge_counter' - * '/Edge_counter' + * '/Edge_counter' */ static void Edge_counter(boolean_T rtu_Enable, boolean_T rtu_b_edge, int8_T rtu_z_dir, int8_T rtu_z_dirPrev, uint8_T *rty_cnt, DW_Edge_counter *localDW) @@ -281,10 +281,10 @@ static void Edge_counter(boolean_T rtu_Enable, boolean_T rtu_b_edge, int8_T /* RelationalOperator: '/Relational Operator1' */ rtb_RelationalOperator1_i = (rtu_z_dir == rtu_z_dirPrev); - /* Switch: '/Switch1' incorporates: - * Constant: '/Constant23' + /* Switch: '/Switch1' incorporates: + * Constant: '/Constant23' * Logic: '/Logical Operator2' - * UnitDelay: '/UnitDelay1' + * UnitDelay: '/UnitDelay1' */ if (!rtb_RelationalOperator1_i) { rtb_RelationalOperator1_m1 = 0U; @@ -292,7 +292,7 @@ static void Edge_counter(boolean_T rtu_Enable, boolean_T rtu_b_edge, int8_T rtb_RelationalOperator1_m1 = localDW->UnitDelay1_DSTATE; } - /* End of Switch: '/Switch1' */ + /* End of Switch: '/Switch1' */ /* Sum: '/Sum2' incorporates: * Logic: '/Logical Operator1' @@ -300,7 +300,7 @@ static void Edge_counter(boolean_T rtu_Enable, boolean_T rtu_b_edge, int8_T *rty_cnt = (uint8_T)((uint32_T)(rtu_b_edge && rtb_RelationalOperator1_i) + rtb_RelationalOperator1_m1); - /* Update for UnitDelay: '/UnitDelay1' */ + /* Update for UnitDelay: '/UnitDelay1' */ localDW->UnitDelay1_DSTATE = *rty_cnt; } else { if (localDW->Edge_counter_MODE) { @@ -313,78 +313,71 @@ static void Edge_counter(boolean_T rtu_Enable, boolean_T rtu_b_edge, int8_T /* * Output and update for trigger system: - * '/Moving_Average_Filter' - * '/Moving_Average_Filter' + * '/Motor_Speed_Calculation' + * '/Motor_Speed_Calculation' */ -static void Moving_Average_Filter(boolean_T rtu_Trigger, int32_T rtu_n_motRaw, - int32_T *rty_n_mot, DW_Moving_Average_Filter *localDW, - ZCE_Moving_Average_Filter *localZCE) +static void Motor_Speed_Calculation(boolean_T rtu_Trigger, int16_T rtu_z_counter, + int8_T rtu_z_dir, int32_T *rty_n_mot, DW_Motor_Speed_Calculation *localDW, + ZCE_Motor_Speed_Calculation *localZCE) { - int32_T rtb_UnitDelay1_f; + int32_T rtb_Sum2; - /* Outputs for Triggered SubSystem: '/Moving_Average_Filter' incorporates: + /* Outputs for Triggered SubSystem: '/Motor_Speed_Calculation' incorporates: * TriggerPort: '/Trigger' */ - if (rtu_Trigger && (localZCE->Moving_Average_Filter_Trig_ZCE != POS_ZCSIG)) { - /* UnitDelay: '/UnitDelay1' */ - rtb_UnitDelay1_f = localDW->UnitDelay1_DSTATE; - - /* Product: '/Divide4' incorporates: + if (rtu_Trigger && (localZCE->Motor_Speed_Calculation_Trig_ZC != POS_ZCSIG)) { + /* Switch: '/Switch' incorporates: * Constant: '/Constant1' - * Sum: '/Sum2' - * UnitDelay: '/UnitDelay5' + * Constant: '/cf_spdCoef' + * Constant: '/z_maxCntRst' + * Product: '/Divide4' + * RelationalOperator: '/Relational Operator1' */ - *rty_n_mot = ((localDW->UnitDelay5_DSTATE + rtb_UnitDelay1_f) + rtu_n_motRaw) - / 3; - - /* Update for UnitDelay: '/UnitDelay5' */ - localDW->UnitDelay5_DSTATE = rtb_UnitDelay1_f; - - /* Update for UnitDelay: '/UnitDelay1' */ - localDW->UnitDelay1_DSTATE = rtu_n_motRaw; - } - - localZCE->Moving_Average_Filter_Trig_ZCE = rtu_Trigger; - - /* End of Outputs for SubSystem: '/Moving_Average_Filter' */ -} - -/* - * Output and update for trigger system: - * '/Raw_ Speed_calculation' - * '/Raw_ Speed_calculation' - */ -static void Raw_Speed_calculation(boolean_T rtu_Trigger, int16_T rtu_z_counter, - int8_T rtu_z_dir, int32_T *rty_n_motRaw, ZCE_Raw_Speed_calculation *localZCE) -{ - int32_T rtb_Switch_p; - - /* Outputs for Triggered SubSystem: '/Raw_ Speed_calculation' incorporates: - * TriggerPort: '/Trigger' - */ - if (rtu_Trigger && (localZCE->Raw_Speed_calculation_Trig_ZCE != POS_ZCSIG)) { - /* Switch: '/Switch' incorporates: - * Constant: '/Constant1' - * Constant: '/cf_spdCoef' - * Constant: '/z_maxCntRst' - * Product: '/Divide4' - * RelationalOperator: '/Relational Operator1' - */ - if (rtu_z_counter > rtP.z_maxCntRst) { - rtb_Switch_p = 0; + if (rtu_z_counter >= rtP.z_maxCntRst) { + rtb_Sum2 = 0; } else { - rtb_Switch_p = rtP.cf_spdCoef / rtu_z_counter; + rtb_Sum2 = rtP.cf_speedCoef / rtu_z_counter; } - /* End of Switch: '/Switch' */ + /* End of Switch: '/Switch' */ - /* Product: '/Product2' */ - *rty_n_motRaw = rtb_Switch_p * rtu_z_dir; + /* Product: '/Product2' */ + rtb_Sum2 *= rtu_z_dir; + + /* Product: '/Divide1' incorporates: + * Constant: '/Constant2' + * Sum: '/Sum2' + * UnitDelay: '/UnitDelay1' + * UnitDelay: '/UnitDelay5' + */ + *rty_n_mot = ((localDW->UnitDelay5_DSTATE + localDW->UnitDelay1_DSTATE) + + rtb_Sum2) / 3; + + /* Update for UnitDelay: '/UnitDelay5' incorporates: + * UnitDelay: '/UnitDelay1' + */ + localDW->UnitDelay5_DSTATE = localDW->UnitDelay1_DSTATE; + + /* Update for UnitDelay: '/UnitDelay1' */ + localDW->UnitDelay1_DSTATE = rtb_Sum2; } - localZCE->Raw_Speed_calculation_Trig_ZCE = rtu_Trigger; + localZCE->Motor_Speed_Calculation_Trig_ZC = rtu_Trigger; - /* End of Outputs for SubSystem: '/Raw_ Speed_calculation' */ + /* End of Outputs for SubSystem: '/Motor_Speed_Calculation' */ +} + +/* Output and update for atomic system: '/falling_edge2' */ +static void falling_edge2(void) +{ + /* Logic: '/Logical Operator' incorporates: + * Logic: '/Logical Operator1' + * UnitDelay: '/UnitDelay' + */ + rtDW.LogicalOperator = ((!rtDW.Logic[0]) && rtDW.UnitDelay_DSTATE_b); + + /* Update for UnitDelay: '/UnitDelay' */ + rtDW.UnitDelay_DSTATE_b = rtDW.Logic[0]; } /* Output and update for atomic system: '/rising_edge' */ @@ -394,16 +387,16 @@ static void rising_edge(void) * Logic: '/Logical Operator1' * UnitDelay: '/UnitDelay' */ - rtDW.LogicalOperator = (rtDW.RelationalOperator4 && (!rtDW.UnitDelay_DSTATE_l)); + rtDW.LogicalOperator_h = (rtDW.LogicalOperator5 && (!rtDW.UnitDelay_DSTATE_l)); /* Update for UnitDelay: '/UnitDelay' */ - rtDW.UnitDelay_DSTATE_l = rtDW.RelationalOperator4; + rtDW.UnitDelay_DSTATE_l = rtDW.LogicalOperator5; } /* * Output and update for action system: * '/F03_01_Pure_Trapezoidal_Method' - * '/F03_01_Pure_Trapezoidal_Method' + * '/F03_01_Pure_Trapezoidal_Method' */ static void F03_01_Pure_Trapezoidal_Method(int32_T rtu_a_elecAngleAdv, int16_T *rty_r_phaA_Trap, int16_T *rty_r_phaB_Trap, int16_T *rty_r_phaC_Trap) @@ -411,27 +404,27 @@ static void F03_01_Pure_Trapezoidal_Method(int32_T rtu_a_elecAngleAdv, int16_T uint8_T rtb_a_trapElecAngle_XA_o1; uint32_T rtb_a_trapElecAngle_XA_o2; - /* PreLookup: '/a_trapElecAngle_XA' */ + /* PreLookup: '/a_trapElecAngle_XA' */ rtb_a_trapElecAngle_XA_o1 = plook_u8s32u32n31_evenc_s(rtu_a_elecAngleAdv, 0, 60U, 6U, &rtb_a_trapElecAngle_XA_o2); - /* Interpolation_n-D: '/r_trapPhaA_M1' */ + /* Interpolation_n-D: '/r_trapPhaA_M1' */ *rty_r_phaA_Trap = intrp1d_s16s32s32u8u32n31l_s(rtb_a_trapElecAngle_XA_o1, - rtb_a_trapElecAngle_XA_o2, rtConstP.pooled8); - - /* Interpolation_n-D: '/r_trapPhaB_M1' */ - *rty_r_phaB_Trap = intrp1d_s16s32s32u8u32n31l_s(rtb_a_trapElecAngle_XA_o1, rtb_a_trapElecAngle_XA_o2, rtConstP.pooled9); - /* Interpolation_n-D: '/r_trapPhaC_M1' */ - *rty_r_phaC_Trap = intrp1d_s16s32s32u8u32n31l_s(rtb_a_trapElecAngle_XA_o1, + /* Interpolation_n-D: '/r_trapPhaB_M1' */ + *rty_r_phaB_Trap = intrp1d_s16s32s32u8u32n31l_s(rtb_a_trapElecAngle_XA_o1, rtb_a_trapElecAngle_XA_o2, rtConstP.pooled10); + + /* Interpolation_n-D: '/r_trapPhaC_M1' */ + *rty_r_phaC_Trap = intrp1d_s16s32s32u8u32n31l_s(rtb_a_trapElecAngle_XA_o1, + rtb_a_trapElecAngle_XA_o2, rtConstP.pooled11); } /* * Output and update for action system: * '/F03_02_Sinusoidal_Method' - * '/F03_02_Sinusoidal_Method' + * '/F03_02_Sinusoidal_Method' */ static void F03_02_Sinusoidal_Method(int32_T rtu_a_elecAngleAdv, int16_T *rty_r_phaA_Sin, int16_T *rty_r_phaB_Sin, int16_T *rty_r_phaC_Sin) @@ -439,27 +432,27 @@ static void F03_02_Sinusoidal_Method(int32_T rtu_a_elecAngleAdv, int16_T uint8_T rtb_a_sinElecAngle_XA_o1; uint32_T rtb_a_sinElecAngle_XA_o2; - /* PreLookup: '/a_sinElecAngle_XA' */ + /* PreLookup: '/a_sinElecAngle_XA' */ rtb_a_sinElecAngle_XA_o1 = plook_u8s32u32n31_evenc_s(rtu_a_elecAngleAdv, 0, 10U, 36U, &rtb_a_sinElecAngle_XA_o2); - /* Interpolation_n-D: '/r_sinPhaA_M1' */ + /* Interpolation_n-D: '/r_sinPhaA_M1' */ *rty_r_phaA_Sin = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, - rtb_a_sinElecAngle_XA_o2, rtConstP.pooled11); - - /* Interpolation_n-D: '/r_sinPhaB_M1' */ - *rty_r_phaB_Sin = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, rtb_a_sinElecAngle_XA_o2, rtConstP.pooled12); - /* Interpolation_n-D: '/r_sinPhaC_M1' */ - *rty_r_phaC_Sin = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, + /* Interpolation_n-D: '/r_sinPhaB_M1' */ + *rty_r_phaB_Sin = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, rtb_a_sinElecAngle_XA_o2, rtConstP.pooled13); + + /* Interpolation_n-D: '/r_sinPhaC_M1' */ + *rty_r_phaC_Sin = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, + rtb_a_sinElecAngle_XA_o2, rtConstP.pooled14); } /* * Output and update for action system: * '/F03_02_Sinusoidal3rd_Method' - * '/F03_02_Sinusoidal3rd_Method' + * '/F03_02_Sinusoidal3rd_Method' */ static void F03_02_Sinusoidal3rd_Method(int32_T rtu_a_elecAngleAdv, int16_T *rty_r_phaA_Sin3, int16_T *rty_r_phaB_Sin3, int16_T *rty_r_phaC_Sin3) @@ -467,21 +460,21 @@ static void F03_02_Sinusoidal3rd_Method(int32_T rtu_a_elecAngleAdv, int16_T uint8_T rtb_a_sinElecAngle_XA_o1; uint32_T rtb_a_sinElecAngle_XA_o2; - /* PreLookup: '/a_sinElecAngle_XA' */ + /* PreLookup: '/a_sinElecAngle_XA' */ rtb_a_sinElecAngle_XA_o1 = plook_u8s32u32n31_evenc_s(rtu_a_elecAngleAdv, 0, 10U, 36U, &rtb_a_sinElecAngle_XA_o2); - /* Interpolation_n-D: '/r_sin3PhaA_M1' */ + /* Interpolation_n-D: '/r_sin3PhaA_M1' */ *rty_r_phaA_Sin3 = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, - rtb_a_sinElecAngle_XA_o2, rtConstP.pooled14); - - /* Interpolation_n-D: '/r_sin3PhaB_M1' */ - *rty_r_phaB_Sin3 = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, rtb_a_sinElecAngle_XA_o2, rtConstP.pooled15); - /* Interpolation_n-D: '/r_sin3PhaC_M1' */ - *rty_r_phaC_Sin3 = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, + /* Interpolation_n-D: '/r_sin3PhaB_M1' */ + *rty_r_phaB_Sin3 = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, rtb_a_sinElecAngle_XA_o2, rtConstP.pooled16); + + /* Interpolation_n-D: '/r_sin3PhaC_M1' */ + *rty_r_phaC_Sin3 = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, + rtb_a_sinElecAngle_XA_o2, rtConstP.pooled17); } /* @@ -509,9 +502,9 @@ static void F02_Electrical_Angle_Calculatio(int32_T rtu_r_DC, uint8_T rtu_z_pos, *rty_a_elecAngleAdv, int32_T *rty_a_elecAngle) { uint8_T rtb_Switch3; - int32_T rtb_Sum3_e; int16_T rtb_a_phaAdv_M2; uint32_T rtb_r_phaAdvDC_XA_o2; + int32_T rtu_r_DC_0; /* Switch: '/Switch3' incorporates: * Constant: '/Constant16' @@ -527,6 +520,7 @@ static void F02_Electrical_Angle_Calculatio(int32_T rtu_r_DC, uint8_T rtu_z_pos, /* End of Switch: '/Switch3' */ /* Sum: '/Sum2' incorporates: + * Constant: '/a_elecAngle1' * Product: '/Divide4' * Product: '/Divide5' * Product: '/Product6' @@ -536,23 +530,20 @@ static void F02_Electrical_Angle_Calculatio(int32_T rtu_r_DC, uint8_T rtu_z_pos, /* Switch: '/Switch_PhaAdv' incorporates: * Constant: '/a_elecPeriod1' - * Constant: '/a_elecPeriod2' - * Product: '/Divide2' - * Product: '/Divide3' - * Sum: '/Sum3' + * Math: '/Math Function' */ if (rtP.b_phaAdvEna) { /* Abs: '/Abs2' */ if (rtu_r_DC < 0) { - rtb_Sum3_e = -rtu_r_DC; + rtu_r_DC_0 = -rtu_r_DC; } else { - rtb_Sum3_e = rtu_r_DC; + rtu_r_DC_0 = rtu_r_DC; } /* End of Abs: '/Abs2' */ /* PreLookup: '/r_phaAdvDC_XA' */ - rtb_Switch3 = plook_u8s32u32n31_evenc_s(rtb_Sum3_e, rtP.r_phaAdvDC_XA[0], + rtb_Switch3 = plook_u8s32u32n31_evenc_s(rtu_r_DC_0, rtP.r_phaAdvDC_XA[0], (uint32_T)rtP.r_phaAdvDC_XA[1] - rtP.r_phaAdvDC_XA[0], 10U, &rtb_r_phaAdvDC_XA_o2); @@ -563,8 +554,8 @@ static void F02_Electrical_Angle_Calculatio(int32_T rtu_r_DC, uint8_T rtu_z_pos, /* Sum: '/Sum3' incorporates: * Product: '/Product2' */ - rtb_Sum3_e = rtu_z_dir * rtb_a_phaAdv_M2 + *rty_a_elecAngle; - *rty_a_elecAngleAdv = rtb_Sum3_e - div_nde_s32_floor(rtb_Sum3_e, 360) * 360; + rtu_r_DC_0 = rtu_z_dir * rtb_a_phaAdv_M2 + *rty_a_elecAngle; + *rty_a_elecAngleAdv = rtu_r_DC_0 - div_nde_s32_floor(rtu_r_DC_0, 360) * 360; } else { *rty_a_elecAngleAdv = *rty_a_elecAngle; } @@ -572,23 +563,35 @@ static void F02_Electrical_Angle_Calculatio(int32_T rtu_r_DC, uint8_T rtu_z_pos, /* End of Switch: '/Switch_PhaAdv' */ } -/* Output and update for atomic system: '/rising_edge' */ +/* Output and update for atomic system: '/falling_edge2' */ +static void falling_edge2_b(void) +{ + /* Logic: '/Logical Operator' incorporates: + * Logic: '/Logical Operator1' + * UnitDelay: '/UnitDelay' + */ + rtDW.LogicalOperator_h = ((!rtDW.Logic_j[0]) && rtDW.UnitDelay_DSTATE_i); + + /* Update for UnitDelay: '/UnitDelay' */ + rtDW.UnitDelay_DSTATE_i = rtDW.Logic_j[0]; +} + +/* Output and update for atomic system: '/rising_edge' */ static void rising_edge_f(void) { - /* Logic: '/Logical Operator' incorporates: - * Logic: '/Logical Operator1' - * UnitDelay: '/UnitDelay' + /* Logic: '/Logical Operator' incorporates: + * Logic: '/Logical Operator1' + * UnitDelay: '/UnitDelay' */ - rtDW.LogicalOperator = (rtDW.RelationalOperator4 && (!rtDW.UnitDelay_DSTATE_k)); + rtDW.LogicalOperator_h = (rtDW.LogicalOperator5 && (!rtDW.UnitDelay_DSTATE_k)); - /* Update for UnitDelay: '/UnitDelay' */ - rtDW.UnitDelay_DSTATE_k = rtDW.RelationalOperator4; + /* Update for UnitDelay: '/UnitDelay' */ + rtDW.UnitDelay_DSTATE_k = rtDW.LogicalOperator5; } /* Model step function */ void BLDC_controller_step(void) { - int32_T rowIdx; uint8_T rtb_Sum; boolean_T rtb_LogicalOperator; boolean_T rtb_LogicalOperator3; @@ -602,7 +605,6 @@ void BLDC_controller_step(void) int16_T rtb_Sum1_c; int32_T rtb_Switch1_idx_0; int32_T rtb_Switch1_idx_1; - boolean_T rtb_Logic_idx_0; uint8_T tmp; /* Outputs for Atomic SubSystem: '/BLDC_controller' */ @@ -628,6 +630,18 @@ void BLDC_controller_step(void) 0) ^ (rtU.b_hallCLeft != 0) ^ (rtDW.UnitDelay_DSTATE != 0) ^ (rtDW.UnitDelay1_DSTATE_p != 0)) ^ (rtDW.UnitDelay2_DSTATE != 0); + /* Outputs for Enabled SubSystem: '/F01_03_Direction_Detection' */ + + /* Selector: '/Selector' incorporates: + * Constant: '/vec_hallToPos' + * UnitDelay: '/UnitDelay1' + */ + F01_03_Direction_Detection(rtb_LogicalOperator, rtConstP.pooled26[rtb_Sum], + rtDW.UnitDelay1_DSTATE_g, &rtDW.Switch2_e, &rtDW.UnitDelay1_k, + &rtDW.F01_03_Direction_Detection_o); + + /* End of Outputs for SubSystem: '/F01_03_Direction_Detection' */ + /* Logic: '/Logical Operator3' incorporates: * Constant: '/z_maxCntRst' * RelationalOperator: '/Relational Operator1' @@ -636,18 +650,6 @@ void BLDC_controller_step(void) rtb_LogicalOperator3 = (rtb_LogicalOperator || (rtDW.z_counterRawPrev_DSTATE > rtP.z_maxCntRst)); - /* Outputs for Enabled SubSystem: '/F01_03_Direction_Detection' */ - - /* Selector: '/Selector' incorporates: - * Constant: '/vec_hallToPos' - * UnitDelay: '/UnitDelay1' - */ - F01_03_Direction_Detection(rtb_LogicalOperator, rtConstP.pooled27[rtb_Sum], - rtDW.UnitDelay1_DSTATE_g, &rtDW.Switch2_e, &rtDW.UnitDelay1_k, - &rtDW.F01_03_Direction_Detection_o); - - /* End of Outputs for SubSystem: '/F01_03_Direction_Detection' */ - /* Outputs for Enabled SubSystem: '/Edge_counter' */ /* Logic: '/Logical Operator2' incorporates: @@ -658,64 +660,62 @@ void BLDC_controller_step(void) /* End of Outputs for SubSystem: '/Edge_counter' */ - /* Abs: '/Abs4' incorporates: - * UnitDelay: '/UnitDelay10' + /* Logic: '/Logical Operator5' incorporates: + * Constant: '/z_maxCntRst2' + * RelationalOperator: '/Relational Operator3' + * RelationalOperator: '/Relational Operator6' + * UnitDelay: '/z_counterRawPrev' */ - if (rtDW.rpm_signed_c < 0) { - rtb_Switch1_idx_0 = -rtDW.rpm_signed_c; - } else { - rtb_Switch1_idx_0 = rtDW.rpm_signed_c; - } - - /* End of Abs: '/Abs4' */ - - /* RelationalOperator: '/Relational Operator4' incorporates: - * Constant: '/n_thresSpdDeacv' - */ - rtDW.RelationalOperator4 = (rtb_Switch1_idx_0 < rtP.n_thresSpdDeacv); + rtDW.LogicalOperator5 = ((rtDW.Switch2_e != rtDW.UnitDelay1_k) || + (rtDW.z_counterRawPrev_DSTATE > rtP.z_maxCntRst)); /* Outputs for Atomic SubSystem: '/rising_edge' */ rising_edge(); /* End of Outputs for SubSystem: '/rising_edge' */ - /* CombinatorialLogic: '/Logic' incorporates: + /* CombinatorialLogic: '/Logic' incorporates: * Constant: '/z_nrEdgeSpdAcv' - * Memory: '/Memory' + * Memory: '/Memory' * RelationalOperator: '/Relational Operator5' */ - rowIdx = (int32_T)(((((uint32_T)(rtDW.Sum2_l >= rtP.z_nrEdgeSpdAcv) << 1) + - rtDW.LogicalOperator) << 1) + rtDW.Memory_PreviousInput); - rtb_Logic_idx_0 = rtConstP.pooled31[(uint32_T)rowIdx]; + rtb_Switch1_idx_0 = (int32_T)(((((uint32_T)(rtDW.Sum2_l >= rtP.z_nrEdgeSpdAcv) + << 1) + rtDW.LogicalOperator_h) << 1) + rtDW.Memory_PreviousInput); + rtDW.Logic[0U] = rtConstP.pooled30[(uint32_T)rtb_Switch1_idx_0]; + rtDW.Logic[1U] = rtConstP.pooled30[rtb_Switch1_idx_0 + 8U]; + + /* Outputs for Atomic SubSystem: '/falling_edge2' */ + falling_edge2(); + + /* End of Outputs for SubSystem: '/falling_edge2' */ /* Switch: '/Switch' incorporates: - * CombinatorialLogic: '/Logic' * Logic: '/Logical Operator1' + * Switch: '/Switch1' * UnitDelay: '/z_counter2' * UnitDelay: '/z_counterRawPrev' */ - if (rtb_LogicalOperator3 && rtConstP.pooled31[(uint32_T)rowIdx]) { + if (rtb_LogicalOperator3 && rtDW.Logic[0]) { rtb_Switch = rtDW.z_counterRawPrev_DSTATE; + } else if (rtDW.LogicalOperator) { + /* Switch: '/Switch1' incorporates: + * Constant: '/z_maxCntRst1' + */ + rtb_Switch = rtP.z_maxCntRst; } else { rtb_Switch = rtDW.z_counter2_DSTATE; } /* End of Switch: '/Switch' */ - /* Outputs for Triggered SubSystem: '/Raw_ Speed_calculation' */ - Raw_Speed_calculation(rtb_LogicalOperator3, rtb_Switch, rtDW.Switch2_e, - &rtDW.rpm_signed_c, &rtPrevZCX.Raw_Speed_calculation_m); - - /* End of Outputs for SubSystem: '/Raw_ Speed_calculation' */ - - /* Outputs for Triggered SubSystem: '/Moving_Average_Filter' */ + /* Outputs for Triggered SubSystem: '/Motor_Speed_Calculation' */ /* Outport: '/n_motLeft' */ - Moving_Average_Filter(rtb_LogicalOperator3, rtDW.rpm_signed_c, &rtY.n_motLeft, - &rtDW.Moving_Average_Filter_l, - &rtPrevZCX.Moving_Average_Filter_l); + Motor_Speed_Calculation(rtb_LogicalOperator3, rtb_Switch, rtDW.Switch2_e, + &rtY.n_motLeft, &rtDW.Motor_Speed_Calculation_m, + &rtPrevZCX.Motor_Speed_Calculation_m); - /* End of Outputs for SubSystem: '/Moving_Average_Filter' */ + /* End of Outputs for SubSystem: '/Motor_Speed_Calculation' */ /* Abs: '/Abs5' incorporates: * Outport: '/n_motLeft' @@ -774,7 +774,7 @@ void BLDC_controller_step(void) /* Outputs for IfAction SubSystem: '/F02_Electrical_Angle_Calculation' incorporates: * ActionPort: '/Action Port' */ - F02_Electrical_Angle_Calculatio(rtU.r_DCLeft, rtConstP.pooled27[rtb_Sum], + F02_Electrical_Angle_Calculatio(rtU.r_DCLeft, rtConstP.pooled26[rtb_Sum], rtDW.Switch2_e, rtb_Switch, rtb_Sum1, &rtDW.Switch_PhaAdv_a, &rtY.a_elecAngleLeft); @@ -789,7 +789,7 @@ void BLDC_controller_step(void) switch (rtP.z_ctrlTypSel) { case 1: /* Outputs for IfAction SubSystem: '/F03_01_Pure_Trapezoidal_Method' incorporates: - * ActionPort: '/Action Port' + * ActionPort: '/Action Port' */ F03_01_Pure_Trapezoidal_Method(rtDW.Switch_PhaAdv_a, &rtDW.Merge, &rtDW.Merge1, &rtDW.Merge2); @@ -799,7 +799,7 @@ void BLDC_controller_step(void) case 2: /* Outputs for IfAction SubSystem: '/F03_02_Sinusoidal_Method' incorporates: - * ActionPort: '/Action Port' + * ActionPort: '/Action Port' */ F03_02_Sinusoidal_Method(rtDW.Switch_PhaAdv_a, &rtDW.Merge, &rtDW.Merge1, &rtDW.Merge2); @@ -809,7 +809,7 @@ void BLDC_controller_step(void) case 3: /* Outputs for IfAction SubSystem: '/F03_02_Sinusoidal3rd_Method' incorporates: - * ActionPort: '/Action Port' + * ActionPort: '/Action Port' */ F03_02_Sinusoidal3rd_Method(rtDW.Switch_PhaAdv_a, &rtDW.Merge, &rtDW.Merge1, &rtDW.Merge2); @@ -855,7 +855,7 @@ void BLDC_controller_step(void) rtb_Switch1_idx_1 = rtU.r_DCLeft * rtDW.Merge1; rtb_Abs1 = rtU.r_DCLeft * rtDW.Merge2; } else { - if (rtConstP.pooled27[rtb_Sum] < 5) { + if (rtConstP.pooled26[rtb_Sum] < 5) { /* LookupNDDirect: '/z_commutMap_M1' incorporates: * Constant: '/vec_hallToPos' * Selector: '/Selector' @@ -863,7 +863,7 @@ void BLDC_controller_step(void) * About '/z_commutMap_M1': * 2-dimensional Direct Look-Up returning a Column */ - tmp = rtConstP.pooled27[rtb_Sum]; + tmp = rtConstP.pooled26[rtb_Sum]; } else { /* LookupNDDirect: '/z_commutMap_M1' * @@ -879,9 +879,9 @@ void BLDC_controller_step(void) * 2-dimensional Direct Look-Up returning a Column */ rtb_Abs1 = tmp * 3; - rtb_Switch1_idx_0 = rtU.r_DCLeft * rtConstP.pooled17[rtb_Abs1]; - rtb_Switch1_idx_1 = rtConstP.pooled17[1 + rtb_Abs1] * rtU.r_DCLeft; - rtb_Abs1 = rtConstP.pooled17[2 + rtb_Abs1] * rtU.r_DCLeft; + rtb_Switch1_idx_0 = rtU.r_DCLeft * rtConstP.pooled18[rtb_Abs1]; + rtb_Switch1_idx_1 = rtConstP.pooled18[1 + rtb_Abs1] * rtU.r_DCLeft; + rtb_Abs1 = rtConstP.pooled18[2 + rtb_Abs1] * rtU.r_DCLeft; } /* End of Switch: '/Switch1' */ @@ -904,9 +904,9 @@ void BLDC_controller_step(void) */ rtY.DC_phaCLeft = rtb_Abs1 / 1000; - /* Sum: '/Sum' incorporates: - * Gain: '/g_Ha' - * Gain: '/g_Hb' + /* Sum: '/Sum' incorporates: + * Gain: '/g_Ha' + * Gain: '/g_Hb' * Inport: '/b_hallARight' * Inport: '/b_hallBRight' * Inport: '/b_hallCRight' @@ -914,107 +914,106 @@ void BLDC_controller_step(void) rtb_Sum_a = (uint8_T)((uint32_T)(uint8_T)((uint32_T)(uint8_T)(rtU.b_hallARight << 2) + (uint8_T)(rtU.b_hallBRight << 1)) + rtU.b_hallCRight); - /* Logic: '/Logical Operator' incorporates: + /* Logic: '/Logical Operator' incorporates: * Inport: '/b_hallARight' * Inport: '/b_hallBRight' * Inport: '/b_hallCRight' - * UnitDelay: '/UnitDelay' - * UnitDelay: '/UnitDelay1' - * UnitDelay: '/UnitDelay2' + * UnitDelay: '/UnitDelay' + * UnitDelay: '/UnitDelay1' + * UnitDelay: '/UnitDelay2' */ rtb_LogicalOperator = (boolean_T)((rtU.b_hallARight != 0) ^ (rtU.b_hallBRight != 0) ^ (rtU.b_hallCRight != 0) ^ (rtDW.UnitDelay_DSTATE_j != 0) ^ (rtDW.UnitDelay1_DSTATE_f != 0)) ^ (rtDW.UnitDelay2_DSTATE_b != 0); - /* Logic: '/Logical Operator3' incorporates: - * Constant: '/z_maxCntRst' - * RelationalOperator: '/Relational Operator1' - * UnitDelay: '/z_counterRawPrev' + /* Outputs for Enabled SubSystem: '/F01_03_Direction_Detection' */ + + /* Selector: '/Selector' incorporates: + * Constant: '/vec_hallToPos' + * UnitDelay: '/UnitDelay1' + */ + F01_03_Direction_Detection(rtb_LogicalOperator, rtConstP.pooled26[rtb_Sum_a], + rtDW.UnitDelay1_DSTATE_j, &rtDW.Switch2, &rtDW.UnitDelay1, + &rtDW.F01_03_Direction_Detection_j); + + /* End of Outputs for SubSystem: '/F01_03_Direction_Detection' */ + + /* Logic: '/Logical Operator3' incorporates: + * Constant: '/z_maxCntRst' + * RelationalOperator: '/Relational Operator1' + * UnitDelay: '/z_counterRawPrev' */ rtb_LogicalOperator3 = (rtb_LogicalOperator || (rtDW.z_counterRawPrev_DSTATE_p > rtP.z_maxCntRst)); - /* Outputs for Enabled SubSystem: '/F01_03_Direction_Detection' */ + /* Outputs for Enabled SubSystem: '/Edge_counter' */ - /* Selector: '/Selector' incorporates: - * Constant: '/vec_hallToPos' - * UnitDelay: '/UnitDelay1' - */ - F01_03_Direction_Detection(rtb_LogicalOperator, rtConstP.pooled27[rtb_Sum_a], - rtDW.UnitDelay1_DSTATE_j, &rtDW.Switch2, &rtDW.UnitDelay1, - &rtDW.F01_03_Direction_Detection_j); - - /* End of Outputs for SubSystem: '/F01_03_Direction_Detection' */ - - /* Outputs for Enabled SubSystem: '/Edge_counter' */ - - /* Logic: '/Logical Operator2' incorporates: - * UnitDelay: '/UnitDelay8' + /* Logic: '/Logical Operator2' incorporates: + * UnitDelay: '/UnitDelay8' */ Edge_counter(!rtDW.UnitDelay8_DSTATE_p, rtb_LogicalOperator, rtDW.Switch2, rtDW.UnitDelay1, &rtDW.Sum2_i, &rtDW.Edge_counter_l); - /* End of Outputs for SubSystem: '/Edge_counter' */ + /* End of Outputs for SubSystem: '/Edge_counter' */ - /* Abs: '/Abs4' incorporates: - * UnitDelay: '/UnitDelay10' + /* Logic: '/Logical Operator5' incorporates: + * Constant: '/z_maxCntRst2' + * RelationalOperator: '/Relational Operator3' + * RelationalOperator: '/Relational Operator6' + * UnitDelay: '/z_counterRawPrev' */ - if (rtDW.rpm_signed < 0) { - rtb_Switch1_idx_0 = -rtDW.rpm_signed; - } else { - rtb_Switch1_idx_0 = rtDW.rpm_signed; - } + rtDW.LogicalOperator5 = ((rtDW.Switch2 != rtDW.UnitDelay1) || + (rtDW.z_counterRawPrev_DSTATE_p > rtP.z_maxCntRst)); - /* End of Abs: '/Abs4' */ - - /* RelationalOperator: '/Relational Operator4' incorporates: - * Constant: '/n_thresSpdDeacv' - */ - rtDW.RelationalOperator4 = (rtb_Switch1_idx_0 < rtP.n_thresSpdDeacv); - - /* Outputs for Atomic SubSystem: '/rising_edge' */ + /* Outputs for Atomic SubSystem: '/rising_edge' */ rising_edge_f(); - /* End of Outputs for SubSystem: '/rising_edge' */ + /* End of Outputs for SubSystem: '/rising_edge' */ - /* CombinatorialLogic: '/Logic' incorporates: - * Constant: '/z_nrEdgeSpdAcv' - * Memory: '/Memory' - * RelationalOperator: '/Relational Operator5' + /* CombinatorialLogic: '/Logic' incorporates: + * Constant: '/z_nrEdgeSpdAcv' + * Memory: '/Memory' + * RelationalOperator: '/Relational Operator5' */ - rowIdx = (int32_T)(((((uint32_T)(rtDW.Sum2_i >= rtP.z_nrEdgeSpdAcv) << 1) + - rtDW.LogicalOperator) << 1) + rtDW.Memory_PreviousInput_i); + rtb_Switch1_idx_0 = (int32_T)(((((uint32_T)(rtDW.Sum2_i >= rtP.z_nrEdgeSpdAcv) + << 1) + rtDW.LogicalOperator_h) << 1) + rtDW.Memory_PreviousInput_i); + rtDW.Logic_j[0U] = rtConstP.pooled30[(uint32_T)rtb_Switch1_idx_0]; + rtDW.Logic_j[1U] = rtConstP.pooled30[rtb_Switch1_idx_0 + 8U]; - /* Switch: '/Switch' incorporates: - * CombinatorialLogic: '/Logic' - * Logic: '/Logical Operator1' - * UnitDelay: '/z_counter2' - * UnitDelay: '/z_counterRawPrev' + /* Outputs for Atomic SubSystem: '/falling_edge2' */ + falling_edge2_b(); + + /* End of Outputs for SubSystem: '/falling_edge2' */ + + /* Switch: '/Switch' incorporates: + * Logic: '/Logical Operator1' + * Switch: '/Switch1' + * UnitDelay: '/z_counter2' + * UnitDelay: '/z_counterRawPrev' */ - if (rtb_LogicalOperator3 && rtConstP.pooled31[(uint32_T)rowIdx]) { + if (rtb_LogicalOperator3 && rtDW.Logic_j[0]) { rtb_Switch_b = rtDW.z_counterRawPrev_DSTATE_p; + } else if (rtDW.LogicalOperator_h) { + /* Switch: '/Switch1' incorporates: + * Constant: '/z_maxCntRst1' + */ + rtb_Switch_b = rtP.z_maxCntRst; } else { rtb_Switch_b = rtDW.z_counter2_DSTATE_h; } - /* End of Switch: '/Switch' */ + /* End of Switch: '/Switch' */ - /* Outputs for Triggered SubSystem: '/Raw_ Speed_calculation' */ - Raw_Speed_calculation(rtb_LogicalOperator3, rtb_Switch_b, rtDW.Switch2, - &rtDW.rpm_signed, &rtPrevZCX.Raw_Speed_calculation_k); - - /* End of Outputs for SubSystem: '/Raw_ Speed_calculation' */ - - /* Outputs for Triggered SubSystem: '/Moving_Average_Filter' */ + /* Outputs for Triggered SubSystem: '/Motor_Speed_Calculation' */ /* Outport: '/n_motRight' */ - Moving_Average_Filter(rtb_LogicalOperator3, rtDW.rpm_signed, &rtY.n_motRight, - &rtDW.Moving_Average_Filter_n, - &rtPrevZCX.Moving_Average_Filter_n); + Motor_Speed_Calculation(rtb_LogicalOperator3, rtb_Switch_b, rtDW.Switch2, + &rtY.n_motRight, &rtDW.Motor_Speed_Calculation_k, + &rtPrevZCX.Motor_Speed_Calculation_k); - /* End of Outputs for SubSystem: '/Moving_Average_Filter' */ + /* End of Outputs for SubSystem: '/Motor_Speed_Calculation' */ - /* Abs: '/Abs5' incorporates: + /* Abs: '/Abs5' incorporates: * Outport: '/n_motRight' */ if (rtY.n_motRight < 0) { @@ -1023,9 +1022,9 @@ void BLDC_controller_step(void) rtb_Abs1 = rtY.n_motRight; } - /* End of Abs: '/Abs5' */ + /* End of Abs: '/Abs5' */ - /* Relay: '/Relay' */ + /* Relay: '/Relay' */ if (rtb_Abs1 >= rtP.n_commDeacvHi) { rtDW.Relay_Mode_m = true; } else { @@ -1034,9 +1033,9 @@ void BLDC_controller_step(void) } } - /* Switch: '/Switch1' incorporates: - * Constant: '/Constant23' - * UnitDelay: '/UnitDelay1' + /* Switch: '/Switch1' incorporates: + * Constant: '/Constant23' + * UnitDelay: '/UnitDelay1' */ if (rtb_LogicalOperator3) { rtb_Sum1_c = 0; @@ -1044,17 +1043,17 @@ void BLDC_controller_step(void) rtb_Sum1_c = rtDW.UnitDelay1_DSTATE_k; } - /* End of Switch: '/Switch1' */ + /* End of Switch: '/Switch1' */ - /* Sum: '/Sum1' */ + /* Sum: '/Sum1' */ rtb_Sum1_c++; /* If: '/If1' incorporates: - * Constant: '/z_ctrlTypSel1' - * Constant: '/vec_hallToPos' + * Constant: '/z_ctrlTypSel1' + * Constant: '/vec_hallToPos' * Inport: '/r_DCRight' * Outport: '/a_elecAngleRight' - * Selector: '/Selector' + * Selector: '/Selector' */ rtPrevAction = rtDW.If1_ActiveSubsystem_j; rtAction = -1; @@ -1069,9 +1068,9 @@ void BLDC_controller_step(void) if (rtAction == 0) { /* Outputs for IfAction SubSystem: '/F02_Electrical_Angle_Calculation' incorporates: - * ActionPort: '/Action Port' + * ActionPort: '/Action Port' */ - F02_Electrical_Angle_Calculatio(rtU.r_DCRight, rtConstP.pooled27[rtb_Sum_a], + F02_Electrical_Angle_Calculatio(rtU.r_DCRight, rtConstP.pooled26[rtb_Sum_a], rtDW.Switch2, rtb_Switch_b, rtb_Sum1_c, &rtDW.Switch_PhaAdv, &rtY.a_elecAngleRight); @@ -1080,44 +1079,44 @@ void BLDC_controller_step(void) /* End of If: '/If1' */ - /* SwitchCase: '/Switch Case' incorporates: - * Constant: '/z_ctrlTypSel1' + /* SwitchCase: '/Switch Case' incorporates: + * Constant: '/z_ctrlTypSel1' */ switch (rtP.z_ctrlTypSel) { case 1: - /* Outputs for IfAction SubSystem: '/F03_01_Pure_Trapezoidal_Method' incorporates: - * ActionPort: '/Action Port' + /* Outputs for IfAction SubSystem: '/F03_01_Pure_Trapezoidal_Method' incorporates: + * ActionPort: '/Action Port' */ F03_01_Pure_Trapezoidal_Method(rtDW.Switch_PhaAdv, &rtDW.Merge_j, &rtDW.Merge1_m, &rtDW.Merge2_d); - /* End of Outputs for SubSystem: '/F03_01_Pure_Trapezoidal_Method' */ + /* End of Outputs for SubSystem: '/F03_01_Pure_Trapezoidal_Method' */ break; case 2: - /* Outputs for IfAction SubSystem: '/F03_02_Sinusoidal_Method' incorporates: - * ActionPort: '/Action Port' + /* Outputs for IfAction SubSystem: '/F03_02_Sinusoidal_Method' incorporates: + * ActionPort: '/Action Port' */ F03_02_Sinusoidal_Method(rtDW.Switch_PhaAdv, &rtDW.Merge_j, &rtDW.Merge1_m, &rtDW.Merge2_d); - /* End of Outputs for SubSystem: '/F03_02_Sinusoidal_Method' */ + /* End of Outputs for SubSystem: '/F03_02_Sinusoidal_Method' */ break; case 3: - /* Outputs for IfAction SubSystem: '/F03_02_Sinusoidal3rd_Method' incorporates: - * ActionPort: '/Action Port' + /* Outputs for IfAction SubSystem: '/F03_02_Sinusoidal3rd_Method' incorporates: + * ActionPort: '/Action Port' */ F03_02_Sinusoidal3rd_Method(rtDW.Switch_PhaAdv, &rtDW.Merge_j, &rtDW.Merge1_m, &rtDW.Merge2_d); - /* End of Outputs for SubSystem: '/F03_02_Sinusoidal3rd_Method' */ + /* End of Outputs for SubSystem: '/F03_02_Sinusoidal3rd_Method' */ break; } - /* End of SwitchCase: '/Switch Case' */ + /* End of SwitchCase: '/Switch Case' */ - /* Abs: '/Abs1' incorporates: + /* Abs: '/Abs1' incorporates: * Inport: '/r_DCRight' */ if (rtU.r_DCRight < 0) { @@ -1126,24 +1125,24 @@ void BLDC_controller_step(void) rtb_Switch1_idx_0 = rtU.r_DCRight; } - /* End of Abs: '/Abs1' */ + /* End of Abs: '/Abs1' */ - /* Switch: '/Switch1' incorporates: - * Constant: '/z_ctrlTypSel1' - * Constant: '/CTRL_COMM' - * Constant: '/r_commDCDeacv' - * Constant: '/vec_hallToPos' + /* Switch: '/Switch1' incorporates: + * Constant: '/z_ctrlTypSel1' + * Constant: '/CTRL_COMM' + * Constant: '/r_commDCDeacv' + * Constant: '/vec_hallToPos' * Inport: '/r_DCRight' - * Logic: '/Logical Operator3' - * LookupNDDirect: '/z_commutMap_M1' - * Product: '/Divide2' - * Product: '/Divide4' - * RelationalOperator: '/Relational Operator1' - * RelationalOperator: '/Relational Operator2' - * Relay: '/Relay' - * Selector: '/Selector' + * Logic: '/Logical Operator3' + * LookupNDDirect: '/z_commutMap_M1' + * Product: '/Divide2' + * Product: '/Divide4' + * RelationalOperator: '/Relational Operator1' + * RelationalOperator: '/Relational Operator2' + * Relay: '/Relay' + * Selector: '/Selector' * - * About '/z_commutMap_M1': + * About '/z_commutMap_M1': * 2-dimensional Direct Look-Up returning a Column */ if (rtDW.Relay_Mode_m && (rtb_Switch1_idx_0 > rtP.r_commDCDeacv) && @@ -1152,46 +1151,46 @@ void BLDC_controller_step(void) rtb_Switch1_idx_1 = rtU.r_DCRight * rtDW.Merge1_m; rtb_Abs1 = rtU.r_DCRight * rtDW.Merge2_d; } else { - if (rtConstP.pooled27[rtb_Sum_a] < 5) { - /* LookupNDDirect: '/z_commutMap_M1' incorporates: - * Constant: '/vec_hallToPos' - * Selector: '/Selector' + if (rtConstP.pooled26[rtb_Sum_a] < 5) { + /* LookupNDDirect: '/z_commutMap_M1' incorporates: + * Constant: '/vec_hallToPos' + * Selector: '/Selector' * - * About '/z_commutMap_M1': + * About '/z_commutMap_M1': * 2-dimensional Direct Look-Up returning a Column */ - tmp = rtConstP.pooled27[rtb_Sum_a]; + tmp = rtConstP.pooled26[rtb_Sum_a]; } else { - /* LookupNDDirect: '/z_commutMap_M1' + /* LookupNDDirect: '/z_commutMap_M1' * - * About '/z_commutMap_M1': + * About '/z_commutMap_M1': * 2-dimensional Direct Look-Up returning a Column */ tmp = 5U; } - /* LookupNDDirect: '/z_commutMap_M1' + /* LookupNDDirect: '/z_commutMap_M1' * - * About '/z_commutMap_M1': + * About '/z_commutMap_M1': * 2-dimensional Direct Look-Up returning a Column */ rtb_Abs1 = tmp * 3; - rtb_Switch1_idx_0 = rtU.r_DCRight * rtConstP.pooled17[rtb_Abs1]; - rtb_Switch1_idx_1 = rtConstP.pooled17[1 + rtb_Abs1] * rtU.r_DCRight; - rtb_Abs1 = rtConstP.pooled17[2 + rtb_Abs1] * rtU.r_DCRight; + rtb_Switch1_idx_0 = rtU.r_DCRight * rtConstP.pooled18[rtb_Abs1]; + rtb_Switch1_idx_1 = rtConstP.pooled18[1 + rtb_Abs1] * rtU.r_DCRight; + rtb_Abs1 = rtConstP.pooled18[2 + rtb_Abs1] * rtU.r_DCRight; } - /* End of Switch: '/Switch1' */ + /* End of Switch: '/Switch1' */ /* Outport: '/DC_phaARight' incorporates: - * Constant: '/Constant1' - * Product: '/Divide1' + * Constant: '/Constant1' + * Product: '/Divide1' */ rtY.DC_phaARight = rtb_Switch1_idx_0 / 1000; /* Outport: '/DC_phaBRight' incorporates: - * Constant: '/Constant1' - * Product: '/Divide1' + * Constant: '/Constant1' + * Product: '/Divide1' */ rtY.DC_phaBRight = rtb_Switch1_idx_1 / 1000; @@ -1210,20 +1209,20 @@ void BLDC_controller_step(void) */ rtDW.UnitDelay2_DSTATE = rtU.b_hallCLeft; - /* Update for UnitDelay: '/z_counterRawPrev' */ - rtDW.z_counterRawPrev_DSTATE = rtb_Sum1; - /* Update for UnitDelay: '/UnitDelay1' incorporates: * Constant: '/vec_hallToPos' * Selector: '/Selector' */ - rtDW.UnitDelay1_DSTATE_g = rtConstP.pooled27[rtb_Sum]; + rtDW.UnitDelay1_DSTATE_g = rtConstP.pooled26[rtb_Sum]; + + /* Update for UnitDelay: '/z_counterRawPrev' */ + rtDW.z_counterRawPrev_DSTATE = rtb_Sum1; /* Update for UnitDelay: '/UnitDelay8' */ - rtDW.UnitDelay8_DSTATE = rtb_Logic_idx_0; + rtDW.UnitDelay8_DSTATE = rtDW.Logic[0]; - /* Update for Memory: '/Memory' */ - rtDW.Memory_PreviousInput = rtb_Logic_idx_0; + /* Update for Memory: '/Memory' */ + rtDW.Memory_PreviousInput = rtDW.Logic[0]; /* Update for UnitDelay: '/z_counter2' */ rtDW.z_counter2_DSTATE = rtb_Switch; @@ -1231,49 +1230,45 @@ void BLDC_controller_step(void) /* Update for UnitDelay: '/UnitDelay1' */ rtDW.UnitDelay1_DSTATE = rtb_Sum1; - /* Update for UnitDelay: '/UnitDelay' incorporates: + /* Update for UnitDelay: '/UnitDelay' incorporates: * Inport: '/b_hallARight' */ rtDW.UnitDelay_DSTATE_j = rtU.b_hallARight; - /* Update for UnitDelay: '/UnitDelay1' incorporates: + /* Update for UnitDelay: '/UnitDelay1' incorporates: * Inport: '/b_hallBRight' */ rtDW.UnitDelay1_DSTATE_f = rtU.b_hallBRight; - /* Update for UnitDelay: '/UnitDelay2' incorporates: + /* Update for UnitDelay: '/UnitDelay2' incorporates: * Inport: '/b_hallCRight' */ rtDW.UnitDelay2_DSTATE_b = rtU.b_hallCRight; - /* Update for UnitDelay: '/z_counterRawPrev' */ + /* Update for UnitDelay: '/UnitDelay1' incorporates: + * Constant: '/vec_hallToPos' + * Selector: '/Selector' + */ + rtDW.UnitDelay1_DSTATE_j = rtConstP.pooled26[rtb_Sum_a]; + + /* Update for UnitDelay: '/z_counterRawPrev' */ rtDW.z_counterRawPrev_DSTATE_p = rtb_Sum1_c; - /* Update for UnitDelay: '/UnitDelay1' incorporates: - * Constant: '/vec_hallToPos' - * Selector: '/Selector' - */ - rtDW.UnitDelay1_DSTATE_j = rtConstP.pooled27[rtb_Sum_a]; + /* Update for UnitDelay: '/UnitDelay8' */ + rtDW.UnitDelay8_DSTATE_p = rtDW.Logic_j[0]; - /* Update for UnitDelay: '/UnitDelay8' incorporates: - * CombinatorialLogic: '/Logic' - */ - rtDW.UnitDelay8_DSTATE_p = rtConstP.pooled31[(uint32_T)rowIdx]; + /* Update for Memory: '/Memory' */ + rtDW.Memory_PreviousInput_i = rtDW.Logic_j[0]; - /* Update for Memory: '/Memory' incorporates: - * CombinatorialLogic: '/Logic' - */ - rtDW.Memory_PreviousInput_i = rtConstP.pooled31[(uint32_T)rowIdx]; - - /* Update for UnitDelay: '/z_counter2' */ + /* Update for UnitDelay: '/z_counter2' */ rtDW.z_counter2_DSTATE_h = rtb_Switch_b; - /* Update for UnitDelay: '/UnitDelay1' */ + /* Update for UnitDelay: '/UnitDelay1' */ rtDW.UnitDelay1_DSTATE_k = rtb_Sum1_c; /* Outport: '/DC_phaCRight' incorporates: - * Constant: '/Constant1' - * Product: '/Divide1' + * Constant: '/Constant1' + * Product: '/Divide1' */ rtY.DC_phaCRight = rtb_Abs1 / 1000; @@ -1291,17 +1286,17 @@ void BLDC_controller_initialize(void) rtDW.If1_ActiveSubsystem_j = -1; /* End of Start for SubSystem: '/BLDC_controller' */ - rtPrevZCX.Raw_Speed_calculation_k.Raw_Speed_calculation_Trig_ZCE = POS_ZCSIG; - rtPrevZCX.Moving_Average_Filter_n.Moving_Average_Filter_Trig_ZCE = POS_ZCSIG; - rtPrevZCX.Raw_Speed_calculation_m.Raw_Speed_calculation_Trig_ZCE = POS_ZCSIG; - rtPrevZCX.Moving_Average_Filter_l.Moving_Average_Filter_Trig_ZCE = POS_ZCSIG; + rtPrevZCX.Motor_Speed_Calculation_k.Motor_Speed_Calculation_Trig_ZC = + POS_ZCSIG; + rtPrevZCX.Motor_Speed_Calculation_m.Motor_Speed_Calculation_Trig_ZC = + POS_ZCSIG; /* SystemInitialize for Atomic SubSystem: '/BLDC_controller' */ /* InitializeConditions for UnitDelay: '/z_counter2' */ - rtDW.z_counter2_DSTATE = 5000; + rtDW.z_counter2_DSTATE = rtP.z_maxCntRst; - /* InitializeConditions for UnitDelay: '/z_counter2' */ - rtDW.z_counter2_DSTATE_h = 5000; + /* InitializeConditions for UnitDelay: '/z_counter2' */ + rtDW.z_counter2_DSTATE_h = rtP.z_maxCntRst; /* End of SystemInitialize for SubSystem: '/BLDC_controller' */ } diff --git a/01_Matlab/BLDC_controller_ert_rtw/BLDC_controller.h b/01_Matlab/BLDC_controller_ert_rtw/BLDC_controller.h index 38c3dc3..8c99184 100644 --- a/01_Matlab/BLDC_controller_ert_rtw/BLDC_controller.h +++ b/01_Matlab/BLDC_controller_ert_rtw/BLDC_controller.h @@ -7,9 +7,9 @@ * * Code generated for Simulink model 'BLDC_controller'. * - * Model version : 1.800 + * Model version : 1.817 * Simulink Coder version : 8.13 (R2017b) 24-Jul-2017 - * C/C++ source code generated on : Sat May 25 21:42:39 2019 + * C/C++ source code generated on : Tue May 28 19:55:33 2019 * * Target selection: ert.tlc * Embedded hardware selection: ARM Compatible->ARM Cortex @@ -40,171 +40,167 @@ typedef struct { /* Block signals and states (auto storage) for system '/Edge_counter' */ typedef struct { - uint8_T UnitDelay1_DSTATE; /* '/UnitDelay1' */ + uint8_T UnitDelay1_DSTATE; /* '/UnitDelay1' */ boolean_T Edge_counter_MODE; /* '/Edge_counter' */ } DW_Edge_counter; -/* Block signals and states (auto storage) for system '/Moving_Average_Filter' */ +/* Block signals and states (auto storage) for system '/Motor_Speed_Calculation' */ typedef struct { int32_T UnitDelay5_DSTATE; /* '/UnitDelay5' */ int32_T UnitDelay1_DSTATE; /* '/UnitDelay1' */ -} DW_Moving_Average_Filter; +} DW_Motor_Speed_Calculation; -/* Zero-crossing (trigger) state for system '/Moving_Average_Filter' */ +/* Zero-crossing (trigger) state for system '/Motor_Speed_Calculation' */ typedef struct { - ZCSigState Moving_Average_Filter_Trig_ZCE;/* '/Moving_Average_Filter' */ -} ZCE_Moving_Average_Filter; - -/* Zero-crossing (trigger) state for system '/Raw_ Speed_calculation' */ -typedef struct { - ZCSigState Raw_Speed_calculation_Trig_ZCE;/* '/Raw_ Speed_calculation' */ -} ZCE_Raw_Speed_calculation; + ZCSigState Motor_Speed_Calculation_Trig_ZC;/* '/Motor_Speed_Calculation' */ +} ZCE_Motor_Speed_Calculation; /* Block signals and states (auto storage) for system '' */ typedef struct { - DW_Moving_Average_Filter Moving_Average_Filter_n;/* '/Moving_Average_Filter' */ - DW_Edge_counter Edge_counter_l; /* '/Edge_counter' */ - DW_F01_03_Direction_Detection F01_03_Direction_Detection_j;/* '/F01_03_Direction_Detection' */ - DW_Moving_Average_Filter Moving_Average_Filter_l;/* '/Moving_Average_Filter' */ + DW_Motor_Speed_Calculation Motor_Speed_Calculation_k;/* '/Motor_Speed_Calculation' */ + DW_Edge_counter Edge_counter_l; /* '/Edge_counter' */ + DW_F01_03_Direction_Detection F01_03_Direction_Detection_j;/* '/F01_03_Direction_Detection' */ + DW_Motor_Speed_Calculation Motor_Speed_Calculation_m;/* '/Motor_Speed_Calculation' */ DW_Edge_counter Edge_counter_f; /* '/Edge_counter' */ DW_F01_03_Direction_Detection F01_03_Direction_Detection_o;/* '/F01_03_Direction_Detection' */ - int32_T Switch_PhaAdv; /* '/Switch_PhaAdv' */ - int32_T rpm_signed; /* '/Product2' */ + int32_T Switch_PhaAdv; /* '/Switch_PhaAdv' */ int32_T Switch_PhaAdv_a; /* '/Switch_PhaAdv' */ - int32_T rpm_signed_c; /* '/Product2' */ int16_T Merge; /* '/Merge' */ int16_T Merge1; /* '/Merge1' */ int16_T Merge2; /* '/Merge2' */ - int16_T Merge_j; /* '/Merge' */ - int16_T Merge1_m; /* '/Merge1' */ - int16_T Merge2_d; /* '/Merge2' */ + int16_T Merge_j; /* '/Merge' */ + int16_T Merge1_m; /* '/Merge1' */ + int16_T Merge2_d; /* '/Merge2' */ int16_T z_counterRawPrev_DSTATE; /* '/z_counterRawPrev' */ int16_T z_counter2_DSTATE; /* '/z_counter2' */ int16_T UnitDelay1_DSTATE; /* '/UnitDelay1' */ - int16_T z_counterRawPrev_DSTATE_p; /* '/z_counterRawPrev' */ - int16_T z_counter2_DSTATE_h; /* '/z_counter2' */ - int16_T UnitDelay1_DSTATE_k; /* '/UnitDelay1' */ - int8_T UnitDelay1; /* '/UnitDelay1' */ - int8_T Switch2; /* '/Switch2' */ + int16_T z_counterRawPrev_DSTATE_p; /* '/z_counterRawPrev' */ + int16_T z_counter2_DSTATE_h; /* '/z_counter2' */ + int16_T UnitDelay1_DSTATE_k; /* '/UnitDelay1' */ + int8_T UnitDelay1; /* '/UnitDelay1' */ + int8_T Switch2; /* '/Switch2' */ int8_T UnitDelay1_k; /* '/UnitDelay1' */ int8_T Switch2_e; /* '/Switch2' */ int8_T If1_ActiveSubsystem; /* '/If1' */ int8_T If1_ActiveSubsystem_j; /* '/If1' */ - uint8_T Sum2_i; /* '/Sum2' */ + uint8_T Sum2_i; /* '/Sum2' */ uint8_T Sum2_l; /* '/Sum2' */ uint8_T UnitDelay_DSTATE; /* '/UnitDelay' */ uint8_T UnitDelay1_DSTATE_p; /* '/UnitDelay1' */ uint8_T UnitDelay2_DSTATE; /* '/UnitDelay2' */ uint8_T UnitDelay1_DSTATE_g; /* '/UnitDelay1' */ - uint8_T UnitDelay_DSTATE_j; /* '/UnitDelay' */ - uint8_T UnitDelay1_DSTATE_f; /* '/UnitDelay1' */ - uint8_T UnitDelay2_DSTATE_b; /* '/UnitDelay2' */ - uint8_T UnitDelay1_DSTATE_j; /* '/UnitDelay1' */ - boolean_T RelationalOperator4; /* '/Relational Operator4' */ - boolean_T LogicalOperator; /* '/Logical Operator' */ + uint8_T UnitDelay_DSTATE_j; /* '/UnitDelay' */ + uint8_T UnitDelay1_DSTATE_f; /* '/UnitDelay1' */ + uint8_T UnitDelay2_DSTATE_b; /* '/UnitDelay2' */ + uint8_T UnitDelay1_DSTATE_j; /* '/UnitDelay1' */ + boolean_T Logic[2]; /* '/Logic' */ + boolean_T Logic_j[2]; /* '/Logic' */ + boolean_T LogicalOperator; /* '/Logical Operator' */ + boolean_T LogicalOperator5; /* '/Logical Operator5' */ + boolean_T LogicalOperator_h; /* '/Logical Operator' */ boolean_T UnitDelay8_DSTATE; /* '/UnitDelay8' */ - boolean_T UnitDelay8_DSTATE_p; /* '/UnitDelay8' */ - boolean_T UnitDelay_DSTATE_k; /* '/UnitDelay' */ + boolean_T UnitDelay8_DSTATE_p; /* '/UnitDelay8' */ + boolean_T UnitDelay_DSTATE_k; /* '/UnitDelay' */ + boolean_T UnitDelay_DSTATE_i; /* '/UnitDelay' */ boolean_T UnitDelay_DSTATE_l; /* '/UnitDelay' */ - boolean_T Memory_PreviousInput; /* '/Memory' */ + boolean_T UnitDelay_DSTATE_b; /* '/UnitDelay' */ + boolean_T Memory_PreviousInput; /* '/Memory' */ boolean_T Relay_Mode; /* '/Relay' */ - boolean_T Memory_PreviousInput_i; /* '/Memory' */ - boolean_T Relay_Mode_m; /* '/Relay' */ + boolean_T Memory_PreviousInput_i; /* '/Memory' */ + boolean_T Relay_Mode_m; /* '/Relay' */ } DW; /* Zero-crossing (trigger) state */ typedef struct { - ZCE_Raw_Speed_calculation Raw_Speed_calculation_k;/* '/Raw_ Speed_calculation' */ - ZCE_Moving_Average_Filter Moving_Average_Filter_n;/* '/Moving_Average_Filter' */ - ZCE_Raw_Speed_calculation Raw_Speed_calculation_m;/* '/Raw_ Speed_calculation' */ - ZCE_Moving_Average_Filter Moving_Average_Filter_l;/* '/Moving_Average_Filter' */ + ZCE_Motor_Speed_Calculation Motor_Speed_Calculation_k;/* '/Motor_Speed_Calculation' */ + ZCE_Motor_Speed_Calculation Motor_Speed_Calculation_m;/* '/Motor_Speed_Calculation' */ } PrevZCX; /* Constant parameters (auto storage) */ typedef struct { /* Pooled Parameter (Expression: r_trapPhaA_M1) * Referenced by: - * '/r_trapPhaA_M1' - * '/r_trapPhaA_M1' - */ - int16_T pooled8[7]; - - /* Pooled Parameter (Expression: r_trapPhaB_M1) - * Referenced by: - * '/r_trapPhaB_M1' - * '/r_trapPhaB_M1' + * '/r_trapPhaA_M1' + * '/r_trapPhaA_M1' */ int16_T pooled9[7]; - /* Pooled Parameter (Expression: r_trapPhaC_M1) + /* Pooled Parameter (Expression: r_trapPhaB_M1) * Referenced by: - * '/r_trapPhaC_M1' - * '/r_trapPhaC_M1' + * '/r_trapPhaB_M1' + * '/r_trapPhaB_M1' */ int16_T pooled10[7]; + /* Pooled Parameter (Expression: r_trapPhaC_M1) + * Referenced by: + * '/r_trapPhaC_M1' + * '/r_trapPhaC_M1' + */ + int16_T pooled11[7]; + /* Pooled Parameter (Expression: r_sinPhaA_M1) * Referenced by: - * '/r_sinPhaA_M1' - * '/r_sinPhaA_M1' - */ - int16_T pooled11[37]; - - /* Pooled Parameter (Expression: r_sinPhaB_M1) - * Referenced by: - * '/r_sinPhaB_M1' - * '/r_sinPhaB_M1' + * '/r_sinPhaA_M1' + * '/r_sinPhaA_M1' */ int16_T pooled12[37]; - /* Pooled Parameter (Expression: r_sinPhaC_M1) + /* Pooled Parameter (Expression: r_sinPhaB_M1) * Referenced by: - * '/r_sinPhaC_M1' - * '/r_sinPhaC_M1' + * '/r_sinPhaB_M1' + * '/r_sinPhaB_M1' */ int16_T pooled13[37]; - /* Pooled Parameter (Expression: r_sin3PhaA_M1) + /* Pooled Parameter (Expression: r_sinPhaC_M1) * Referenced by: - * '/r_sin3PhaA_M1' - * '/r_sin3PhaA_M1' + * '/r_sinPhaC_M1' + * '/r_sinPhaC_M1' */ int16_T pooled14[37]; - /* Pooled Parameter (Expression: r_sin3PhaB_M1) + /* Pooled Parameter (Expression: r_sin3PhaA_M1) * Referenced by: - * '/r_sin3PhaB_M1' - * '/r_sin3PhaB_M1' + * '/r_sin3PhaA_M1' + * '/r_sin3PhaA_M1' */ int16_T pooled15[37]; - /* Pooled Parameter (Expression: r_sin3PhaC_M1) + /* Pooled Parameter (Expression: r_sin3PhaB_M1) * Referenced by: - * '/r_sin3PhaC_M1' - * '/r_sin3PhaC_M1' + * '/r_sin3PhaB_M1' + * '/r_sin3PhaB_M1' */ int16_T pooled16[37]; + /* Pooled Parameter (Expression: r_sin3PhaC_M1) + * Referenced by: + * '/r_sin3PhaC_M1' + * '/r_sin3PhaC_M1' + */ + int16_T pooled17[37]; + /* Pooled Parameter (Expression: z_commutMap_M1) * Referenced by: * '/z_commutMap_M1' - * '/z_commutMap_M1' + * '/z_commutMap_M1' */ - int16_T pooled17[18]; + int16_T pooled18[18]; /* Pooled Parameter (Expression: vec_hallToPos) * Referenced by: * '/vec_hallToPos' - * '/vec_hallToPos' + * '/vec_hallToPos' */ - uint8_T pooled27[8]; + uint8_T pooled26[8]; /* Pooled Parameter (Expression: [0 1;1 0;0 1;0 1;1 0;1 0;0 0;0 0]) * Referenced by: - * '/Logic' - * '/Logic' + * '/Logic' + * '/Logic' */ - boolean_T pooled31[16]; + boolean_T pooled30[16]; } ConstP; /* External inputs (root inport signals with auto storage) */ @@ -235,62 +231,63 @@ typedef struct { /* Parameters (auto storage) */ struct P_ { - int32_T cf_spdCoef; /* Variable: cf_spdCoef + int32_T cf_speedCoef; /* Variable: cf_speedCoef * Referenced by: - * '/cf_spdCoef' - * '/cf_spdCoef' + * '/cf_spdCoef' + * '/cf_spdCoef' */ int32_T n_commAcvLo; /* Variable: n_commAcvLo * Referenced by: * '/Relay' - * '/Relay' + * '/Relay' */ int32_T n_commDeacvHi; /* Variable: n_commDeacvHi * Referenced by: * '/Relay' - * '/Relay' - */ - int32_T n_thresSpdDeacv; /* Variable: n_thresSpdDeacv - * Referenced by: - * '/n_thresSpdDeacv' - * '/n_thresSpdDeacv' + * '/Relay' */ int32_T r_commDCDeacv; /* Variable: r_commDCDeacv * Referenced by: * '/r_commDCDeacv' - * '/r_commDCDeacv' + * '/r_commDCDeacv' */ int32_T r_phaAdvDC_XA[11]; /* Variable: r_phaAdvDC_XA * Referenced by: * '/r_phaAdvDC_XA' - * '/r_phaAdvDC_XA' + * '/r_phaAdvDC_XA' */ int16_T a_phaAdv_M1[11]; /* Variable: a_phaAdv_M1 * Referenced by: * '/a_phaAdv_M2' - * '/a_phaAdv_M2' + * '/a_phaAdv_M2' */ int16_T z_maxCntRst; /* Variable: z_maxCntRst * Referenced by: * '/z_maxCntRst' - * '/z_maxCntRst' - * '/z_maxCntRst' - * '/z_maxCntRst' + * '/z_maxCntRst1' + * '/z_maxCntRst2' + * '/z_counter2' + * '/z_maxCntRst' + * '/z_maxCntRst1' + * '/z_maxCntRst2' + * '/z_counter2' + * '/z_maxCntRst' + * '/z_maxCntRst' */ uint8_T z_ctrlTypSel; /* Variable: z_ctrlTypSel * Referenced by: * '/z_ctrlTypSel1' - * '/z_ctrlTypSel1' + * '/z_ctrlTypSel1' */ uint8_T z_nrEdgeSpdAcv; /* Variable: z_nrEdgeSpdAcv * Referenced by: * '/z_nrEdgeSpdAcv' - * '/z_nrEdgeSpdAcv' + * '/z_nrEdgeSpdAcv' */ boolean_T b_phaAdvEna; /* Variable: b_phaAdvEna * Referenced by: * '/a_elecPeriod1' - * '/a_elecPeriod1' + * '/a_elecPeriod1' */ }; @@ -321,8 +318,8 @@ extern void BLDC_controller_step(void); * * Block '/Scope2' : Unused code path elimination * Block '/Scope' : Unused code path elimination - * Block '/Scope2' : Unused code path elimination - * Block '/Scope' : Unused code path elimination + * Block '/Scope2' : Unused code path elimination + * Block '/Scope' : Unused code path elimination */ /*- @@ -370,70 +367,66 @@ extern void BLDC_controller_step(void); * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_02_Position_Calculation/signal_log6' * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_03_Direction_Detection/signal_log6' * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Edge_counter' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Moving_Average_Filter' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Raw_ Speed_calculation' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/S-R Flip-Flop' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Motor_Speed_Calculation' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/S-R Flip-Flop' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/falling_edge2' * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/rising_edge' * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/rst_Delay' * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log1' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log2' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log3' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log4' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log6' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Edge_counter/rst_Delay' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F02_Electrical_Angle_Calculation/Modulo_Calculation' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F02_Electrical_Angle_Calculation/signal_log1' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F02_Electrical_Angle_Calculation/signal_log2' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F02_Electrical_Angle_Calculation/signal_log6' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/F03_01_Pure_Trapezoidal_Method' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/F03_02_Sinusoidal3rd_Method' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/F03_02_Sinusoidal_Method' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/signal_log1' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/signal_log2' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/signal_log6' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F04_Control_Type_Management/signal_log1' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F04_Control_Type_Management/signal_log2' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F04_Control_Type_Management/signal_log6' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F02_Electrical_Angle_Calculation' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F04_Control_Type_Management' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/signal_log1' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/signal_log2' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/signal_log3' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/signal_log6' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_01_Edge_Detector' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_02_Position_Calculation' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_03_Direction_Detection' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_01_Edge_Detector/signal_log6' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_02_Position_Calculation/signal_log6' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_03_Direction_Detection/signal_log6' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Edge_counter' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Moving_Average_Filter' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Raw_ Speed_calculation' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/S-R Flip-Flop' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/rising_edge' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/rst_Delay' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log1' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log2' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log3' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log4' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log6' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Edge_counter/rst_Delay' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F02_Electrical_Angle_Calculation/Modulo_Calculation' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F02_Electrical_Angle_Calculation/signal_log1' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F02_Electrical_Angle_Calculation/signal_log2' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F02_Electrical_Angle_Calculation/signal_log6' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/F03_01_Pure_Trapezoidal_Method' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/F03_02_Sinusoidal3rd_Method' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/F03_02_Sinusoidal_Method' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/signal_log1' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/signal_log2' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/signal_log6' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F04_Control_Type_Management/signal_log1' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F04_Control_Type_Management/signal_log2' - * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F04_Control_Type_Management/signal_log6' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log3' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log4' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log5' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Edge_counter/rst_Delay' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F02_Electrical_Angle_Calculation/signal_log1' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F02_Electrical_Angle_Calculation/signal_log2' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F02_Electrical_Angle_Calculation/signal_log6' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/F03_01_Pure_Trapezoidal_Method' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/F03_02_Sinusoidal3rd_Method' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/F03_02_Sinusoidal_Method' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/signal_log1' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/signal_log2' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/signal_log6' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F04_Control_Type_Management/signal_log1' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F04_Control_Type_Management/signal_log2' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F04_Control_Type_Management/signal_log6' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F02_Electrical_Angle_Calculation' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F04_Control_Type_Management' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/signal_log1' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/signal_log2' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/signal_log3' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/signal_log6' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_01_Edge_Detector' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_02_Position_Calculation' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_03_Direction_Detection' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_01_Edge_Detector/signal_log6' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_02_Position_Calculation/signal_log6' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_03_Direction_Detection/signal_log6' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Edge_counter' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Motor_Speed_Calculation' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/S-R Flip-Flop' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/falling_edge2' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/rising_edge' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/rst_Delay' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log1' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log3' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log4' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log5' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Edge_counter/rst_Delay' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F02_Electrical_Angle_Calculation/signal_log1' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F02_Electrical_Angle_Calculation/signal_log2' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F02_Electrical_Angle_Calculation/signal_log6' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/F03_01_Pure_Trapezoidal_Method' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/F03_02_Sinusoidal3rd_Method' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/F03_02_Sinusoidal_Method' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/signal_log1' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/signal_log2' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/signal_log6' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F04_Control_Type_Management/signal_log1' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F04_Control_Type_Management/signal_log2' + * '' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F04_Control_Type_Management/signal_log6' */ #endif /* RTW_HEADER_BLDC_controller_h_ */ diff --git a/01_Matlab/BLDC_controller_ert_rtw/BLDC_controller.mk b/01_Matlab/BLDC_controller_ert_rtw/BLDC_controller.mk index 24abe51..2520b0d 100644 --- a/01_Matlab/BLDC_controller_ert_rtw/BLDC_controller.mk +++ b/01_Matlab/BLDC_controller_ert_rtw/BLDC_controller.mk @@ -2,7 +2,7 @@ ## Makefile generated for Simulink model 'BLDC_controller'. ## ## Makefile : BLDC_controller.mk -## Generated on : Fri May 24 22:25:17 2019 +## Generated on : Tue May 28 18:31:31 2019 ## MATLAB Coder version: 3.4 (R2017b) ## ## Build Info: @@ -32,7 +32,7 @@ MATLAB_ROOT = C:/PROGRA~1/MATLAB/R2017b MATLAB_BIN = C:/PROGRA~1/MATLAB/R2017b/bin MATLAB_ARCH_BIN = $(MATLAB_BIN)/win64 MASTER_ANCHOR_DIR = -START_DIR = D:/Work_home/Projects_STM32/01_Motor_control +START_DIR = D:/Work_home/01_Motor_control ARCH = win64 SOLVER = SOLVER_OBJ = diff --git a/01_Matlab/BLDC_controller_ert_rtw/BLDC_controller_data.c b/01_Matlab/BLDC_controller_ert_rtw/BLDC_controller_data.c index 299e57f..0458de2 100644 --- a/01_Matlab/BLDC_controller_ert_rtw/BLDC_controller_data.c +++ b/01_Matlab/BLDC_controller_ert_rtw/BLDC_controller_data.c @@ -7,9 +7,9 @@ * * Code generated for Simulink model 'BLDC_controller'. * - * Model version : 1.800 + * Model version : 1.817 * Simulink Coder version : 8.13 (R2017b) 24-Jul-2017 - * C/C++ source code generated on : Sat May 25 21:42:39 2019 + * C/C++ source code generated on : Tue May 28 19:55:33 2019 * * Target selection: ert.tlc * Embedded hardware selection: ARM Compatible->ARM Cortex @@ -25,82 +25,81 @@ /* Block parameters (auto storage) */ P rtP = { - /* Variable: cf_spdCoef + /* Variable: cf_speedCoef * Referenced by: - * '/cf_spdCoef' - * '/cf_spdCoef' + * '/cf_spdCoef' + * '/cf_spdCoef' */ 66667, /* Variable: n_commAcvLo * Referenced by: * '/Relay' - * '/Relay' + * '/Relay' */ 100, /* Variable: n_commDeacvHi * Referenced by: * '/Relay' - * '/Relay' + * '/Relay' */ 180, - /* Variable: n_thresSpdDeacv - * Referenced by: - * '/n_thresSpdDeacv' - * '/n_thresSpdDeacv' - */ - 5, - /* Variable: r_commDCDeacv * Referenced by: * '/r_commDCDeacv' - * '/r_commDCDeacv' + * '/r_commDCDeacv' */ 70, /* Variable: r_phaAdvDC_XA * Referenced by: * '/r_phaAdvDC_XA' - * '/r_phaAdvDC_XA' + * '/r_phaAdvDC_XA' */ { 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 }, /* Variable: a_phaAdv_M1 * Referenced by: * '/a_phaAdv_M2' - * '/a_phaAdv_M2' + * '/a_phaAdv_M2' */ { 0, 0, 7, 2, 2, 2, 4, 5, 9, 16, 25 }, /* Variable: z_maxCntRst * Referenced by: * '/z_maxCntRst' - * '/z_maxCntRst' - * '/z_maxCntRst' - * '/z_maxCntRst' + * '/z_maxCntRst1' + * '/z_maxCntRst2' + * '/z_counter2' + * '/z_maxCntRst' + * '/z_maxCntRst1' + * '/z_maxCntRst2' + * '/z_counter2' + * '/z_maxCntRst' + * '/z_maxCntRst' */ 2000, /* Variable: z_ctrlTypSel * Referenced by: * '/z_ctrlTypSel1' - * '/z_ctrlTypSel1' + * '/z_ctrlTypSel1' */ 3U, /* Variable: z_nrEdgeSpdAcv * Referenced by: * '/z_nrEdgeSpdAcv' - * '/z_nrEdgeSpdAcv' + * '/z_nrEdgeSpdAcv' */ - 5U, + 3U, /* Variable: b_phaAdvEna * Referenced by: * '/a_elecPeriod1' - * '/a_elecPeriod1' + * '/a_elecPeriod1' */ 1 }; @@ -109,29 +108,29 @@ P rtP = { const ConstP rtConstP = { /* Pooled Parameter (Expression: r_trapPhaA_M1) * Referenced by: - * '/r_trapPhaA_M1' - * '/r_trapPhaA_M1' + * '/r_trapPhaA_M1' + * '/r_trapPhaA_M1' */ { 1000, 1000, 1000, -1000, -1000, -1000, 1000 }, /* Pooled Parameter (Expression: r_trapPhaB_M1) * Referenced by: - * '/r_trapPhaB_M1' - * '/r_trapPhaB_M1' + * '/r_trapPhaB_M1' + * '/r_trapPhaB_M1' */ { -1000, -1000, 1000, 1000, 1000, -1000, -1000 }, /* Pooled Parameter (Expression: r_trapPhaC_M1) * Referenced by: - * '/r_trapPhaC_M1' - * '/r_trapPhaC_M1' + * '/r_trapPhaC_M1' + * '/r_trapPhaC_M1' */ { 1000, -1000, -1000, -1000, 1000, 1000, 1000 }, /* Pooled Parameter (Expression: r_sinPhaA_M1) * Referenced by: - * '/r_sinPhaA_M1' - * '/r_sinPhaA_M1' + * '/r_sinPhaA_M1' + * '/r_sinPhaA_M1' */ { 500, 643, 766, 866, 940, 985, 1000, 985, 940, 866, 766, 643, 500, 342, 174, 0, -174, -342, -500, -643, -766, -866, -940, -985, -1000, -985, -940, -866, @@ -139,8 +138,8 @@ const ConstP rtConstP = { /* Pooled Parameter (Expression: r_sinPhaB_M1) * Referenced by: - * '/r_sinPhaB_M1' - * '/r_sinPhaB_M1' + * '/r_sinPhaB_M1' + * '/r_sinPhaB_M1' */ { -1000, -985, -940, -866, -766, -643, -500, -342, -174, 0, 174, 342, 500, 643, 766, 866, 940, 985, 1000, 985, 940, 866, 766, 643, 500, 342, 174, 0, -174, @@ -148,8 +147,8 @@ const ConstP rtConstP = { /* Pooled Parameter (Expression: r_sinPhaC_M1) * Referenced by: - * '/r_sinPhaC_M1' - * '/r_sinPhaC_M1' + * '/r_sinPhaC_M1' + * '/r_sinPhaC_M1' */ { 500, 342, 174, 0, -174, -342, -500, -643, -766, -866, -940, -985, -1000, -985, -940, -866, -766, -643, -500, -342, -174, 0, 174, 342, 500, 643, 766, @@ -157,8 +156,8 @@ const ConstP rtConstP = { /* Pooled Parameter (Expression: r_sin3PhaA_M1) * Referenced by: - * '/r_sin3PhaA_M1' - * '/r_sin3PhaA_M1' + * '/r_sin3PhaA_M1' + * '/r_sin3PhaA_M1' */ { 795, 930, 991, 996, 971, 942, 930, 942, 971, 996, 991, 930, 795, 584, 310, 0, -310, -584, -795, -930, -991, -996, -971, -942, -930, -942, -971, -996, -991, @@ -166,8 +165,8 @@ const ConstP rtConstP = { /* Pooled Parameter (Expression: r_sin3PhaB_M1) * Referenced by: - * '/r_sin3PhaB_M1' - * '/r_sin3PhaB_M1' + * '/r_sin3PhaB_M1' + * '/r_sin3PhaB_M1' */ { -930, -942, -971, -996, -991, -930, -795, -584, -310, 0, 310, 584, 795, 930, 991, 996, 971, 942, 930, 942, 971, 996, 991, 930, 795, 584, 310, 0, -310, @@ -175,8 +174,8 @@ const ConstP rtConstP = { /* Pooled Parameter (Expression: r_sin3PhaC_M1) * Referenced by: - * '/r_sin3PhaC_M1' - * '/r_sin3PhaC_M1' + * '/r_sin3PhaC_M1' + * '/r_sin3PhaC_M1' */ { 795, 584, 310, 0, -310, -584, -795, -930, -991, -996, -971, -942, -930, -942, -971, -996, -991, -930, -795, -584, -310, 0, 310, 584, 795, 930, 991, 996, @@ -185,7 +184,7 @@ const ConstP rtConstP = { /* Pooled Parameter (Expression: z_commutMap_M1) * Referenced by: * '/z_commutMap_M1' - * '/z_commutMap_M1' + * '/z_commutMap_M1' */ { 1000, -1000, 0, 1000, 0, -1000, 0, 1000, -1000, -1000, 1000, 0, -1000, 0, 1000, 0, -1000, 1000 }, @@ -193,14 +192,14 @@ const ConstP rtConstP = { /* Pooled Parameter (Expression: vec_hallToPos) * Referenced by: * '/vec_hallToPos' - * '/vec_hallToPos' + * '/vec_hallToPos' */ { 0U, 5U, 3U, 4U, 1U, 0U, 2U, 0U }, /* Pooled Parameter (Expression: [0 1;1 0;0 1;0 1;1 0;1 0;0 0;0 0]) * Referenced by: - * '/Logic' - * '/Logic' + * '/Logic' + * '/Logic' */ { 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0 } }; diff --git a/01_Matlab/BLDC_controller_ert_rtw/buildInfo.mat b/01_Matlab/BLDC_controller_ert_rtw/buildInfo.mat index 65c6fe9..e4d7fe7 100644 Binary files a/01_Matlab/BLDC_controller_ert_rtw/buildInfo.mat and b/01_Matlab/BLDC_controller_ert_rtw/buildInfo.mat differ diff --git a/01_Matlab/BLDC_controller_ert_rtw/build_exception.mat b/01_Matlab/BLDC_controller_ert_rtw/build_exception.mat new file mode 100644 index 0000000..dbaacdc Binary files /dev/null and b/01_Matlab/BLDC_controller_ert_rtw/build_exception.mat differ diff --git a/01_Matlab/BLDC_controller_ert_rtw/codeInfo.mat b/01_Matlab/BLDC_controller_ert_rtw/codeInfo.mat index 32f1a99..c585fbe 100644 Binary files a/01_Matlab/BLDC_controller_ert_rtw/codeInfo.mat and b/01_Matlab/BLDC_controller_ert_rtw/codeInfo.mat differ diff --git a/01_Matlab/BLDC_controller_ert_rtw/codedescriptor.dmr b/01_Matlab/BLDC_controller_ert_rtw/codedescriptor.dmr index a7ec4aa..56cd3cc 100644 Binary files a/01_Matlab/BLDC_controller_ert_rtw/codedescriptor.dmr and b/01_Matlab/BLDC_controller_ert_rtw/codedescriptor.dmr differ diff --git a/01_Matlab/BLDC_controller_ert_rtw/ert_main.c b/01_Matlab/BLDC_controller_ert_rtw/ert_main.c index 64f939a..53238cd 100644 --- a/01_Matlab/BLDC_controller_ert_rtw/ert_main.c +++ b/01_Matlab/BLDC_controller_ert_rtw/ert_main.c @@ -7,9 +7,9 @@ * * Code generated for Simulink model 'BLDC_controller'. * - * Model version : 1.800 + * Model version : 1.817 * Simulink Coder version : 8.13 (R2017b) 24-Jul-2017 - * C/C++ source code generated on : Sat May 25 21:42:39 2019 + * C/C++ source code generated on : Tue May 28 19:55:33 2019 * * Target selection: ert.tlc * Embedded hardware selection: ARM Compatible->ARM Cortex diff --git a/01_Matlab/BLDC_controller_ert_rtw/html/BLDC_controller_c.html b/01_Matlab/BLDC_controller_ert_rtw/html/BLDC_controller_c.html index b0d6692..f491ff9 100644 --- a/01_Matlab/BLDC_controller_ert_rtw/html/BLDC_controller_c.html +++ b/01_Matlab/BLDC_controller_ert_rtw/html/BLDC_controller_c.html @@ -21,9 +21,9 @@ 7 * 8 * Code generated for Simulink model 'BLDC_controller'. 9 * - 10 * Model version : 1.800 + 10 * Model version : 1.817 11 * Simulink Coder version : 8.13 (R2017b) 24-Jul-2017 - 12 * C/C++ source code generated on : Sat May 25 21:42:39 2019 + 12 * C/C++ source code generated on : Tue May 28 19:55:33 2019 13 * 14 * Target selection: ert.tlc 15 * Embedded hardware selection: ARM Compatible->ARM Cortex @@ -122,23 +122,23 @@ 108 static void Edge_counter_Disable(uint8_T *rty_cnt, DW_Edge_counter *localDW); 109 static void Edge_counter(boolean_T rtu_Enable, boolean_T rtu_b_edge, int8_T 110 rtu_z_dir, int8_T rtu_z_dirPrev, uint8_T *rty_cnt, DW_Edge_counter *localDW); - 111 static void Moving_Average_Filter(boolean_T rtu_Trigger, int32_T rtu_n_motRaw, - 112 int32_T *rty_n_mot, DW_Moving_Average_Filter *localDW, - 113 ZCE_Moving_Average_Filter *localZCE); - 114 static void Raw_Speed_calculation(boolean_T rtu_Trigger, int16_T rtu_z_counter, - 115 int8_T rtu_z_dir, int32_T *rty_n_motRaw, ZCE_Raw_Speed_calculation *localZCE); - 116 static void F03_01_Pure_Trapezoidal_Method(int32_T rtu_a_elecAngleAdv, int16_T - 117 *rty_r_phaA_Trap, int16_T *rty_r_phaB_Trap, int16_T *rty_r_phaC_Trap); - 118 static void F03_02_Sinusoidal_Method(int32_T rtu_a_elecAngleAdv, int16_T - 119 *rty_r_phaA_Sin, int16_T *rty_r_phaB_Sin, int16_T *rty_r_phaC_Sin); - 120 static void F03_02_Sinusoidal3rd_Method(int32_T rtu_a_elecAngleAdv, int16_T - 121 *rty_r_phaA_Sin3, int16_T *rty_r_phaB_Sin3, int16_T *rty_r_phaC_Sin3); - 122 static void F02_Electrical_Angle_Ca_Disable(int32_T *rty_a_elecAngleAdv, int32_T - 123 *rty_a_elecAngle); - 124 static void F02_Electrical_Angle_Calculatio(int32_T rtu_r_DC, uint8_T rtu_z_pos, - 125 int8_T rtu_z_dir, int16_T rtu_z_counter, int16_T rtu_z_counterRaw, int32_T - 126 *rty_a_elecAngleAdv, int32_T *rty_a_elecAngle); - 127 static void rising_edge(void); + 111 static void Motor_Speed_Calculation(boolean_T rtu_Trigger, int16_T rtu_z_counter, + 112 int8_T rtu_z_dir, int32_T *rty_n_mot, DW_Motor_Speed_Calculation *localDW, + 113 ZCE_Motor_Speed_Calculation *localZCE); + 114 static void F03_01_Pure_Trapezoidal_Method(int32_T rtu_a_elecAngleAdv, int16_T + 115 *rty_r_phaA_Trap, int16_T *rty_r_phaB_Trap, int16_T *rty_r_phaC_Trap); + 116 static void F03_02_Sinusoidal_Method(int32_T rtu_a_elecAngleAdv, int16_T + 117 *rty_r_phaA_Sin, int16_T *rty_r_phaB_Sin, int16_T *rty_r_phaC_Sin); + 118 static void F03_02_Sinusoidal3rd_Method(int32_T rtu_a_elecAngleAdv, int16_T + 119 *rty_r_phaA_Sin3, int16_T *rty_r_phaB_Sin3, int16_T *rty_r_phaC_Sin3); + 120 static void F02_Electrical_Angle_Ca_Disable(int32_T *rty_a_elecAngleAdv, int32_T + 121 *rty_a_elecAngle); + 122 static void F02_Electrical_Angle_Calculatio(int32_T rtu_r_DC, uint8_T rtu_z_pos, + 123 int8_T rtu_z_dir, int16_T rtu_z_counter, int16_T rtu_z_counterRaw, int32_T + 124 *rty_a_elecAngleAdv, int32_T *rty_a_elecAngle); + 125 static void falling_edge2(void); + 126 static void rising_edge(void); + 127 static void falling_edge2_b(void); 128 static void rising_edge_f(void); 129 static uint8_T plook_u8s32u32n31_evenc_s(int32_T u, int32_T bp0, uint32_T 130 bpSpace, uint32_T maxIndex, uint32_T *fraction) @@ -199,7 +199,7 @@ 185 /* 186 * Output and update for enable system: 187 * '<S12>/F01_03_Direction_Detection' - 188 * '<S52>/F01_03_Direction_Detection' + 188 * '<S50>/F01_03_Direction_Detection' 189 */ 190 static void F01_03_Direction_Detection(boolean_T rtu_Enable, uint8_T rtu_z_pos, 191 uint8_T rtu_z_posPrev, int8_T *rty_z_dir, int8_T *rty_z_dirPrev, @@ -247,18 +247,18 @@ 233 /* 234 * System reset for enable system: 235 * '<S23>/Edge_counter' - 236 * '<S63>/Edge_counter' + 236 * '<S61>/Edge_counter' 237 */ 238 static void Edge_counter_Reset(DW_Edge_counter *localDW) 239 { - 240 /* InitializeConditions for UnitDelay: '<S38>/UnitDelay1' */ + 240 /* InitializeConditions for UnitDelay: '<S37>/UnitDelay1' */ 241 localDW->UnitDelay1_DSTATE = 0U; 242 } 243 244 /* 245 * Disable for enable system: 246 * '<S23>/Edge_counter' - 247 * '<S63>/Edge_counter' + 247 * '<S61>/Edge_counter' 248 */ 249 static void Edge_counter_Disable(uint8_T *rty_cnt, DW_Edge_counter *localDW) 250 { @@ -275,7 +275,7 @@ 261 /* 262 * Output and update for enable system: 263 * '<S23>/Edge_counter' - 264 * '<S63>/Edge_counter' + 264 * '<S61>/Edge_counter' 265 */ 266 static void Edge_counter(boolean_T rtu_Enable, boolean_T rtu_b_edge, int8_T 267 rtu_z_dir, int8_T rtu_z_dirPrev, uint8_T *rty_cnt, DW_Edge_counter *localDW) @@ -295,10 +295,10 @@ 281 /* RelationalOperator: '<S27>/Relational Operator1' */ 282 rtb_RelationalOperator1_i = (rtu_z_dir == rtu_z_dirPrev); 283 - 284 /* Switch: '<S38>/Switch1' incorporates: - 285 * Constant: '<S38>/Constant23' + 284 /* Switch: '<S37>/Switch1' incorporates: + 285 * Constant: '<S37>/Constant23' 286 * Logic: '<S27>/Logical Operator2' - 287 * UnitDelay: '<S38>/UnitDelay1' + 287 * UnitDelay: '<S37>/UnitDelay1' 288 */ 289 if (!rtb_RelationalOperator1_i) { 290 rtb_RelationalOperator1_m1 = 0U; @@ -306,7 +306,7 @@ 292 rtb_RelationalOperator1_m1 = localDW->UnitDelay1_DSTATE; 293 } 294 - 295 /* End of Switch: '<S38>/Switch1' */ + 295 /* End of Switch: '<S37>/Switch1' */ 296 297 /* Sum: '<S27>/Sum2' incorporates: 298 * Logic: '<S27>/Logical Operator1' @@ -314,7 +314,7 @@ 300 *rty_cnt = (uint8_T)((uint32_T)(rtu_b_edge && rtb_RelationalOperator1_i) + 301 rtb_RelationalOperator1_m1); 302 - 303 /* Update for UnitDelay: '<S38>/UnitDelay1' */ + 303 /* Update for UnitDelay: '<S37>/UnitDelay1' */ 304 localDW->UnitDelay1_DSTATE = *rty_cnt; 305 } else { 306 if (localDW->Edge_counter_MODE) { @@ -327,409 +327,409 @@ 313 314 /* 315 * Output and update for trigger system: - 316 * '<S23>/Moving_Average_Filter' - 317 * '<S63>/Moving_Average_Filter' + 316 * '<S23>/Motor_Speed_Calculation' + 317 * '<S61>/Motor_Speed_Calculation' 318 */ - 319 static void Moving_Average_Filter(boolean_T rtu_Trigger, int32_T rtu_n_motRaw, - 320 int32_T *rty_n_mot, DW_Moving_Average_Filter *localDW, - 321 ZCE_Moving_Average_Filter *localZCE) + 319 static void Motor_Speed_Calculation(boolean_T rtu_Trigger, int16_T rtu_z_counter, + 320 int8_T rtu_z_dir, int32_T *rty_n_mot, DW_Motor_Speed_Calculation *localDW, + 321 ZCE_Motor_Speed_Calculation *localZCE) 322 { - 323 int32_T rtb_UnitDelay1_f; + 323 int32_T rtb_Sum2; 324 - 325 /* Outputs for Triggered SubSystem: '<S23>/Moving_Average_Filter' incorporates: - 326 * TriggerPort: '<S28>/Trigger' + 325 /* Outputs for Triggered SubSystem: '<S23>/Motor_Speed_Calculation' incorporates: + 326 * TriggerPort: '<S28>/Trigger' 327 */ - 328 if (rtu_Trigger && (localZCE->Moving_Average_Filter_Trig_ZCE != POS_ZCSIG)) { - 329 /* UnitDelay: '<S28>/UnitDelay1' */ - 330 rtb_UnitDelay1_f = localDW->UnitDelay1_DSTATE; - 331 - 332 /* Product: '<S28>/Divide4' incorporates: - 333 * Constant: '<S28>/Constant1' - 334 * Sum: '<S28>/Sum2' - 335 * UnitDelay: '<S28>/UnitDelay5' - 336 */ - 337 *rty_n_mot = ((localDW->UnitDelay5_DSTATE + rtb_UnitDelay1_f) + rtu_n_motRaw) - 338 / 3; - 339 - 340 /* Update for UnitDelay: '<S28>/UnitDelay5' */ - 341 localDW->UnitDelay5_DSTATE = rtb_UnitDelay1_f; - 342 - 343 /* Update for UnitDelay: '<S28>/UnitDelay1' */ - 344 localDW->UnitDelay1_DSTATE = rtu_n_motRaw; - 345 } + 328 if (rtu_Trigger && (localZCE->Motor_Speed_Calculation_Trig_ZC != POS_ZCSIG)) { + 329 /* Switch: '<S28>/Switch' incorporates: + 330 * Constant: '<S28>/Constant1' + 331 * Constant: '<S28>/cf_spdCoef' + 332 * Constant: '<S28>/z_maxCntRst' + 333 * Product: '<S28>/Divide4' + 334 * RelationalOperator: '<S28>/Relational Operator1' + 335 */ + 336 if (rtu_z_counter >= rtP.z_maxCntRst) { + 337 rtb_Sum2 = 0; + 338 } else { + 339 rtb_Sum2 = rtP.cf_speedCoef / rtu_z_counter; + 340 } + 341 + 342 /* End of Switch: '<S28>/Switch' */ + 343 + 344 /* Product: '<S28>/Product2' */ + 345 rtb_Sum2 *= rtu_z_dir; 346 - 347 localZCE->Moving_Average_Filter_Trig_ZCE = rtu_Trigger; - 348 - 349 /* End of Outputs for SubSystem: '<S23>/Moving_Average_Filter' */ - 350 } - 351 - 352 /* - 353 * Output and update for trigger system: - 354 * '<S23>/Raw_ Speed_calculation' - 355 * '<S63>/Raw_ Speed_calculation' - 356 */ - 357 static void Raw_Speed_calculation(boolean_T rtu_Trigger, int16_T rtu_z_counter, - 358 int8_T rtu_z_dir, int32_T *rty_n_motRaw, ZCE_Raw_Speed_calculation *localZCE) - 359 { - 360 int32_T rtb_Switch_p; - 361 - 362 /* Outputs for Triggered SubSystem: '<S23>/Raw_ Speed_calculation' incorporates: - 363 * TriggerPort: '<S29>/Trigger' - 364 */ - 365 if (rtu_Trigger && (localZCE->Raw_Speed_calculation_Trig_ZCE != POS_ZCSIG)) { - 366 /* Switch: '<S29>/Switch' incorporates: - 367 * Constant: '<S29>/Constant1' - 368 * Constant: '<S29>/cf_spdCoef' - 369 * Constant: '<S29>/z_maxCntRst' - 370 * Product: '<S29>/Divide4' - 371 * RelationalOperator: '<S29>/Relational Operator1' - 372 */ - 373 if (rtu_z_counter > rtP.z_maxCntRst) { - 374 rtb_Switch_p = 0; - 375 } else { - 376 rtb_Switch_p = rtP.cf_spdCoef / rtu_z_counter; - 377 } + 347 /* Product: '<S28>/Divide1' incorporates: + 348 * Constant: '<S28>/Constant2' + 349 * Sum: '<S28>/Sum2' + 350 * UnitDelay: '<S28>/UnitDelay1' + 351 * UnitDelay: '<S28>/UnitDelay5' + 352 */ + 353 *rty_n_mot = ((localDW->UnitDelay5_DSTATE + localDW->UnitDelay1_DSTATE) + + 354 rtb_Sum2) / 3; + 355 + 356 /* Update for UnitDelay: '<S28>/UnitDelay5' incorporates: + 357 * UnitDelay: '<S28>/UnitDelay1' + 358 */ + 359 localDW->UnitDelay5_DSTATE = localDW->UnitDelay1_DSTATE; + 360 + 361 /* Update for UnitDelay: '<S28>/UnitDelay1' */ + 362 localDW->UnitDelay1_DSTATE = rtb_Sum2; + 363 } + 364 + 365 localZCE->Motor_Speed_Calculation_Trig_ZC = rtu_Trigger; + 366 + 367 /* End of Outputs for SubSystem: '<S23>/Motor_Speed_Calculation' */ + 368 } + 369 + 370 /* Output and update for atomic system: '<S23>/falling_edge2' */ + 371 static void falling_edge2(void) + 372 { + 373 /* Logic: '<S30>/Logical Operator' incorporates: + 374 * Logic: '<S30>/Logical Operator1' + 375 * UnitDelay: '<S30>/UnitDelay' + 376 */ + 377 rtDW.LogicalOperator = ((!rtDW.Logic[0]) && rtDW.UnitDelay_DSTATE_b); 378 - 379 /* End of Switch: '<S29>/Switch' */ - 380 - 381 /* Product: '<S29>/Product2' */ - 382 *rty_n_motRaw = rtb_Switch_p * rtu_z_dir; - 383 } - 384 - 385 localZCE->Raw_Speed_calculation_Trig_ZCE = rtu_Trigger; - 386 - 387 /* End of Outputs for SubSystem: '<S23>/Raw_ Speed_calculation' */ - 388 } - 389 - 390 /* Output and update for atomic system: '<S23>/rising_edge' */ - 391 static void rising_edge(void) - 392 { - 393 /* Logic: '<S31>/Logical Operator' incorporates: - 394 * Logic: '<S31>/Logical Operator1' - 395 * UnitDelay: '<S31>/UnitDelay' - 396 */ - 397 rtDW.LogicalOperator = (rtDW.RelationalOperator4 && (!rtDW.UnitDelay_DSTATE_l)); - 398 - 399 /* Update for UnitDelay: '<S31>/UnitDelay' */ - 400 rtDW.UnitDelay_DSTATE_l = rtDW.RelationalOperator4; - 401 } - 402 - 403 /* - 404 * Output and update for action system: - 405 * '<S14>/F03_01_Pure_Trapezoidal_Method' - 406 * '<S54>/F03_01_Pure_Trapezoidal_Method' - 407 */ - 408 static void F03_01_Pure_Trapezoidal_Method(int32_T rtu_a_elecAngleAdv, int16_T - 409 *rty_r_phaA_Trap, int16_T *rty_r_phaB_Trap, int16_T *rty_r_phaC_Trap) - 410 { - 411 uint8_T rtb_a_trapElecAngle_XA_o1; - 412 uint32_T rtb_a_trapElecAngle_XA_o2; - 413 - 414 /* PreLookup: '<S43>/a_trapElecAngle_XA' */ - 415 rtb_a_trapElecAngle_XA_o1 = plook_u8s32u32n31_evenc_s(rtu_a_elecAngleAdv, 0, - 416 60U, 6U, &rtb_a_trapElecAngle_XA_o2); - 417 - 418 /* Interpolation_n-D: '<S43>/r_trapPhaA_M1' */ - 419 *rty_r_phaA_Trap = intrp1d_s16s32s32u8u32n31l_s(rtb_a_trapElecAngle_XA_o1, - 420 rtb_a_trapElecAngle_XA_o2, rtConstP.pooled8); - 421 - 422 /* Interpolation_n-D: '<S43>/r_trapPhaB_M1' */ - 423 *rty_r_phaB_Trap = intrp1d_s16s32s32u8u32n31l_s(rtb_a_trapElecAngle_XA_o1, - 424 rtb_a_trapElecAngle_XA_o2, rtConstP.pooled9); - 425 - 426 /* Interpolation_n-D: '<S43>/r_trapPhaC_M1' */ - 427 *rty_r_phaC_Trap = intrp1d_s16s32s32u8u32n31l_s(rtb_a_trapElecAngle_XA_o1, - 428 rtb_a_trapElecAngle_XA_o2, rtConstP.pooled10); - 429 } - 430 - 431 /* - 432 * Output and update for action system: - 433 * '<S14>/F03_02_Sinusoidal_Method' - 434 * '<S54>/F03_02_Sinusoidal_Method' - 435 */ - 436 static void F03_02_Sinusoidal_Method(int32_T rtu_a_elecAngleAdv, int16_T - 437 *rty_r_phaA_Sin, int16_T *rty_r_phaB_Sin, int16_T *rty_r_phaC_Sin) - 438 { - 439 uint8_T rtb_a_sinElecAngle_XA_o1; - 440 uint32_T rtb_a_sinElecAngle_XA_o2; - 441 - 442 /* PreLookup: '<S45>/a_sinElecAngle_XA' */ - 443 rtb_a_sinElecAngle_XA_o1 = plook_u8s32u32n31_evenc_s(rtu_a_elecAngleAdv, 0, - 444 10U, 36U, &rtb_a_sinElecAngle_XA_o2); - 445 - 446 /* Interpolation_n-D: '<S45>/r_sinPhaA_M1' */ - 447 *rty_r_phaA_Sin = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, - 448 rtb_a_sinElecAngle_XA_o2, rtConstP.pooled11); - 449 - 450 /* Interpolation_n-D: '<S45>/r_sinPhaB_M1' */ - 451 *rty_r_phaB_Sin = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, - 452 rtb_a_sinElecAngle_XA_o2, rtConstP.pooled12); - 453 - 454 /* Interpolation_n-D: '<S45>/r_sinPhaC_M1' */ - 455 *rty_r_phaC_Sin = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, - 456 rtb_a_sinElecAngle_XA_o2, rtConstP.pooled13); - 457 } - 458 - 459 /* - 460 * Output and update for action system: - 461 * '<S14>/F03_02_Sinusoidal3rd_Method' - 462 * '<S54>/F03_02_Sinusoidal3rd_Method' - 463 */ - 464 static void F03_02_Sinusoidal3rd_Method(int32_T rtu_a_elecAngleAdv, int16_T - 465 *rty_r_phaA_Sin3, int16_T *rty_r_phaB_Sin3, int16_T *rty_r_phaC_Sin3) - 466 { - 467 uint8_T rtb_a_sinElecAngle_XA_o1; - 468 uint32_T rtb_a_sinElecAngle_XA_o2; - 469 - 470 /* PreLookup: '<S44>/a_sinElecAngle_XA' */ - 471 rtb_a_sinElecAngle_XA_o1 = plook_u8s32u32n31_evenc_s(rtu_a_elecAngleAdv, 0, - 472 10U, 36U, &rtb_a_sinElecAngle_XA_o2); - 473 - 474 /* Interpolation_n-D: '<S44>/r_sin3PhaA_M1' */ - 475 *rty_r_phaA_Sin3 = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, - 476 rtb_a_sinElecAngle_XA_o2, rtConstP.pooled14); - 477 - 478 /* Interpolation_n-D: '<S44>/r_sin3PhaB_M1' */ - 479 *rty_r_phaB_Sin3 = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, - 480 rtb_a_sinElecAngle_XA_o2, rtConstP.pooled15); - 481 - 482 /* Interpolation_n-D: '<S44>/r_sin3PhaC_M1' */ - 483 *rty_r_phaC_Sin3 = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, - 484 rtb_a_sinElecAngle_XA_o2, rtConstP.pooled16); - 485 } - 486 - 487 /* - 488 * Disable for action system: - 489 * '<S2>/F02_Electrical_Angle_Calculation' - 490 * '<S3>/F02_Electrical_Angle_Calculation' - 491 */ - 492 static void F02_Electrical_Angle_Ca_Disable(int32_T *rty_a_elecAngleAdv, int32_T - 493 *rty_a_elecAngle) - 494 { - 495 /* Disable for Outport: '<S13>/a_elecAngleAdv' */ - 496 *rty_a_elecAngleAdv = 0; - 497 - 498 /* Disable for Outport: '<S13>/a_elecAngle' */ - 499 *rty_a_elecAngle = 0; - 500 } - 501 - 502 /* - 503 * Output and update for action system: - 504 * '<S2>/F02_Electrical_Angle_Calculation' - 505 * '<S3>/F02_Electrical_Angle_Calculation' - 506 */ - 507 static void F02_Electrical_Angle_Calculatio(int32_T rtu_r_DC, uint8_T rtu_z_pos, - 508 int8_T rtu_z_dir, int16_T rtu_z_counter, int16_T rtu_z_counterRaw, int32_T - 509 *rty_a_elecAngleAdv, int32_T *rty_a_elecAngle) - 510 { - 511 uint8_T rtb_Switch3; - 512 int32_T rtb_Sum3_e; - 513 int16_T rtb_a_phaAdv_M2; - 514 uint32_T rtb_r_phaAdvDC_XA_o2; - 515 - 516 /* Switch: '<S13>/Switch3' incorporates: - 517 * Constant: '<S13>/Constant16' - 518 * RelationalOperator: '<S13>/Relational Operator7' - 519 * Sum: '<S13>/Sum1' - 520 */ - 521 if (rtu_z_dir == 1) { - 522 rtb_Switch3 = rtu_z_pos; - 523 } else { - 524 rtb_Switch3 = (uint8_T)(rtu_z_pos + 1U); - 525 } - 526 - 527 /* End of Switch: '<S13>/Switch3' */ - 528 - 529 /* Sum: '<S13>/Sum2' incorporates: - 530 * Product: '<S13>/Divide4' - 531 * Product: '<S13>/Divide5' - 532 * Product: '<S13>/Product6' - 533 */ - 534 *rty_a_elecAngle = 60 * rtu_z_counterRaw / rtu_z_counter * rtu_z_dir + - 535 rtb_Switch3 * 60; - 536 - 537 /* Switch: '<S13>/Switch_PhaAdv' incorporates: - 538 * Constant: '<S13>/a_elecPeriod1' - 539 * Constant: '<S13>/a_elecPeriod2' - 540 * Product: '<S39>/Divide2' - 541 * Product: '<S39>/Divide3' - 542 * Sum: '<S39>/Sum3' - 543 */ - 544 if (rtP.b_phaAdvEna) { - 545 /* Abs: '<S13>/Abs2' */ - 546 if (rtu_r_DC < 0) { - 547 rtb_Sum3_e = -rtu_r_DC; - 548 } else { - 549 rtb_Sum3_e = rtu_r_DC; - 550 } - 551 - 552 /* End of Abs: '<S13>/Abs2' */ + 379 /* Update for UnitDelay: '<S30>/UnitDelay' */ + 380 rtDW.UnitDelay_DSTATE_b = rtDW.Logic[0]; + 381 } + 382 + 383 /* Output and update for atomic system: '<S23>/rising_edge' */ + 384 static void rising_edge(void) + 385 { + 386 /* Logic: '<S31>/Logical Operator' incorporates: + 387 * Logic: '<S31>/Logical Operator1' + 388 * UnitDelay: '<S31>/UnitDelay' + 389 */ + 390 rtDW.LogicalOperator_h = (rtDW.LogicalOperator5 && (!rtDW.UnitDelay_DSTATE_l)); + 391 + 392 /* Update for UnitDelay: '<S31>/UnitDelay' */ + 393 rtDW.UnitDelay_DSTATE_l = rtDW.LogicalOperator5; + 394 } + 395 + 396 /* + 397 * Output and update for action system: + 398 * '<S14>/F03_01_Pure_Trapezoidal_Method' + 399 * '<S52>/F03_01_Pure_Trapezoidal_Method' + 400 */ + 401 static void F03_01_Pure_Trapezoidal_Method(int32_T rtu_a_elecAngleAdv, int16_T + 402 *rty_r_phaA_Trap, int16_T *rty_r_phaB_Trap, int16_T *rty_r_phaC_Trap) + 403 { + 404 uint8_T rtb_a_trapElecAngle_XA_o1; + 405 uint32_T rtb_a_trapElecAngle_XA_o2; + 406 + 407 /* PreLookup: '<S41>/a_trapElecAngle_XA' */ + 408 rtb_a_trapElecAngle_XA_o1 = plook_u8s32u32n31_evenc_s(rtu_a_elecAngleAdv, 0, + 409 60U, 6U, &rtb_a_trapElecAngle_XA_o2); + 410 + 411 /* Interpolation_n-D: '<S41>/r_trapPhaA_M1' */ + 412 *rty_r_phaA_Trap = intrp1d_s16s32s32u8u32n31l_s(rtb_a_trapElecAngle_XA_o1, + 413 rtb_a_trapElecAngle_XA_o2, rtConstP.pooled9); + 414 + 415 /* Interpolation_n-D: '<S41>/r_trapPhaB_M1' */ + 416 *rty_r_phaB_Trap = intrp1d_s16s32s32u8u32n31l_s(rtb_a_trapElecAngle_XA_o1, + 417 rtb_a_trapElecAngle_XA_o2, rtConstP.pooled10); + 418 + 419 /* Interpolation_n-D: '<S41>/r_trapPhaC_M1' */ + 420 *rty_r_phaC_Trap = intrp1d_s16s32s32u8u32n31l_s(rtb_a_trapElecAngle_XA_o1, + 421 rtb_a_trapElecAngle_XA_o2, rtConstP.pooled11); + 422 } + 423 + 424 /* + 425 * Output and update for action system: + 426 * '<S14>/F03_02_Sinusoidal_Method' + 427 * '<S52>/F03_02_Sinusoidal_Method' + 428 */ + 429 static void F03_02_Sinusoidal_Method(int32_T rtu_a_elecAngleAdv, int16_T + 430 *rty_r_phaA_Sin, int16_T *rty_r_phaB_Sin, int16_T *rty_r_phaC_Sin) + 431 { + 432 uint8_T rtb_a_sinElecAngle_XA_o1; + 433 uint32_T rtb_a_sinElecAngle_XA_o2; + 434 + 435 /* PreLookup: '<S43>/a_sinElecAngle_XA' */ + 436 rtb_a_sinElecAngle_XA_o1 = plook_u8s32u32n31_evenc_s(rtu_a_elecAngleAdv, 0, + 437 10U, 36U, &rtb_a_sinElecAngle_XA_o2); + 438 + 439 /* Interpolation_n-D: '<S43>/r_sinPhaA_M1' */ + 440 *rty_r_phaA_Sin = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, + 441 rtb_a_sinElecAngle_XA_o2, rtConstP.pooled12); + 442 + 443 /* Interpolation_n-D: '<S43>/r_sinPhaB_M1' */ + 444 *rty_r_phaB_Sin = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, + 445 rtb_a_sinElecAngle_XA_o2, rtConstP.pooled13); + 446 + 447 /* Interpolation_n-D: '<S43>/r_sinPhaC_M1' */ + 448 *rty_r_phaC_Sin = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, + 449 rtb_a_sinElecAngle_XA_o2, rtConstP.pooled14); + 450 } + 451 + 452 /* + 453 * Output and update for action system: + 454 * '<S14>/F03_02_Sinusoidal3rd_Method' + 455 * '<S52>/F03_02_Sinusoidal3rd_Method' + 456 */ + 457 static void F03_02_Sinusoidal3rd_Method(int32_T rtu_a_elecAngleAdv, int16_T + 458 *rty_r_phaA_Sin3, int16_T *rty_r_phaB_Sin3, int16_T *rty_r_phaC_Sin3) + 459 { + 460 uint8_T rtb_a_sinElecAngle_XA_o1; + 461 uint32_T rtb_a_sinElecAngle_XA_o2; + 462 + 463 /* PreLookup: '<S42>/a_sinElecAngle_XA' */ + 464 rtb_a_sinElecAngle_XA_o1 = plook_u8s32u32n31_evenc_s(rtu_a_elecAngleAdv, 0, + 465 10U, 36U, &rtb_a_sinElecAngle_XA_o2); + 466 + 467 /* Interpolation_n-D: '<S42>/r_sin3PhaA_M1' */ + 468 *rty_r_phaA_Sin3 = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, + 469 rtb_a_sinElecAngle_XA_o2, rtConstP.pooled15); + 470 + 471 /* Interpolation_n-D: '<S42>/r_sin3PhaB_M1' */ + 472 *rty_r_phaB_Sin3 = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, + 473 rtb_a_sinElecAngle_XA_o2, rtConstP.pooled16); + 474 + 475 /* Interpolation_n-D: '<S42>/r_sin3PhaC_M1' */ + 476 *rty_r_phaC_Sin3 = intrp1d_s16s32s32u8u32n31l_s(rtb_a_sinElecAngle_XA_o1, + 477 rtb_a_sinElecAngle_XA_o2, rtConstP.pooled17); + 478 } + 479 + 480 /* + 481 * Disable for action system: + 482 * '<S2>/F02_Electrical_Angle_Calculation' + 483 * '<S3>/F02_Electrical_Angle_Calculation' + 484 */ + 485 static void F02_Electrical_Angle_Ca_Disable(int32_T *rty_a_elecAngleAdv, int32_T + 486 *rty_a_elecAngle) + 487 { + 488 /* Disable for Outport: '<S13>/a_elecAngleAdv' */ + 489 *rty_a_elecAngleAdv = 0; + 490 + 491 /* Disable for Outport: '<S13>/a_elecAngle' */ + 492 *rty_a_elecAngle = 0; + 493 } + 494 + 495 /* + 496 * Output and update for action system: + 497 * '<S2>/F02_Electrical_Angle_Calculation' + 498 * '<S3>/F02_Electrical_Angle_Calculation' + 499 */ + 500 static void F02_Electrical_Angle_Calculatio(int32_T rtu_r_DC, uint8_T rtu_z_pos, + 501 int8_T rtu_z_dir, int16_T rtu_z_counter, int16_T rtu_z_counterRaw, int32_T + 502 *rty_a_elecAngleAdv, int32_T *rty_a_elecAngle) + 503 { + 504 uint8_T rtb_Switch3; + 505 int16_T rtb_a_phaAdv_M2; + 506 uint32_T rtb_r_phaAdvDC_XA_o2; + 507 int32_T rtu_r_DC_0; + 508 + 509 /* Switch: '<S13>/Switch3' incorporates: + 510 * Constant: '<S13>/Constant16' + 511 * RelationalOperator: '<S13>/Relational Operator7' + 512 * Sum: '<S13>/Sum1' + 513 */ + 514 if (rtu_z_dir == 1) { + 515 rtb_Switch3 = rtu_z_pos; + 516 } else { + 517 rtb_Switch3 = (uint8_T)(rtu_z_pos + 1U); + 518 } + 519 + 520 /* End of Switch: '<S13>/Switch3' */ + 521 + 522 /* Sum: '<S13>/Sum2' incorporates: + 523 * Constant: '<S13>/a_elecAngle1' + 524 * Product: '<S13>/Divide4' + 525 * Product: '<S13>/Divide5' + 526 * Product: '<S13>/Product6' + 527 */ + 528 *rty_a_elecAngle = 60 * rtu_z_counterRaw / rtu_z_counter * rtu_z_dir + + 529 rtb_Switch3 * 60; + 530 + 531 /* Switch: '<S13>/Switch_PhaAdv' incorporates: + 532 * Constant: '<S13>/a_elecPeriod1' + 533 * Math: '<S13>/Math Function' + 534 */ + 535 if (rtP.b_phaAdvEna) { + 536 /* Abs: '<S13>/Abs2' */ + 537 if (rtu_r_DC < 0) { + 538 rtu_r_DC_0 = -rtu_r_DC; + 539 } else { + 540 rtu_r_DC_0 = rtu_r_DC; + 541 } + 542 + 543 /* End of Abs: '<S13>/Abs2' */ + 544 + 545 /* PreLookup: '<S13>/r_phaAdvDC_XA' */ + 546 rtb_Switch3 = plook_u8s32u32n31_evenc_s(rtu_r_DC_0, rtP.r_phaAdvDC_XA[0], + 547 (uint32_T)rtP.r_phaAdvDC_XA[1] - rtP.r_phaAdvDC_XA[0], 10U, + 548 &rtb_r_phaAdvDC_XA_o2); + 549 + 550 /* Interpolation_n-D: '<S13>/a_phaAdv_M2' */ + 551 rtb_a_phaAdv_M2 = intrp1d_s16s32s32u8u32n31l_s(rtb_Switch3, + 552 rtb_r_phaAdvDC_XA_o2, rtP.a_phaAdv_M1); 553 - 554 /* PreLookup: '<S13>/r_phaAdvDC_XA' */ - 555 rtb_Switch3 = plook_u8s32u32n31_evenc_s(rtb_Sum3_e, rtP.r_phaAdvDC_XA[0], - 556 (uint32_T)rtP.r_phaAdvDC_XA[1] - rtP.r_phaAdvDC_XA[0], 10U, - 557 &rtb_r_phaAdvDC_XA_o2); - 558 - 559 /* Interpolation_n-D: '<S13>/a_phaAdv_M2' */ - 560 rtb_a_phaAdv_M2 = intrp1d_s16s32s32u8u32n31l_s(rtb_Switch3, - 561 rtb_r_phaAdvDC_XA_o2, rtP.a_phaAdv_M1); + 554 /* Sum: '<S13>/Sum3' incorporates: + 555 * Product: '<S13>/Product2' + 556 */ + 557 rtu_r_DC_0 = rtu_z_dir * rtb_a_phaAdv_M2 + *rty_a_elecAngle; + 558 *rty_a_elecAngleAdv = rtu_r_DC_0 - div_nde_s32_floor(rtu_r_DC_0, 360) * 360; + 559 } else { + 560 *rty_a_elecAngleAdv = *rty_a_elecAngle; + 561 } 562 - 563 /* Sum: '<S13>/Sum3' incorporates: - 564 * Product: '<S13>/Product2' - 565 */ - 566 rtb_Sum3_e = rtu_z_dir * rtb_a_phaAdv_M2 + *rty_a_elecAngle; - 567 *rty_a_elecAngleAdv = rtb_Sum3_e - div_nde_s32_floor(rtb_Sum3_e, 360) * 360; - 568 } else { - 569 *rty_a_elecAngleAdv = *rty_a_elecAngle; - 570 } - 571 - 572 /* End of Switch: '<S13>/Switch_PhaAdv' */ - 573 } + 563 /* End of Switch: '<S13>/Switch_PhaAdv' */ + 564 } + 565 + 566 /* Output and update for atomic system: '<S61>/falling_edge2' */ + 567 static void falling_edge2_b(void) + 568 { + 569 /* Logic: '<S68>/Logical Operator' incorporates: + 570 * Logic: '<S68>/Logical Operator1' + 571 * UnitDelay: '<S68>/UnitDelay' + 572 */ + 573 rtDW.LogicalOperator_h = ((!rtDW.Logic_j[0]) && rtDW.UnitDelay_DSTATE_i); 574 - 575 /* Output and update for atomic system: '<S63>/rising_edge' */ - 576 static void rising_edge_f(void) - 577 { - 578 /* Logic: '<S71>/Logical Operator' incorporates: - 579 * Logic: '<S71>/Logical Operator1' - 580 * UnitDelay: '<S71>/UnitDelay' - 581 */ - 582 rtDW.LogicalOperator = (rtDW.RelationalOperator4 && (!rtDW.UnitDelay_DSTATE_k)); - 583 - 584 /* Update for UnitDelay: '<S71>/UnitDelay' */ - 585 rtDW.UnitDelay_DSTATE_k = rtDW.RelationalOperator4; - 586 } + 575 /* Update for UnitDelay: '<S68>/UnitDelay' */ + 576 rtDW.UnitDelay_DSTATE_i = rtDW.Logic_j[0]; + 577 } + 578 + 579 /* Output and update for atomic system: '<S61>/rising_edge' */ + 580 static void rising_edge_f(void) + 581 { + 582 /* Logic: '<S69>/Logical Operator' incorporates: + 583 * Logic: '<S69>/Logical Operator1' + 584 * UnitDelay: '<S69>/UnitDelay' + 585 */ + 586 rtDW.LogicalOperator_h = (rtDW.LogicalOperator5 && (!rtDW.UnitDelay_DSTATE_k)); 587 - 588 /* Model step function */ - 589 void BLDC_controller_step(void) - 590 { - 591 int32_T rowIdx; - 592 uint8_T rtb_Sum; - 593 boolean_T rtb_LogicalOperator; - 594 boolean_T rtb_LogicalOperator3; - 595 int32_T rtb_Abs1; - 596 int8_T rtPrevAction; - 597 int8_T rtAction; - 598 uint8_T rtb_Sum_a; - 599 int16_T rtb_Switch; - 600 int16_T rtb_Switch_b; - 601 int16_T rtb_Sum1; - 602 int16_T rtb_Sum1_c; - 603 int32_T rtb_Switch1_idx_0; - 604 int32_T rtb_Switch1_idx_1; - 605 boolean_T rtb_Logic_idx_0; - 606 uint8_T tmp; - 607 - 608 /* Outputs for Atomic SubSystem: '<Root>/BLDC_controller' */ - 609 /* Sum: '<S21>/Sum' incorporates: - 610 * Gain: '<S21>/g_Ha' - 611 * Gain: '<S21>/g_Hb' - 612 * Inport: '<Root>/b_hallALeft ' - 613 * Inport: '<Root>/b_hallBLeft' - 614 * Inport: '<Root>/b_hallCLeft' - 615 */ - 616 rtb_Sum = (uint8_T)((uint32_T)(uint8_T)((uint32_T)(uint8_T)(rtU.b_hallALeft << - 617 2) + (uint8_T)(rtU.b_hallBLeft << 1)) + rtU.b_hallCLeft); - 618 - 619 /* Logic: '<S20>/Logical Operator' incorporates: - 620 * Inport: '<Root>/b_hallALeft ' - 621 * Inport: '<Root>/b_hallBLeft' - 622 * Inport: '<Root>/b_hallCLeft' - 623 * UnitDelay: '<S20>/UnitDelay' - 624 * UnitDelay: '<S20>/UnitDelay1' - 625 * UnitDelay: '<S20>/UnitDelay2' - 626 */ - 627 rtb_LogicalOperator = (boolean_T)((rtU.b_hallALeft != 0) ^ (rtU.b_hallBLeft != - 628 0) ^ (rtU.b_hallCLeft != 0) ^ (rtDW.UnitDelay_DSTATE != 0) ^ - 629 (rtDW.UnitDelay1_DSTATE_p != 0)) ^ (rtDW.UnitDelay2_DSTATE != 0); - 630 - 631 /* Logic: '<S23>/Logical Operator3' incorporates: - 632 * Constant: '<S23>/z_maxCntRst' - 633 * RelationalOperator: '<S23>/Relational Operator1' - 634 * UnitDelay: '<S23>/z_counterRawPrev' - 635 */ - 636 rtb_LogicalOperator3 = (rtb_LogicalOperator || (rtDW.z_counterRawPrev_DSTATE > - 637 rtP.z_maxCntRst)); - 638 - 639 /* Outputs for Enabled SubSystem: '<S12>/F01_03_Direction_Detection' */ - 640 - 641 /* Selector: '<S21>/Selector' incorporates: - 642 * Constant: '<S21>/vec_hallToPos' - 643 * UnitDelay: '<S21>/UnitDelay1' - 644 */ - 645 F01_03_Direction_Detection(rtb_LogicalOperator, rtConstP.pooled27[rtb_Sum], - 646 rtDW.UnitDelay1_DSTATE_g, &rtDW.Switch2_e, &rtDW.UnitDelay1_k, - 647 &rtDW.F01_03_Direction_Detection_o); - 648 - 649 /* End of Outputs for SubSystem: '<S12>/F01_03_Direction_Detection' */ - 650 - 651 /* Outputs for Enabled SubSystem: '<S23>/Edge_counter' */ + 588 /* Update for UnitDelay: '<S69>/UnitDelay' */ + 589 rtDW.UnitDelay_DSTATE_k = rtDW.LogicalOperator5; + 590 } + 591 + 592 /* Model step function */ + 593 void BLDC_controller_step(void) + 594 { + 595 uint8_T rtb_Sum; + 596 boolean_T rtb_LogicalOperator; + 597 boolean_T rtb_LogicalOperator3; + 598 int32_T rtb_Abs1; + 599 int8_T rtPrevAction; + 600 int8_T rtAction; + 601 uint8_T rtb_Sum_a; + 602 int16_T rtb_Switch; + 603 int16_T rtb_Switch_b; + 604 int16_T rtb_Sum1; + 605 int16_T rtb_Sum1_c; + 606 int32_T rtb_Switch1_idx_0; + 607 int32_T rtb_Switch1_idx_1; + 608 uint8_T tmp; + 609 + 610 /* Outputs for Atomic SubSystem: '<Root>/BLDC_controller' */ + 611 /* Sum: '<S21>/Sum' incorporates: + 612 * Gain: '<S21>/g_Ha' + 613 * Gain: '<S21>/g_Hb' + 614 * Inport: '<Root>/b_hallALeft ' + 615 * Inport: '<Root>/b_hallBLeft' + 616 * Inport: '<Root>/b_hallCLeft' + 617 */ + 618 rtb_Sum = (uint8_T)((uint32_T)(uint8_T)((uint32_T)(uint8_T)(rtU.b_hallALeft << + 619 2) + (uint8_T)(rtU.b_hallBLeft << 1)) + rtU.b_hallCLeft); + 620 + 621 /* Logic: '<S20>/Logical Operator' incorporates: + 622 * Inport: '<Root>/b_hallALeft ' + 623 * Inport: '<Root>/b_hallBLeft' + 624 * Inport: '<Root>/b_hallCLeft' + 625 * UnitDelay: '<S20>/UnitDelay' + 626 * UnitDelay: '<S20>/UnitDelay1' + 627 * UnitDelay: '<S20>/UnitDelay2' + 628 */ + 629 rtb_LogicalOperator = (boolean_T)((rtU.b_hallALeft != 0) ^ (rtU.b_hallBLeft != + 630 0) ^ (rtU.b_hallCLeft != 0) ^ (rtDW.UnitDelay_DSTATE != 0) ^ + 631 (rtDW.UnitDelay1_DSTATE_p != 0)) ^ (rtDW.UnitDelay2_DSTATE != 0); + 632 + 633 /* Outputs for Enabled SubSystem: '<S12>/F01_03_Direction_Detection' */ + 634 + 635 /* Selector: '<S21>/Selector' incorporates: + 636 * Constant: '<S21>/vec_hallToPos' + 637 * UnitDelay: '<S21>/UnitDelay1' + 638 */ + 639 F01_03_Direction_Detection(rtb_LogicalOperator, rtConstP.pooled26[rtb_Sum], + 640 rtDW.UnitDelay1_DSTATE_g, &rtDW.Switch2_e, &rtDW.UnitDelay1_k, + 641 &rtDW.F01_03_Direction_Detection_o); + 642 + 643 /* End of Outputs for SubSystem: '<S12>/F01_03_Direction_Detection' */ + 644 + 645 /* Logic: '<S23>/Logical Operator3' incorporates: + 646 * Constant: '<S23>/z_maxCntRst' + 647 * RelationalOperator: '<S23>/Relational Operator1' + 648 * UnitDelay: '<S23>/z_counterRawPrev' + 649 */ + 650 rtb_LogicalOperator3 = (rtb_LogicalOperator || (rtDW.z_counterRawPrev_DSTATE > + 651 rtP.z_maxCntRst)); 652 - 653 /* Logic: '<S23>/Logical Operator2' incorporates: - 654 * UnitDelay: '<S23>/UnitDelay8' - 655 */ - 656 Edge_counter(!rtDW.UnitDelay8_DSTATE, rtb_LogicalOperator, rtDW.Switch2_e, - 657 rtDW.UnitDelay1_k, &rtDW.Sum2_l, &rtDW.Edge_counter_f); - 658 - 659 /* End of Outputs for SubSystem: '<S23>/Edge_counter' */ + 653 /* Outputs for Enabled SubSystem: '<S23>/Edge_counter' */ + 654 + 655 /* Logic: '<S23>/Logical Operator2' incorporates: + 656 * UnitDelay: '<S23>/UnitDelay8' + 657 */ + 658 Edge_counter(!rtDW.UnitDelay8_DSTATE, rtb_LogicalOperator, rtDW.Switch2_e, + 659 rtDW.UnitDelay1_k, &rtDW.Sum2_l, &rtDW.Edge_counter_f); 660 - 661 /* Abs: '<S23>/Abs4' incorporates: - 662 * UnitDelay: '<S23>/UnitDelay10' - 663 */ - 664 if (rtDW.rpm_signed_c < 0) { - 665 rtb_Switch1_idx_0 = -rtDW.rpm_signed_c; - 666 } else { - 667 rtb_Switch1_idx_0 = rtDW.rpm_signed_c; - 668 } - 669 - 670 /* End of Abs: '<S23>/Abs4' */ + 661 /* End of Outputs for SubSystem: '<S23>/Edge_counter' */ + 662 + 663 /* Logic: '<S23>/Logical Operator5' incorporates: + 664 * Constant: '<S23>/z_maxCntRst2' + 665 * RelationalOperator: '<S23>/Relational Operator3' + 666 * RelationalOperator: '<S23>/Relational Operator6' + 667 * UnitDelay: '<S23>/z_counterRawPrev' + 668 */ + 669 rtDW.LogicalOperator5 = ((rtDW.Switch2_e != rtDW.UnitDelay1_k) || + 670 (rtDW.z_counterRawPrev_DSTATE > rtP.z_maxCntRst)); 671 - 672 /* RelationalOperator: '<S23>/Relational Operator4' incorporates: - 673 * Constant: '<S23>/n_thresSpdDeacv' - 674 */ - 675 rtDW.RelationalOperator4 = (rtb_Switch1_idx_0 < rtP.n_thresSpdDeacv); + 672 /* Outputs for Atomic SubSystem: '<S23>/rising_edge' */ + 673 rising_edge(); + 674 + 675 /* End of Outputs for SubSystem: '<S23>/rising_edge' */ 676 - 677 /* Outputs for Atomic SubSystem: '<S23>/rising_edge' */ - 678 rising_edge(); - 679 - 680 /* End of Outputs for SubSystem: '<S23>/rising_edge' */ - 681 - 682 /* CombinatorialLogic: '<S30>/Logic' incorporates: - 683 * Constant: '<S23>/z_nrEdgeSpdAcv' - 684 * Memory: '<S30>/Memory' - 685 * RelationalOperator: '<S23>/Relational Operator5' - 686 */ - 687 rowIdx = (int32_T)(((((uint32_T)(rtDW.Sum2_l >= rtP.z_nrEdgeSpdAcv) << 1) + - 688 rtDW.LogicalOperator) << 1) + rtDW.Memory_PreviousInput); - 689 rtb_Logic_idx_0 = rtConstP.pooled31[(uint32_T)rowIdx]; - 690 - 691 /* Switch: '<S23>/Switch' incorporates: - 692 * CombinatorialLogic: '<S30>/Logic' + 677 /* CombinatorialLogic: '<S29>/Logic' incorporates: + 678 * Constant: '<S23>/z_nrEdgeSpdAcv' + 679 * Memory: '<S29>/Memory' + 680 * RelationalOperator: '<S23>/Relational Operator5' + 681 */ + 682 rtb_Switch1_idx_0 = (int32_T)(((((uint32_T)(rtDW.Sum2_l >= rtP.z_nrEdgeSpdAcv) + 683 << 1) + rtDW.LogicalOperator_h) << 1) + rtDW.Memory_PreviousInput); + 684 rtDW.Logic[0U] = rtConstP.pooled30[(uint32_T)rtb_Switch1_idx_0]; + 685 rtDW.Logic[1U] = rtConstP.pooled30[rtb_Switch1_idx_0 + 8U]; + 686 + 687 /* Outputs for Atomic SubSystem: '<S23>/falling_edge2' */ + 688 falling_edge2(); + 689 + 690 /* End of Outputs for SubSystem: '<S23>/falling_edge2' */ + 691 + 692 /* Switch: '<S23>/Switch' incorporates: 693 * Logic: '<S23>/Logical Operator1' - 694 * UnitDelay: '<S23>/z_counter2' - 695 * UnitDelay: '<S23>/z_counterRawPrev' - 696 */ - 697 if (rtb_LogicalOperator3 && rtConstP.pooled31[(uint32_T)rowIdx]) { - 698 rtb_Switch = rtDW.z_counterRawPrev_DSTATE; - 699 } else { - 700 rtb_Switch = rtDW.z_counter2_DSTATE; - 701 } - 702 - 703 /* End of Switch: '<S23>/Switch' */ - 704 - 705 /* Outputs for Triggered SubSystem: '<S23>/Raw_ Speed_calculation' */ - 706 Raw_Speed_calculation(rtb_LogicalOperator3, rtb_Switch, rtDW.Switch2_e, - 707 &rtDW.rpm_signed_c, &rtPrevZCX.Raw_Speed_calculation_m); + 694 * Switch: '<S23>/Switch1' + 695 * UnitDelay: '<S23>/z_counter2' + 696 * UnitDelay: '<S23>/z_counterRawPrev' + 697 */ + 698 if (rtb_LogicalOperator3 && rtDW.Logic[0]) { + 699 rtb_Switch = rtDW.z_counterRawPrev_DSTATE; + 700 } else if (rtDW.LogicalOperator) { + 701 /* Switch: '<S23>/Switch1' incorporates: + 702 * Constant: '<S23>/z_maxCntRst1' + 703 */ + 704 rtb_Switch = rtP.z_maxCntRst; + 705 } else { + 706 rtb_Switch = rtDW.z_counter2_DSTATE; + 707 } 708 - 709 /* End of Outputs for SubSystem: '<S23>/Raw_ Speed_calculation' */ + 709 /* End of Switch: '<S23>/Switch' */ 710 - 711 /* Outputs for Triggered SubSystem: '<S23>/Moving_Average_Filter' */ + 711 /* Outputs for Triggered SubSystem: '<S23>/Motor_Speed_Calculation' */ 712 713 /* Outport: '<Root>/n_motLeft' */ - 714 Moving_Average_Filter(rtb_LogicalOperator3, rtDW.rpm_signed_c, &rtY.n_motLeft, - 715 &rtDW.Moving_Average_Filter_l, - 716 &rtPrevZCX.Moving_Average_Filter_l); + 714 Motor_Speed_Calculation(rtb_LogicalOperator3, rtb_Switch, rtDW.Switch2_e, + 715 &rtY.n_motLeft, &rtDW.Motor_Speed_Calculation_m, + 716 &rtPrevZCX.Motor_Speed_Calculation_m); 717 - 718 /* End of Outputs for SubSystem: '<S23>/Moving_Average_Filter' */ + 718 /* End of Outputs for SubSystem: '<S23>/Motor_Speed_Calculation' */ 719 720 /* Abs: '<S15>/Abs5' incorporates: 721 * Outport: '<Root>/n_motLeft' @@ -788,7 +788,7 @@ 774 /* Outputs for IfAction SubSystem: '<S2>/F02_Electrical_Angle_Calculation' incorporates: 775 * ActionPort: '<S13>/Action Port' 776 */ - 777 F02_Electrical_Angle_Calculatio(rtU.r_DCLeft, rtConstP.pooled27[rtb_Sum], + 777 F02_Electrical_Angle_Calculatio(rtU.r_DCLeft, rtConstP.pooled26[rtb_Sum], 778 rtDW.Switch2_e, rtb_Switch, rtb_Sum1, &rtDW.Switch_PhaAdv_a, 779 &rtY.a_elecAngleLeft); 780 @@ -803,7 +803,7 @@ 789 switch (rtP.z_ctrlTypSel) { 790 case 1: 791 /* Outputs for IfAction SubSystem: '<S14>/F03_01_Pure_Trapezoidal_Method' incorporates: - 792 * ActionPort: '<S43>/Action Port' + 792 * ActionPort: '<S41>/Action Port' 793 */ 794 F03_01_Pure_Trapezoidal_Method(rtDW.Switch_PhaAdv_a, &rtDW.Merge, 795 &rtDW.Merge1, &rtDW.Merge2); @@ -813,7 +813,7 @@ 799 800 case 2: 801 /* Outputs for IfAction SubSystem: '<S14>/F03_02_Sinusoidal_Method' incorporates: - 802 * ActionPort: '<S45>/Action Port' + 802 * ActionPort: '<S43>/Action Port' 803 */ 804 F03_02_Sinusoidal_Method(rtDW.Switch_PhaAdv_a, &rtDW.Merge, &rtDW.Merge1, 805 &rtDW.Merge2); @@ -823,7 +823,7 @@ 809 810 case 3: 811 /* Outputs for IfAction SubSystem: '<S14>/F03_02_Sinusoidal3rd_Method' incorporates: - 812 * ActionPort: '<S44>/Action Port' + 812 * ActionPort: '<S42>/Action Port' 813 */ 814 F03_02_Sinusoidal3rd_Method(rtDW.Switch_PhaAdv_a, &rtDW.Merge, &rtDW.Merge1, 815 &rtDW.Merge2); @@ -869,7 +869,7 @@ 855 rtb_Switch1_idx_1 = rtU.r_DCLeft * rtDW.Merge1; 856 rtb_Abs1 = rtU.r_DCLeft * rtDW.Merge2; 857 } else { - 858 if (rtConstP.pooled27[rtb_Sum] < 5) { + 858 if (rtConstP.pooled26[rtb_Sum] < 5) { 859 /* LookupNDDirect: '<S15>/z_commutMap_M1' incorporates: 860 * Constant: '<S21>/vec_hallToPos' 861 * Selector: '<S21>/Selector' @@ -877,7 +877,7 @@ 863 * About '<S15>/z_commutMap_M1': 864 * 2-dimensional Direct Look-Up returning a Column 865 */ - 866 tmp = rtConstP.pooled27[rtb_Sum]; + 866 tmp = rtConstP.pooled26[rtb_Sum]; 867 } else { 868 /* LookupNDDirect: '<S15>/z_commutMap_M1' 869 * @@ -893,9 +893,9 @@ 879 * 2-dimensional Direct Look-Up returning a Column 880 */ 881 rtb_Abs1 = tmp * 3; - 882 rtb_Switch1_idx_0 = rtU.r_DCLeft * rtConstP.pooled17[rtb_Abs1]; - 883 rtb_Switch1_idx_1 = rtConstP.pooled17[1 + rtb_Abs1] * rtU.r_DCLeft; - 884 rtb_Abs1 = rtConstP.pooled17[2 + rtb_Abs1] * rtU.r_DCLeft; + 882 rtb_Switch1_idx_0 = rtU.r_DCLeft * rtConstP.pooled18[rtb_Abs1]; + 883 rtb_Switch1_idx_1 = rtConstP.pooled18[1 + rtb_Abs1] * rtU.r_DCLeft; + 884 rtb_Abs1 = rtConstP.pooled18[2 + rtb_Abs1] * rtU.r_DCLeft; 885 } 886 887 /* End of Switch: '<S15>/Switch1' */ @@ -918,9 +918,9 @@ 904 */ 905 rtY.DC_phaCLeft = rtb_Abs1 / 1000; 906 - 907 /* Sum: '<S61>/Sum' incorporates: - 908 * Gain: '<S61>/g_Ha' - 909 * Gain: '<S61>/g_Hb' + 907 /* Sum: '<S59>/Sum' incorporates: + 908 * Gain: '<S59>/g_Ha' + 909 * Gain: '<S59>/g_Hb' 910 * Inport: '<Root>/b_hallARight' 911 * Inport: '<Root>/b_hallBRight' 912 * Inport: '<Root>/b_hallCRight' @@ -928,404 +928,399 @@ 914 rtb_Sum_a = (uint8_T)((uint32_T)(uint8_T)((uint32_T)(uint8_T)(rtU.b_hallARight 915 << 2) + (uint8_T)(rtU.b_hallBRight << 1)) + rtU.b_hallCRight); 916 - 917 /* Logic: '<S60>/Logical Operator' incorporates: + 917 /* Logic: '<S58>/Logical Operator' incorporates: 918 * Inport: '<Root>/b_hallARight' 919 * Inport: '<Root>/b_hallBRight' 920 * Inport: '<Root>/b_hallCRight' - 921 * UnitDelay: '<S60>/UnitDelay' - 922 * UnitDelay: '<S60>/UnitDelay1' - 923 * UnitDelay: '<S60>/UnitDelay2' + 921 * UnitDelay: '<S58>/UnitDelay' + 922 * UnitDelay: '<S58>/UnitDelay1' + 923 * UnitDelay: '<S58>/UnitDelay2' 924 */ 925 rtb_LogicalOperator = (boolean_T)((rtU.b_hallARight != 0) ^ (rtU.b_hallBRight 926 != 0) ^ (rtU.b_hallCRight != 0) ^ (rtDW.UnitDelay_DSTATE_j != 0) ^ 927 (rtDW.UnitDelay1_DSTATE_f != 0)) ^ (rtDW.UnitDelay2_DSTATE_b != 0); 928 - 929 /* Logic: '<S63>/Logical Operator3' incorporates: - 930 * Constant: '<S63>/z_maxCntRst' - 931 * RelationalOperator: '<S63>/Relational Operator1' - 932 * UnitDelay: '<S63>/z_counterRawPrev' - 933 */ - 934 rtb_LogicalOperator3 = (rtb_LogicalOperator || (rtDW.z_counterRawPrev_DSTATE_p - 935 > rtP.z_maxCntRst)); - 936 - 937 /* Outputs for Enabled SubSystem: '<S52>/F01_03_Direction_Detection' */ + 929 /* Outputs for Enabled SubSystem: '<S50>/F01_03_Direction_Detection' */ + 930 + 931 /* Selector: '<S59>/Selector' incorporates: + 932 * Constant: '<S59>/vec_hallToPos' + 933 * UnitDelay: '<S59>/UnitDelay1' + 934 */ + 935 F01_03_Direction_Detection(rtb_LogicalOperator, rtConstP.pooled26[rtb_Sum_a], + 936 rtDW.UnitDelay1_DSTATE_j, &rtDW.Switch2, &rtDW.UnitDelay1, + 937 &rtDW.F01_03_Direction_Detection_j); 938 - 939 /* Selector: '<S61>/Selector' incorporates: - 940 * Constant: '<S61>/vec_hallToPos' - 941 * UnitDelay: '<S61>/UnitDelay1' - 942 */ - 943 F01_03_Direction_Detection(rtb_LogicalOperator, rtConstP.pooled27[rtb_Sum_a], - 944 rtDW.UnitDelay1_DSTATE_j, &rtDW.Switch2, &rtDW.UnitDelay1, - 945 &rtDW.F01_03_Direction_Detection_j); - 946 - 947 /* End of Outputs for SubSystem: '<S52>/F01_03_Direction_Detection' */ + 939 /* End of Outputs for SubSystem: '<S50>/F01_03_Direction_Detection' */ + 940 + 941 /* Logic: '<S61>/Logical Operator3' incorporates: + 942 * Constant: '<S61>/z_maxCntRst' + 943 * RelationalOperator: '<S61>/Relational Operator1' + 944 * UnitDelay: '<S61>/z_counterRawPrev' + 945 */ + 946 rtb_LogicalOperator3 = (rtb_LogicalOperator || (rtDW.z_counterRawPrev_DSTATE_p + 947 > rtP.z_maxCntRst)); 948 - 949 /* Outputs for Enabled SubSystem: '<S63>/Edge_counter' */ + 949 /* Outputs for Enabled SubSystem: '<S61>/Edge_counter' */ 950 - 951 /* Logic: '<S63>/Logical Operator2' incorporates: - 952 * UnitDelay: '<S63>/UnitDelay8' + 951 /* Logic: '<S61>/Logical Operator2' incorporates: + 952 * UnitDelay: '<S61>/UnitDelay8' 953 */ 954 Edge_counter(!rtDW.UnitDelay8_DSTATE_p, rtb_LogicalOperator, rtDW.Switch2, 955 rtDW.UnitDelay1, &rtDW.Sum2_i, &rtDW.Edge_counter_l); 956 - 957 /* End of Outputs for SubSystem: '<S63>/Edge_counter' */ + 957 /* End of Outputs for SubSystem: '<S61>/Edge_counter' */ 958 - 959 /* Abs: '<S63>/Abs4' incorporates: - 960 * UnitDelay: '<S63>/UnitDelay10' - 961 */ - 962 if (rtDW.rpm_signed < 0) { - 963 rtb_Switch1_idx_0 = -rtDW.rpm_signed; - 964 } else { - 965 rtb_Switch1_idx_0 = rtDW.rpm_signed; - 966 } + 959 /* Logic: '<S61>/Logical Operator5' incorporates: + 960 * Constant: '<S61>/z_maxCntRst2' + 961 * RelationalOperator: '<S61>/Relational Operator3' + 962 * RelationalOperator: '<S61>/Relational Operator6' + 963 * UnitDelay: '<S61>/z_counterRawPrev' + 964 */ + 965 rtDW.LogicalOperator5 = ((rtDW.Switch2 != rtDW.UnitDelay1) || + 966 (rtDW.z_counterRawPrev_DSTATE_p > rtP.z_maxCntRst)); 967 - 968 /* End of Abs: '<S63>/Abs4' */ - 969 - 970 /* RelationalOperator: '<S63>/Relational Operator4' incorporates: - 971 * Constant: '<S63>/n_thresSpdDeacv' - 972 */ - 973 rtDW.RelationalOperator4 = (rtb_Switch1_idx_0 < rtP.n_thresSpdDeacv); - 974 - 975 /* Outputs for Atomic SubSystem: '<S63>/rising_edge' */ - 976 rising_edge_f(); - 977 - 978 /* End of Outputs for SubSystem: '<S63>/rising_edge' */ - 979 - 980 /* CombinatorialLogic: '<S70>/Logic' incorporates: - 981 * Constant: '<S63>/z_nrEdgeSpdAcv' - 982 * Memory: '<S70>/Memory' - 983 * RelationalOperator: '<S63>/Relational Operator5' - 984 */ - 985 rowIdx = (int32_T)(((((uint32_T)(rtDW.Sum2_i >= rtP.z_nrEdgeSpdAcv) << 1) + - 986 rtDW.LogicalOperator) << 1) + rtDW.Memory_PreviousInput_i); + 968 /* Outputs for Atomic SubSystem: '<S61>/rising_edge' */ + 969 rising_edge_f(); + 970 + 971 /* End of Outputs for SubSystem: '<S61>/rising_edge' */ + 972 + 973 /* CombinatorialLogic: '<S67>/Logic' incorporates: + 974 * Constant: '<S61>/z_nrEdgeSpdAcv' + 975 * Memory: '<S67>/Memory' + 976 * RelationalOperator: '<S61>/Relational Operator5' + 977 */ + 978 rtb_Switch1_idx_0 = (int32_T)(((((uint32_T)(rtDW.Sum2_i >= rtP.z_nrEdgeSpdAcv) + 979 << 1) + rtDW.LogicalOperator_h) << 1) + rtDW.Memory_PreviousInput_i); + 980 rtDW.Logic_j[0U] = rtConstP.pooled30[(uint32_T)rtb_Switch1_idx_0]; + 981 rtDW.Logic_j[1U] = rtConstP.pooled30[rtb_Switch1_idx_0 + 8U]; + 982 + 983 /* Outputs for Atomic SubSystem: '<S61>/falling_edge2' */ + 984 falling_edge2_b(); + 985 + 986 /* End of Outputs for SubSystem: '<S61>/falling_edge2' */ 987 - 988 /* Switch: '<S63>/Switch' incorporates: - 989 * CombinatorialLogic: '<S70>/Logic' - 990 * Logic: '<S63>/Logical Operator1' - 991 * UnitDelay: '<S63>/z_counter2' - 992 * UnitDelay: '<S63>/z_counterRawPrev' + 988 /* Switch: '<S61>/Switch' incorporates: + 989 * Logic: '<S61>/Logical Operator1' + 990 * Switch: '<S61>/Switch1' + 991 * UnitDelay: '<S61>/z_counter2' + 992 * UnitDelay: '<S61>/z_counterRawPrev' 993 */ - 994 if (rtb_LogicalOperator3 && rtConstP.pooled31[(uint32_T)rowIdx]) { + 994 if (rtb_LogicalOperator3 && rtDW.Logic_j[0]) { 995 rtb_Switch_b = rtDW.z_counterRawPrev_DSTATE_p; - 996 } else { - 997 rtb_Switch_b = rtDW.z_counter2_DSTATE_h; - 998 } - 999 - 1000 /* End of Switch: '<S63>/Switch' */ - 1001 - 1002 /* Outputs for Triggered SubSystem: '<S63>/Raw_ Speed_calculation' */ - 1003 Raw_Speed_calculation(rtb_LogicalOperator3, rtb_Switch_b, rtDW.Switch2, - 1004 &rtDW.rpm_signed, &rtPrevZCX.Raw_Speed_calculation_k); - 1005 - 1006 /* End of Outputs for SubSystem: '<S63>/Raw_ Speed_calculation' */ - 1007 - 1008 /* Outputs for Triggered SubSystem: '<S63>/Moving_Average_Filter' */ - 1009 - 1010 /* Outport: '<Root>/n_motRight' */ - 1011 Moving_Average_Filter(rtb_LogicalOperator3, rtDW.rpm_signed, &rtY.n_motRight, - 1012 &rtDW.Moving_Average_Filter_n, - 1013 &rtPrevZCX.Moving_Average_Filter_n); - 1014 - 1015 /* End of Outputs for SubSystem: '<S63>/Moving_Average_Filter' */ - 1016 - 1017 /* Abs: '<S55>/Abs5' incorporates: - 1018 * Outport: '<Root>/n_motRight' - 1019 */ - 1020 if (rtY.n_motRight < 0) { - 1021 rtb_Abs1 = -rtY.n_motRight; - 1022 } else { - 1023 rtb_Abs1 = rtY.n_motRight; - 1024 } - 1025 - 1026 /* End of Abs: '<S55>/Abs5' */ - 1027 - 1028 /* Relay: '<S55>/Relay' */ - 1029 if (rtb_Abs1 >= rtP.n_commDeacvHi) { - 1030 rtDW.Relay_Mode_m = true; - 1031 } else { - 1032 if (rtb_Abs1 <= rtP.n_commAcvLo) { - 1033 rtDW.Relay_Mode_m = false; - 1034 } - 1035 } - 1036 - 1037 /* Switch: '<S72>/Switch1' incorporates: - 1038 * Constant: '<S72>/Constant23' - 1039 * UnitDelay: '<S72>/UnitDelay1' - 1040 */ - 1041 if (rtb_LogicalOperator3) { - 1042 rtb_Sum1_c = 0; - 1043 } else { - 1044 rtb_Sum1_c = rtDW.UnitDelay1_DSTATE_k; - 1045 } - 1046 - 1047 /* End of Switch: '<S72>/Switch1' */ - 1048 - 1049 /* Sum: '<S63>/Sum1' */ - 1050 rtb_Sum1_c++; - 1051 - 1052 /* If: '<S3>/If1' incorporates: - 1053 * Constant: '<S52>/z_ctrlTypSel1' - 1054 * Constant: '<S61>/vec_hallToPos' - 1055 * Inport: '<Root>/r_DCRight' - 1056 * Outport: '<Root>/a_elecAngleRight' - 1057 * Selector: '<S61>/Selector' - 1058 */ - 1059 rtPrevAction = rtDW.If1_ActiveSubsystem_j; - 1060 rtAction = -1; - 1061 if (rtP.z_ctrlTypSel != 0) { - 1062 rtAction = 0; - 1063 } - 1064 - 1065 rtDW.If1_ActiveSubsystem_j = rtAction; - 1066 if ((rtPrevAction != rtAction) && (rtPrevAction == 0)) { - 1067 F02_Electrical_Angle_Ca_Disable(&rtDW.Switch_PhaAdv, &rtY.a_elecAngleRight); - 1068 } - 1069 - 1070 if (rtAction == 0) { - 1071 /* Outputs for IfAction SubSystem: '<S3>/F02_Electrical_Angle_Calculation' incorporates: - 1072 * ActionPort: '<S53>/Action Port' - 1073 */ - 1074 F02_Electrical_Angle_Calculatio(rtU.r_DCRight, rtConstP.pooled27[rtb_Sum_a], - 1075 rtDW.Switch2, rtb_Switch_b, rtb_Sum1_c, &rtDW.Switch_PhaAdv, - 1076 &rtY.a_elecAngleRight); - 1077 - 1078 /* End of Outputs for SubSystem: '<S3>/F02_Electrical_Angle_Calculation' */ - 1079 } - 1080 - 1081 /* End of If: '<S3>/If1' */ - 1082 - 1083 /* SwitchCase: '<S54>/Switch Case' incorporates: - 1084 * Constant: '<S52>/z_ctrlTypSel1' - 1085 */ - 1086 switch (rtP.z_ctrlTypSel) { - 1087 case 1: - 1088 /* Outputs for IfAction SubSystem: '<S54>/F03_01_Pure_Trapezoidal_Method' incorporates: - 1089 * ActionPort: '<S83>/Action Port' - 1090 */ - 1091 F03_01_Pure_Trapezoidal_Method(rtDW.Switch_PhaAdv, &rtDW.Merge_j, - 1092 &rtDW.Merge1_m, &rtDW.Merge2_d); - 1093 - 1094 /* End of Outputs for SubSystem: '<S54>/F03_01_Pure_Trapezoidal_Method' */ - 1095 break; - 1096 - 1097 case 2: - 1098 /* Outputs for IfAction SubSystem: '<S54>/F03_02_Sinusoidal_Method' incorporates: - 1099 * ActionPort: '<S85>/Action Port' - 1100 */ - 1101 F03_02_Sinusoidal_Method(rtDW.Switch_PhaAdv, &rtDW.Merge_j, &rtDW.Merge1_m, - 1102 &rtDW.Merge2_d); - 1103 - 1104 /* End of Outputs for SubSystem: '<S54>/F03_02_Sinusoidal_Method' */ - 1105 break; - 1106 - 1107 case 3: - 1108 /* Outputs for IfAction SubSystem: '<S54>/F03_02_Sinusoidal3rd_Method' incorporates: - 1109 * ActionPort: '<S84>/Action Port' - 1110 */ - 1111 F03_02_Sinusoidal3rd_Method(rtDW.Switch_PhaAdv, &rtDW.Merge_j, - 1112 &rtDW.Merge1_m, &rtDW.Merge2_d); - 1113 - 1114 /* End of Outputs for SubSystem: '<S54>/F03_02_Sinusoidal3rd_Method' */ - 1115 break; - 1116 } - 1117 - 1118 /* End of SwitchCase: '<S54>/Switch Case' */ - 1119 - 1120 /* Abs: '<S55>/Abs1' incorporates: - 1121 * Inport: '<Root>/r_DCRight' - 1122 */ - 1123 if (rtU.r_DCRight < 0) { - 1124 rtb_Switch1_idx_0 = -rtU.r_DCRight; - 1125 } else { - 1126 rtb_Switch1_idx_0 = rtU.r_DCRight; - 1127 } - 1128 - 1129 /* End of Abs: '<S55>/Abs1' */ - 1130 - 1131 /* Switch: '<S55>/Switch1' incorporates: - 1132 * Constant: '<S52>/z_ctrlTypSel1' - 1133 * Constant: '<S55>/CTRL_COMM' - 1134 * Constant: '<S55>/r_commDCDeacv' - 1135 * Constant: '<S61>/vec_hallToPos' - 1136 * Inport: '<Root>/r_DCRight' - 1137 * Logic: '<S55>/Logical Operator3' - 1138 * LookupNDDirect: '<S55>/z_commutMap_M1' - 1139 * Product: '<S55>/Divide2' - 1140 * Product: '<S55>/Divide4' - 1141 * RelationalOperator: '<S55>/Relational Operator1' - 1142 * RelationalOperator: '<S55>/Relational Operator2' - 1143 * Relay: '<S55>/Relay' - 1144 * Selector: '<S61>/Selector' - 1145 * - 1146 * About '<S55>/z_commutMap_M1': - 1147 * 2-dimensional Direct Look-Up returning a Column - 1148 */ - 1149 if (rtDW.Relay_Mode_m && (rtb_Switch1_idx_0 > rtP.r_commDCDeacv) && - 1150 (rtP.z_ctrlTypSel != 0)) { - 1151 rtb_Switch1_idx_0 = rtU.r_DCRight * rtDW.Merge_j; - 1152 rtb_Switch1_idx_1 = rtU.r_DCRight * rtDW.Merge1_m; - 1153 rtb_Abs1 = rtU.r_DCRight * rtDW.Merge2_d; - 1154 } else { - 1155 if (rtConstP.pooled27[rtb_Sum_a] < 5) { - 1156 /* LookupNDDirect: '<S55>/z_commutMap_M1' incorporates: - 1157 * Constant: '<S61>/vec_hallToPos' - 1158 * Selector: '<S61>/Selector' - 1159 * - 1160 * About '<S55>/z_commutMap_M1': - 1161 * 2-dimensional Direct Look-Up returning a Column - 1162 */ - 1163 tmp = rtConstP.pooled27[rtb_Sum_a]; - 1164 } else { - 1165 /* LookupNDDirect: '<S55>/z_commutMap_M1' - 1166 * - 1167 * About '<S55>/z_commutMap_M1': - 1168 * 2-dimensional Direct Look-Up returning a Column - 1169 */ - 1170 tmp = 5U; - 1171 } - 1172 - 1173 /* LookupNDDirect: '<S55>/z_commutMap_M1' - 1174 * - 1175 * About '<S55>/z_commutMap_M1': - 1176 * 2-dimensional Direct Look-Up returning a Column - 1177 */ - 1178 rtb_Abs1 = tmp * 3; - 1179 rtb_Switch1_idx_0 = rtU.r_DCRight * rtConstP.pooled17[rtb_Abs1]; - 1180 rtb_Switch1_idx_1 = rtConstP.pooled17[1 + rtb_Abs1] * rtU.r_DCRight; - 1181 rtb_Abs1 = rtConstP.pooled17[2 + rtb_Abs1] * rtU.r_DCRight; - 1182 } - 1183 - 1184 /* End of Switch: '<S55>/Switch1' */ - 1185 - 1186 /* Outport: '<Root>/DC_phaARight' incorporates: - 1187 * Constant: '<S55>/Constant1' - 1188 * Product: '<S55>/Divide1' - 1189 */ - 1190 rtY.DC_phaARight = rtb_Switch1_idx_0 / 1000; - 1191 - 1192 /* Outport: '<Root>/DC_phaBRight' incorporates: - 1193 * Constant: '<S55>/Constant1' - 1194 * Product: '<S55>/Divide1' - 1195 */ - 1196 rtY.DC_phaBRight = rtb_Switch1_idx_1 / 1000; - 1197 - 1198 /* Update for UnitDelay: '<S20>/UnitDelay' incorporates: - 1199 * Inport: '<Root>/b_hallALeft ' - 1200 */ - 1201 rtDW.UnitDelay_DSTATE = rtU.b_hallALeft; - 1202 - 1203 /* Update for UnitDelay: '<S20>/UnitDelay1' incorporates: - 1204 * Inport: '<Root>/b_hallBLeft' - 1205 */ - 1206 rtDW.UnitDelay1_DSTATE_p = rtU.b_hallBLeft; - 1207 - 1208 /* Update for UnitDelay: '<S20>/UnitDelay2' incorporates: - 1209 * Inport: '<Root>/b_hallCLeft' - 1210 */ - 1211 rtDW.UnitDelay2_DSTATE = rtU.b_hallCLeft; - 1212 - 1213 /* Update for UnitDelay: '<S23>/z_counterRawPrev' */ - 1214 rtDW.z_counterRawPrev_DSTATE = rtb_Sum1; - 1215 - 1216 /* Update for UnitDelay: '<S21>/UnitDelay1' incorporates: - 1217 * Constant: '<S21>/vec_hallToPos' - 1218 * Selector: '<S21>/Selector' - 1219 */ - 1220 rtDW.UnitDelay1_DSTATE_g = rtConstP.pooled27[rtb_Sum]; - 1221 - 1222 /* Update for UnitDelay: '<S23>/UnitDelay8' */ - 1223 rtDW.UnitDelay8_DSTATE = rtb_Logic_idx_0; - 1224 - 1225 /* Update for Memory: '<S30>/Memory' */ - 1226 rtDW.Memory_PreviousInput = rtb_Logic_idx_0; - 1227 - 1228 /* Update for UnitDelay: '<S23>/z_counter2' */ - 1229 rtDW.z_counter2_DSTATE = rtb_Switch; - 1230 - 1231 /* Update for UnitDelay: '<S32>/UnitDelay1' */ - 1232 rtDW.UnitDelay1_DSTATE = rtb_Sum1; - 1233 - 1234 /* Update for UnitDelay: '<S60>/UnitDelay' incorporates: - 1235 * Inport: '<Root>/b_hallARight' - 1236 */ - 1237 rtDW.UnitDelay_DSTATE_j = rtU.b_hallARight; - 1238 - 1239 /* Update for UnitDelay: '<S60>/UnitDelay1' incorporates: - 1240 * Inport: '<Root>/b_hallBRight' - 1241 */ - 1242 rtDW.UnitDelay1_DSTATE_f = rtU.b_hallBRight; - 1243 - 1244 /* Update for UnitDelay: '<S60>/UnitDelay2' incorporates: - 1245 * Inport: '<Root>/b_hallCRight' - 1246 */ - 1247 rtDW.UnitDelay2_DSTATE_b = rtU.b_hallCRight; - 1248 - 1249 /* Update for UnitDelay: '<S63>/z_counterRawPrev' */ - 1250 rtDW.z_counterRawPrev_DSTATE_p = rtb_Sum1_c; - 1251 - 1252 /* Update for UnitDelay: '<S61>/UnitDelay1' incorporates: - 1253 * Constant: '<S61>/vec_hallToPos' - 1254 * Selector: '<S61>/Selector' - 1255 */ - 1256 rtDW.UnitDelay1_DSTATE_j = rtConstP.pooled27[rtb_Sum_a]; - 1257 - 1258 /* Update for UnitDelay: '<S63>/UnitDelay8' incorporates: - 1259 * CombinatorialLogic: '<S70>/Logic' - 1260 */ - 1261 rtDW.UnitDelay8_DSTATE_p = rtConstP.pooled31[(uint32_T)rowIdx]; + 996 } else if (rtDW.LogicalOperator_h) { + 997 /* Switch: '<S61>/Switch1' incorporates: + 998 * Constant: '<S61>/z_maxCntRst1' + 999 */ + 1000 rtb_Switch_b = rtP.z_maxCntRst; + 1001 } else { + 1002 rtb_Switch_b = rtDW.z_counter2_DSTATE_h; + 1003 } + 1004 + 1005 /* End of Switch: '<S61>/Switch' */ + 1006 + 1007 /* Outputs for Triggered SubSystem: '<S61>/Motor_Speed_Calculation' */ + 1008 + 1009 /* Outport: '<Root>/n_motRight' */ + 1010 Motor_Speed_Calculation(rtb_LogicalOperator3, rtb_Switch_b, rtDW.Switch2, + 1011 &rtY.n_motRight, &rtDW.Motor_Speed_Calculation_k, + 1012 &rtPrevZCX.Motor_Speed_Calculation_k); + 1013 + 1014 /* End of Outputs for SubSystem: '<S61>/Motor_Speed_Calculation' */ + 1015 + 1016 /* Abs: '<S53>/Abs5' incorporates: + 1017 * Outport: '<Root>/n_motRight' + 1018 */ + 1019 if (rtY.n_motRight < 0) { + 1020 rtb_Abs1 = -rtY.n_motRight; + 1021 } else { + 1022 rtb_Abs1 = rtY.n_motRight; + 1023 } + 1024 + 1025 /* End of Abs: '<S53>/Abs5' */ + 1026 + 1027 /* Relay: '<S53>/Relay' */ + 1028 if (rtb_Abs1 >= rtP.n_commDeacvHi) { + 1029 rtDW.Relay_Mode_m = true; + 1030 } else { + 1031 if (rtb_Abs1 <= rtP.n_commAcvLo) { + 1032 rtDW.Relay_Mode_m = false; + 1033 } + 1034 } + 1035 + 1036 /* Switch: '<S70>/Switch1' incorporates: + 1037 * Constant: '<S70>/Constant23' + 1038 * UnitDelay: '<S70>/UnitDelay1' + 1039 */ + 1040 if (rtb_LogicalOperator3) { + 1041 rtb_Sum1_c = 0; + 1042 } else { + 1043 rtb_Sum1_c = rtDW.UnitDelay1_DSTATE_k; + 1044 } + 1045 + 1046 /* End of Switch: '<S70>/Switch1' */ + 1047 + 1048 /* Sum: '<S61>/Sum1' */ + 1049 rtb_Sum1_c++; + 1050 + 1051 /* If: '<S3>/If1' incorporates: + 1052 * Constant: '<S50>/z_ctrlTypSel1' + 1053 * Constant: '<S59>/vec_hallToPos' + 1054 * Inport: '<Root>/r_DCRight' + 1055 * Outport: '<Root>/a_elecAngleRight' + 1056 * Selector: '<S59>/Selector' + 1057 */ + 1058 rtPrevAction = rtDW.If1_ActiveSubsystem_j; + 1059 rtAction = -1; + 1060 if (rtP.z_ctrlTypSel != 0) { + 1061 rtAction = 0; + 1062 } + 1063 + 1064 rtDW.If1_ActiveSubsystem_j = rtAction; + 1065 if ((rtPrevAction != rtAction) && (rtPrevAction == 0)) { + 1066 F02_Electrical_Angle_Ca_Disable(&rtDW.Switch_PhaAdv, &rtY.a_elecAngleRight); + 1067 } + 1068 + 1069 if (rtAction == 0) { + 1070 /* Outputs for IfAction SubSystem: '<S3>/F02_Electrical_Angle_Calculation' incorporates: + 1071 * ActionPort: '<S51>/Action Port' + 1072 */ + 1073 F02_Electrical_Angle_Calculatio(rtU.r_DCRight, rtConstP.pooled26[rtb_Sum_a], + 1074 rtDW.Switch2, rtb_Switch_b, rtb_Sum1_c, &rtDW.Switch_PhaAdv, + 1075 &rtY.a_elecAngleRight); + 1076 + 1077 /* End of Outputs for SubSystem: '<S3>/F02_Electrical_Angle_Calculation' */ + 1078 } + 1079 + 1080 /* End of If: '<S3>/If1' */ + 1081 + 1082 /* SwitchCase: '<S52>/Switch Case' incorporates: + 1083 * Constant: '<S50>/z_ctrlTypSel1' + 1084 */ + 1085 switch (rtP.z_ctrlTypSel) { + 1086 case 1: + 1087 /* Outputs for IfAction SubSystem: '<S52>/F03_01_Pure_Trapezoidal_Method' incorporates: + 1088 * ActionPort: '<S79>/Action Port' + 1089 */ + 1090 F03_01_Pure_Trapezoidal_Method(rtDW.Switch_PhaAdv, &rtDW.Merge_j, + 1091 &rtDW.Merge1_m, &rtDW.Merge2_d); + 1092 + 1093 /* End of Outputs for SubSystem: '<S52>/F03_01_Pure_Trapezoidal_Method' */ + 1094 break; + 1095 + 1096 case 2: + 1097 /* Outputs for IfAction SubSystem: '<S52>/F03_02_Sinusoidal_Method' incorporates: + 1098 * ActionPort: '<S81>/Action Port' + 1099 */ + 1100 F03_02_Sinusoidal_Method(rtDW.Switch_PhaAdv, &rtDW.Merge_j, &rtDW.Merge1_m, + 1101 &rtDW.Merge2_d); + 1102 + 1103 /* End of Outputs for SubSystem: '<S52>/F03_02_Sinusoidal_Method' */ + 1104 break; + 1105 + 1106 case 3: + 1107 /* Outputs for IfAction SubSystem: '<S52>/F03_02_Sinusoidal3rd_Method' incorporates: + 1108 * ActionPort: '<S80>/Action Port' + 1109 */ + 1110 F03_02_Sinusoidal3rd_Method(rtDW.Switch_PhaAdv, &rtDW.Merge_j, + 1111 &rtDW.Merge1_m, &rtDW.Merge2_d); + 1112 + 1113 /* End of Outputs for SubSystem: '<S52>/F03_02_Sinusoidal3rd_Method' */ + 1114 break; + 1115 } + 1116 + 1117 /* End of SwitchCase: '<S52>/Switch Case' */ + 1118 + 1119 /* Abs: '<S53>/Abs1' incorporates: + 1120 * Inport: '<Root>/r_DCRight' + 1121 */ + 1122 if (rtU.r_DCRight < 0) { + 1123 rtb_Switch1_idx_0 = -rtU.r_DCRight; + 1124 } else { + 1125 rtb_Switch1_idx_0 = rtU.r_DCRight; + 1126 } + 1127 + 1128 /* End of Abs: '<S53>/Abs1' */ + 1129 + 1130 /* Switch: '<S53>/Switch1' incorporates: + 1131 * Constant: '<S50>/z_ctrlTypSel1' + 1132 * Constant: '<S53>/CTRL_COMM' + 1133 * Constant: '<S53>/r_commDCDeacv' + 1134 * Constant: '<S59>/vec_hallToPos' + 1135 * Inport: '<Root>/r_DCRight' + 1136 * Logic: '<S53>/Logical Operator3' + 1137 * LookupNDDirect: '<S53>/z_commutMap_M1' + 1138 * Product: '<S53>/Divide2' + 1139 * Product: '<S53>/Divide4' + 1140 * RelationalOperator: '<S53>/Relational Operator1' + 1141 * RelationalOperator: '<S53>/Relational Operator2' + 1142 * Relay: '<S53>/Relay' + 1143 * Selector: '<S59>/Selector' + 1144 * + 1145 * About '<S53>/z_commutMap_M1': + 1146 * 2-dimensional Direct Look-Up returning a Column + 1147 */ + 1148 if (rtDW.Relay_Mode_m && (rtb_Switch1_idx_0 > rtP.r_commDCDeacv) && + 1149 (rtP.z_ctrlTypSel != 0)) { + 1150 rtb_Switch1_idx_0 = rtU.r_DCRight * rtDW.Merge_j; + 1151 rtb_Switch1_idx_1 = rtU.r_DCRight * rtDW.Merge1_m; + 1152 rtb_Abs1 = rtU.r_DCRight * rtDW.Merge2_d; + 1153 } else { + 1154 if (rtConstP.pooled26[rtb_Sum_a] < 5) { + 1155 /* LookupNDDirect: '<S53>/z_commutMap_M1' incorporates: + 1156 * Constant: '<S59>/vec_hallToPos' + 1157 * Selector: '<S59>/Selector' + 1158 * + 1159 * About '<S53>/z_commutMap_M1': + 1160 * 2-dimensional Direct Look-Up returning a Column + 1161 */ + 1162 tmp = rtConstP.pooled26[rtb_Sum_a]; + 1163 } else { + 1164 /* LookupNDDirect: '<S53>/z_commutMap_M1' + 1165 * + 1166 * About '<S53>/z_commutMap_M1': + 1167 * 2-dimensional Direct Look-Up returning a Column + 1168 */ + 1169 tmp = 5U; + 1170 } + 1171 + 1172 /* LookupNDDirect: '<S53>/z_commutMap_M1' + 1173 * + 1174 * About '<S53>/z_commutMap_M1': + 1175 * 2-dimensional Direct Look-Up returning a Column + 1176 */ + 1177 rtb_Abs1 = tmp * 3; + 1178 rtb_Switch1_idx_0 = rtU.r_DCRight * rtConstP.pooled18[rtb_Abs1]; + 1179 rtb_Switch1_idx_1 = rtConstP.pooled18[1 + rtb_Abs1] * rtU.r_DCRight; + 1180 rtb_Abs1 = rtConstP.pooled18[2 + rtb_Abs1] * rtU.r_DCRight; + 1181 } + 1182 + 1183 /* End of Switch: '<S53>/Switch1' */ + 1184 + 1185 /* Outport: '<Root>/DC_phaARight' incorporates: + 1186 * Constant: '<S53>/Constant1' + 1187 * Product: '<S53>/Divide1' + 1188 */ + 1189 rtY.DC_phaARight = rtb_Switch1_idx_0 / 1000; + 1190 + 1191 /* Outport: '<Root>/DC_phaBRight' incorporates: + 1192 * Constant: '<S53>/Constant1' + 1193 * Product: '<S53>/Divide1' + 1194 */ + 1195 rtY.DC_phaBRight = rtb_Switch1_idx_1 / 1000; + 1196 + 1197 /* Update for UnitDelay: '<S20>/UnitDelay' incorporates: + 1198 * Inport: '<Root>/b_hallALeft ' + 1199 */ + 1200 rtDW.UnitDelay_DSTATE = rtU.b_hallALeft; + 1201 + 1202 /* Update for UnitDelay: '<S20>/UnitDelay1' incorporates: + 1203 * Inport: '<Root>/b_hallBLeft' + 1204 */ + 1205 rtDW.UnitDelay1_DSTATE_p = rtU.b_hallBLeft; + 1206 + 1207 /* Update for UnitDelay: '<S20>/UnitDelay2' incorporates: + 1208 * Inport: '<Root>/b_hallCLeft' + 1209 */ + 1210 rtDW.UnitDelay2_DSTATE = rtU.b_hallCLeft; + 1211 + 1212 /* Update for UnitDelay: '<S21>/UnitDelay1' incorporates: + 1213 * Constant: '<S21>/vec_hallToPos' + 1214 * Selector: '<S21>/Selector' + 1215 */ + 1216 rtDW.UnitDelay1_DSTATE_g = rtConstP.pooled26[rtb_Sum]; + 1217 + 1218 /* Update for UnitDelay: '<S23>/z_counterRawPrev' */ + 1219 rtDW.z_counterRawPrev_DSTATE = rtb_Sum1; + 1220 + 1221 /* Update for UnitDelay: '<S23>/UnitDelay8' */ + 1222 rtDW.UnitDelay8_DSTATE = rtDW.Logic[0]; + 1223 + 1224 /* Update for Memory: '<S29>/Memory' */ + 1225 rtDW.Memory_PreviousInput = rtDW.Logic[0]; + 1226 + 1227 /* Update for UnitDelay: '<S23>/z_counter2' */ + 1228 rtDW.z_counter2_DSTATE = rtb_Switch; + 1229 + 1230 /* Update for UnitDelay: '<S32>/UnitDelay1' */ + 1231 rtDW.UnitDelay1_DSTATE = rtb_Sum1; + 1232 + 1233 /* Update for UnitDelay: '<S58>/UnitDelay' incorporates: + 1234 * Inport: '<Root>/b_hallARight' + 1235 */ + 1236 rtDW.UnitDelay_DSTATE_j = rtU.b_hallARight; + 1237 + 1238 /* Update for UnitDelay: '<S58>/UnitDelay1' incorporates: + 1239 * Inport: '<Root>/b_hallBRight' + 1240 */ + 1241 rtDW.UnitDelay1_DSTATE_f = rtU.b_hallBRight; + 1242 + 1243 /* Update for UnitDelay: '<S58>/UnitDelay2' incorporates: + 1244 * Inport: '<Root>/b_hallCRight' + 1245 */ + 1246 rtDW.UnitDelay2_DSTATE_b = rtU.b_hallCRight; + 1247 + 1248 /* Update for UnitDelay: '<S59>/UnitDelay1' incorporates: + 1249 * Constant: '<S59>/vec_hallToPos' + 1250 * Selector: '<S59>/Selector' + 1251 */ + 1252 rtDW.UnitDelay1_DSTATE_j = rtConstP.pooled26[rtb_Sum_a]; + 1253 + 1254 /* Update for UnitDelay: '<S61>/z_counterRawPrev' */ + 1255 rtDW.z_counterRawPrev_DSTATE_p = rtb_Sum1_c; + 1256 + 1257 /* Update for UnitDelay: '<S61>/UnitDelay8' */ + 1258 rtDW.UnitDelay8_DSTATE_p = rtDW.Logic_j[0]; + 1259 + 1260 /* Update for Memory: '<S67>/Memory' */ + 1261 rtDW.Memory_PreviousInput_i = rtDW.Logic_j[0]; 1262 - 1263 /* Update for Memory: '<S70>/Memory' incorporates: - 1264 * CombinatorialLogic: '<S70>/Logic' - 1265 */ - 1266 rtDW.Memory_PreviousInput_i = rtConstP.pooled31[(uint32_T)rowIdx]; - 1267 - 1268 /* Update for UnitDelay: '<S63>/z_counter2' */ - 1269 rtDW.z_counter2_DSTATE_h = rtb_Switch_b; - 1270 - 1271 /* Update for UnitDelay: '<S72>/UnitDelay1' */ - 1272 rtDW.UnitDelay1_DSTATE_k = rtb_Sum1_c; - 1273 - 1274 /* Outport: '<Root>/DC_phaCRight' incorporates: - 1275 * Constant: '<S55>/Constant1' - 1276 * Product: '<S55>/Divide1' - 1277 */ - 1278 rtY.DC_phaCRight = rtb_Abs1 / 1000; - 1279 - 1280 /* End of Outputs for SubSystem: '<Root>/BLDC_controller' */ - 1281 } - 1282 - 1283 /* Model initialize function */ - 1284 void BLDC_controller_initialize(void) - 1285 { - 1286 /* Start for Atomic SubSystem: '<Root>/BLDC_controller' */ - 1287 /* Start for If: '<S2>/If1' */ - 1288 rtDW.If1_ActiveSubsystem = -1; - 1289 - 1290 /* Start for If: '<S3>/If1' */ - 1291 rtDW.If1_ActiveSubsystem_j = -1; - 1292 - 1293 /* End of Start for SubSystem: '<Root>/BLDC_controller' */ - 1294 rtPrevZCX.Raw_Speed_calculation_k.Raw_Speed_calculation_Trig_ZCE = POS_ZCSIG; - 1295 rtPrevZCX.Moving_Average_Filter_n.Moving_Average_Filter_Trig_ZCE = POS_ZCSIG; - 1296 rtPrevZCX.Raw_Speed_calculation_m.Raw_Speed_calculation_Trig_ZCE = POS_ZCSIG; - 1297 rtPrevZCX.Moving_Average_Filter_l.Moving_Average_Filter_Trig_ZCE = POS_ZCSIG; - 1298 - 1299 /* SystemInitialize for Atomic SubSystem: '<Root>/BLDC_controller' */ - 1300 /* InitializeConditions for UnitDelay: '<S23>/z_counter2' */ - 1301 rtDW.z_counter2_DSTATE = 5000; - 1302 - 1303 /* InitializeConditions for UnitDelay: '<S63>/z_counter2' */ - 1304 rtDW.z_counter2_DSTATE_h = 5000; - 1305 - 1306 /* End of SystemInitialize for SubSystem: '<Root>/BLDC_controller' */ - 1307 } - 1308 - 1309 /* - 1310 * File trailer for generated code. - 1311 * - 1312 * [EOF] - 1313 */ - 1314 + 1263 /* Update for UnitDelay: '<S61>/z_counter2' */ + 1264 rtDW.z_counter2_DSTATE_h = rtb_Switch_b; + 1265 + 1266 /* Update for UnitDelay: '<S70>/UnitDelay1' */ + 1267 rtDW.UnitDelay1_DSTATE_k = rtb_Sum1_c; + 1268 + 1269 /* Outport: '<Root>/DC_phaCRight' incorporates: + 1270 * Constant: '<S53>/Constant1' + 1271 * Product: '<S53>/Divide1' + 1272 */ + 1273 rtY.DC_phaCRight = rtb_Abs1 / 1000; + 1274 + 1275 /* End of Outputs for SubSystem: '<Root>/BLDC_controller' */ + 1276 } + 1277 + 1278 /* Model initialize function */ + 1279 void BLDC_controller_initialize(void) + 1280 { + 1281 /* Start for Atomic SubSystem: '<Root>/BLDC_controller' */ + 1282 /* Start for If: '<S2>/If1' */ + 1283 rtDW.If1_ActiveSubsystem = -1; + 1284 + 1285 /* Start for If: '<S3>/If1' */ + 1286 rtDW.If1_ActiveSubsystem_j = -1; + 1287 + 1288 /* End of Start for SubSystem: '<Root>/BLDC_controller' */ + 1289 rtPrevZCX.Motor_Speed_Calculation_k.Motor_Speed_Calculation_Trig_ZC = + 1290 POS_ZCSIG; + 1291 rtPrevZCX.Motor_Speed_Calculation_m.Motor_Speed_Calculation_Trig_ZC = + 1292 POS_ZCSIG; + 1293 + 1294 /* SystemInitialize for Atomic SubSystem: '<Root>/BLDC_controller' */ + 1295 /* InitializeConditions for UnitDelay: '<S23>/z_counter2' */ + 1296 rtDW.z_counter2_DSTATE = rtP.z_maxCntRst; + 1297 + 1298 /* InitializeConditions for UnitDelay: '<S61>/z_counter2' */ + 1299 rtDW.z_counter2_DSTATE_h = rtP.z_maxCntRst; + 1300 + 1301 /* End of SystemInitialize for SubSystem: '<Root>/BLDC_controller' */ + 1302 } + 1303 + 1304 /* + 1305 * File trailer for generated code. + 1306 * + 1307 * [EOF] + 1308 */ + 1309

diff --git a/01_Matlab/BLDC_controller_ert_rtw/html/BLDC_controller_data_c.html b/01_Matlab/BLDC_controller_ert_rtw/html/BLDC_controller_data_c.html index 581ea13..3b009bd 100644 --- a/01_Matlab/BLDC_controller_ert_rtw/html/BLDC_controller_data_c.html +++ b/01_Matlab/BLDC_controller_ert_rtw/html/BLDC_controller_data_c.html @@ -21,9 +21,9 @@ 7 * 8 * Code generated for Simulink model 'BLDC_controller'. 9 * - 10 * Model version : 1.800 + 10 * Model version : 1.817 11 * Simulink Coder version : 8.13 (R2017b) 24-Jul-2017 - 12 * C/C++ source code generated on : Sat May 25 21:42:39 2019 + 12 * C/C++ source code generated on : Tue May 28 19:55:33 2019 13 * 14 * Target selection: ert.tlc 15 * Embedded hardware selection: ARM Compatible->ARM Cortex @@ -39,192 +39,191 @@ 25 26 /* Block parameters (auto storage) */ 27 P rtP = { - 28 /* Variable: cf_spdCoef + 28 /* Variable: cf_speedCoef 29 * Referenced by: - 30 * '<S29>/cf_spdCoef' - 31 * '<S69>/cf_spdCoef' + 30 * '<S28>/cf_spdCoef' + 31 * '<S66>/cf_spdCoef' 32 */ 33 66667, 34 35 /* Variable: n_commAcvLo 36 * Referenced by: 37 * '<S15>/Relay' - 38 * '<S55>/Relay' + 38 * '<S53>/Relay' 39 */ 40 100, 41 42 /* Variable: n_commDeacvHi 43 * Referenced by: 44 * '<S15>/Relay' - 45 * '<S55>/Relay' + 45 * '<S53>/Relay' 46 */ 47 180, 48 - 49 /* Variable: n_thresSpdDeacv + 49 /* Variable: r_commDCDeacv 50 * Referenced by: - 51 * '<S23>/n_thresSpdDeacv' - 52 * '<S63>/n_thresSpdDeacv' + 51 * '<S15>/r_commDCDeacv' + 52 * '<S53>/r_commDCDeacv' 53 */ - 54 5, + 54 70, 55 - 56 /* Variable: r_commDCDeacv + 56 /* Variable: r_phaAdvDC_XA 57 * Referenced by: - 58 * '<S15>/r_commDCDeacv' - 59 * '<S55>/r_commDCDeacv' + 58 * '<S13>/r_phaAdvDC_XA' + 59 * '<S51>/r_phaAdvDC_XA' 60 */ - 61 70, + 61 { 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 }, 62 - 63 /* Variable: r_phaAdvDC_XA + 63 /* Variable: a_phaAdv_M1 64 * Referenced by: - 65 * '<S13>/r_phaAdvDC_XA' - 66 * '<S53>/r_phaAdvDC_XA' + 65 * '<S13>/a_phaAdv_M2' + 66 * '<S51>/a_phaAdv_M2' 67 */ - 68 { 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 }, + 68 { 0, 0, 7, 2, 2, 2, 4, 5, 9, 16, 25 }, 69 - 70 /* Variable: a_phaAdv_M1 + 70 /* Variable: z_maxCntRst 71 * Referenced by: - 72 * '<S13>/a_phaAdv_M2' - 73 * '<S53>/a_phaAdv_M2' - 74 */ - 75 { 0, 0, 7, 2, 2, 2, 4, 5, 9, 16, 25 }, - 76 - 77 /* Variable: z_maxCntRst - 78 * Referenced by: - 79 * '<S23>/z_maxCntRst' - 80 * '<S63>/z_maxCntRst' - 81 * '<S29>/z_maxCntRst' - 82 * '<S69>/z_maxCntRst' - 83 */ - 84 2000, - 85 - 86 /* Variable: z_ctrlTypSel - 87 * Referenced by: - 88 * '<S12>/z_ctrlTypSel1' - 89 * '<S52>/z_ctrlTypSel1' - 90 */ - 91 3U, - 92 - 93 /* Variable: z_nrEdgeSpdAcv - 94 * Referenced by: - 95 * '<S23>/z_nrEdgeSpdAcv' - 96 * '<S63>/z_nrEdgeSpdAcv' - 97 */ - 98 5U, - 99 - 100 /* Variable: b_phaAdvEna - 101 * Referenced by: - 102 * '<S13>/a_elecPeriod1' - 103 * '<S53>/a_elecPeriod1' - 104 */ - 105 1 - 106 }; - 107 - 108 /* Constant parameters (auto storage) */ - 109 const ConstP rtConstP = { - 110 /* Pooled Parameter (Expression: r_trapPhaA_M1) - 111 * Referenced by: - 112 * '<S43>/r_trapPhaA_M1' - 113 * '<S83>/r_trapPhaA_M1' - 114 */ - 115 { 1000, 1000, 1000, -1000, -1000, -1000, 1000 }, - 116 - 117 /* Pooled Parameter (Expression: r_trapPhaB_M1) - 118 * Referenced by: - 119 * '<S43>/r_trapPhaB_M1' - 120 * '<S83>/r_trapPhaB_M1' - 121 */ - 122 { -1000, -1000, 1000, 1000, 1000, -1000, -1000 }, - 123 - 124 /* Pooled Parameter (Expression: r_trapPhaC_M1) - 125 * Referenced by: - 126 * '<S43>/r_trapPhaC_M1' - 127 * '<S83>/r_trapPhaC_M1' - 128 */ - 129 { 1000, -1000, -1000, -1000, 1000, 1000, 1000 }, - 130 - 131 /* Pooled Parameter (Expression: r_sinPhaA_M1) - 132 * Referenced by: - 133 * '<S45>/r_sinPhaA_M1' - 134 * '<S85>/r_sinPhaA_M1' - 135 */ - 136 { 500, 643, 766, 866, 940, 985, 1000, 985, 940, 866, 766, 643, 500, 342, 174, - 137 0, -174, -342, -500, -643, -766, -866, -940, -985, -1000, -985, -940, -866, - 138 -766, -643, -500, -342, -174, 0, 174, 342, 500 }, - 139 - 140 /* Pooled Parameter (Expression: r_sinPhaB_M1) - 141 * Referenced by: - 142 * '<S45>/r_sinPhaB_M1' - 143 * '<S85>/r_sinPhaB_M1' - 144 */ - 145 { -1000, -985, -940, -866, -766, -643, -500, -342, -174, 0, 174, 342, 500, 643, - 146 766, 866, 940, 985, 1000, 985, 940, 866, 766, 643, 500, 342, 174, 0, -174, - 147 -342, -500, -643, -766, -866, -940, -985, -1000 }, - 148 - 149 /* Pooled Parameter (Expression: r_sinPhaC_M1) - 150 * Referenced by: - 151 * '<S45>/r_sinPhaC_M1' - 152 * '<S85>/r_sinPhaC_M1' - 153 */ - 154 { 500, 342, 174, 0, -174, -342, -500, -643, -766, -866, -940, -985, -1000, - 155 -985, -940, -866, -766, -643, -500, -342, -174, 0, 174, 342, 500, 643, 766, - 156 866, 940, 985, 1000, 985, 940, 866, 766, 643, 500 }, - 157 - 158 /* Pooled Parameter (Expression: r_sin3PhaA_M1) - 159 * Referenced by: - 160 * '<S44>/r_sin3PhaA_M1' - 161 * '<S84>/r_sin3PhaA_M1' - 162 */ - 163 { 795, 930, 991, 996, 971, 942, 930, 942, 971, 996, 991, 930, 795, 584, 310, 0, - 164 -310, -584, -795, -930, -991, -996, -971, -942, -930, -942, -971, -996, -991, - 165 -930, -795, -584, -310, 0, 310, 584, 795 }, - 166 - 167 /* Pooled Parameter (Expression: r_sin3PhaB_M1) - 168 * Referenced by: - 169 * '<S44>/r_sin3PhaB_M1' - 170 * '<S84>/r_sin3PhaB_M1' - 171 */ - 172 { -930, -942, -971, -996, -991, -930, -795, -584, -310, 0, 310, 584, 795, 930, - 173 991, 996, 971, 942, 930, 942, 971, 996, 991, 930, 795, 584, 310, 0, -310, - 174 -584, -795, -930, -991, -996, -971, -942, -930 }, - 175 - 176 /* Pooled Parameter (Expression: r_sin3PhaC_M1) - 177 * Referenced by: - 178 * '<S44>/r_sin3PhaC_M1' - 179 * '<S84>/r_sin3PhaC_M1' - 180 */ - 181 { 795, 584, 310, 0, -310, -584, -795, -930, -991, -996, -971, -942, -930, -942, - 182 -971, -996, -991, -930, -795, -584, -310, 0, 310, 584, 795, 930, 991, 996, - 183 971, 942, 930, 942, 971, 996, 991, 930, 795 }, - 184 - 185 /* Pooled Parameter (Expression: z_commutMap_M1) - 186 * Referenced by: - 187 * '<S15>/z_commutMap_M1' - 188 * '<S55>/z_commutMap_M1' - 189 */ - 190 { 1000, -1000, 0, 1000, 0, -1000, 0, 1000, -1000, -1000, 1000, 0, -1000, 0, - 191 1000, 0, -1000, 1000 }, - 192 - 193 /* Pooled Parameter (Expression: vec_hallToPos) - 194 * Referenced by: - 195 * '<S21>/vec_hallToPos' - 196 * '<S61>/vec_hallToPos' - 197 */ - 198 { 0U, 5U, 3U, 4U, 1U, 0U, 2U, 0U }, - 199 - 200 /* Pooled Parameter (Expression: [0 1;1 0;0 1;0 1;1 0;1 0;0 0;0 0]) - 201 * Referenced by: - 202 * '<S30>/Logic' - 203 * '<S70>/Logic' - 204 */ - 205 { 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0 } - 206 }; - 207 - 208 /* - 209 * File trailer for generated code. - 210 * - 211 * [EOF] - 212 */ - 213 + 72 * '<S23>/z_maxCntRst' + 73 * '<S23>/z_maxCntRst1' + 74 * '<S23>/z_maxCntRst2' + 75 * '<S23>/z_counter2' + 76 * '<S61>/z_maxCntRst' + 77 * '<S61>/z_maxCntRst1' + 78 * '<S61>/z_maxCntRst2' + 79 * '<S61>/z_counter2' + 80 * '<S28>/z_maxCntRst' + 81 * '<S66>/z_maxCntRst' + 82 */ + 83 2000, + 84 + 85 /* Variable: z_ctrlTypSel + 86 * Referenced by: + 87 * '<S12>/z_ctrlTypSel1' + 88 * '<S50>/z_ctrlTypSel1' + 89 */ + 90 3U, + 91 + 92 /* Variable: z_nrEdgeSpdAcv + 93 * Referenced by: + 94 * '<S23>/z_nrEdgeSpdAcv' + 95 * '<S61>/z_nrEdgeSpdAcv' + 96 */ + 97 3U, + 98 + 99 /* Variable: b_phaAdvEna + 100 * Referenced by: + 101 * '<S13>/a_elecPeriod1' + 102 * '<S51>/a_elecPeriod1' + 103 */ + 104 1 + 105 }; + 106 + 107 /* Constant parameters (auto storage) */ + 108 const ConstP rtConstP = { + 109 /* Pooled Parameter (Expression: r_trapPhaA_M1) + 110 * Referenced by: + 111 * '<S41>/r_trapPhaA_M1' + 112 * '<S79>/r_trapPhaA_M1' + 113 */ + 114 { 1000, 1000, 1000, -1000, -1000, -1000, 1000 }, + 115 + 116 /* Pooled Parameter (Expression: r_trapPhaB_M1) + 117 * Referenced by: + 118 * '<S41>/r_trapPhaB_M1' + 119 * '<S79>/r_trapPhaB_M1' + 120 */ + 121 { -1000, -1000, 1000, 1000, 1000, -1000, -1000 }, + 122 + 123 /* Pooled Parameter (Expression: r_trapPhaC_M1) + 124 * Referenced by: + 125 * '<S41>/r_trapPhaC_M1' + 126 * '<S79>/r_trapPhaC_M1' + 127 */ + 128 { 1000, -1000, -1000, -1000, 1000, 1000, 1000 }, + 129 + 130 /* Pooled Parameter (Expression: r_sinPhaA_M1) + 131 * Referenced by: + 132 * '<S43>/r_sinPhaA_M1' + 133 * '<S81>/r_sinPhaA_M1' + 134 */ + 135 { 500, 643, 766, 866, 940, 985, 1000, 985, 940, 866, 766, 643, 500, 342, 174, + 136 0, -174, -342, -500, -643, -766, -866, -940, -985, -1000, -985, -940, -866, + 137 -766, -643, -500, -342, -174, 0, 174, 342, 500 }, + 138 + 139 /* Pooled Parameter (Expression: r_sinPhaB_M1) + 140 * Referenced by: + 141 * '<S43>/r_sinPhaB_M1' + 142 * '<S81>/r_sinPhaB_M1' + 143 */ + 144 { -1000, -985, -940, -866, -766, -643, -500, -342, -174, 0, 174, 342, 500, 643, + 145 766, 866, 940, 985, 1000, 985, 940, 866, 766, 643, 500, 342, 174, 0, -174, + 146 -342, -500, -643, -766, -866, -940, -985, -1000 }, + 147 + 148 /* Pooled Parameter (Expression: r_sinPhaC_M1) + 149 * Referenced by: + 150 * '<S43>/r_sinPhaC_M1' + 151 * '<S81>/r_sinPhaC_M1' + 152 */ + 153 { 500, 342, 174, 0, -174, -342, -500, -643, -766, -866, -940, -985, -1000, + 154 -985, -940, -866, -766, -643, -500, -342, -174, 0, 174, 342, 500, 643, 766, + 155 866, 940, 985, 1000, 985, 940, 866, 766, 643, 500 }, + 156 + 157 /* Pooled Parameter (Expression: r_sin3PhaA_M1) + 158 * Referenced by: + 159 * '<S42>/r_sin3PhaA_M1' + 160 * '<S80>/r_sin3PhaA_M1' + 161 */ + 162 { 795, 930, 991, 996, 971, 942, 930, 942, 971, 996, 991, 930, 795, 584, 310, 0, + 163 -310, -584, -795, -930, -991, -996, -971, -942, -930, -942, -971, -996, -991, + 164 -930, -795, -584, -310, 0, 310, 584, 795 }, + 165 + 166 /* Pooled Parameter (Expression: r_sin3PhaB_M1) + 167 * Referenced by: + 168 * '<S42>/r_sin3PhaB_M1' + 169 * '<S80>/r_sin3PhaB_M1' + 170 */ + 171 { -930, -942, -971, -996, -991, -930, -795, -584, -310, 0, 310, 584, 795, 930, + 172 991, 996, 971, 942, 930, 942, 971, 996, 991, 930, 795, 584, 310, 0, -310, + 173 -584, -795, -930, -991, -996, -971, -942, -930 }, + 174 + 175 /* Pooled Parameter (Expression: r_sin3PhaC_M1) + 176 * Referenced by: + 177 * '<S42>/r_sin3PhaC_M1' + 178 * '<S80>/r_sin3PhaC_M1' + 179 */ + 180 { 795, 584, 310, 0, -310, -584, -795, -930, -991, -996, -971, -942, -930, -942, + 181 -971, -996, -991, -930, -795, -584, -310, 0, 310, 584, 795, 930, 991, 996, + 182 971, 942, 930, 942, 971, 996, 991, 930, 795 }, + 183 + 184 /* Pooled Parameter (Expression: z_commutMap_M1) + 185 * Referenced by: + 186 * '<S15>/z_commutMap_M1' + 187 * '<S53>/z_commutMap_M1' + 188 */ + 189 { 1000, -1000, 0, 1000, 0, -1000, 0, 1000, -1000, -1000, 1000, 0, -1000, 0, + 190 1000, 0, -1000, 1000 }, + 191 + 192 /* Pooled Parameter (Expression: vec_hallToPos) + 193 * Referenced by: + 194 * '<S21>/vec_hallToPos' + 195 * '<S59>/vec_hallToPos' + 196 */ + 197 { 0U, 5U, 3U, 4U, 1U, 0U, 2U, 0U }, + 198 + 199 /* Pooled Parameter (Expression: [0 1;1 0;0 1;0 1;1 0;1 0;0 0;0 0]) + 200 * Referenced by: + 201 * '<S29>/Logic' + 202 * '<S67>/Logic' + 203 */ + 204 { 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0 } + 205 }; + 206 + 207 /* + 208 * File trailer for generated code. + 209 * + 210 * [EOF] + 211 */ + 212

diff --git a/01_Matlab/BLDC_controller_ert_rtw/html/BLDC_controller_h.html b/01_Matlab/BLDC_controller_ert_rtw/html/BLDC_controller_h.html index 015cf27..7cf5d7f 100644 --- a/01_Matlab/BLDC_controller_ert_rtw/html/BLDC_controller_h.html +++ b/01_Matlab/BLDC_controller_ert_rtw/html/BLDC_controller_h.html @@ -21,9 +21,9 @@ 7 * 8 * Code generated for Simulink model 'BLDC_controller'. 9 * - 10 * Model version : 1.800 + 10 * Model version : 1.817 11 * Simulink Coder version : 8.13 (R2017b) 24-Jul-2017 - 12 * C/C++ source code generated on : Sat May 25 21:42:39 2019 + 12 * C/C++ source code generated on : Tue May 28 19:55:33 2019 13 * 14 * Target selection: ert.tlc 15 * Embedded hardware selection: ARM Compatible->ARM Cortex @@ -54,409 +54,402 @@ 40 41 /* Block signals and states (auto storage) for system '<S23>/Edge_counter' */ 42 typedef struct { - 43 uint8_T UnitDelay1_DSTATE; /* '<S38>/UnitDelay1' */ + 43 uint8_T UnitDelay1_DSTATE; /* '<S37>/UnitDelay1' */ 44 boolean_T Edge_counter_MODE; /* '<S23>/Edge_counter' */ 45 } DW_Edge_counter; 46 - 47 /* Block signals and states (auto storage) for system '<S23>/Moving_Average_Filter' */ + 47 /* Block signals and states (auto storage) for system '<S23>/Motor_Speed_Calculation' */ 48 typedef struct { - 49 int32_T UnitDelay5_DSTATE; /* '<S28>/UnitDelay5' */ - 50 int32_T UnitDelay1_DSTATE; /* '<S28>/UnitDelay1' */ - 51 } DW_Moving_Average_Filter; + 49 int32_T UnitDelay5_DSTATE; /* '<S28>/UnitDelay5' */ + 50 int32_T UnitDelay1_DSTATE; /* '<S28>/UnitDelay1' */ + 51 } DW_Motor_Speed_Calculation; 52 - 53 /* Zero-crossing (trigger) state for system '<S23>/Moving_Average_Filter' */ + 53 /* Zero-crossing (trigger) state for system '<S23>/Motor_Speed_Calculation' */ 54 typedef struct { - 55 ZCSigState Moving_Average_Filter_Trig_ZCE;/* '<S23>/Moving_Average_Filter' */ - 56 } ZCE_Moving_Average_Filter; + 55 ZCSigState Motor_Speed_Calculation_Trig_ZC;/* '<S23>/Motor_Speed_Calculation' */ + 56 } ZCE_Motor_Speed_Calculation; 57 - 58 /* Zero-crossing (trigger) state for system '<S23>/Raw_ Speed_calculation' */ + 58 /* Block signals and states (auto storage) for system '<Root>' */ 59 typedef struct { - 60 ZCSigState Raw_Speed_calculation_Trig_ZCE;/* '<S23>/Raw_ Speed_calculation' */ - 61 } ZCE_Raw_Speed_calculation; - 62 - 63 /* Block signals and states (auto storage) for system '<Root>' */ - 64 typedef struct { - 65 DW_Moving_Average_Filter Moving_Average_Filter_n;/* '<S63>/Moving_Average_Filter' */ - 66 DW_Edge_counter Edge_counter_l; /* '<S63>/Edge_counter' */ - 67 DW_F01_03_Direction_Detection F01_03_Direction_Detection_j;/* '<S52>/F01_03_Direction_Detection' */ - 68 DW_Moving_Average_Filter Moving_Average_Filter_l;/* '<S23>/Moving_Average_Filter' */ - 69 DW_Edge_counter Edge_counter_f; /* '<S23>/Edge_counter' */ - 70 DW_F01_03_Direction_Detection F01_03_Direction_Detection_o;/* '<S12>/F01_03_Direction_Detection' */ - 71 int32_T Switch_PhaAdv; /* '<S53>/Switch_PhaAdv' */ - 72 int32_T rpm_signed; /* '<S69>/Product2' */ - 73 int32_T Switch_PhaAdv_a; /* '<S13>/Switch_PhaAdv' */ - 74 int32_T rpm_signed_c; /* '<S29>/Product2' */ - 75 int16_T Merge; /* '<S14>/Merge' */ - 76 int16_T Merge1; /* '<S14>/Merge1' */ - 77 int16_T Merge2; /* '<S14>/Merge2' */ - 78 int16_T Merge_j; /* '<S54>/Merge' */ - 79 int16_T Merge1_m; /* '<S54>/Merge1' */ - 80 int16_T Merge2_d; /* '<S54>/Merge2' */ - 81 int16_T z_counterRawPrev_DSTATE; /* '<S23>/z_counterRawPrev' */ - 82 int16_T z_counter2_DSTATE; /* '<S23>/z_counter2' */ - 83 int16_T UnitDelay1_DSTATE; /* '<S32>/UnitDelay1' */ - 84 int16_T z_counterRawPrev_DSTATE_p; /* '<S63>/z_counterRawPrev' */ - 85 int16_T z_counter2_DSTATE_h; /* '<S63>/z_counter2' */ - 86 int16_T UnitDelay1_DSTATE_k; /* '<S72>/UnitDelay1' */ - 87 int8_T UnitDelay1; /* '<S62>/UnitDelay1' */ - 88 int8_T Switch2; /* '<S62>/Switch2' */ - 89 int8_T UnitDelay1_k; /* '<S22>/UnitDelay1' */ - 90 int8_T Switch2_e; /* '<S22>/Switch2' */ - 91 int8_T If1_ActiveSubsystem; /* '<S2>/If1' */ - 92 int8_T If1_ActiveSubsystem_j; /* '<S3>/If1' */ - 93 uint8_T Sum2_i; /* '<S67>/Sum2' */ - 94 uint8_T Sum2_l; /* '<S27>/Sum2' */ - 95 uint8_T UnitDelay_DSTATE; /* '<S20>/UnitDelay' */ - 96 uint8_T UnitDelay1_DSTATE_p; /* '<S20>/UnitDelay1' */ - 97 uint8_T UnitDelay2_DSTATE; /* '<S20>/UnitDelay2' */ - 98 uint8_T UnitDelay1_DSTATE_g; /* '<S21>/UnitDelay1' */ - 99 uint8_T UnitDelay_DSTATE_j; /* '<S60>/UnitDelay' */ - 100 uint8_T UnitDelay1_DSTATE_f; /* '<S60>/UnitDelay1' */ - 101 uint8_T UnitDelay2_DSTATE_b; /* '<S60>/UnitDelay2' */ - 102 uint8_T UnitDelay1_DSTATE_j; /* '<S61>/UnitDelay1' */ - 103 boolean_T RelationalOperator4; /* '<S63>/Relational Operator4' */ - 104 boolean_T LogicalOperator; /* '<S71>/Logical Operator' */ - 105 boolean_T UnitDelay8_DSTATE; /* '<S23>/UnitDelay8' */ - 106 boolean_T UnitDelay8_DSTATE_p; /* '<S63>/UnitDelay8' */ - 107 boolean_T UnitDelay_DSTATE_k; /* '<S71>/UnitDelay' */ - 108 boolean_T UnitDelay_DSTATE_l; /* '<S31>/UnitDelay' */ - 109 boolean_T Memory_PreviousInput; /* '<S30>/Memory' */ - 110 boolean_T Relay_Mode; /* '<S15>/Relay' */ - 111 boolean_T Memory_PreviousInput_i; /* '<S70>/Memory' */ - 112 boolean_T Relay_Mode_m; /* '<S55>/Relay' */ - 113 } DW; - 114 - 115 /* Zero-crossing (trigger) state */ - 116 typedef struct { - 117 ZCE_Raw_Speed_calculation Raw_Speed_calculation_k;/* '<S63>/Raw_ Speed_calculation' */ - 118 ZCE_Moving_Average_Filter Moving_Average_Filter_n;/* '<S63>/Moving_Average_Filter' */ - 119 ZCE_Raw_Speed_calculation Raw_Speed_calculation_m;/* '<S23>/Raw_ Speed_calculation' */ - 120 ZCE_Moving_Average_Filter Moving_Average_Filter_l;/* '<S23>/Moving_Average_Filter' */ - 121 } PrevZCX; - 122 - 123 /* Constant parameters (auto storage) */ - 124 typedef struct { - 125 /* Pooled Parameter (Expression: r_trapPhaA_M1) - 126 * Referenced by: - 127 * '<S43>/r_trapPhaA_M1' - 128 * '<S83>/r_trapPhaA_M1' - 129 */ - 130 int16_T pooled8[7]; - 131 - 132 /* Pooled Parameter (Expression: r_trapPhaB_M1) - 133 * Referenced by: - 134 * '<S43>/r_trapPhaB_M1' - 135 * '<S83>/r_trapPhaB_M1' - 136 */ - 137 int16_T pooled9[7]; - 138 - 139 /* Pooled Parameter (Expression: r_trapPhaC_M1) - 140 * Referenced by: - 141 * '<S43>/r_trapPhaC_M1' - 142 * '<S83>/r_trapPhaC_M1' - 143 */ - 144 int16_T pooled10[7]; - 145 - 146 /* Pooled Parameter (Expression: r_sinPhaA_M1) - 147 * Referenced by: - 148 * '<S45>/r_sinPhaA_M1' - 149 * '<S85>/r_sinPhaA_M1' - 150 */ - 151 int16_T pooled11[37]; - 152 - 153 /* Pooled Parameter (Expression: r_sinPhaB_M1) - 154 * Referenced by: - 155 * '<S45>/r_sinPhaB_M1' - 156 * '<S85>/r_sinPhaB_M1' - 157 */ - 158 int16_T pooled12[37]; - 159 - 160 /* Pooled Parameter (Expression: r_sinPhaC_M1) - 161 * Referenced by: - 162 * '<S45>/r_sinPhaC_M1' - 163 * '<S85>/r_sinPhaC_M1' - 164 */ - 165 int16_T pooled13[37]; - 166 - 167 /* Pooled Parameter (Expression: r_sin3PhaA_M1) - 168 * Referenced by: - 169 * '<S44>/r_sin3PhaA_M1' - 170 * '<S84>/r_sin3PhaA_M1' - 171 */ - 172 int16_T pooled14[37]; - 173 - 174 /* Pooled Parameter (Expression: r_sin3PhaB_M1) - 175 * Referenced by: - 176 * '<S44>/r_sin3PhaB_M1' - 177 * '<S84>/r_sin3PhaB_M1' - 178 */ - 179 int16_T pooled15[37]; - 180 - 181 /* Pooled Parameter (Expression: r_sin3PhaC_M1) - 182 * Referenced by: - 183 * '<S44>/r_sin3PhaC_M1' - 184 * '<S84>/r_sin3PhaC_M1' - 185 */ - 186 int16_T pooled16[37]; - 187 - 188 /* Pooled Parameter (Expression: z_commutMap_M1) - 189 * Referenced by: - 190 * '<S15>/z_commutMap_M1' - 191 * '<S55>/z_commutMap_M1' - 192 */ - 193 int16_T pooled17[18]; - 194 - 195 /* Pooled Parameter (Expression: vec_hallToPos) - 196 * Referenced by: - 197 * '<S21>/vec_hallToPos' - 198 * '<S61>/vec_hallToPos' - 199 */ - 200 uint8_T pooled27[8]; - 201 - 202 /* Pooled Parameter (Expression: [0 1;1 0;0 1;0 1;1 0;1 0;0 0;0 0]) - 203 * Referenced by: - 204 * '<S30>/Logic' - 205 * '<S70>/Logic' - 206 */ - 207 boolean_T pooled31[16]; - 208 } ConstP; - 209 - 210 /* External inputs (root inport signals with auto storage) */ - 211 typedef struct { - 212 uint8_T b_hallALeft; /* '<Root>/b_hallALeft ' */ - 213 uint8_T b_hallBLeft; /* '<Root>/b_hallBLeft' */ - 214 uint8_T b_hallCLeft; /* '<Root>/b_hallCLeft' */ - 215 int32_T r_DCLeft; /* '<Root>/r_DCLeft' */ - 216 uint8_T b_hallARight; /* '<Root>/b_hallARight' */ - 217 uint8_T b_hallBRight; /* '<Root>/b_hallBRight' */ - 218 uint8_T b_hallCRight; /* '<Root>/b_hallCRight' */ - 219 int32_T r_DCRight; /* '<Root>/r_DCRight' */ - 220 } ExtU; - 221 - 222 /* External outputs (root outports fed by signals with auto storage) */ - 223 typedef struct { - 224 int32_T DC_phaALeft; /* '<Root>/DC_phaALeft' */ - 225 int32_T DC_phaBLeft; /* '<Root>/DC_phaBLeft' */ - 226 int32_T DC_phaCLeft; /* '<Root>/DC_phaCLeft' */ - 227 int32_T n_motLeft; /* '<Root>/n_motLeft' */ - 228 int32_T a_elecAngleLeft; /* '<Root>/a_elecAngleLeft' */ - 229 int32_T DC_phaARight; /* '<Root>/DC_phaARight' */ - 230 int32_T DC_phaBRight; /* '<Root>/DC_phaBRight' */ - 231 int32_T DC_phaCRight; /* '<Root>/DC_phaCRight' */ - 232 int32_T n_motRight; /* '<Root>/n_motRight' */ - 233 int32_T a_elecAngleRight; /* '<Root>/a_elecAngleRight' */ - 234 } ExtY; - 235 - 236 /* Parameters (auto storage) */ - 237 struct P_ { - 238 int32_T cf_spdCoef; /* Variable: cf_spdCoef - 239 * Referenced by: - 240 * '<S29>/cf_spdCoef' - 241 * '<S69>/cf_spdCoef' - 242 */ - 243 int32_T n_commAcvLo; /* Variable: n_commAcvLo - 244 * Referenced by: - 245 * '<S15>/Relay' - 246 * '<S55>/Relay' - 247 */ - 248 int32_T n_commDeacvHi; /* Variable: n_commDeacvHi - 249 * Referenced by: - 250 * '<S15>/Relay' - 251 * '<S55>/Relay' - 252 */ - 253 int32_T n_thresSpdDeacv; /* Variable: n_thresSpdDeacv - 254 * Referenced by: - 255 * '<S23>/n_thresSpdDeacv' - 256 * '<S63>/n_thresSpdDeacv' - 257 */ - 258 int32_T r_commDCDeacv; /* Variable: r_commDCDeacv - 259 * Referenced by: - 260 * '<S15>/r_commDCDeacv' - 261 * '<S55>/r_commDCDeacv' - 262 */ - 263 int32_T r_phaAdvDC_XA[11]; /* Variable: r_phaAdvDC_XA - 264 * Referenced by: - 265 * '<S13>/r_phaAdvDC_XA' - 266 * '<S53>/r_phaAdvDC_XA' - 267 */ - 268 int16_T a_phaAdv_M1[11]; /* Variable: a_phaAdv_M1 - 269 * Referenced by: - 270 * '<S13>/a_phaAdv_M2' - 271 * '<S53>/a_phaAdv_M2' - 272 */ - 273 int16_T z_maxCntRst; /* Variable: z_maxCntRst - 274 * Referenced by: - 275 * '<S23>/z_maxCntRst' - 276 * '<S63>/z_maxCntRst' - 277 * '<S29>/z_maxCntRst' - 278 * '<S69>/z_maxCntRst' - 279 */ - 280 uint8_T z_ctrlTypSel; /* Variable: z_ctrlTypSel - 281 * Referenced by: - 282 * '<S12>/z_ctrlTypSel1' - 283 * '<S52>/z_ctrlTypSel1' - 284 */ - 285 uint8_T z_nrEdgeSpdAcv; /* Variable: z_nrEdgeSpdAcv - 286 * Referenced by: - 287 * '<S23>/z_nrEdgeSpdAcv' - 288 * '<S63>/z_nrEdgeSpdAcv' - 289 */ - 290 boolean_T b_phaAdvEna; /* Variable: b_phaAdvEna - 291 * Referenced by: - 292 * '<S13>/a_elecPeriod1' - 293 * '<S53>/a_elecPeriod1' - 294 */ - 295 }; + 60 DW_Motor_Speed_Calculation Motor_Speed_Calculation_k;/* '<S61>/Motor_Speed_Calculation' */ + 61 DW_Edge_counter Edge_counter_l; /* '<S61>/Edge_counter' */ + 62 DW_F01_03_Direction_Detection F01_03_Direction_Detection_j;/* '<S50>/F01_03_Direction_Detection' */ + 63 DW_Motor_Speed_Calculation Motor_Speed_Calculation_m;/* '<S23>/Motor_Speed_Calculation' */ + 64 DW_Edge_counter Edge_counter_f; /* '<S23>/Edge_counter' */ + 65 DW_F01_03_Direction_Detection F01_03_Direction_Detection_o;/* '<S12>/F01_03_Direction_Detection' */ + 66 int32_T Switch_PhaAdv; /* '<S51>/Switch_PhaAdv' */ + 67 int32_T Switch_PhaAdv_a; /* '<S13>/Switch_PhaAdv' */ + 68 int16_T Merge; /* '<S14>/Merge' */ + 69 int16_T Merge1; /* '<S14>/Merge1' */ + 70 int16_T Merge2; /* '<S14>/Merge2' */ + 71 int16_T Merge_j; /* '<S52>/Merge' */ + 72 int16_T Merge1_m; /* '<S52>/Merge1' */ + 73 int16_T Merge2_d; /* '<S52>/Merge2' */ + 74 int16_T z_counterRawPrev_DSTATE; /* '<S23>/z_counterRawPrev' */ + 75 int16_T z_counter2_DSTATE; /* '<S23>/z_counter2' */ + 76 int16_T UnitDelay1_DSTATE; /* '<S32>/UnitDelay1' */ + 77 int16_T z_counterRawPrev_DSTATE_p; /* '<S61>/z_counterRawPrev' */ + 78 int16_T z_counter2_DSTATE_h; /* '<S61>/z_counter2' */ + 79 int16_T UnitDelay1_DSTATE_k; /* '<S70>/UnitDelay1' */ + 80 int8_T UnitDelay1; /* '<S60>/UnitDelay1' */ + 81 int8_T Switch2; /* '<S60>/Switch2' */ + 82 int8_T UnitDelay1_k; /* '<S22>/UnitDelay1' */ + 83 int8_T Switch2_e; /* '<S22>/Switch2' */ + 84 int8_T If1_ActiveSubsystem; /* '<S2>/If1' */ + 85 int8_T If1_ActiveSubsystem_j; /* '<S3>/If1' */ + 86 uint8_T Sum2_i; /* '<S65>/Sum2' */ + 87 uint8_T Sum2_l; /* '<S27>/Sum2' */ + 88 uint8_T UnitDelay_DSTATE; /* '<S20>/UnitDelay' */ + 89 uint8_T UnitDelay1_DSTATE_p; /* '<S20>/UnitDelay1' */ + 90 uint8_T UnitDelay2_DSTATE; /* '<S20>/UnitDelay2' */ + 91 uint8_T UnitDelay1_DSTATE_g; /* '<S21>/UnitDelay1' */ + 92 uint8_T UnitDelay_DSTATE_j; /* '<S58>/UnitDelay' */ + 93 uint8_T UnitDelay1_DSTATE_f; /* '<S58>/UnitDelay1' */ + 94 uint8_T UnitDelay2_DSTATE_b; /* '<S58>/UnitDelay2' */ + 95 uint8_T UnitDelay1_DSTATE_j; /* '<S59>/UnitDelay1' */ + 96 boolean_T Logic[2]; /* '<S29>/Logic' */ + 97 boolean_T Logic_j[2]; /* '<S67>/Logic' */ + 98 boolean_T LogicalOperator; /* '<S30>/Logical Operator' */ + 99 boolean_T LogicalOperator5; /* '<S61>/Logical Operator5' */ + 100 boolean_T LogicalOperator_h; /* '<S68>/Logical Operator' */ + 101 boolean_T UnitDelay8_DSTATE; /* '<S23>/UnitDelay8' */ + 102 boolean_T UnitDelay8_DSTATE_p; /* '<S61>/UnitDelay8' */ + 103 boolean_T UnitDelay_DSTATE_k; /* '<S69>/UnitDelay' */ + 104 boolean_T UnitDelay_DSTATE_i; /* '<S68>/UnitDelay' */ + 105 boolean_T UnitDelay_DSTATE_l; /* '<S31>/UnitDelay' */ + 106 boolean_T UnitDelay_DSTATE_b; /* '<S30>/UnitDelay' */ + 107 boolean_T Memory_PreviousInput; /* '<S29>/Memory' */ + 108 boolean_T Relay_Mode; /* '<S15>/Relay' */ + 109 boolean_T Memory_PreviousInput_i; /* '<S67>/Memory' */ + 110 boolean_T Relay_Mode_m; /* '<S53>/Relay' */ + 111 } DW; + 112 + 113 /* Zero-crossing (trigger) state */ + 114 typedef struct { + 115 ZCE_Motor_Speed_Calculation Motor_Speed_Calculation_k;/* '<S61>/Motor_Speed_Calculation' */ + 116 ZCE_Motor_Speed_Calculation Motor_Speed_Calculation_m;/* '<S23>/Motor_Speed_Calculation' */ + 117 } PrevZCX; + 118 + 119 /* Constant parameters (auto storage) */ + 120 typedef struct { + 121 /* Pooled Parameter (Expression: r_trapPhaA_M1) + 122 * Referenced by: + 123 * '<S41>/r_trapPhaA_M1' + 124 * '<S79>/r_trapPhaA_M1' + 125 */ + 126 int16_T pooled9[7]; + 127 + 128 /* Pooled Parameter (Expression: r_trapPhaB_M1) + 129 * Referenced by: + 130 * '<S41>/r_trapPhaB_M1' + 131 * '<S79>/r_trapPhaB_M1' + 132 */ + 133 int16_T pooled10[7]; + 134 + 135 /* Pooled Parameter (Expression: r_trapPhaC_M1) + 136 * Referenced by: + 137 * '<S41>/r_trapPhaC_M1' + 138 * '<S79>/r_trapPhaC_M1' + 139 */ + 140 int16_T pooled11[7]; + 141 + 142 /* Pooled Parameter (Expression: r_sinPhaA_M1) + 143 * Referenced by: + 144 * '<S43>/r_sinPhaA_M1' + 145 * '<S81>/r_sinPhaA_M1' + 146 */ + 147 int16_T pooled12[37]; + 148 + 149 /* Pooled Parameter (Expression: r_sinPhaB_M1) + 150 * Referenced by: + 151 * '<S43>/r_sinPhaB_M1' + 152 * '<S81>/r_sinPhaB_M1' + 153 */ + 154 int16_T pooled13[37]; + 155 + 156 /* Pooled Parameter (Expression: r_sinPhaC_M1) + 157 * Referenced by: + 158 * '<S43>/r_sinPhaC_M1' + 159 * '<S81>/r_sinPhaC_M1' + 160 */ + 161 int16_T pooled14[37]; + 162 + 163 /* Pooled Parameter (Expression: r_sin3PhaA_M1) + 164 * Referenced by: + 165 * '<S42>/r_sin3PhaA_M1' + 166 * '<S80>/r_sin3PhaA_M1' + 167 */ + 168 int16_T pooled15[37]; + 169 + 170 /* Pooled Parameter (Expression: r_sin3PhaB_M1) + 171 * Referenced by: + 172 * '<S42>/r_sin3PhaB_M1' + 173 * '<S80>/r_sin3PhaB_M1' + 174 */ + 175 int16_T pooled16[37]; + 176 + 177 /* Pooled Parameter (Expression: r_sin3PhaC_M1) + 178 * Referenced by: + 179 * '<S42>/r_sin3PhaC_M1' + 180 * '<S80>/r_sin3PhaC_M1' + 181 */ + 182 int16_T pooled17[37]; + 183 + 184 /* Pooled Parameter (Expression: z_commutMap_M1) + 185 * Referenced by: + 186 * '<S15>/z_commutMap_M1' + 187 * '<S53>/z_commutMap_M1' + 188 */ + 189 int16_T pooled18[18]; + 190 + 191 /* Pooled Parameter (Expression: vec_hallToPos) + 192 * Referenced by: + 193 * '<S21>/vec_hallToPos' + 194 * '<S59>/vec_hallToPos' + 195 */ + 196 uint8_T pooled26[8]; + 197 + 198 /* Pooled Parameter (Expression: [0 1;1 0;0 1;0 1;1 0;1 0;0 0;0 0]) + 199 * Referenced by: + 200 * '<S29>/Logic' + 201 * '<S67>/Logic' + 202 */ + 203 boolean_T pooled30[16]; + 204 } ConstP; + 205 + 206 /* External inputs (root inport signals with auto storage) */ + 207 typedef struct { + 208 uint8_T b_hallALeft; /* '<Root>/b_hallALeft ' */ + 209 uint8_T b_hallBLeft; /* '<Root>/b_hallBLeft' */ + 210 uint8_T b_hallCLeft; /* '<Root>/b_hallCLeft' */ + 211 int32_T r_DCLeft; /* '<Root>/r_DCLeft' */ + 212 uint8_T b_hallARight; /* '<Root>/b_hallARight' */ + 213 uint8_T b_hallBRight; /* '<Root>/b_hallBRight' */ + 214 uint8_T b_hallCRight; /* '<Root>/b_hallCRight' */ + 215 int32_T r_DCRight; /* '<Root>/r_DCRight' */ + 216 } ExtU; + 217 + 218 /* External outputs (root outports fed by signals with auto storage) */ + 219 typedef struct { + 220 int32_T DC_phaALeft; /* '<Root>/DC_phaALeft' */ + 221 int32_T DC_phaBLeft; /* '<Root>/DC_phaBLeft' */ + 222 int32_T DC_phaCLeft; /* '<Root>/DC_phaCLeft' */ + 223 int32_T n_motLeft; /* '<Root>/n_motLeft' */ + 224 int32_T a_elecAngleLeft; /* '<Root>/a_elecAngleLeft' */ + 225 int32_T DC_phaARight; /* '<Root>/DC_phaARight' */ + 226 int32_T DC_phaBRight; /* '<Root>/DC_phaBRight' */ + 227 int32_T DC_phaCRight; /* '<Root>/DC_phaCRight' */ + 228 int32_T n_motRight; /* '<Root>/n_motRight' */ + 229 int32_T a_elecAngleRight; /* '<Root>/a_elecAngleRight' */ + 230 } ExtY; + 231 + 232 /* Parameters (auto storage) */ + 233 struct P_ { + 234 int32_T cf_speedCoef; /* Variable: cf_speedCoef + 235 * Referenced by: + 236 * '<S28>/cf_spdCoef' + 237 * '<S66>/cf_spdCoef' + 238 */ + 239 int32_T n_commAcvLo; /* Variable: n_commAcvLo + 240 * Referenced by: + 241 * '<S15>/Relay' + 242 * '<S53>/Relay' + 243 */ + 244 int32_T n_commDeacvHi; /* Variable: n_commDeacvHi + 245 * Referenced by: + 246 * '<S15>/Relay' + 247 * '<S53>/Relay' + 248 */ + 249 int32_T r_commDCDeacv; /* Variable: r_commDCDeacv + 250 * Referenced by: + 251 * '<S15>/r_commDCDeacv' + 252 * '<S53>/r_commDCDeacv' + 253 */ + 254 int32_T r_phaAdvDC_XA[11]; /* Variable: r_phaAdvDC_XA + 255 * Referenced by: + 256 * '<S13>/r_phaAdvDC_XA' + 257 * '<S51>/r_phaAdvDC_XA' + 258 */ + 259 int16_T a_phaAdv_M1[11]; /* Variable: a_phaAdv_M1 + 260 * Referenced by: + 261 * '<S13>/a_phaAdv_M2' + 262 * '<S51>/a_phaAdv_M2' + 263 */ + 264 int16_T z_maxCntRst; /* Variable: z_maxCntRst + 265 * Referenced by: + 266 * '<S23>/z_maxCntRst' + 267 * '<S23>/z_maxCntRst1' + 268 * '<S23>/z_maxCntRst2' + 269 * '<S23>/z_counter2' + 270 * '<S61>/z_maxCntRst' + 271 * '<S61>/z_maxCntRst1' + 272 * '<S61>/z_maxCntRst2' + 273 * '<S61>/z_counter2' + 274 * '<S28>/z_maxCntRst' + 275 * '<S66>/z_maxCntRst' + 276 */ + 277 uint8_T z_ctrlTypSel; /* Variable: z_ctrlTypSel + 278 * Referenced by: + 279 * '<S12>/z_ctrlTypSel1' + 280 * '<S50>/z_ctrlTypSel1' + 281 */ + 282 uint8_T z_nrEdgeSpdAcv; /* Variable: z_nrEdgeSpdAcv + 283 * Referenced by: + 284 * '<S23>/z_nrEdgeSpdAcv' + 285 * '<S61>/z_nrEdgeSpdAcv' + 286 */ + 287 boolean_T b_phaAdvEna; /* Variable: b_phaAdvEna + 288 * Referenced by: + 289 * '<S13>/a_elecPeriod1' + 290 * '<S51>/a_elecPeriod1' + 291 */ + 292 }; + 293 + 294 /* Parameters (auto storage) */ + 295 typedef struct P_ P; 296 - 297 /* Parameters (auto storage) */ - 298 typedef struct P_ P; + 297 /* Block parameters (auto storage) */ + 298 extern P rtP; 299 - 300 /* Block parameters (auto storage) */ - 301 extern P rtP; + 300 /* Block signals and states (auto storage) */ + 301 extern DW rtDW; 302 - 303 /* Block signals and states (auto storage) */ - 304 extern DW rtDW; + 303 /* External inputs (root inport signals with auto storage) */ + 304 extern ExtU rtU; 305 - 306 /* External inputs (root inport signals with auto storage) */ - 307 extern ExtU rtU; + 306 /* External outputs (root outports fed by signals with auto storage) */ + 307 extern ExtY rtY; 308 - 309 /* External outputs (root outports fed by signals with auto storage) */ - 310 extern ExtY rtY; + 309 /* Constant parameters (auto storage) */ + 310 extern const ConstP rtConstP; 311 - 312 /* Constant parameters (auto storage) */ - 313 extern const ConstP rtConstP; - 314 - 315 /* Model entry point functions */ - 316 extern void BLDC_controller_initialize(void); - 317 extern void BLDC_controller_step(void); - 318 - 319 /*- - 320 * These blocks were eliminated from the model due to optimizations: - 321 * - 322 * Block '<S23>/Scope2' : Unused code path elimination - 323 * Block '<S13>/Scope' : Unused code path elimination - 324 * Block '<S63>/Scope2' : Unused code path elimination - 325 * Block '<S53>/Scope' : Unused code path elimination - 326 */ - 327 - 328 /*- - 329 * The generated code includes comments that allow you to trace directly - 330 * back to the appropriate location in the model. The basic format - 331 * is <system>/block_name, where system is the system number (uniquely - 332 * assigned by Simulink) and block_name is the name of the block. - 333 * - 334 * Note that this particular code originates from a subsystem build, - 335 * and has its own system numbers different from the parent model. - 336 * Refer to the system hierarchy for this subsystem below, and use the - 337 * MATLAB hilite_system command to trace the generated code back - 338 * to the parent model. For example, + 312 /* Model entry point functions */ + 313 extern void BLDC_controller_initialize(void); + 314 extern void BLDC_controller_step(void); + 315 + 316 /*- + 317 * These blocks were eliminated from the model due to optimizations: + 318 * + 319 * Block '<S23>/Scope2' : Unused code path elimination + 320 * Block '<S13>/Scope' : Unused code path elimination + 321 * Block '<S61>/Scope2' : Unused code path elimination + 322 * Block '<S51>/Scope' : Unused code path elimination + 323 */ + 324 + 325 /*- + 326 * The generated code includes comments that allow you to trace directly + 327 * back to the appropriate location in the model. The basic format + 328 * is <system>/block_name, where system is the system number (uniquely + 329 * assigned by Simulink) and block_name is the name of the block. + 330 * + 331 * Note that this particular code originates from a subsystem build, + 332 * and has its own system numbers different from the parent model. + 333 * Refer to the system hierarchy for this subsystem below, and use the + 334 * MATLAB hilite_system command to trace the generated code back + 335 * to the parent model. For example, + 336 * + 337 * hilite_system('BLDCmotorControl_R2017b/BLDC_controller') - opens subsystem BLDCmotorControl_R2017b/BLDC_controller + 338 * hilite_system('BLDCmotorControl_R2017b/BLDC_controller/Kp') - opens and selects block Kp 339 * - 340 * hilite_system('BLDCmotorControl_R2017b/BLDC_controller') - opens subsystem BLDCmotorControl_R2017b/BLDC_controller - 341 * hilite_system('BLDCmotorControl_R2017b/BLDC_controller/Kp') - opens and selects block Kp - 342 * - 343 * Here is the system hierarchy for this model - 344 * - 345 * '<Root>' : 'BLDCmotorControl_R2017b' - 346 * '<S1>' : 'BLDCmotorControl_R2017b/BLDC_controller' - 347 * '<S2>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left' - 348 * '<S3>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right' - 349 * '<S4>' : 'BLDCmotorControl_R2017b/BLDC_controller/signal_log1' - 350 * '<S5>' : 'BLDCmotorControl_R2017b/BLDC_controller/signal_log2' - 351 * '<S6>' : 'BLDCmotorControl_R2017b/BLDC_controller/signal_log3' - 352 * '<S7>' : 'BLDCmotorControl_R2017b/BLDC_controller/signal_log4' - 353 * '<S8>' : 'BLDCmotorControl_R2017b/BLDC_controller/signal_log5' - 354 * '<S9>' : 'BLDCmotorControl_R2017b/BLDC_controller/signal_log6' - 355 * '<S10>' : 'BLDCmotorControl_R2017b/BLDC_controller/signal_log7' - 356 * '<S11>' : 'BLDCmotorControl_R2017b/BLDC_controller/signal_log8' - 357 * '<S12>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations' - 358 * '<S13>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F02_Electrical_Angle_Calculation' - 359 * '<S14>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection' - 360 * '<S15>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F04_Control_Type_Management' - 361 * '<S16>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/signal_log1' - 362 * '<S17>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/signal_log2' - 363 * '<S18>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/signal_log3' - 364 * '<S19>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/signal_log6' - 365 * '<S20>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_01_Edge_Detector' - 366 * '<S21>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_02_Position_Calculation' - 367 * '<S22>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_03_Direction_Detection' - 368 * '<S23>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation' - 369 * '<S24>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_01_Edge_Detector/signal_log6' - 370 * '<S25>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_02_Position_Calculation/signal_log6' - 371 * '<S26>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_03_Direction_Detection/signal_log6' - 372 * '<S27>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Edge_counter' - 373 * '<S28>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Moving_Average_Filter' - 374 * '<S29>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Raw_ Speed_calculation' - 375 * '<S30>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/S-R Flip-Flop' - 376 * '<S31>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/rising_edge' - 377 * '<S32>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/rst_Delay' - 378 * '<S33>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log1' - 379 * '<S34>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log2' - 380 * '<S35>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log3' - 381 * '<S36>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log4' - 382 * '<S37>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log6' - 383 * '<S38>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Edge_counter/rst_Delay' - 384 * '<S39>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F02_Electrical_Angle_Calculation/Modulo_Calculation' - 385 * '<S40>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F02_Electrical_Angle_Calculation/signal_log1' - 386 * '<S41>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F02_Electrical_Angle_Calculation/signal_log2' - 387 * '<S42>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F02_Electrical_Angle_Calculation/signal_log6' - 388 * '<S43>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/F03_01_Pure_Trapezoidal_Method' - 389 * '<S44>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/F03_02_Sinusoidal3rd_Method' - 390 * '<S45>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/F03_02_Sinusoidal_Method' - 391 * '<S46>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/signal_log1' - 392 * '<S47>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/signal_log2' - 393 * '<S48>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/signal_log6' - 394 * '<S49>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F04_Control_Type_Management/signal_log1' - 395 * '<S50>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F04_Control_Type_Management/signal_log2' - 396 * '<S51>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F04_Control_Type_Management/signal_log6' - 397 * '<S52>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations' - 398 * '<S53>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F02_Electrical_Angle_Calculation' - 399 * '<S54>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection' - 400 * '<S55>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F04_Control_Type_Management' - 401 * '<S56>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/signal_log1' - 402 * '<S57>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/signal_log2' - 403 * '<S58>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/signal_log3' - 404 * '<S59>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/signal_log6' - 405 * '<S60>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_01_Edge_Detector' - 406 * '<S61>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_02_Position_Calculation' - 407 * '<S62>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_03_Direction_Detection' - 408 * '<S63>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation' - 409 * '<S64>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_01_Edge_Detector/signal_log6' - 410 * '<S65>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_02_Position_Calculation/signal_log6' - 411 * '<S66>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_03_Direction_Detection/signal_log6' - 412 * '<S67>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Edge_counter' - 413 * '<S68>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Moving_Average_Filter' - 414 * '<S69>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Raw_ Speed_calculation' - 415 * '<S70>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/S-R Flip-Flop' - 416 * '<S71>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/rising_edge' - 417 * '<S72>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/rst_Delay' - 418 * '<S73>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log1' - 419 * '<S74>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log2' - 420 * '<S75>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log3' - 421 * '<S76>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log4' - 422 * '<S77>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log6' - 423 * '<S78>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Edge_counter/rst_Delay' - 424 * '<S79>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F02_Electrical_Angle_Calculation/Modulo_Calculation' - 425 * '<S80>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F02_Electrical_Angle_Calculation/signal_log1' - 426 * '<S81>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F02_Electrical_Angle_Calculation/signal_log2' - 427 * '<S82>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F02_Electrical_Angle_Calculation/signal_log6' - 428 * '<S83>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/F03_01_Pure_Trapezoidal_Method' - 429 * '<S84>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/F03_02_Sinusoidal3rd_Method' - 430 * '<S85>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/F03_02_Sinusoidal_Method' - 431 * '<S86>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/signal_log1' - 432 * '<S87>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/signal_log2' - 433 * '<S88>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/signal_log6' - 434 * '<S89>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F04_Control_Type_Management/signal_log1' - 435 * '<S90>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F04_Control_Type_Management/signal_log2' - 436 * '<S91>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F04_Control_Type_Management/signal_log6' + 340 * Here is the system hierarchy for this model + 341 * + 342 * '<Root>' : 'BLDCmotorControl_R2017b' + 343 * '<S1>' : 'BLDCmotorControl_R2017b/BLDC_controller' + 344 * '<S2>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left' + 345 * '<S3>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right' + 346 * '<S4>' : 'BLDCmotorControl_R2017b/BLDC_controller/signal_log1' + 347 * '<S5>' : 'BLDCmotorControl_R2017b/BLDC_controller/signal_log2' + 348 * '<S6>' : 'BLDCmotorControl_R2017b/BLDC_controller/signal_log3' + 349 * '<S7>' : 'BLDCmotorControl_R2017b/BLDC_controller/signal_log4' + 350 * '<S8>' : 'BLDCmotorControl_R2017b/BLDC_controller/signal_log5' + 351 * '<S9>' : 'BLDCmotorControl_R2017b/BLDC_controller/signal_log6' + 352 * '<S10>' : 'BLDCmotorControl_R2017b/BLDC_controller/signal_log7' + 353 * '<S11>' : 'BLDCmotorControl_R2017b/BLDC_controller/signal_log8' + 354 * '<S12>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations' + 355 * '<S13>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F02_Electrical_Angle_Calculation' + 356 * '<S14>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection' + 357 * '<S15>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F04_Control_Type_Management' + 358 * '<S16>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/signal_log1' + 359 * '<S17>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/signal_log2' + 360 * '<S18>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/signal_log3' + 361 * '<S19>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/signal_log6' + 362 * '<S20>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_01_Edge_Detector' + 363 * '<S21>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_02_Position_Calculation' + 364 * '<S22>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_03_Direction_Detection' + 365 * '<S23>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation' + 366 * '<S24>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_01_Edge_Detector/signal_log6' + 367 * '<S25>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_02_Position_Calculation/signal_log6' + 368 * '<S26>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_03_Direction_Detection/signal_log6' + 369 * '<S27>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Edge_counter' + 370 * '<S28>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Motor_Speed_Calculation' + 371 * '<S29>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/S-R Flip-Flop' + 372 * '<S30>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/falling_edge2' + 373 * '<S31>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/rising_edge' + 374 * '<S32>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/rst_Delay' + 375 * '<S33>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log1' + 376 * '<S34>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log3' + 377 * '<S35>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log4' + 378 * '<S36>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log5' + 379 * '<S37>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Edge_counter/rst_Delay' + 380 * '<S38>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F02_Electrical_Angle_Calculation/signal_log1' + 381 * '<S39>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F02_Electrical_Angle_Calculation/signal_log2' + 382 * '<S40>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F02_Electrical_Angle_Calculation/signal_log6' + 383 * '<S41>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/F03_01_Pure_Trapezoidal_Method' + 384 * '<S42>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/F03_02_Sinusoidal3rd_Method' + 385 * '<S43>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/F03_02_Sinusoidal_Method' + 386 * '<S44>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/signal_log1' + 387 * '<S45>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/signal_log2' + 388 * '<S46>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F03_Control_Method_Selection/signal_log6' + 389 * '<S47>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F04_Control_Type_Management/signal_log1' + 390 * '<S48>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F04_Control_Type_Management/signal_log2' + 391 * '<S49>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Left/F04_Control_Type_Management/signal_log6' + 392 * '<S50>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations' + 393 * '<S51>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F02_Electrical_Angle_Calculation' + 394 * '<S52>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection' + 395 * '<S53>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F04_Control_Type_Management' + 396 * '<S54>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/signal_log1' + 397 * '<S55>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/signal_log2' + 398 * '<S56>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/signal_log3' + 399 * '<S57>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/signal_log6' + 400 * '<S58>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_01_Edge_Detector' + 401 * '<S59>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_02_Position_Calculation' + 402 * '<S60>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_03_Direction_Detection' + 403 * '<S61>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation' + 404 * '<S62>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_01_Edge_Detector/signal_log6' + 405 * '<S63>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_02_Position_Calculation/signal_log6' + 406 * '<S64>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_03_Direction_Detection/signal_log6' + 407 * '<S65>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Edge_counter' + 408 * '<S66>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Motor_Speed_Calculation' + 409 * '<S67>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/S-R Flip-Flop' + 410 * '<S68>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/falling_edge2' + 411 * '<S69>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/rising_edge' + 412 * '<S70>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/rst_Delay' + 413 * '<S71>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log1' + 414 * '<S72>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log3' + 415 * '<S73>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log4' + 416 * '<S74>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/signal_log5' + 417 * '<S75>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F01_Preliminary_Calculations/F01_04_Speed_Calculation/Edge_counter/rst_Delay' + 418 * '<S76>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F02_Electrical_Angle_Calculation/signal_log1' + 419 * '<S77>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F02_Electrical_Angle_Calculation/signal_log2' + 420 * '<S78>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F02_Electrical_Angle_Calculation/signal_log6' + 421 * '<S79>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/F03_01_Pure_Trapezoidal_Method' + 422 * '<S80>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/F03_02_Sinusoidal3rd_Method' + 423 * '<S81>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/F03_02_Sinusoidal_Method' + 424 * '<S82>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/signal_log1' + 425 * '<S83>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/signal_log2' + 426 * '<S84>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F03_Control_Method_Selection/signal_log6' + 427 * '<S85>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F04_Control_Type_Management/signal_log1' + 428 * '<S86>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F04_Control_Type_Management/signal_log2' + 429 * '<S87>' : 'BLDCmotorControl_R2017b/BLDC_controller/BLDC_controller_Right/F04_Control_Type_Management/signal_log6' + 430 */ + 431 #endif /* RTW_HEADER_BLDC_controller_h_ */ + 432 + 433 /* + 434 * File trailer for generated code. + 435 * + 436 * [EOF] 437 */ - 438 #endif /* RTW_HEADER_BLDC_controller_h_ */ - 439 - 440 /* - 441 * File trailer for generated code. - 442 * - 443 * [EOF] - 444 */ - 445 + 438

diff --git a/01_Matlab/BLDC_controller_ert_rtw/html/BLDC_controller_interface.html b/01_Matlab/BLDC_controller_ert_rtw/html/BLDC_controller_interface.html index 94d9596..331ce17 100644 --- a/01_Matlab/BLDC_controller_ert_rtw/html/BLDC_controller_interface.html +++ b/01_Matlab/BLDC_controller_ert_rtw/html/BLDC_controller_interface.html @@ -557,10 +557,10 @@ Dimension -cf_spdCoef +cf_speedCoef -rtP.cf_spdCoef +rtP.cf_speedCoef int32_T @@ -602,21 +602,6 @@ int32_T -n_thresSpdDeacv - - -rtP.n_thresSpdDeacv - - -int32_T - - -1 - - - - - r_commDCDeacv @@ -630,7 +615,7 @@ int32_T - + r_phaAdvDC_XA @@ -645,7 +630,7 @@ int32_T - + a_phaAdv_M1 @@ -660,7 +645,7 @@ int16_T - + z_maxCntRst @@ -675,7 +660,7 @@ int16_T - + z_ctrlTypSel @@ -690,7 +675,7 @@ uint8_T - + z_nrEdgeSpdAcv @@ -705,7 +690,7 @@ uint8_T - + b_phaAdvEna diff --git a/01_Matlab/BLDC_controller_ert_rtw/html/BLDC_controller_metrics.html b/01_Matlab/BLDC_controller_ert_rtw/html/BLDC_controller_metrics.html index 714115c..71c6cbc 100644 --- a/01_Matlab/BLDC_controller_ert_rtw/html/BLDC_controller_metrics.html +++ b/01_Matlab/BLDC_controller_ert_rtw/html/BLDC_controller_metrics.html @@ -40,7 +40,7 @@ Global Variables
  • - + Function Information @@ -100,7 +100,7 @@ Function Information : -754 +746   @@ -115,7 +115,7 @@ Function Information : -2,139 +2,126   @@ -169,13 +169,13 @@ BLDC_controller.c -510 +506 -1,314 +1,309 -05/25/2019 9:42 PM +05/28/2019 7:55 PM @@ -187,13 +187,13 @@ BLDC_controller.h -140 +137 -445 +438 -05/25/2019 9:42 PM +05/28/2019 7:55 PM @@ -211,7 +211,7 @@ rtwtypes.h 109 -05/25/2019 9:42 PM +05/28/2019 7:55 PM @@ -223,13 +223,13 @@ BLDC_controller_data.c -41 +40 -213 +212 -05/25/2019 9:42 PM +05/28/2019 7:55 PM @@ -247,7 +247,7 @@ zero_crossing_types.h 58 -05/25/2019 9:42 PM +05/28/2019 7:55 PM @@ -325,19 +325,19 @@ Global variables defined in the generated code. @@ -352,177 +352,11 @@ rtP
    -[+] -rtP +[+] +rtDW -91 +87 -25  +150  -18  +126 
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - -
    -[+] -rtDW - - - -88 - -132  - -118  -
    - -
    - - -