Update BLDC controller

- added possbility to switch the Control mode while motor is spinning. NOT yet checked how motors behaves when swiching is triggered!
- added Cruise Control functionality: activated by button1 to GND (Blue Left or Right cable depending on selection). Functionality NOT yet tested in practice!
- extended Phase current measurements z_selPhaCurMeasABC : {iA,iB} = 0; {iB,iC} = 1; {iA,iC} = 2
- added interface for external motor angle measurement from as sensor, e.g., encoder. The selection can be done via b_angleMeasEna: 0 = Estimated (default), 1 = Measured.
- update the Field weakening Lo and Hi to fully blended.
- minor improvements:
   - Buttons initialization
   - lowered ADC margins in auto-calibration
   - commented out ADC_SAMPLETIME_239CYCLES_5, reported to give some issues when Hall sensor ADC input is used
This commit is contained in:
EmanuelFeru 2020-10-12 22:55:39 +02:00
parent 2890745fbb
commit b76e8ee466
10 changed files with 1785 additions and 1120 deletions

View File

@ -3,9 +3,9 @@
* *
* Code generated for Simulink model 'BLDC_controller'. * Code generated for Simulink model 'BLDC_controller'.
* *
* Model version : 1.1260 * Model version : 1.1284
* Simulink Coder version : 8.13 (R2017b) 24-Jul-2017 * Simulink Coder version : 8.13 (R2017b) 24-Jul-2017
* C/C++ source code generated on : Tue Mar 24 11:01:08 2020 * C/C++ source code generated on : Sun Oct 11 21:38:56 2020
* *
* Target selection: ert.tlc * Target selection: ert.tlc
* Embedded hardware selection: ARM Compatible->ARM Cortex * Embedded hardware selection: ARM Compatible->ARM Cortex
@ -32,82 +32,97 @@ typedef struct tag_RTM RT_MODEL;
/* Block signals and states (auto storage) for system '<S12>/Counter' */ /* Block signals and states (auto storage) for system '<S12>/Counter' */
typedef struct { typedef struct {
int16_T UnitDelay_DSTATE; /* '<S16>/UnitDelay' */ int16_T UnitDelay_DSTATE; /* '<S17>/UnitDelay' */
} DW_Counter; } DW_Counter;
/* Block signals and states (auto storage) for system '<S54>/PI_clamp_fixdt' */ /* Block signals and states (auto storage) for system '<S57>/PI_clamp_fixdt' */
typedef struct { typedef struct {
int32_T UnitDelay_DSTATE; /* '<S68>/UnitDelay' */ int32_T ResettableDelay_DSTATE; /* '<S71>/Resettable Delay' */
boolean_T UnitDelay1_DSTATE; /* '<S65>/UnitDelay1' */ uint8_T icLoad; /* '<S71>/Resettable Delay' */
boolean_T UnitDelay1_DSTATE; /* '<S68>/UnitDelay1' */
} DW_PI_clamp_fixdt; } DW_PI_clamp_fixdt;
/* Block signals and states (auto storage) for system '<S41>/Low_Pass_Filter' */ /* Block signals and states (auto storage) for system '<S55>/PI_clamp_fixdt' */
typedef struct { typedef struct {
int32_T UnitDelay1_DSTATE[2]; /* '<S50>/UnitDelay1' */ int32_T ResettableDelay_DSTATE; /* '<S61>/Resettable Delay' */
uint8_T icLoad; /* '<S61>/Resettable Delay' */
boolean_T UnitDelay1_DSTATE; /* '<S59>/UnitDelay1' */
} DW_PI_clamp_fixdt_i;
/* Block signals and states (auto storage) for system '<S56>/PI_clamp_fixdt' */
typedef struct {
int16_T ResettableDelay_DSTATE; /* '<S66>/Resettable Delay' */
uint8_T icLoad; /* '<S66>/Resettable Delay' */
boolean_T UnitDelay1_DSTATE; /* '<S63>/UnitDelay1' */
} DW_PI_clamp_fixdt_e;
/* Block signals and states (auto storage) for system '<S43>/Low_Pass_Filter' */
typedef struct {
int32_T UnitDelay1_DSTATE[2]; /* '<S53>/UnitDelay1' */
} DW_Low_Pass_Filter; } DW_Low_Pass_Filter;
/* Block signals and states (auto storage) for system '<S73>/I_backCalc_fixdt' */ /* Block signals and states (auto storage) for system '<S76>/I_backCalc_fixdt' */
typedef struct { typedef struct {
int32_T UnitDelay_DSTATE; /* '<S78>/UnitDelay' */ int32_T UnitDelay_DSTATE; /* '<S81>/UnitDelay' */
int32_T UnitDelay_DSTATE_h; /* '<S80>/UnitDelay' */ int32_T UnitDelay_DSTATE_h; /* '<S83>/UnitDelay' */
} DW_I_backCalc_fixdt; } DW_I_backCalc_fixdt;
/* Block signals and states (auto storage) for system '<S21>/Counter' */ /* Block signals and states (auto storage) for system '<S23>/Counter' */
typedef struct { typedef struct {
uint16_T UnitDelay_DSTATE; /* '<S26>/UnitDelay' */ uint16_T UnitDelay_DSTATE; /* '<S28>/UnitDelay' */
} DW_Counter_l; } DW_Counter_l;
/* Block signals and states (auto storage) for system '<S17>/either_edge' */ /* Block signals and states (auto storage) for system '<S19>/either_edge' */
typedef struct { typedef struct {
boolean_T UnitDelay_DSTATE; /* '<S22>/UnitDelay' */ boolean_T UnitDelay_DSTATE; /* '<S24>/UnitDelay' */
} DW_either_edge; } DW_either_edge;
/* Block signals and states (auto storage) for system '<S3>/Debounce_Filter' */ /* Block signals and states (auto storage) for system '<S3>/Debounce_Filter' */
typedef struct { typedef struct {
DW_either_edge either_edge_k; /* '<S17>/either_edge' */ DW_either_edge either_edge_k; /* '<S19>/either_edge' */
DW_Counter_l Counter_h; /* '<S20>/Counter' */ DW_Counter_l Counter_h; /* '<S22>/Counter' */
DW_Counter_l Counter_i0; /* '<S21>/Counter' */ DW_Counter_l Counter_i0; /* '<S23>/Counter' */
boolean_T UnitDelay_DSTATE; /* '<S17>/UnitDelay' */ boolean_T UnitDelay_DSTATE; /* '<S19>/UnitDelay' */
} DW_Debounce_Filter; } DW_Debounce_Filter;
/* Block signals and states (auto storage) for system '<Root>' */ /* Block signals and states (auto storage) for system '<Root>' */
typedef struct { typedef struct {
DW_either_edge either_edge_a; /* '<S3>/either_edge' */ DW_either_edge either_edge_a; /* '<S3>/either_edge' */
DW_Debounce_Filter Debounce_Filter_f;/* '<S3>/Debounce_Filter' */ DW_Debounce_Filter Debounce_Filter_f;/* '<S3>/Debounce_Filter' */
DW_I_backCalc_fixdt I_backCalc_fixdt_g;/* '<S72>/I_backCalc_fixdt' */ DW_I_backCalc_fixdt I_backCalc_fixdt_g;/* '<S75>/I_backCalc_fixdt' */
DW_I_backCalc_fixdt I_backCalc_fixdt1;/* '<S73>/I_backCalc_fixdt1' */ DW_I_backCalc_fixdt I_backCalc_fixdt1;/* '<S76>/I_backCalc_fixdt1' */
DW_I_backCalc_fixdt I_backCalc_fixdt_i;/* '<S73>/I_backCalc_fixdt' */ DW_I_backCalc_fixdt I_backCalc_fixdt_i;/* '<S76>/I_backCalc_fixdt' */
DW_Low_Pass_Filter Low_Pass_Filter_m;/* '<S41>/Low_Pass_Filter' */ DW_Low_Pass_Filter Low_Pass_Filter_m;/* '<S43>/Low_Pass_Filter' */
DW_PI_clamp_fixdt PI_clamp_fixdt_a; /* '<S53>/PI_clamp_fixdt' */ DW_PI_clamp_fixdt_e PI_clamp_fixdt_at;/* '<S56>/PI_clamp_fixdt' */
DW_PI_clamp_fixdt PI_clamp_fixdt_o; /* '<S52>/PI_clamp_fixdt' */ DW_PI_clamp_fixdt_i PI_clamp_fixdt_oc;/* '<S55>/PI_clamp_fixdt' */
DW_PI_clamp_fixdt PI_clamp_fixdt_k; /* '<S54>/PI_clamp_fixdt' */ DW_PI_clamp_fixdt PI_clamp_fixdt_k; /* '<S57>/PI_clamp_fixdt' */
DW_Counter Counter_e; /* '<S12>/Counter' */ DW_Counter Counter_e; /* '<S12>/Counter' */
int32_T Divide1; /* '<S71>/Divide1' */ int32_T Divide1; /* '<S74>/Divide1' */
int32_T UnitDelay_DSTATE; /* '<S36>/UnitDelay' */ int32_T UnitDelay_DSTATE; /* '<S38>/UnitDelay' */
int16_T Gain4[3]; /* '<S43>/Gain4' */ int16_T Gain4[3]; /* '<S45>/Gain4' */
int16_T DataTypeConversion[2]; /* '<S50>/Data Type Conversion' */ int16_T DataTypeConversion[2]; /* '<S53>/Data Type Conversion' */
int16_T z_counterRawPrev; /* '<S15>/z_counterRawPrev' */ int16_T z_counterRawPrev; /* '<S16>/z_counterRawPrev' */
int16_T Merge1; /* '<S29>/Merge1' */ int16_T Merge1; /* '<S31>/Merge1' */
int16_T Divide3; /* '<S5>/Divide3' */ int16_T Divide3; /* '<S5>/Divide3' */
int16_T Vd_max1; /* '<S45>/Vd_max1' */ int16_T Vd_max1; /* '<S47>/Vd_max1' */
int16_T Gain3; /* '<S45>/Gain3' */ int16_T Gain3; /* '<S47>/Gain3' */
int16_T Vq_max_M1; /* '<S45>/Vq_max_M1' */ int16_T Vq_max_M1; /* '<S47>/Vq_max_M1' */
int16_T Gain5; /* '<S45>/Gain5' */ int16_T Gain5; /* '<S47>/Gain5' */
int16_T i_max; /* '<S45>/i_max' */ int16_T i_max; /* '<S47>/i_max' */
int16_T Divide1_a; /* '<S45>/Divide1' */ int16_T Divide1_a; /* '<S47>/Divide1' */
int16_T Gain1; /* '<S45>/Gain1' */ int16_T Gain1; /* '<S47>/Gain1' */
int16_T Gain4_c; /* '<S45>/Gain4' */ int16_T Gain4_c; /* '<S47>/Gain4' */
int16_T Switch2; /* '<S77>/Switch2' */ int16_T Switch2; /* '<S80>/Switch2' */
int16_T Switch2_l; /* '<S83>/Switch2' */ int16_T Switch2_l; /* '<S86>/Switch2' */
int16_T Switch2_c; /* '<S81>/Switch2' */ int16_T Switch2_c; /* '<S84>/Switch2' */
int16_T Merge; /* '<S42>/Merge' */ int16_T Merge; /* '<S44>/Merge' */
int16_T Switch1; /* '<S69>/Switch1' */ int16_T Switch1; /* '<S72>/Switch1' */
int16_T Divide11; /* '<S15>/Divide11' */ int16_T Divide11; /* '<S16>/Divide11' */
int16_T UnitDelay3_DSTATE; /* '<S12>/UnitDelay3' */ int16_T UnitDelay3_DSTATE; /* '<S12>/UnitDelay3' */
int16_T UnitDelay4_DSTATE; /* '<S15>/UnitDelay4' */ int16_T UnitDelay4_DSTATE; /* '<S16>/UnitDelay4' */
int16_T UnitDelay2_DSTATE; /* '<S15>/UnitDelay2' */ int16_T UnitDelay2_DSTATE; /* '<S16>/UnitDelay2' */
int16_T UnitDelay3_DSTATE_o; /* '<S15>/UnitDelay3' */ int16_T UnitDelay3_DSTATE_o; /* '<S16>/UnitDelay3' */
int16_T UnitDelay5_DSTATE; /* '<S15>/UnitDelay5' */ int16_T UnitDelay5_DSTATE; /* '<S16>/UnitDelay5' */
int16_T UnitDelay4_DSTATE_e; /* '<S12>/UnitDelay4' */ int16_T UnitDelay4_DSTATE_e; /* '<S12>/UnitDelay4' */
int16_T UnitDelay4_DSTATE_eu; /* '<S7>/UnitDelay4' */ int16_T UnitDelay4_DSTATE_eu; /* '<S7>/UnitDelay4' */
int16_T UnitDelay4_DSTATE_h; /* '<S6>/UnitDelay4' */ int16_T UnitDelay4_DSTATE_h; /* '<S6>/UnitDelay4' */
@ -115,8 +130,10 @@ typedef struct {
int8_T UnitDelay2_DSTATE_b; /* '<S11>/UnitDelay2' */ int8_T UnitDelay2_DSTATE_b; /* '<S11>/UnitDelay2' */
int8_T If4_ActiveSubsystem; /* '<S1>/If4' */ int8_T If4_ActiveSubsystem; /* '<S1>/If4' */
int8_T If1_ActiveSubsystem; /* '<S1>/If1' */ int8_T If1_ActiveSubsystem; /* '<S1>/If1' */
int8_T If2_ActiveSubsystem; /* '<S29>/If2' */ int8_T If2_ActiveSubsystem; /* '<S31>/If2' */
int8_T If2_ActiveSubsystem_a; /* '<S6>/If2' */ int8_T If2_ActiveSubsystem_a; /* '<S6>/If2' */
int8_T If1_ActiveSubsystem_e; /* '<S6>/If1' */
int8_T SwitchCase_ActiveSubsystem; /* '<S44>/Switch Case' */
uint8_T z_ctrlMod; /* '<S4>/F03_02_Control_Mode_Manager' */ uint8_T z_ctrlMod; /* '<S4>/F03_02_Control_Mode_Manager' */
uint8_T UnitDelay3_DSTATE_fy; /* '<S9>/UnitDelay3' */ uint8_T UnitDelay3_DSTATE_fy; /* '<S9>/UnitDelay3' */
uint8_T UnitDelay1_DSTATE; /* '<S9>/UnitDelay1' */ uint8_T UnitDelay1_DSTATE; /* '<S9>/UnitDelay1' */
@ -124,51 +141,51 @@ typedef struct {
uint8_T is_active_c1_BLDC_controller;/* '<S4>/F03_02_Control_Mode_Manager' */ uint8_T is_active_c1_BLDC_controller;/* '<S4>/F03_02_Control_Mode_Manager' */
uint8_T is_c1_BLDC_controller; /* '<S4>/F03_02_Control_Mode_Manager' */ uint8_T is_c1_BLDC_controller; /* '<S4>/F03_02_Control_Mode_Manager' */
uint8_T is_ACTIVE; /* '<S4>/F03_02_Control_Mode_Manager' */ uint8_T is_ACTIVE; /* '<S4>/F03_02_Control_Mode_Manager' */
boolean_T Merge_n; /* '<S17>/Merge' */ boolean_T Merge_n; /* '<S19>/Merge' */
boolean_T dz_cntTrnsDet; /* '<S15>/dz_cntTrnsDet' */ boolean_T dz_cntTrnsDet; /* '<S16>/dz_cntTrnsDet' */
boolean_T UnitDelay2_DSTATE_g; /* '<S8>/UnitDelay2' */ boolean_T UnitDelay2_DSTATE_g; /* '<S8>/UnitDelay2' */
boolean_T UnitDelay5_DSTATE_l; /* '<S8>/UnitDelay5' */ boolean_T UnitDelay5_DSTATE_l; /* '<S8>/UnitDelay5' */
boolean_T UnitDelay6_DSTATE; /* '<S8>/UnitDelay6' */ boolean_T UnitDelay6_DSTATE; /* '<S8>/UnitDelay6' */
boolean_T UnitDelay_DSTATE_e; /* '<S35>/UnitDelay' */ boolean_T UnitDelay_DSTATE_b; /* '<S37>/UnitDelay' */
boolean_T UnitDelay1_DSTATE_n; /* '<S15>/UnitDelay1' */ boolean_T UnitDelay1_DSTATE_n; /* '<S16>/UnitDelay1' */
boolean_T n_commDeacv_Mode; /* '<S12>/n_commDeacv' */ boolean_T n_commDeacv_Mode; /* '<S12>/n_commDeacv' */
boolean_T dz_cntTrnsDet_Mode; /* '<S15>/dz_cntTrnsDet' */ boolean_T dz_cntTrnsDet_Mode; /* '<S16>/dz_cntTrnsDet' */
} DW; } DW;
/* Constant parameters (auto storage) */ /* Constant parameters (auto storage) */
typedef struct { typedef struct {
/* Computed Parameter: r_sin3PhaA_M1_Table /* Computed Parameter: r_sin3PhaA_M1_Table
* Referenced by: '<S86>/r_sin3PhaA_M1' * Referenced by: '<S89>/r_sin3PhaA_M1'
*/ */
int16_T r_sin3PhaA_M1_Table[181]; int16_T r_sin3PhaA_M1_Table[181];
/* Computed Parameter: r_sin3PhaB_M1_Table /* Computed Parameter: r_sin3PhaB_M1_Table
* Referenced by: '<S86>/r_sin3PhaB_M1' * Referenced by: '<S89>/r_sin3PhaB_M1'
*/ */
int16_T r_sin3PhaB_M1_Table[181]; int16_T r_sin3PhaB_M1_Table[181];
/* Computed Parameter: r_sin3PhaC_M1_Table /* Computed Parameter: r_sin3PhaC_M1_Table
* Referenced by: '<S86>/r_sin3PhaC_M1' * Referenced by: '<S89>/r_sin3PhaC_M1'
*/ */
int16_T r_sin3PhaC_M1_Table[181]; int16_T r_sin3PhaC_M1_Table[181];
/* Computed Parameter: r_sin_M1_Table /* Computed Parameter: r_sin_M1_Table
* Referenced by: '<S47>/r_sin_M1' * Referenced by: '<S49>/r_sin_M1'
*/ */
int16_T r_sin_M1_Table[181]; int16_T r_sin_M1_Table[181];
/* Computed Parameter: r_cos_M1_Table /* Computed Parameter: r_cos_M1_Table
* Referenced by: '<S47>/r_cos_M1' * Referenced by: '<S49>/r_cos_M1'
*/ */
int16_T r_cos_M1_Table[181]; int16_T r_cos_M1_Table[181];
/* Computed Parameter: iq_maxSca_M1_Table /* Computed Parameter: iq_maxSca_M1_Table
* Referenced by: '<S45>/iq_maxSca_M1' * Referenced by: '<S47>/iq_maxSca_M1'
*/ */
uint16_T iq_maxSca_M1_Table[50]; uint16_T iq_maxSca_M1_Table[50];
/* Computed Parameter: z_commutMap_M1_table /* Computed Parameter: z_commutMap_M1_table
* Referenced by: '<S84>/z_commutMap_M1' * Referenced by: '<S87>/z_commutMap_M1'
*/ */
int8_T z_commutMap_M1_table[18]; int8_T z_commutMap_M1_table[18];
@ -189,6 +206,7 @@ typedef struct {
int16_T i_phaAB; /* '<Root>/i_phaAB' */ int16_T i_phaAB; /* '<Root>/i_phaAB' */
int16_T i_phaBC; /* '<Root>/i_phaBC' */ int16_T i_phaBC; /* '<Root>/i_phaBC' */
int16_T i_DCLink; /* '<Root>/i_DCLink' */ int16_T i_DCLink; /* '<Root>/i_DCLink' */
int16_T a_mechAngle; /* '<Root>/a_mechAngle' */
} ExtU; } ExtU;
/* External outputs (root outports fed by signals with auto storage) */ /* External outputs (root outports fed by signals with auto storage) */
@ -199,20 +217,23 @@ typedef struct {
uint8_T z_errCode; /* '<Root>/z_errCode' */ uint8_T z_errCode; /* '<Root>/z_errCode' */
int16_T n_mot; /* '<Root>/n_mot' */ int16_T n_mot; /* '<Root>/n_mot' */
int16_T a_elecAngle; /* '<Root>/a_elecAngle' */ int16_T a_elecAngle; /* '<Root>/a_elecAngle' */
int16_T r_devSignal1; /* '<Root>/r_devSignal1' */ int16_T iq; /* '<Root>/iq' */
int16_T r_devSignal2; /* '<Root>/r_devSignal2' */ int16_T id; /* '<Root>/id' */
} ExtY; } ExtY;
/* Parameters (auto storage) */ /* Parameters (auto storage) */
struct P_ { struct P_ {
int32_T dV_openRate; /* Variable: dV_openRate int32_T dV_openRate; /* Variable: dV_openRate
* Referenced by: '<S33>/dV_openRate' * Referenced by: '<S35>/dV_openRate'
*/ */
int16_T dz_cntTrnsDetHi; /* Variable: dz_cntTrnsDetHi int16_T dz_cntTrnsDetHi; /* Variable: dz_cntTrnsDetHi
* Referenced by: '<S15>/dz_cntTrnsDet' * Referenced by: '<S16>/dz_cntTrnsDet'
*/ */
int16_T dz_cntTrnsDetLo; /* Variable: dz_cntTrnsDetLo int16_T dz_cntTrnsDetLo; /* Variable: dz_cntTrnsDetLo
* Referenced by: '<S15>/dz_cntTrnsDet' * Referenced by: '<S16>/dz_cntTrnsDet'
*/
int16_T n_cruiseMotTgt; /* Variable: n_cruiseMotTgt
* Referenced by: '<S55>/n_cruiseMotTgt'
*/ */
int16_T z_maxCntRst; /* Variable: z_maxCntRst int16_T z_maxCntRst; /* Variable: z_maxCntRst
* Referenced by: * Referenced by:
@ -220,10 +241,10 @@ struct P_ {
* '<S12>/z_maxCntRst' * '<S12>/z_maxCntRst'
* '<S12>/z_maxCntRst2' * '<S12>/z_maxCntRst2'
* '<S12>/UnitDelay3' * '<S12>/UnitDelay3'
* '<S15>/z_counter' * '<S16>/z_counter'
*/ */
uint16_T cf_speedCoef; /* Variable: cf_speedCoef uint16_T cf_speedCoef; /* Variable: cf_speedCoef
* Referenced by: '<S15>/cf_speedCoef' * Referenced by: '<S16>/cf_speedCoef'
*/ */
uint16_T t_errDequal; /* Variable: t_errDequal uint16_T t_errDequal; /* Variable: t_errDequal
* Referenced by: '<S3>/t_errDequal' * Referenced by: '<S3>/t_errDequal'
@ -233,22 +254,22 @@ struct P_ {
*/ */
int16_T Vd_max; /* Variable: Vd_max int16_T Vd_max; /* Variable: Vd_max
* Referenced by: * Referenced by:
* '<S45>/Vd_max1' * '<S47>/Vd_max1'
* '<S32>/Vd_max' * '<S34>/Vd_max'
*/ */
int16_T Vq_max_M1[46]; /* Variable: Vq_max_M1 int16_T Vq_max_M1[46]; /* Variable: Vq_max_M1
* Referenced by: '<S45>/Vq_max_M1' * Referenced by: '<S47>/Vq_max_M1'
*/ */
int16_T Vq_max_XA[46]; /* Variable: Vq_max_XA int16_T Vq_max_XA[46]; /* Variable: Vq_max_XA
* Referenced by: '<S45>/Vq_max_XA' * Referenced by: '<S47>/Vq_max_XA'
*/ */
int16_T a_phaAdvMax; /* Variable: a_phaAdvMax int16_T a_phaAdvMax; /* Variable: a_phaAdvMax
* Referenced by: '<S5>/a_phaAdvMax' * Referenced by: '<S5>/a_phaAdvMax'
*/ */
int16_T i_max; /* Variable: i_max int16_T i_max; /* Variable: i_max
* Referenced by: * Referenced by:
* '<S45>/i_max' * '<S47>/i_max'
* '<S32>/i_max' * '<S34>/i_max'
*/ */
int16_T id_fieldWeakMax; /* Variable: id_fieldWeakMax int16_T id_fieldWeakMax; /* Variable: id_fieldWeakMax
* Referenced by: '<S5>/id_fieldWeakMax' * Referenced by: '<S5>/id_fieldWeakMax'
@ -267,8 +288,8 @@ struct P_ {
*/ */
int16_T n_max; /* Variable: n_max int16_T n_max; /* Variable: n_max
* Referenced by: * Referenced by:
* '<S45>/n_max1' * '<S47>/n_max1'
* '<S32>/n_max' * '<S34>/n_max'
*/ */
int16_T n_stdStillDet; /* Variable: n_stdStillDet int16_T n_stdStillDet; /* Variable: n_stdStillDet
* Referenced by: '<S12>/n_stdStillDet' * Referenced by: '<S12>/n_stdStillDet'
@ -284,42 +305,56 @@ struct P_ {
*/ */
uint16_T cf_KbLimProt; /* Variable: cf_KbLimProt uint16_T cf_KbLimProt; /* Variable: cf_KbLimProt
* Referenced by: * Referenced by:
* '<S72>/cf_KbLimProt' * '<S75>/cf_KbLimProt'
* '<S73>/cf_KbLimProt' * '<S76>/cf_KbLimProt'
*/ */
uint16_T cf_idKp; /* Variable: cf_idKp uint16_T cf_idKp; /* Variable: cf_idKp
* Referenced by: '<S54>/cf_idKp1' * Referenced by: '<S57>/cf_idKp1'
*/ */
uint16_T cf_iqKp; /* Variable: cf_iqKp uint16_T cf_iqKp; /* Variable: cf_iqKp
* Referenced by: '<S53>/cf_iqKp' * Referenced by: '<S56>/cf_iqKp'
*/ */
uint16_T cf_nKp; /* Variable: cf_nKp uint16_T cf_nKp; /* Variable: cf_nKp
* Referenced by: '<S52>/cf_nKp' * Referenced by: '<S55>/cf_nKp'
*/ */
uint16_T cf_currFilt; /* Variable: cf_currFilt uint16_T cf_currFilt; /* Variable: cf_currFilt
* Referenced by: '<S41>/cf_currFilt' * Referenced by: '<S43>/cf_currFilt'
*/ */
uint16_T cf_idKi; /* Variable: cf_idKi uint16_T cf_idKi; /* Variable: cf_idKi
* Referenced by: '<S54>/cf_idKi1' * Referenced by: '<S57>/cf_idKi1'
*/ */
uint16_T cf_iqKi; /* Variable: cf_iqKi uint16_T cf_iqKi; /* Variable: cf_iqKi
* Referenced by: '<S53>/cf_iqKi' * Referenced by: '<S56>/cf_iqKi'
*/ */
uint16_T cf_iqKiLimProt; /* Variable: cf_iqKiLimProt uint16_T cf_iqKiLimProt; /* Variable: cf_iqKiLimProt
* Referenced by: * Referenced by:
* '<S71>/cf_iqKiLimProt' * '<S74>/cf_iqKiLimProt'
* '<S73>/cf_iqKiLimProt' * '<S76>/cf_iqKiLimProt'
*/ */
uint16_T cf_nKi; /* Variable: cf_nKi uint16_T cf_nKi; /* Variable: cf_nKi
* Referenced by: '<S52>/cf_nKi' * Referenced by: '<S55>/cf_nKi'
*/ */
uint16_T cf_nKiLimProt; /* Variable: cf_nKiLimProt uint16_T cf_nKiLimProt; /* Variable: cf_nKiLimProt
* Referenced by: * Referenced by:
* '<S72>/cf_nKiLimProt' * '<S75>/cf_nKiLimProt'
* '<S73>/cf_nKiLimProt' * '<S76>/cf_nKiLimProt'
*/
uint8_T n_polePairs; /* Variable: n_polePairs
* Referenced by: '<S14>/n_polePairs'
*/ */
uint8_T z_ctrlTypSel; /* Variable: z_ctrlTypSel uint8_T z_ctrlTypSel; /* Variable: z_ctrlTypSel
* Referenced by: '<S1>/z_ctrlTypSel1' * Referenced by: '<S1>/z_ctrlTypSel'
*/
uint8_T z_selPhaCurMeasABC; /* Variable: z_selPhaCurMeasABC
* Referenced by: '<S42>/z_selPhaCurMeasABC'
*/
boolean_T b_angleMeasEna; /* Variable: b_angleMeasEna
* Referenced by:
* '<S2>/b_angleMeasEna'
* '<S12>/b_angleMeasEna'
*/
boolean_T b_cruiseCtrlEna; /* Variable: b_cruiseCtrlEna
* Referenced by: '<S1>/b_cruiseCtrlEna'
*/ */
boolean_T b_diagEna; /* Variable: b_diagEna boolean_T b_diagEna; /* Variable: b_diagEna
* Referenced by: '<S1>/b_diagEna' * Referenced by: '<S1>/b_diagEna'
@ -327,10 +362,7 @@ struct P_ {
boolean_T b_fieldWeakEna; /* Variable: b_fieldWeakEna boolean_T b_fieldWeakEna; /* Variable: b_fieldWeakEna
* Referenced by: * Referenced by:
* '<S1>/b_fieldWeakEna' * '<S1>/b_fieldWeakEna'
* '<S87>/b_fieldWeakEna' * '<S90>/b_fieldWeakEna'
*/
boolean_T b_selPhaABCurrMeas; /* Variable: b_selPhaABCurrMeas
* Referenced by: '<S40>/b_selPhaABCurrMeas'
*/ */
}; };
@ -357,30 +389,30 @@ extern void BLDC_controller_step(RT_MODEL *const rtM);
* *
* Block '<S12>/Scope2' : Unused code path elimination * Block '<S12>/Scope2' : Unused code path elimination
* Block '<S13>/Scope' : Unused code path elimination * Block '<S13>/Scope' : Unused code path elimination
* Block '<S37>/Data Type Duplicate' : Unused code path elimination
* Block '<S37>/Data Type Propagation' : Unused code path elimination
* Block '<S38>/Data Type Duplicate' : Unused code path elimination
* Block '<S38>/Data Type Propagation' : Unused code path elimination
* Block '<S39>/Data Type Duplicate' : Unused code path elimination * Block '<S39>/Data Type Duplicate' : Unused code path elimination
* Block '<S39>/Data Type Propagation' : Unused code path elimination * Block '<S39>/Data Type Propagation' : Unused code path elimination
* Block '<S61>/Data Type Duplicate' : Unused code path elimination * Block '<S40>/Data Type Duplicate' : Unused code path elimination
* Block '<S61>/Data Type Propagation' : Unused code path elimination * Block '<S40>/Data Type Propagation' : Unused code path elimination
* Block '<S66>/Data Type Duplicate' : Unused code path elimination * Block '<S41>/Data Type Duplicate' : Unused code path elimination
* Block '<S66>/Data Type Propagation' : Unused code path elimination * Block '<S41>/Data Type Propagation' : Unused code path elimination
* Block '<S70>/Data Type Duplicate' : Unused code path elimination * Block '<S64>/Data Type Duplicate' : Unused code path elimination
* Block '<S70>/Data Type Propagation' : Unused code path elimination * Block '<S64>/Data Type Propagation' : Unused code path elimination
* Block '<S74>/Data Type Duplicate' : Unused code path elimination * Block '<S69>/Data Type Duplicate' : Unused code path elimination
* Block '<S74>/Data Type Propagation' : Unused code path elimination * Block '<S69>/Data Type Propagation' : Unused code path elimination
* Block '<S73>/Data Type Duplicate' : Unused code path elimination
* Block '<S73>/Data Type Propagation' : Unused code path elimination
* Block '<S77>/Data Type Duplicate' : Unused code path elimination * Block '<S77>/Data Type Duplicate' : Unused code path elimination
* Block '<S77>/Data Type Propagation' : Unused code path elimination * Block '<S77>/Data Type Propagation' : Unused code path elimination
* Block '<S81>/Data Type Duplicate' : Unused code path elimination * Block '<S80>/Data Type Duplicate' : Unused code path elimination
* Block '<S81>/Data Type Propagation' : Unused code path elimination * Block '<S80>/Data Type Propagation' : Unused code path elimination
* Block '<S83>/Data Type Duplicate' : Unused code path elimination * Block '<S84>/Data Type Duplicate' : Unused code path elimination
* Block '<S83>/Data Type Propagation' : Unused code path elimination * Block '<S84>/Data Type Propagation' : Unused code path elimination
* Block '<S86>/Data Type Duplicate' : Unused code path elimination
* Block '<S86>/Data Type Propagation' : Unused code path elimination
* Block '<S6>/Scope12' : Unused code path elimination * Block '<S6>/Scope12' : Unused code path elimination
* Block '<S6>/Scope8' : Unused code path elimination * Block '<S6>/Scope8' : Unused code path elimination
* Block '<S6>/Scope9' : Unused code path elimination * Block '<S90>/Scope' : Unused code path elimination
* Block '<S87>/Scope' : Unused code path elimination * Block '<S66>/Data Type Conversion1' : Eliminate redundant data type conversion
* Block '<S8>/Data Type Conversion' : Eliminate redundant data type conversion * Block '<S8>/Data Type Conversion' : Eliminate redundant data type conversion
*/ */
@ -396,100 +428,103 @@ extern void BLDC_controller_step(RT_MODEL *const rtM);
* MATLAB hilite_system command to trace the generated code back * MATLAB hilite_system command to trace the generated code back
* to the parent model. For example, * to the parent model. For example,
* *
* hilite_system('BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller') - opens subsystem BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller * hilite_system('BLDCmotor_FOC_R2017b_fixdt/BLDC_controller') - opens subsystem BLDCmotor_FOC_R2017b_fixdt/BLDC_controller
* hilite_system('BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/Kp') - opens and selects block Kp * hilite_system('BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/Kp') - opens and selects block Kp
* *
* Here is the system hierarchy for this model * Here is the system hierarchy for this model
* *
* '<Root>' : 'BLDCmotorControl_FOC_R2017b_fixdt' * '<Root>' : 'BLDCmotor_FOC_R2017b_fixdt'
* '<S1>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller' * '<S1>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller'
* '<S2>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F01_Estimations' * '<S2>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F01_Estimations'
* '<S3>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics' * '<S3>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics'
* '<S4>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager' * '<S4>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager'
* '<S5>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F04_Field_Weakening' * '<S5>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F04_Field_Weakening'
* '<S6>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control' * '<S6>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control'
* '<S7>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F06_Control_Type_Management' * '<S7>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F06_Control_Type_Management'
* '<S8>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/Task_Scheduler' * '<S8>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/Task_Scheduler'
* '<S9>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F01_Estimations/F01_01_Edge_Detector' * '<S9>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F01_Estimations/F01_01_Edge_Detector'
* '<S10>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F01_Estimations/F01_02_Position_Calculation' * '<S10>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F01_Estimations/F01_02_Position_Calculation'
* '<S11>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F01_Estimations/F01_03_Direction_Detection' * '<S11>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F01_Estimations/F01_03_Direction_Detection'
* '<S12>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F01_Estimations/F01_04_Speed_Estimation' * '<S12>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F01_Estimations/F01_04_Speed_Estimation'
* '<S13>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F01_Estimations/F01_05_Electrical_Angle_Estimation' * '<S13>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F01_Estimations/F01_05_Electrical_Angle_Estimation'
* '<S14>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F01_Estimations/F01_04_Speed_Estimation/Counter' * '<S14>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F01_Estimations/F01_06_Electrical_Angle_Measurement'
* '<S15>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F01_Estimations/F01_04_Speed_Estimation/Raw_Motor_Speed_Estimation' * '<S15>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F01_Estimations/F01_04_Speed_Estimation/Counter'
* '<S16>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F01_Estimations/F01_04_Speed_Estimation/Counter/rst_Delay' * '<S16>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F01_Estimations/F01_04_Speed_Estimation/Raw_Motor_Speed_Estimation'
* '<S17>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics/Debounce_Filter' * '<S17>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F01_Estimations/F01_04_Speed_Estimation/Counter/rst_Delay'
* '<S18>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics/either_edge' * '<S18>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F01_Estimations/F01_06_Electrical_Angle_Measurement/Modulo_fixdt'
* '<S19>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics/Debounce_Filter/Default' * '<S19>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics/Debounce_Filter'
* '<S20>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics/Debounce_Filter/Dequalification' * '<S20>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics/either_edge'
* '<S21>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics/Debounce_Filter/Qualification' * '<S21>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics/Debounce_Filter/Default'
* '<S22>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics/Debounce_Filter/either_edge' * '<S22>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics/Debounce_Filter/Dequalification'
* '<S23>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics/Debounce_Filter/Dequalification/Counter' * '<S23>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics/Debounce_Filter/Qualification'
* '<S24>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics/Debounce_Filter/Dequalification/Counter/rst_Delay' * '<S24>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics/Debounce_Filter/either_edge'
* '<S25>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics/Debounce_Filter/Qualification/Counter' * '<S25>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics/Debounce_Filter/Dequalification/Counter'
* '<S26>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics/Debounce_Filter/Qualification/Counter/rst_Delay' * '<S26>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics/Debounce_Filter/Dequalification/Counter/rst_Delay'
* '<S27>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_01_Mode_Transition_Calculation' * '<S27>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics/Debounce_Filter/Qualification/Counter'
* '<S28>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_02_Control_Mode_Manager' * '<S28>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F02_Diagnostics/Debounce_Filter/Qualification/Counter/rst_Delay'
* '<S29>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_03_Input_Target_Synthesis' * '<S29>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_01_Mode_Transition_Calculation'
* '<S30>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_03_Input_Target_Synthesis/Default_Control_Type' * '<S30>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_02_Control_Mode_Manager'
* '<S31>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_03_Input_Target_Synthesis/Default_Mode' * '<S31>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_03_Input_Target_Synthesis'
* '<S32>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_03_Input_Target_Synthesis/FOC_Control_Type' * '<S32>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_03_Input_Target_Synthesis/Default_Control_Type'
* '<S33>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_03_Input_Target_Synthesis/Open_Mode' * '<S33>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_03_Input_Target_Synthesis/Default_Mode'
* '<S34>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_03_Input_Target_Synthesis/Open_Mode/Rate_Limiter' * '<S34>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_03_Input_Target_Synthesis/FOC_Control_Type'
* '<S35>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_03_Input_Target_Synthesis/Open_Mode/rising_edge_init' * '<S35>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_03_Input_Target_Synthesis/Open_Mode'
* '<S36>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_03_Input_Target_Synthesis/Open_Mode/Rate_Limiter/Delay_Init1' * '<S36>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_03_Input_Target_Synthesis/Open_Mode/Rate_Limiter'
* '<S37>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_03_Input_Target_Synthesis/Open_Mode/Rate_Limiter/Saturation Dynamic' * '<S37>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_03_Input_Target_Synthesis/Open_Mode/rising_edge_init'
* '<S38>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F04_Field_Weakening/Saturation Dynamic' * '<S38>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_03_Input_Target_Synthesis/Open_Mode/Rate_Limiter/Delay_Init1'
* '<S39>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F04_Field_Weakening/Saturation Dynamic1' * '<S39>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F03_Control_Mode_Manager/F03_03_Input_Target_Synthesis/Open_Mode/Rate_Limiter/Saturation Dynamic'
* '<S40>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Clarke_Transform' * '<S40>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F04_Field_Weakening/Saturation Dynamic'
* '<S41>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Current_Filtering' * '<S41>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F04_Field_Weakening/Saturation Dynamic1'
* '<S42>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC' * '<S42>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Clarke_Transform'
* '<S43>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Inv_Clarke_Transform' * '<S43>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Current_Filtering'
* '<S44>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Inv_Park_Transform' * '<S44>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC'
* '<S45>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations' * '<S45>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Inv_Clarke_Transform'
* '<S46>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Park_Transform' * '<S46>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Inv_Park_Transform'
* '<S47>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Sine_Cosine_Approximation' * '<S47>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations'
* '<S48>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Clarke_Transform/Clarke_PhasesAB' * '<S48>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Park_Transform'
* '<S49>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Clarke_Transform/Clarke_PhasesBC' * '<S49>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Sine_Cosine_Approximation'
* '<S50>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Current_Filtering/Low_Pass_Filter' * '<S50>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Clarke_Transform/Clarke_PhasesAB'
* '<S51>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Open_Mode' * '<S51>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Clarke_Transform/Clarke_PhasesAC'
* '<S52>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Speed_Mode' * '<S52>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Clarke_Transform/Clarke_PhasesBC'
* '<S53>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Torque_Mode' * '<S53>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Current_Filtering/Low_Pass_Filter'
* '<S54>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Vd_Calculation' * '<S54>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Open_Mode'
* '<S55>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Voltage_Mode' * '<S55>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Speed_Mode'
* '<S56>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Speed_Mode/PI_clamp_fixdt' * '<S56>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Torque_Mode'
* '<S57>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Speed_Mode/PI_clamp_fixdt/Clamping_circuit' * '<S57>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Vd_Calculation'
* '<S58>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Speed_Mode/PI_clamp_fixdt/Integrator' * '<S58>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Voltage_Mode'
* '<S59>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Speed_Mode/PI_clamp_fixdt/Saturation_hit' * '<S59>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Speed_Mode/PI_clamp_fixdt'
* '<S60>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Torque_Mode/PI_clamp_fixdt' * '<S60>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Speed_Mode/PI_clamp_fixdt/Clamping_circuit'
* '<S61>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Torque_Mode/Saturation Dynamic1' * '<S61>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Speed_Mode/PI_clamp_fixdt/Integrator'
* '<S62>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Torque_Mode/PI_clamp_fixdt/Clamping_circuit' * '<S62>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Speed_Mode/PI_clamp_fixdt/Saturation_hit'
* '<S63>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Torque_Mode/PI_clamp_fixdt/Integrator' * '<S63>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Torque_Mode/PI_clamp_fixdt'
* '<S64>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Torque_Mode/PI_clamp_fixdt/Saturation_hit' * '<S64>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Torque_Mode/Saturation Dynamic1'
* '<S65>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Vd_Calculation/PI_clamp_fixdt' * '<S65>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Torque_Mode/PI_clamp_fixdt/Clamping_circuit'
* '<S66>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Vd_Calculation/Saturation Dynamic' * '<S66>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Torque_Mode/PI_clamp_fixdt/Integrator'
* '<S67>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Vd_Calculation/PI_clamp_fixdt/Clamping_circuit' * '<S67>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Torque_Mode/PI_clamp_fixdt/Saturation_hit'
* '<S68>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Vd_Calculation/PI_clamp_fixdt/Integrator' * '<S68>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Vd_Calculation/PI_clamp_fixdt'
* '<S69>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Vd_Calculation/PI_clamp_fixdt/Saturation_hit' * '<S69>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Vd_Calculation/Saturation Dynamic'
* '<S70>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Voltage_Mode/Saturation Dynamic1' * '<S70>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Vd_Calculation/PI_clamp_fixdt/Clamping_circuit'
* '<S71>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Speed_Mode_Protection' * '<S71>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Vd_Calculation/PI_clamp_fixdt/Integrator'
* '<S72>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Torque_Mode_Protection' * '<S72>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Vd_Calculation/PI_clamp_fixdt/Saturation_hit'
* '<S73>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Voltage_Mode_Protection' * '<S73>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/FOC/Voltage_Mode/Saturation Dynamic1'
* '<S74>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Speed_Mode_Protection/Saturation Dynamic' * '<S74>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Speed_Mode_Protection'
* '<S75>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Torque_Mode_Protection/I_backCalc_fixdt' * '<S75>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Torque_Mode_Protection'
* '<S76>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Torque_Mode_Protection/I_backCalc_fixdt/Integrator' * '<S76>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Voltage_Mode_Protection'
* '<S77>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Torque_Mode_Protection/I_backCalc_fixdt/Saturation Dynamic1' * '<S77>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Speed_Mode_Protection/Saturation Dynamic'
* '<S78>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Voltage_Mode_Protection/I_backCalc_fixdt' * '<S78>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Torque_Mode_Protection/I_backCalc_fixdt'
* '<S79>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Voltage_Mode_Protection/I_backCalc_fixdt1' * '<S79>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Torque_Mode_Protection/I_backCalc_fixdt/Integrator'
* '<S80>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Voltage_Mode_Protection/I_backCalc_fixdt/Integrator' * '<S80>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Torque_Mode_Protection/I_backCalc_fixdt/Saturation Dynamic1'
* '<S81>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Voltage_Mode_Protection/I_backCalc_fixdt/Saturation Dynamic1' * '<S81>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Voltage_Mode_Protection/I_backCalc_fixdt'
* '<S82>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Voltage_Mode_Protection/I_backCalc_fixdt1/Integrator' * '<S82>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Voltage_Mode_Protection/I_backCalc_fixdt1'
* '<S83>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Voltage_Mode_Protection/I_backCalc_fixdt1/Saturation Dynamic1' * '<S83>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Voltage_Mode_Protection/I_backCalc_fixdt/Integrator'
* '<S84>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F06_Control_Type_Management/COM_Method' * '<S84>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Voltage_Mode_Protection/I_backCalc_fixdt/Saturation Dynamic1'
* '<S85>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F06_Control_Type_Management/FOC_Method' * '<S85>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Voltage_Mode_Protection/I_backCalc_fixdt1/Integrator'
* '<S86>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F06_Control_Type_Management/SIN_Method' * '<S86>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F05_Field_Oriented_Control/Motor_Limitations/Voltage_Mode_Protection/I_backCalc_fixdt1/Saturation Dynamic1'
* '<S87>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F06_Control_Type_Management/SIN_Method/Final_Phase_Advance_Calculation' * '<S87>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F06_Control_Type_Management/COM_Method'
* '<S88>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F06_Control_Type_Management/SIN_Method/Final_Phase_Advance_Calculation/Modulo_fixdt' * '<S88>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F06_Control_Type_Management/FOC_Method'
* '<S89>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F06_Control_Type_Management/SIN_Method'
* '<S90>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F06_Control_Type_Management/SIN_Method/Final_Phase_Advance_Calculation'
* '<S91>' : 'BLDCmotor_FOC_R2017b_fixdt/BLDC_controller/F06_Control_Type_Management/SIN_Method/Final_Phase_Advance_Calculation/Modulo_fixdt'
*/ */
#endif /* RTW_HEADER_BLDC_controller_h_ */ #endif /* RTW_HEADER_BLDC_controller_h_ */

View File

@ -152,8 +152,8 @@
#define FIELD_WEAK_ENA 0 // [-] Field Weakening / Phase Advance enable flag: 0 = Disabled (default), 1 = Enabled #define FIELD_WEAK_ENA 0 // [-] Field Weakening / Phase Advance enable flag: 0 = Disabled (default), 1 = Enabled
#define FIELD_WEAK_MAX 5 // [A] Maximum Field Weakening D axis current (only for FOC). Higher current results in higher maximum speed. Up to 10A has been tested using 10" wheels. #define FIELD_WEAK_MAX 5 // [A] Maximum Field Weakening D axis current (only for FOC). Higher current results in higher maximum speed. Up to 10A has been tested using 10" wheels.
#define PHASE_ADV_MAX 25 // [deg] Maximum Phase Advance angle (only for SIN). Higher angle results in higher maximum speed. #define PHASE_ADV_MAX 25 // [deg] Maximum Phase Advance angle (only for SIN). Higher angle results in higher maximum speed.
#define FIELD_WEAK_HI 1500 // [-] Input target High threshold for reaching maximum Field Weakening / Phase Advance. Do NOT set this higher than 1500. #define FIELD_WEAK_HI 1000 // (1000, 1500] Input target High threshold for reaching maximum Field Weakening / Phase Advance. Do NOT set this higher than 1500.
#define FIELD_WEAK_LO 1000 // [-] Input target Low threshold for starting Field Weakening / Phase Advance. Do NOT set this higher than 1000. #define FIELD_WEAK_LO 750 // ( 500, 1000] Input target Low threshold for starting Field Weakening / Phase Advance. Do NOT set this higher than 1000.
// Extra functionality // Extra functionality
// #define STANDSTILL_HOLD_ENABLE // [-] Flag to hold the position when standtill is reached. Only available and makes sense for VOLTAGE or TORQUE mode. // #define STANDSTILL_HOLD_ENABLE // [-] Flag to hold the position when standtill is reached. Only available and makes sense for VOLTAGE or TORQUE mode.
@ -184,6 +184,21 @@
// ############################## CRUISE CONTROL SETTINGS ############################
/* Cruise Control info:
* enable CRUISE_CONTROL_SUPPORT and (SUPPORT_BUTTONS_LEFT or SUPPORT_BUTTONS_RIGHT depending on which cable is the button installed)
* can be activated/deactivated by pressing button1 (Blue cable) to GND
* when activated, it maintains the current speed by switching to SPD_MODE. Acceleration is still possible via the input request, but when released it resumes to previous set speed.
* when deactivated, it returns to previous control MODE and follows the input request.
*/
// #define CRUISE_CONTROL_SUPPORT
// #define SUPPORT_BUTTONS_LEFT // Use button1 (Blue Left cable) to activate/deactivate Cruise Control
// #define SUPPORT_BUTTONS_RIGHT // Use button1 (Blue Right cable) to activate/deactivate Cruise Control
// ######################### END OF CRUISE CONTROL SETTINGS ##########################
// ############################### DEBUG SERIAL ############################### // ############################### DEBUG SERIAL ###############################
/* Connect GND and RX of a 3.3v uart-usb adapter to the left (USART2) or right sensor board cable (USART3) /* Connect GND and RX of a 3.3v uart-usb adapter to the left (USART2) or right sensor board cable (USART3)
* Be careful not to use the red wire of the cable. 15v will destroye evrything. * Be careful not to use the red wire of the cable. 15v will destroye evrything.
@ -378,12 +393,12 @@
#define ADC1_MAX 2500 // max ADC1-value while poti at maximum-position (0 - 4095) #define ADC1_MAX 2500 // max ADC1-value while poti at maximum-position (0 - 4095)
#define ADC2_MIN 500 // min ADC2-value while poti at minimum-position (0 - 4095) #define ADC2_MIN 500 // min ADC2-value while poti at minimum-position (0 - 4095)
#define ADC2_MAX 2200 // max ADC2-value while poti at maximum-position (0 - 4095) #define ADC2_MAX 2200 // max ADC2-value while poti at maximum-position (0 - 4095)
#define SPEED_COEFFICIENT 16384 // 1.0f #define SPEED_COEFFICIENT 16384 // 1.0f
#define STEER_COEFFICIENT 0 // 0.0f #define STEER_COEFFICIENT 0 // 0.0f
// #define INVERT_R_DIRECTION // Invert rotation of right motor // #define INVERT_R_DIRECTION // Invert rotation of right motor
// #define INVERT_L_DIRECTION // Invert rotation of left motor // #define INVERT_L_DIRECTION // Invert rotation of left motor
#define SIDEBOARD_SERIAL_USART3 #define SIDEBOARD_SERIAL_USART3 // Tx -> Rx of right sensor board: for LED battery indication. Comment-out if sideboard is not used!
#define FEEDBACK_SERIAL_USART3 // right sensor board cable, disable if I2C (nunchuk or lcd) is used! #define FEEDBACK_SERIAL_USART3 // Rx <- Tx of right sensor board: to use photosensors as buttons. Comment-out if sideboard is not used!
// #define DEBUG_SERIAL_USART3 // right sensor board cable, disable if I2C (nunchuk or lcd) is used! // #define DEBUG_SERIAL_USART3 // right sensor board cable, disable if I2C (nunchuk or lcd) is used!
// Extra functionality // Extra functionality

View File

@ -3,9 +3,9 @@
* *
* Code generated for Simulink model 'BLDC_controller'. * Code generated for Simulink model 'BLDC_controller'.
* *
* Model version : 1.1260 * Model version : 1.1284
* Simulink Coder version : 8.13 (R2017b) 24-Jul-2017 * Simulink Coder version : 8.13 (R2017b) 24-Jul-2017
* C/C++ source code generated on : Tue Mar 24 11:01:08 2020 * C/C++ source code generated on : Sun Oct 11 21:38:56 2020
* *
* Target selection: ert.tlc * Target selection: ert.tlc
* Embedded hardware selection: ARM Compatible->ARM Cortex * Embedded hardware selection: ARM Compatible->ARM Cortex

View File

@ -71,9 +71,7 @@ In all FOC control modes, the controller features maximum motor speed and maximu
- All the calibratable motor parameters can be found in the 'BLDC_controller_data.c'. I provided you with an already calibrated controller, but if you feel like fine tuning it feel free to do so - All the calibratable motor parameters can be found in the 'BLDC_controller_data.c'. I provided you with an already calibrated controller, but if you feel like fine tuning it feel free to do so
- The parameters are represented in Fixed-point data type for a more efficient code execution - The parameters are represented in Fixed-point data type for a more efficient code execution
- For calibrating the fixed-point parameters use the [Fixed-Point Viewer](https://github.com/EmanuelFeru/FixedPointViewer) tool - For calibrating the fixed-point parameters use the [Fixed-Point Viewer](https://github.com/EmanuelFeru/FixedPointViewer) tool
- The parameters data Fixed-point types are given in the following table: - The controller parameters are given in [this table](https://github.com/EmanuelFeru/bldc-motor-control-FOC/blob/master/02_Figures/paramTable.png)
![Parameters table](/docs/pictures/paramTable.png)
### Diagnostics ### Diagnostics

File diff suppressed because it is too large Load Diff

View File

@ -3,9 +3,9 @@
* *
* Code generated for Simulink model 'BLDC_controller'. * Code generated for Simulink model 'BLDC_controller'.
* *
* Model version : 1.1260 * Model version : 1.1284
* Simulink Coder version : 8.13 (R2017b) 24-Jul-2017 * Simulink Coder version : 8.13 (R2017b) 24-Jul-2017
* C/C++ source code generated on : Tue Mar 24 11:01:08 2020 * C/C++ source code generated on : Sun Oct 11 21:38:56 2020
* *
* Target selection: ert.tlc * Target selection: ert.tlc
* Embedded hardware selection: ARM Compatible->ARM Cortex * Embedded hardware selection: ARM Compatible->ARM Cortex
@ -22,7 +22,7 @@
/* Constant parameters (auto storage) */ /* Constant parameters (auto storage) */
const ConstP rtConstP = { const ConstP rtConstP = {
/* Computed Parameter: r_sin3PhaA_M1_Table /* Computed Parameter: r_sin3PhaA_M1_Table
* Referenced by: '<S86>/r_sin3PhaA_M1' * Referenced by: '<S89>/r_sin3PhaA_M1'
*/ */
{ -13091, -13634, -14126, -14565, -14953, -15289, -15577, -15816, -16009, { -13091, -13634, -14126, -14565, -14953, -15289, -15577, -15816, -16009,
-16159, -16269, -16340, -16377, -16383, -16362, -16317, -16253, -16172, -16159, -16269, -16340, -16377, -16383, -16362, -16317, -16253, -16172,
@ -44,7 +44,7 @@ const ConstP rtConstP = {
-9623, -10411, -11154, -11849, -12496, -13091 }, -9623, -10411, -11154, -11849, -12496, -13091 },
/* Computed Parameter: r_sin3PhaB_M1_Table /* Computed Parameter: r_sin3PhaB_M1_Table
* Referenced by: '<S86>/r_sin3PhaB_M1' * Referenced by: '<S89>/r_sin3PhaB_M1'
*/ */
{ 15172, 15180, 15206, 15248, 15306, 15377, 15461, 15555, 15656, 15762, 15870, { 15172, 15180, 15206, 15248, 15306, 15377, 15461, 15555, 15656, 15762, 15870,
15977, 16079, 16172, 16253, 16317, 16362, 16383, 16377, 16340, 16269, 16159, 15977, 16079, 16172, 16253, 16317, 16362, 16383, 16377, 16340, 16269, 16159,
@ -66,7 +66,7 @@ const ConstP rtConstP = {
15377, 15306, 15248, 15206, 15180, 15172 }, 15377, 15306, 15248, 15206, 15180, 15172 },
/* Computed Parameter: r_sin3PhaC_M1_Table /* Computed Parameter: r_sin3PhaC_M1_Table
* Referenced by: '<S86>/r_sin3PhaC_M1' * Referenced by: '<S89>/r_sin3PhaC_M1'
*/ */
{ -13091, -12496, -11849, -11154, -10411, -9623, -8791, -7921, -7014, -6075, { -13091, -12496, -11849, -11154, -10411, -9623, -8791, -7921, -7014, -6075,
-5107, -4115, -3104, -2077, -1041, 0, 1041, 2077, 3104, 4115, 5107, 6075, -5107, -4115, -3104, -2077, -1041, 0, 1041, 2077, 3104, 4115, 5107, 6075,
@ -88,7 +88,7 @@ const ConstP rtConstP = {
-15289, -14953, -14565, -14126, -13634, -13091 }, -15289, -14953, -14565, -14126, -13634, -13091 },
/* Computed Parameter: r_sin_M1_Table /* Computed Parameter: r_sin_M1_Table
* Referenced by: '<S47>/r_sin_M1' * Referenced by: '<S49>/r_sin_M1'
*/ */
{ 8192, 8682, 9162, 9630, 10087, 10531, 10963, 11381, 11786, 12176, 12551, { 8192, 8682, 9162, 9630, 10087, 10531, 10963, 11381, 11786, 12176, 12551,
12911, 13255, 13583, 13894, 14189, 14466, 14726, 14968, 15191, 15396, 15582, 12911, 13255, 13583, 13894, 14189, 14466, 14726, 14968, 15191, 15396, 15582,
@ -109,7 +109,7 @@ const ConstP rtConstP = {
2280, 2845, 3406, 3964, 4516, 5063, 5604, 6138, 6664, 7182, 7692, 8192 }, 2280, 2845, 3406, 3964, 4516, 5063, 5604, 6138, 6664, 7182, 7692, 8192 },
/* Computed Parameter: r_cos_M1_Table /* Computed Parameter: r_cos_M1_Table
* Referenced by: '<S47>/r_cos_M1' * Referenced by: '<S49>/r_cos_M1'
*/ */
{ 14189, 13894, 13583, 13255, 12911, 12551, 12176, 11786, 11381, 10963, 10531, { 14189, 13894, 13583, 13255, 12911, 12551, 12176, 11786, 11381, 10963, 10531,
10087, 9630, 9162, 8682, 8192, 7692, 7182, 6664, 6138, 5604, 5063, 4516, 10087, 9630, 9162, 8682, 8192, 7692, 7182, 6664, 6138, 5604, 5063, 4516,
@ -130,7 +130,7 @@ const ConstP rtConstP = {
16026, 15897, 15749, 15582, 15396, 15191, 14968, 14726, 14466, 14189 }, 16026, 15897, 15749, 15582, 15396, 15191, 14968, 14726, 14466, 14189 },
/* Computed Parameter: iq_maxSca_M1_Table /* Computed Parameter: iq_maxSca_M1_Table
* Referenced by: '<S45>/iq_maxSca_M1' * Referenced by: '<S47>/iq_maxSca_M1'
*/ */
{ 65535U, 65523U, 65484U, 65418U, 65326U, 65207U, 65062U, 64890U, 64691U, { 65535U, 65523U, 65484U, 65418U, 65326U, 65207U, 65062U, 64890U, 64691U,
64465U, 64211U, 63930U, 63620U, 63281U, 62913U, 62516U, 62088U, 61630U, 64465U, 64211U, 63930U, 63620U, 63281U, 62913U, 62516U, 62088U, 61630U,
@ -140,7 +140,7 @@ const ConstP rtConstP = {
28540U, 25655U, 22323U, 18304U, 12974U }, 28540U, 25655U, 22323U, 18304U, 12974U },
/* Computed Parameter: z_commutMap_M1_table /* Computed Parameter: z_commutMap_M1_table
* Referenced by: '<S84>/z_commutMap_M1' * Referenced by: '<S87>/z_commutMap_M1'
*/ */
{ -1, 1, 0, -1, 0, 1, 0, -1, 1, 1, -1, 0, 1, 0, -1, 0, 1, -1 }, { -1, 1, 0, -1, 0, 1, 0, -1, 1, 1, -1, 0, 1, 0, -1, 0, 1, -1 },
@ -152,32 +152,37 @@ const ConstP rtConstP = {
P rtP_Left = { P rtP_Left = {
/* Variable: dV_openRate /* Variable: dV_openRate
* Referenced by: '<S33>/dV_openRate' * Referenced by: '<S35>/dV_openRate'
*/ */
12288, 12288,
/* Variable: dz_cntTrnsDetHi /* Variable: dz_cntTrnsDetHi
* Referenced by: '<S15>/dz_cntTrnsDet' * Referenced by: '<S16>/dz_cntTrnsDet'
*/ */
40, 40,
/* Variable: dz_cntTrnsDetLo /* Variable: dz_cntTrnsDetLo
* Referenced by: '<S15>/dz_cntTrnsDet' * Referenced by: '<S16>/dz_cntTrnsDet'
*/ */
20, 20,
/* Variable: n_cruiseMotTgt
* Referenced by: '<S55>/n_cruiseMotTgt'
*/
0,
/* Variable: z_maxCntRst /* Variable: z_maxCntRst
* Referenced by: * Referenced by:
* '<S12>/Counter' * '<S12>/Counter'
* '<S12>/z_maxCntRst' * '<S12>/z_maxCntRst'
* '<S12>/z_maxCntRst2' * '<S12>/z_maxCntRst2'
* '<S12>/UnitDelay3' * '<S12>/UnitDelay3'
* '<S15>/z_counter' * '<S16>/z_counter'
*/ */
2000, 2000,
/* Variable: cf_speedCoef /* Variable: cf_speedCoef
* Referenced by: '<S15>/cf_speedCoef' * Referenced by: '<S16>/cf_speedCoef'
*/ */
10667U, 10667U,
@ -193,13 +198,13 @@ P rtP_Left = {
/* Variable: Vd_max /* Variable: Vd_max
* Referenced by: * Referenced by:
* '<S45>/Vd_max1' * '<S47>/Vd_max1'
* '<S32>/Vd_max' * '<S34>/Vd_max'
*/ */
14400, 14400,
/* Variable: Vq_max_M1 /* Variable: Vq_max_M1
* Referenced by: '<S45>/Vq_max_M1' * Referenced by: '<S47>/Vq_max_M1'
*/ */
{ 14400, 14396, 14386, 14368, 14343, 14311, 14271, 14225, 14171, 14109, 14040, { 14400, 14396, 14386, 14368, 14343, 14311, 14271, 14225, 14171, 14109, 14040,
13963, 13879, 13786, 13685, 13576, 13459, 13333, 13198, 13053, 12900, 12736, 13963, 13879, 13786, 13685, 13576, 13459, 13333, 13198, 13053, 12900, 12736,
@ -207,7 +212,7 @@ P rtP_Left = {
9790, 9433, 9051, 8640, 8196, 7713, 7184, 6597, 5935, 5170, 4245, 3019, 0 }, 9790, 9433, 9051, 8640, 8196, 7713, 7184, 6597, 5935, 5170, 4245, 3019, 0 },
/* Variable: Vq_max_XA /* Variable: Vq_max_XA
* Referenced by: '<S45>/Vq_max_XA' * Referenced by: '<S47>/Vq_max_XA'
*/ */
{ 0, 320, 640, 960, 1280, 1600, 1920, 2240, 2560, 2880, 3200, 3520, 3840, 4160, { 0, 320, 640, 960, 1280, 1600, 1920, 2240, 2560, 2880, 3200, 3520, 3840, 4160,
4480, 4800, 5120, 5440, 5760, 6080, 6400, 6720, 7040, 7360, 7680, 8000, 8320, 4480, 4800, 5120, 5440, 5760, 6080, 6400, 6720, 7040, 7360, 7680, 8000, 8320,
@ -221,8 +226,8 @@ P rtP_Left = {
/* Variable: i_max /* Variable: i_max
* Referenced by: * Referenced by:
* '<S45>/i_max' * '<S47>/i_max'
* '<S32>/i_max' * '<S34>/i_max'
*/ */
12000, 12000,
@ -253,10 +258,10 @@ P rtP_Left = {
/* Variable: n_max /* Variable: n_max
* Referenced by: * Referenced by:
* '<S45>/n_max1' * '<S47>/n_max1'
* '<S32>/n_max' * '<S34>/n_max'
*/ */
16000, 24000,
/* Variable: n_stdStillDet /* Variable: n_stdStillDet
* Referenced by: '<S12>/n_stdStillDet' * Referenced by: '<S12>/n_stdStillDet'
@ -271,74 +276,96 @@ P rtP_Left = {
/* Variable: r_fieldWeakHi /* Variable: r_fieldWeakHi
* Referenced by: '<S5>/r_fieldWeakHi' * Referenced by: '<S5>/r_fieldWeakHi'
*/ */
24000, 16000,
/* Variable: r_fieldWeakLo /* Variable: r_fieldWeakLo
* Referenced by: '<S5>/r_fieldWeakLo' * Referenced by: '<S5>/r_fieldWeakLo'
*/ */
16000, 12000,
/* Variable: cf_KbLimProt /* Variable: cf_KbLimProt
* Referenced by: * Referenced by:
* '<S72>/cf_KbLimProt' * '<S75>/cf_KbLimProt'
* '<S73>/cf_KbLimProt' * '<S76>/cf_KbLimProt'
*/ */
768U, 768U,
/* Variable: cf_idKp /* Variable: cf_idKp
* Referenced by: '<S54>/cf_idKp1' * Referenced by: '<S57>/cf_idKp1'
*/ */
819U, 819U,
/* Variable: cf_iqKp /* Variable: cf_iqKp
* Referenced by: '<S53>/cf_iqKp' * Referenced by: '<S56>/cf_iqKp'
*/ */
1229U, 1229U,
/* Variable: cf_nKp /* Variable: cf_nKp
* Referenced by: '<S52>/cf_nKp' * Referenced by: '<S55>/cf_nKp'
*/ */
4833U, 4833U,
/* Variable: cf_currFilt /* Variable: cf_currFilt
* Referenced by: '<S41>/cf_currFilt' * Referenced by: '<S43>/cf_currFilt'
*/ */
7864U, 7864U,
/* Variable: cf_idKi /* Variable: cf_idKi
* Referenced by: '<S54>/cf_idKi1' * Referenced by: '<S57>/cf_idKi1'
*/ */
737U, 737U,
/* Variable: cf_iqKi /* Variable: cf_iqKi
* Referenced by: '<S53>/cf_iqKi' * Referenced by: '<S56>/cf_iqKi'
*/ */
1229U, 1229U,
/* Variable: cf_iqKiLimProt /* Variable: cf_iqKiLimProt
* Referenced by: * Referenced by:
* '<S71>/cf_iqKiLimProt' * '<S74>/cf_iqKiLimProt'
* '<S73>/cf_iqKiLimProt' * '<S76>/cf_iqKiLimProt'
*/ */
737U, 737U,
/* Variable: cf_nKi /* Variable: cf_nKi
* Referenced by: '<S52>/cf_nKi' * Referenced by: '<S55>/cf_nKi'
*/ */
251U, 251U,
/* Variable: cf_nKiLimProt /* Variable: cf_nKiLimProt
* Referenced by: * Referenced by:
* '<S72>/cf_nKiLimProt' * '<S75>/cf_nKiLimProt'
* '<S73>/cf_nKiLimProt' * '<S76>/cf_nKiLimProt'
*/ */
246U, 246U,
/* Variable: n_polePairs
* Referenced by: '<S14>/n_polePairs'
*/
15U,
/* Variable: z_ctrlTypSel /* Variable: z_ctrlTypSel
* Referenced by: '<S1>/z_ctrlTypSel1' * Referenced by: '<S1>/z_ctrlTypSel'
*/ */
2U, 2U,
/* Variable: z_selPhaCurMeasABC
* Referenced by: '<S42>/z_selPhaCurMeasABC'
*/
0U,
/* Variable: b_angleMeasEna
* Referenced by:
* '<S2>/b_angleMeasEna'
* '<S12>/b_angleMeasEna'
*/
0,
/* Variable: b_cruiseCtrlEna
* Referenced by: '<S1>/b_cruiseCtrlEna'
*/
0,
/* Variable: b_diagEna /* Variable: b_diagEna
* Referenced by: '<S1>/b_diagEna' * Referenced by: '<S1>/b_diagEna'
*/ */
@ -347,14 +374,9 @@ P rtP_Left = {
/* Variable: b_fieldWeakEna /* Variable: b_fieldWeakEna
* Referenced by: * Referenced by:
* '<S1>/b_fieldWeakEna' * '<S1>/b_fieldWeakEna'
* '<S87>/b_fieldWeakEna' * '<S90>/b_fieldWeakEna'
*/ */
0, 0
/* Variable: b_selPhaABCurrMeas
* Referenced by: '<S40>/b_selPhaABCurrMeas'
*/
1
}; /* Modifiable parameters */ }; /* Modifiable parameters */
/* /*

View File

@ -167,6 +167,7 @@ void DMA1_Channel1_IRQHandler(void) {
rtU_Left.i_phaAB = curL_phaA; rtU_Left.i_phaAB = curL_phaA;
rtU_Left.i_phaBC = curL_phaB; rtU_Left.i_phaBC = curL_phaB;
rtU_Left.i_DCLink = curL_DC; rtU_Left.i_DCLink = curL_DC;
// rtU_Left.a_mechAngle = ...; // Angle input in DEGREES [0,360] in fixdt(1,16,4) data type. If `angle` is float use `= (int16_t)floor(angle * 16.0F)` If `angle` is integer use `= (int16_t)(angle << 4)`
/* Step the controller */ /* Step the controller */
#ifdef MOTOR_LEFT_ENA #ifdef MOTOR_LEFT_ENA
@ -204,6 +205,7 @@ void DMA1_Channel1_IRQHandler(void) {
rtU_Right.i_phaAB = curR_phaB; rtU_Right.i_phaAB = curR_phaB;
rtU_Right.i_phaBC = curR_phaC; rtU_Right.i_phaBC = curR_phaC;
rtU_Right.i_DCLink = curR_DC; rtU_Right.i_DCLink = curR_DC;
// rtU_Right.a_mechAngle = ...; // Angle input in DEGREES [0,360] in fixdt(1,16,4) data type. If `angle` is float use `= (int16_t)floor(angle * 16.0F)` If `angle` is integer use `= (int16_t)(angle << 4)`
/* Step the controller */ /* Step the controller */
#ifdef MOTOR_RIGHT_ENA #ifdef MOTOR_RIGHT_ENA

View File

@ -398,6 +398,14 @@ void MX_GPIO_Init(void) {
GPIO_InitStruct.Pin = CHARGER_PIN; GPIO_InitStruct.Pin = CHARGER_PIN;
HAL_GPIO_Init(CHARGER_PORT, &GPIO_InitStruct); HAL_GPIO_Init(CHARGER_PORT, &GPIO_InitStruct);
#if defined(SUPPORT_BUTTONS_LEFT) || defined(SUPPORT_BUTTONS_RIGHT)
GPIO_InitStruct.Pin = BUTTON1_PIN;
HAL_GPIO_Init(BUTTON1_PORT, &GPIO_InitStruct);
GPIO_InitStruct.Pin = BUTTON2_PIN;
HAL_GPIO_Init(BUTTON2_PORT, &GPIO_InitStruct);
#endif
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Pin = BUTTON_PIN; GPIO_InitStruct.Pin = BUTTON_PIN;
@ -440,10 +448,12 @@ void MX_GPIO_Init(void) {
HAL_GPIO_Init(DCLINK_PORT, &GPIO_InitStruct); HAL_GPIO_Init(DCLINK_PORT, &GPIO_InitStruct);
//Analog in //Analog in
#if !defined(SUPPORT_BUTTONS_LEFT)
GPIO_InitStruct.Pin = GPIO_PIN_3; GPIO_InitStruct.Pin = GPIO_PIN_3;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_2; GPIO_InitStruct.Pin = GPIO_PIN_2;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
#endif
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
@ -694,7 +704,7 @@ void MX_ADC2_Init(void) {
sConfig.Rank = 4; sConfig.Rank = 4;
HAL_ADC_ConfigChannel(&hadc2, &sConfig); HAL_ADC_ConfigChannel(&hadc2, &sConfig);
sConfig.SamplingTime = ADC_SAMPLETIME_239CYCLES_5; // sConfig.SamplingTime = ADC_SAMPLETIME_239CYCLES_5; // Commented-out to make `uart-l-rx` ADC sample time the same as `uart-l-tx`
sConfig.Channel = ADC_CHANNEL_3; // pa3 uart-l-rx sConfig.Channel = ADC_CHANNEL_3; // pa3 uart-l-rx
sConfig.Rank = 5; sConfig.Rank = 5;
HAL_ADC_ConfigChannel(&hadc2, &sConfig); HAL_ADC_ConfigChannel(&hadc2, &sConfig);

View File

@ -64,11 +64,6 @@ extern volatile uint16_t pwm_captured_ch1_value;
extern volatile uint16_t pwm_captured_ch2_value; extern volatile uint16_t pwm_captured_ch2_value;
#endif #endif
#ifdef BUTTONS_RIGHT
extern volatile uint8_t btn1; // Blue
extern volatile uint8_t btn2; // Green
#endif
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Global variables set here in util.c // Global variables set here in util.c
@ -199,7 +194,8 @@ static uint8_t sensor2_index; // holds the press index number for sens
#endif #endif
#if defined(SUPPORT_BUTTONS) || defined(SUPPORT_BUTTONS_LEFT) || defined(SUPPORT_BUTTONS_RIGHT) #if defined(SUPPORT_BUTTONS) || defined(SUPPORT_BUTTONS_LEFT) || defined(SUPPORT_BUTTONS_RIGHT)
static uint8_t button1, button2; static uint8_t button1; // Blue
static uint8_t button2; // Green
#endif #endif
#ifdef VARIANT_HOVERCAR #ifdef VARIANT_HOVERCAR
@ -211,7 +207,8 @@ static uint8_t brakePressed;
void BLDC_Init(void) { void BLDC_Init(void) {
/* Set BLDC controller parameters */ /* Set BLDC controller parameters */
rtP_Left.b_selPhaABCurrMeas = 1; // Left motor measured current phases {Green, Blue} = {iA, iB} -> do NOT change rtP_Left.b_angleMeasEna = 0; // Motor angle input: 0 = estimated angle, 1 = measured angle (e.g. if encoder is available)
rtP_Left.z_selPhaCurMeasABC = 0; // Left motor measured current phases {Green, Blue} = {iA, iB} -> do NOT change
rtP_Left.z_ctrlTypSel = CTRL_TYP_SEL; rtP_Left.z_ctrlTypSel = CTRL_TYP_SEL;
rtP_Left.b_diagEna = DIAG_ENA; rtP_Left.b_diagEna = DIAG_ENA;
rtP_Left.i_max = (I_MOT_MAX * A2BIT_CONV) << 4; // fixdt(1,16,4) rtP_Left.i_max = (I_MOT_MAX * A2BIT_CONV) << 4; // fixdt(1,16,4)
@ -223,7 +220,7 @@ void BLDC_Init(void) {
rtP_Left.r_fieldWeakLo = FIELD_WEAK_LO << 4; // fixdt(1,16,4) rtP_Left.r_fieldWeakLo = FIELD_WEAK_LO << 4; // fixdt(1,16,4)
rtP_Right = rtP_Left; // Copy the Left motor parameters to the Right motor parameters rtP_Right = rtP_Left; // Copy the Left motor parameters to the Right motor parameters
rtP_Right.b_selPhaABCurrMeas = 0; // Right motor measured current phases {Blue, Yellow} = {iB, iC} -> do NOT change rtP_Right.z_selPhaCurMeasABC = 1; // Right motor measured current phases {Blue, Yellow} = {iB, iC} -> do NOT change
/* Pack LEFT motor data into RTM */ /* Pack LEFT motor data into RTM */
rtM_Left->defaultParam = &rtP_Left; rtM_Left->defaultParam = &rtP_Left;
@ -466,8 +463,8 @@ void adcCalibLim(void) {
// ADC calibration checks // ADC calibration checks
#ifdef ADC_PROTECT_ENA #ifdef ADC_PROTECT_ENA
if ((ADC1_MIN_temp + 150 - ADC_PROTECT_THRESH) > 0 && (ADC1_MAX_temp - 150 + ADC_PROTECT_THRESH) < 4095 && if ((ADC1_MIN_temp + 100 - ADC_PROTECT_THRESH) > 0 && (ADC1_MAX_temp - 100 + ADC_PROTECT_THRESH) < 4095 &&
(ADC2_MIN_temp + 150 - ADC_PROTECT_THRESH) > 0 && (ADC2_MAX_temp - 150 + ADC_PROTECT_THRESH) < 4095) { (ADC2_MIN_temp + 100 - ADC_PROTECT_THRESH) > 0 && (ADC2_MAX_temp - 100 + ADC_PROTECT_THRESH) < 4095) {
adc_cal_valid = 1; adc_cal_valid = 1;
} else { } else {
adc_cal_valid = 0; adc_cal_valid = 0;
@ -477,12 +474,12 @@ void adcCalibLim(void) {
// Add final ADC margin to have exact 0 and MAX at the minimum and maximum ADC value // Add final ADC margin to have exact 0 and MAX at the minimum and maximum ADC value
if (adc_cal_valid && (ADC1_MAX_temp - ADC1_MIN_temp) > 500 && (ADC2_MAX_temp - ADC2_MIN_temp) > 500) { if (adc_cal_valid && (ADC1_MAX_temp - ADC1_MIN_temp) > 500 && (ADC2_MAX_temp - ADC2_MIN_temp) > 500) {
ADC1_MIN_CAL = ADC1_MIN_temp + 150; ADC1_MIN_CAL = ADC1_MIN_temp + 100;
ADC1_MID_CAL = ADC1_MID_temp; ADC1_MID_CAL = ADC1_MID_temp;
ADC1_MAX_CAL = ADC1_MAX_temp - 150; ADC1_MAX_CAL = ADC1_MAX_temp - 100;
ADC2_MIN_CAL = ADC2_MIN_temp + 150; ADC2_MIN_CAL = ADC2_MIN_temp + 100;
ADC2_MID_CAL = ADC2_MID_temp; ADC2_MID_CAL = ADC2_MID_temp;
ADC2_MAX_CAL = ADC2_MAX_temp - 150; ADC2_MAX_CAL = ADC2_MAX_temp - 100;
consoleLog("OK\n"); consoleLog("OK\n");
} else { } else {
adc_cal_valid = 0; adc_cal_valid = 0;
@ -865,6 +862,19 @@ void readCommand(void) {
ctrlModReq = ctrlModReqRaw; // Follow the Mode request ctrlModReq = ctrlModReqRaw; // Follow the Mode request
} }
#if defined(CRUISE_CONTROL_SUPPORT) && (defined(SUPPORT_BUTTONS) || defined(SUPPORT_BUTTONS_LEFT) || defined(SUPPORT_BUTTONS_RIGHT))
if (button1 && ~rtP_Left.b_cruiseCtrlEna) { // Cruise control activated
rtP_Left.n_cruiseMotTgt = rtY_Left.n_mot;
rtP_Right.n_cruiseMotTgt = rtY_Right.n_mot;
rtP_Left.b_cruiseCtrlEna = 1;
rtP_Right.b_cruiseCtrlEna = 1;
shortBeep(2);
} else if (button1 && rtP_Left.b_cruiseCtrlEna) { // Cruise control deactivated
rtP_Left.b_cruiseCtrlEna = 0;
rtP_Right.b_cruiseCtrlEna = 0;
shortBeep(6);
}
#endif
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB