forked from lucysrausch/hoverboard-firmware-hack
► Improved controller: faster and better overall
- the controller is faster and more light in memory footprint - motor control is now done intependenly using Reusable code generation setting in Simulink - fixed bug when chaging direction fast
This commit is contained in:
@@ -7,9 +7,9 @@
|
||||
*
|
||||
* Code generated for Simulink model 'BLDC_controller'.
|
||||
*
|
||||
* Model version : 1.817
|
||||
* Model version : 1.877
|
||||
* Simulink Coder version : 8.13 (R2017b) 24-Jul-2017
|
||||
* C/C++ source code generated on : Tue May 28 19:55:33 2019
|
||||
* C/C++ source code generated on : Wed Jun 5 22:29:28 2019
|
||||
*
|
||||
* Target selection: ert.tlc
|
||||
* Embedded hardware selection: ARM Compatible->ARM Cortex
|
||||
@@ -23,185 +23,75 @@
|
||||
|
||||
#include "BLDC_controller.h"
|
||||
|
||||
/* Block parameters (auto storage) */
|
||||
P rtP = {
|
||||
/* Variable: cf_speedCoef
|
||||
* Referenced by:
|
||||
* '<S28>/cf_spdCoef'
|
||||
* '<S66>/cf_spdCoef'
|
||||
*/
|
||||
66667,
|
||||
|
||||
/* Variable: n_commAcvLo
|
||||
* Referenced by:
|
||||
* '<S15>/Relay'
|
||||
* '<S53>/Relay'
|
||||
*/
|
||||
100,
|
||||
|
||||
/* Variable: n_commDeacvHi
|
||||
* Referenced by:
|
||||
* '<S15>/Relay'
|
||||
* '<S53>/Relay'
|
||||
*/
|
||||
180,
|
||||
|
||||
/* Variable: r_commDCDeacv
|
||||
* Referenced by:
|
||||
* '<S15>/r_commDCDeacv'
|
||||
* '<S53>/r_commDCDeacv'
|
||||
*/
|
||||
70,
|
||||
|
||||
/* Variable: r_phaAdvDC_XA
|
||||
* Referenced by:
|
||||
* '<S13>/r_phaAdvDC_XA'
|
||||
* '<S51>/r_phaAdvDC_XA'
|
||||
*/
|
||||
{ 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 },
|
||||
|
||||
/* Variable: a_phaAdv_M1
|
||||
* Referenced by:
|
||||
* '<S13>/a_phaAdv_M2'
|
||||
* '<S51>/a_phaAdv_M2'
|
||||
*/
|
||||
{ 0, 0, 7, 2, 2, 2, 4, 5, 9, 16, 25 },
|
||||
|
||||
/* Variable: z_maxCntRst
|
||||
* Referenced by:
|
||||
* '<S23>/z_maxCntRst'
|
||||
* '<S23>/z_maxCntRst1'
|
||||
* '<S23>/z_maxCntRst2'
|
||||
* '<S23>/z_counter2'
|
||||
* '<S61>/z_maxCntRst'
|
||||
* '<S61>/z_maxCntRst1'
|
||||
* '<S61>/z_maxCntRst2'
|
||||
* '<S61>/z_counter2'
|
||||
* '<S28>/z_maxCntRst'
|
||||
* '<S66>/z_maxCntRst'
|
||||
*/
|
||||
2000,
|
||||
|
||||
/* Variable: z_ctrlTypSel
|
||||
* Referenced by:
|
||||
* '<S12>/z_ctrlTypSel1'
|
||||
* '<S50>/z_ctrlTypSel1'
|
||||
*/
|
||||
3U,
|
||||
|
||||
/* Variable: z_nrEdgeSpdAcv
|
||||
* Referenced by:
|
||||
* '<S23>/z_nrEdgeSpdAcv'
|
||||
* '<S61>/z_nrEdgeSpdAcv'
|
||||
*/
|
||||
3U,
|
||||
|
||||
/* Variable: b_phaAdvEna
|
||||
* Referenced by:
|
||||
* '<S13>/a_elecPeriod1'
|
||||
* '<S51>/a_elecPeriod1'
|
||||
*/
|
||||
1
|
||||
};
|
||||
|
||||
/* Constant parameters (auto storage) */
|
||||
const ConstP rtConstP = {
|
||||
/* Pooled Parameter (Expression: r_trapPhaA_M1)
|
||||
* Referenced by:
|
||||
* '<S41>/r_trapPhaA_M1'
|
||||
* '<S79>/r_trapPhaA_M1'
|
||||
/* Computed Parameter: r_trapPhaA_M1_Table
|
||||
* Referenced by: '<S18>/r_trapPhaA_M1'
|
||||
*/
|
||||
{ 1000, 1000, 1000, -1000, -1000, -1000, 1000 },
|
||||
|
||||
/* Pooled Parameter (Expression: r_trapPhaB_M1)
|
||||
* Referenced by:
|
||||
* '<S41>/r_trapPhaB_M1'
|
||||
* '<S79>/r_trapPhaB_M1'
|
||||
/* Computed Parameter: r_trapPhaB_M1_Table
|
||||
* Referenced by: '<S18>/r_trapPhaB_M1'
|
||||
*/
|
||||
{ -1000, -1000, 1000, 1000, 1000, -1000, -1000 },
|
||||
|
||||
/* Pooled Parameter (Expression: r_trapPhaC_M1)
|
||||
* Referenced by:
|
||||
* '<S41>/r_trapPhaC_M1'
|
||||
* '<S79>/r_trapPhaC_M1'
|
||||
/* Computed Parameter: r_trapPhaC_M1_Table
|
||||
* Referenced by: '<S18>/r_trapPhaC_M1'
|
||||
*/
|
||||
{ 1000, -1000, -1000, -1000, 1000, 1000, 1000 },
|
||||
|
||||
/* Pooled Parameter (Expression: r_sinPhaA_M1)
|
||||
* Referenced by:
|
||||
* '<S43>/r_sinPhaA_M1'
|
||||
* '<S81>/r_sinPhaA_M1'
|
||||
/* Computed Parameter: r_sinPhaA_M1_Table
|
||||
* Referenced by: '<S19>/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,
|
||||
-766, -643, -500, -342, -174, 0, 174, 342, 500 },
|
||||
|
||||
/* Pooled Parameter (Expression: r_sinPhaB_M1)
|
||||
* Referenced by:
|
||||
* '<S43>/r_sinPhaB_M1'
|
||||
* '<S81>/r_sinPhaB_M1'
|
||||
/* Computed Parameter: r_sinPhaB_M1_Table
|
||||
* Referenced by: '<S19>/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,
|
||||
-342, -500, -643, -766, -866, -940, -985, -1000 },
|
||||
|
||||
/* Pooled Parameter (Expression: r_sinPhaC_M1)
|
||||
* Referenced by:
|
||||
* '<S43>/r_sinPhaC_M1'
|
||||
* '<S81>/r_sinPhaC_M1'
|
||||
/* Computed Parameter: r_sinPhaC_M1_Table
|
||||
* Referenced by: '<S19>/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,
|
||||
866, 940, 985, 1000, 985, 940, 866, 766, 643, 500 },
|
||||
|
||||
/* Pooled Parameter (Expression: r_sin3PhaA_M1)
|
||||
* Referenced by:
|
||||
* '<S42>/r_sin3PhaA_M1'
|
||||
* '<S80>/r_sin3PhaA_M1'
|
||||
/* Computed Parameter: r_sin3PhaA_M1_Table
|
||||
* Referenced by: '<S20>/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,
|
||||
-930, -795, -584, -310, 0, 310, 584, 795 },
|
||||
|
||||
/* Pooled Parameter (Expression: r_sin3PhaB_M1)
|
||||
* Referenced by:
|
||||
* '<S42>/r_sin3PhaB_M1'
|
||||
* '<S80>/r_sin3PhaB_M1'
|
||||
/* Computed Parameter: r_sin3PhaB_M1_Table
|
||||
* Referenced by: '<S20>/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,
|
||||
-584, -795, -930, -991, -996, -971, -942, -930 },
|
||||
|
||||
/* Pooled Parameter (Expression: r_sin3PhaC_M1)
|
||||
* Referenced by:
|
||||
* '<S42>/r_sin3PhaC_M1'
|
||||
* '<S80>/r_sin3PhaC_M1'
|
||||
/* Computed Parameter: r_sin3PhaC_M1_Table
|
||||
* Referenced by: '<S20>/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,
|
||||
971, 942, 930, 942, 971, 996, 991, 930, 795 },
|
||||
|
||||
/* Pooled Parameter (Expression: z_commutMap_M1)
|
||||
* Referenced by:
|
||||
* '<S15>/z_commutMap_M1'
|
||||
* '<S53>/z_commutMap_M1'
|
||||
/* Computed Parameter: z_commutMap_M1_table
|
||||
* Referenced by: '<S10>/z_commutMap_M1'
|
||||
*/
|
||||
{ 1000, -1000, 0, 1000, 0, -1000, 0, 1000, -1000, -1000, 1000, 0, -1000, 0,
|
||||
1000, 0, -1000, 1000 },
|
||||
|
||||
/* Pooled Parameter (Expression: vec_hallToPos)
|
||||
* Referenced by:
|
||||
* '<S21>/vec_hallToPos'
|
||||
* '<S59>/vec_hallToPos'
|
||||
/* Computed Parameter: vec_hallToPos_Value
|
||||
* Referenced by: '<S12>/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:
|
||||
* '<S29>/Logic'
|
||||
* '<S67>/Logic'
|
||||
*/
|
||||
{ 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0 }
|
||||
{ 0, 5, 3, 4, 1, 0, 2, 0 }
|
||||
};
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user