diff --git a/01_Libraries/01_Controller/BLDC_controller_Lib.slx b/01_Libraries/01_Controller/BLDC_controller_Lib.slx index d92ac71..68214d9 100644 Binary files a/01_Libraries/01_Controller/BLDC_controller_Lib.slx and b/01_Libraries/01_Controller/BLDC_controller_Lib.slx differ diff --git a/BLDC_controller_ert_rtw/BLDC_controller.c b/BLDC_controller_ert_rtw/BLDC_controller.c index 439c623..ae63bd4 100644 --- a/BLDC_controller_ert_rtw/BLDC_controller.c +++ b/BLDC_controller_ert_rtw/BLDC_controller.c @@ -3,9 +3,9 @@ * * Code generated for Simulink model 'BLDC_controller'. * - * Model version : 1.1296 + * Model version : 1.1297 * Simulink Coder version : 8.13 (R2017b) 24-Jul-2017 - * C/C++ source code generated on : Tue Oct 20 17:29:57 2020 + * C/C++ source code generated on : Sun Mar 6 11:02:11 2022 * * Target selection: ert.tlc * Embedded hardware selection: ARM Compatible->ARM Cortex @@ -1019,6 +1019,8 @@ void BLDC_controller_step(RT_MODEL *const rtM) int32_T rtb_Sum1_jt; int16_T rtb_Merge_m; int16_T rtb_Merge1; + uint16_T rtb_Divide14_e; + uint16_T rtb_Divide1_f; int16_T rtb_TmpSignalConversionAtLow_Pa[2]; int32_T rtb_Switch1; int32_T rtb_Sum1; @@ -2116,20 +2118,15 @@ void BLDC_controller_step(RT_MODEL *const rtM) /* End of Switch: '/Switch2' */ - /* Switch: '/Switch2' incorporates: - * Constant: '/z_ctrlTypSel' - * Constant: '/CTRL_COMM2' - * Constant: '/a_phaAdvMax' - * Constant: '/id_fieldWeakMax' - * RelationalOperator: '/Relational Operator1' + /* Product: '/Divide14' incorporates: + * Constant: '/r_fieldWeakHi' + * Constant: '/r_fieldWeakLo' + * Sum: '/Sum1' + * Sum: '/Sum3' */ - if (rtP->z_ctrlTypSel == 2) { - rtb_Saturation1 = rtP->id_fieldWeakMax; - } else { - rtb_Saturation1 = rtP->a_phaAdvMax; - } - - /* End of Switch: '/Switch2' */ + rtb_Divide14_e = (uint16_T)(((int16_T)(DataTypeConversion2 - + rtP->r_fieldWeakLo) << 15) / (int16_T)(rtP->r_fieldWeakHi - + rtP->r_fieldWeakLo)); /* Switch: '/Switch2' incorporates: * Constant: '/n_fieldWeakAuthHi' @@ -2151,25 +2148,53 @@ void BLDC_controller_step(RT_MODEL *const rtM) /* End of Switch: '/Switch2' */ - /* Product: '/Divide3' incorporates: + /* Product: '/Divide1' incorporates: * Constant: '/n_fieldWeakAuthHi' * Constant: '/n_fieldWeakAuthLo' - * Constant: '/r_fieldWeakHi' - * Constant: '/r_fieldWeakLo' - * Product: '/Divide1' - * Product: '/Divide14' - * Product: '/Divide2' - * Sum: '/Sum1' * Sum: '/Sum2' - * Sum: '/Sum3' * Sum: '/Sum4' */ - rtDW->Divide3 = (int16_T)(((uint16_T)(((uint32_T)(uint16_T)(((int16_T) - (DataTypeConversion2 - rtP->r_fieldWeakLo) << 15) / (int16_T) - (rtP->r_fieldWeakHi - rtP->r_fieldWeakLo)) * (uint16_T)(((int16_T) - (rtb_Saturation - rtP->n_fieldWeakAuthLo) << 15) / (int16_T) - (rtP->n_fieldWeakAuthHi - rtP->n_fieldWeakAuthLo))) >> 15) * - rtb_Saturation1) >> 15); + rtb_Divide1_f = (uint16_T)(((int16_T)(rtb_Saturation - + rtP->n_fieldWeakAuthLo) << 15) / (int16_T)(rtP->n_fieldWeakAuthHi - + rtP->n_fieldWeakAuthLo)); + + /* Switch: '/Switch1' incorporates: + * MinMax: '/MinMax1' + * RelationalOperator: '/Relational Operator6' + */ + if (rtb_Divide14_e < rtb_Divide1_f) { + /* MinMax: '/MinMax' */ + if (!(rtb_Divide14_e > rtb_Divide1_f)) { + rtb_Divide14_e = rtb_Divide1_f; + } + + /* End of MinMax: '/MinMax' */ + } else { + if (rtb_Divide1_f < rtb_Divide14_e) { + /* MinMax: '/MinMax1' */ + rtb_Divide14_e = rtb_Divide1_f; + } + } + + /* End of Switch: '/Switch1' */ + + /* Switch: '/Switch2' incorporates: + * Constant: '/z_ctrlTypSel' + * Constant: '/CTRL_COMM2' + * Constant: '/a_phaAdvMax' + * Constant: '/id_fieldWeakMax' + * RelationalOperator: '/Relational Operator1' + */ + if (rtP->z_ctrlTypSel == 2) { + rtb_Saturation1 = rtP->id_fieldWeakMax; + } else { + rtb_Saturation1 = rtP->a_phaAdvMax; + } + + /* End of Switch: '/Switch2' */ + + /* Product: '/Divide3' */ + rtDW->Divide3 = (int16_T)((rtb_Saturation1 * rtb_Divide14_e) >> 15); /* End of Outputs for SubSystem: '/Field_Weakening_Enabled' */ } diff --git a/BLDC_controller_ert_rtw/BLDC_controller.h b/BLDC_controller_ert_rtw/BLDC_controller.h index 73f7876..9d663c2 100644 --- a/BLDC_controller_ert_rtw/BLDC_controller.h +++ b/BLDC_controller_ert_rtw/BLDC_controller.h @@ -3,9 +3,9 @@ * * Code generated for Simulink model 'BLDC_controller'. * - * Model version : 1.1296 + * Model version : 1.1297 * Simulink Coder version : 8.13 (R2017b) 24-Jul-2017 - * C/C++ source code generated on : Tue Oct 20 17:29:57 2020 + * C/C++ source code generated on : Sun Mar 6 11:02:11 2022 * * Target selection: ert.tlc * Embedded hardware selection: ARM Compatible->ARM Cortex diff --git a/BLDC_controller_ert_rtw/BLDC_controller_data.c b/BLDC_controller_ert_rtw/BLDC_controller_data.c index 976551a..bee399c 100644 --- a/BLDC_controller_ert_rtw/BLDC_controller_data.c +++ b/BLDC_controller_ert_rtw/BLDC_controller_data.c @@ -3,9 +3,9 @@ * * Code generated for Simulink model 'BLDC_controller'. * - * Model version : 1.1296 + * Model version : 1.1297 * Simulink Coder version : 8.13 (R2017b) 24-Jul-2017 - * C/C++ source code generated on : Tue Oct 20 17:29:57 2020 + * C/C++ source code generated on : Sun Mar 6 11:02:11 2022 * * Target selection: ert.tlc * Embedded hardware selection: ARM Compatible->ARM Cortex diff --git a/BLDC_controller_ert_rtw/ert_main.c b/BLDC_controller_ert_rtw/ert_main.c index 99b5210..aa033c0 100644 --- a/BLDC_controller_ert_rtw/ert_main.c +++ b/BLDC_controller_ert_rtw/ert_main.c @@ -3,9 +3,9 @@ * * Code generated for Simulink model 'BLDC_controller'. * - * Model version : 1.1296 + * Model version : 1.1297 * Simulink Coder version : 8.13 (R2017b) 24-Jul-2017 - * C/C++ source code generated on : Tue Oct 20 17:29:57 2020 + * C/C++ source code generated on : Sun Mar 6 11:02:11 2022 * * Target selection: ert.tlc * Embedded hardware selection: ARM Compatible->ARM Cortex diff --git a/BLDC_controller_ert_rtw/rtwtypes.h b/BLDC_controller_ert_rtw/rtwtypes.h index e6b2250..3f68038 100644 --- a/BLDC_controller_ert_rtw/rtwtypes.h +++ b/BLDC_controller_ert_rtw/rtwtypes.h @@ -3,9 +3,9 @@ * * Code generated for Simulink model 'BLDC_controller'. * - * Model version : 1.1296 + * Model version : 1.1297 * Simulink Coder version : 8.13 (R2017b) 24-Jul-2017 - * C/C++ source code generated on : Tue Oct 20 17:29:57 2020 + * C/C++ source code generated on : Sun Mar 6 11:02:11 2022 * * Target selection: ert.tlc * Embedded hardware selection: ARM Compatible->ARM Cortex diff --git a/BLDCmotor_FOC_R2017b_fixdt.slx b/BLDCmotor_FOC_R2017b_fixdt.slx index 2d61238..c5ec506 100644 Binary files a/BLDCmotor_FOC_R2017b_fixdt.slx and b/BLDCmotor_FOC_R2017b_fixdt.slx differ