Initial commit
This commit is contained in:
commit
5b0b6fecf2
|
@ -0,0 +1,2 @@
|
|||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
|
@ -0,0 +1,4 @@
|
|||
!build/hover.hex
|
||||
.pioenvs/
|
||||
.vscode/
|
||||
01_Matlab/slprj/
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
76821137013022c4791715f428d69e72141182d4
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 136 KiB |
|
@ -0,0 +1,83 @@
|
|||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% This file is part of the hoverboard-new-firmware-hack-FOC project
|
||||
%
|
||||
% Author: Emanuel FERU
|
||||
% Copyright © 2019 Emanuel FERU <aerdronix@gmail.com>
|
||||
%
|
||||
% This program is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% This program is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
%% =========================================================================
|
||||
% get_param(gcb, 'BlockType')
|
||||
|
||||
% Compile model
|
||||
BLDCmotorControl_FOC_R2017b_fixdt([],[],[],'compile');
|
||||
modelName = 'BLDCmotorControl_FOC_R2017b_fixdt';
|
||||
|
||||
Parameter = '';
|
||||
DataType = '';
|
||||
|
||||
% Search for constants
|
||||
Blocks = find_system(modelName, 'regexp', 'on', 'BlockType', 'Constant');
|
||||
for k = 1:length(Blocks)
|
||||
|
||||
if strcmp('yellow',get_param(Blocks{k},'BackgroundColor')) % get only the tunnable parameters
|
||||
|
||||
val = get_param(Blocks{k}, 'Value'); % BreakpointsData, Table
|
||||
typ = get_param(Blocks{k}, 'CompiledPortDataTypes');
|
||||
Parameter{end+1,1} = val;
|
||||
DataType{end+1,1} = typ.Outport{1};
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
% Search for PreLookup
|
||||
Blocks = find_system(modelName, 'regexp', 'on', 'BlockType', 'PreLookup');
|
||||
for k = 1:length(Blocks)
|
||||
|
||||
if strcmp('yellow',get_param(Blocks{k},'BackgroundColor')) % get only the tunnable parameters
|
||||
|
||||
val = get_param(Blocks{k}, 'BreakpointsData'); % BreakpointsData, Table
|
||||
typ = get_param(Blocks{k}, 'CompiledPortDataTypes');
|
||||
Parameter{end+1,1} = val;
|
||||
DataType{end+1,1} = typ.Inport{1};
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
% Search for Interpolation_n-D
|
||||
Blocks = find_system(modelName, 'regexp', 'on', 'BlockType', 'Interpolation_n-D');
|
||||
for k = 1:length(Blocks)
|
||||
|
||||
if strcmp('yellow',get_param(Blocks{k},'BackgroundColor')) % get only the tunnable parameters
|
||||
|
||||
val = get_param(Blocks{k}, 'Table'); % BreakpointsData, Table
|
||||
typ = get_param(Blocks{k}, 'CompiledPortDataTypes');
|
||||
Parameter{end+1,1} = val;
|
||||
DataType{end+1,1} = typ.Outport{1};
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
% Terminate compilation
|
||||
BLDCmotorControl_FOC_R2017b_fixdt([],[],[],'term');
|
||||
|
||||
% Create table
|
||||
T = table(Parameter,DataType);
|
||||
T = unique(T, 'rows'); % remove duplicates
|
||||
T = sortrows(T); % sort
|
||||
writetable(T,'tableParamType.xlsx'); % write to file
|
||||
|
||||
disp('---- Parameters Table: Successful ----');
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,171 @@
|
|||
/*
|
||||
* File: filtLowPass.c
|
||||
*
|
||||
* Code generated for Simulink model 'filtLowPass'.
|
||||
*
|
||||
* Model version : 1.1160
|
||||
* Simulink Coder version : 8.13 (R2017b) 24-Jul-2017
|
||||
* C/C++ source code generated on : Fri Sep 27 08:03:25 2019
|
||||
*
|
||||
* Target selection: ert.tlc
|
||||
* Embedded hardware selection: ARM Compatible->ARM Cortex
|
||||
* Emulation hardware selection:
|
||||
* Differs from embedded hardware (MATLAB Host)
|
||||
* Code generation objectives:
|
||||
* 1. Execution efficiency
|
||||
* 2. RAM efficiency
|
||||
* Validation result: Not run
|
||||
*/
|
||||
|
||||
#include "filtLowPass.h"
|
||||
#ifndef UCHAR_MAX
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#if ( UCHAR_MAX != (0xFFU) ) || ( SCHAR_MAX != (0x7F) )
|
||||
#error Code was generated for compiler with different sized uchar/char. \
|
||||
Consider adjusting Test hardware word size settings on the \
|
||||
Hardware Implementation pane to match your compiler word sizes as \
|
||||
defined in limits.h of the compiler. Alternatively, you can \
|
||||
select the Test hardware is the same as production hardware option and \
|
||||
select the Enable portable word sizes option on the Code Generation > \
|
||||
Verification pane for ERT based targets, which will disable the \
|
||||
preprocessor word size checks.
|
||||
#endif
|
||||
|
||||
#if ( USHRT_MAX != (0xFFFFU) ) || ( SHRT_MAX != (0x7FFF) )
|
||||
#error Code was generated for compiler with different sized ushort/short. \
|
||||
Consider adjusting Test hardware word size settings on the \
|
||||
Hardware Implementation pane to match your compiler word sizes as \
|
||||
defined in limits.h of the compiler. Alternatively, you can \
|
||||
select the Test hardware is the same as production hardware option and \
|
||||
select the Enable portable word sizes option on the Code Generation > \
|
||||
Verification pane for ERT based targets, which will disable the \
|
||||
preprocessor word size checks.
|
||||
#endif
|
||||
|
||||
#if ( UINT_MAX != (0xFFFFFFFFU) ) || ( INT_MAX != (0x7FFFFFFF) )
|
||||
#error Code was generated for compiler with different sized uint/int. \
|
||||
Consider adjusting Test hardware word size settings on the \
|
||||
Hardware Implementation pane to match your compiler word sizes as \
|
||||
defined in limits.h of the compiler. Alternatively, you can \
|
||||
select the Test hardware is the same as production hardware option and \
|
||||
select the Enable portable word sizes option on the Code Generation > \
|
||||
Verification pane for ERT based targets, which will disable the \
|
||||
preprocessor word size checks.
|
||||
#endif
|
||||
|
||||
#if ( ULONG_MAX != (0xFFFFFFFFU) ) || ( LONG_MAX != (0x7FFFFFFF) )
|
||||
#error Code was generated for compiler with different sized ulong/long. \
|
||||
Consider adjusting Test hardware word size settings on the \
|
||||
Hardware Implementation pane to match your compiler word sizes as \
|
||||
defined in limits.h of the compiler. Alternatively, you can \
|
||||
select the Test hardware is the same as production hardware option and \
|
||||
select the Enable portable word sizes option on the Code Generation > \
|
||||
Verification pane for ERT based targets, which will disable the \
|
||||
preprocessor word size checks.
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
||||
/* Skip this size verification because of preprocessor limitation */
|
||||
#if ( ULLONG_MAX != (0xFFFFFFFFFFFFFFFFULL) ) || ( LLONG_MAX != (0x7FFFFFFFFFFFFFFFLL) )
|
||||
#error Code was generated for compiler with different sized ulong_long/long_long. \
|
||||
Consider adjusting Test hardware word size settings on the \
|
||||
Hardware Implementation pane to match your compiler word sizes as \
|
||||
defined in limits.h of the compiler. Alternatively, you can \
|
||||
select the Test hardware is the same as production hardware option and \
|
||||
select the Enable portable word sizes option on the Code Generation > \
|
||||
Verification pane for ERT based targets, which will disable the \
|
||||
preprocessor word size checks.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern int16_T filtLowPass_l(int16_T rtu_u, uint16_T rtu_coef, DW_filtLowPass
|
||||
*localDW);
|
||||
|
||||
/*===========*
|
||||
* Constants *
|
||||
*===========*/
|
||||
#define RT_PI 3.14159265358979323846
|
||||
#define RT_PIF 3.1415927F
|
||||
#define RT_LN_10 2.30258509299404568402
|
||||
#define RT_LN_10F 2.3025851F
|
||||
#define RT_LOG10E 0.43429448190325182765
|
||||
#define RT_LOG10EF 0.43429449F
|
||||
#define RT_E 2.7182818284590452354
|
||||
#define RT_EF 2.7182817F
|
||||
|
||||
/*
|
||||
* UNUSED_PARAMETER(x)
|
||||
* Used to specify that a function parameter (argument) is required but not
|
||||
* accessed by the function body.
|
||||
*/
|
||||
#ifndef UNUSED_PARAMETER
|
||||
# if defined(__LCC__)
|
||||
# define UNUSED_PARAMETER(x) /* do nothing */
|
||||
# else
|
||||
|
||||
/*
|
||||
* This is the semi-ANSI standard way of indicating that an
|
||||
* unused function parameter is required.
|
||||
*/
|
||||
# define UNUSED_PARAMETER(x) (void) (x)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Output and update for atomic system: '<Root>/filtLowPass' */
|
||||
int16_T filtLowPass_l(int16_T rtu_u, uint16_T rtu_coef, DW_filtLowPass *localDW)
|
||||
{
|
||||
int16_T rtb_Sum1;
|
||||
|
||||
/* Outputs for Atomic SubSystem: '<S1>/Low_Pass_Filter1' */
|
||||
/* Sum: '<S2>/Sum1' incorporates:
|
||||
* DataTypeConversion: '<S1>/Data Type Conversion'
|
||||
* Product: '<S2>/Divide1'
|
||||
* Product: '<S2>/Divide2'
|
||||
* Sum: '<S2>/Sum5'
|
||||
* UnitDelay: '<S2>/UnitDelay3'
|
||||
*/
|
||||
rtb_Sum1 = (int16_T)((((int16_T)(rtu_u << 4) * rtu_coef) >> 16) + (((int32_T)
|
||||
(65535U - rtu_coef) * localDW->UnitDelay3_DSTATE) >> 16));
|
||||
|
||||
/* Update for UnitDelay: '<S2>/UnitDelay3' */
|
||||
localDW->UnitDelay3_DSTATE = rtb_Sum1;
|
||||
|
||||
/* End of Outputs for SubSystem: '<S1>/Low_Pass_Filter1' */
|
||||
|
||||
/* DataTypeConversion: '<S1>/Data Type Conversion1' */
|
||||
return (int16_T)(rtb_Sum1 >> 4);
|
||||
}
|
||||
|
||||
/* Model step function */
|
||||
void filtLowPass_step(RT_MODEL *const rtM)
|
||||
{
|
||||
DW *rtDW = ((DW *) rtM->dwork);
|
||||
ExtU *rtU = (ExtU *) rtM->inputs;
|
||||
ExtY *rtY = (ExtY *) rtM->outputs;
|
||||
|
||||
/* Outputs for Atomic SubSystem: '<Root>/filtLowPass' */
|
||||
|
||||
/* Outport: '<Root>/y' incorporates:
|
||||
* Inport: '<Root>/coef'
|
||||
* Inport: '<Root>/u'
|
||||
*/
|
||||
rtY->y = (int16_T) filtLowPass_l(rtU->u, rtU->coef, &rtDW->filtLowPass_l2);
|
||||
|
||||
/* End of Outputs for SubSystem: '<Root>/filtLowPass' */
|
||||
}
|
||||
|
||||
/* Model initialize function */
|
||||
void filtLowPass_initialize(RT_MODEL *const rtM)
|
||||
{
|
||||
/* (no initialization code required) */
|
||||
UNUSED_PARAMETER(rtM);
|
||||
}
|
||||
|
||||
/*
|
||||
* File trailer for generated code.
|
||||
*
|
||||
* [EOF]
|
||||
*/
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* File: filtLowPass.h
|
||||
*
|
||||
* Code generated for Simulink model 'filtLowPass'.
|
||||
*
|
||||
* Model version : 1.1160
|
||||
* Simulink Coder version : 8.13 (R2017b) 24-Jul-2017
|
||||
* C/C++ source code generated on : Fri Sep 27 08:03:25 2019
|
||||
*
|
||||
* Target selection: ert.tlc
|
||||
* Embedded hardware selection: ARM Compatible->ARM Cortex
|
||||
* Emulation hardware selection:
|
||||
* Differs from embedded hardware (MATLAB Host)
|
||||
* Code generation objectives:
|
||||
* 1. Execution efficiency
|
||||
* 2. RAM efficiency
|
||||
* Validation result: Not run
|
||||
*/
|
||||
|
||||
#ifndef RTW_HEADER_filtLowPass_h_
|
||||
#define RTW_HEADER_filtLowPass_h_
|
||||
#ifndef filtLowPass_COMMON_INCLUDES_
|
||||
# define filtLowPass_COMMON_INCLUDES_
|
||||
#include "rtwtypes.h"
|
||||
#endif /* filtLowPass_COMMON_INCLUDES_ */
|
||||
|
||||
/* Macros for accessing real-time model data structure */
|
||||
|
||||
/* Forward declaration for rtModel */
|
||||
typedef struct tag_RTM RT_MODEL;
|
||||
|
||||
/* Block signals and states (auto storage) for system '<Root>/filtLowPass' */
|
||||
typedef struct {
|
||||
int16_T UnitDelay3_DSTATE; /* '<S2>/UnitDelay3' */
|
||||
} DW_filtLowPass;
|
||||
|
||||
/* Block signals and states (auto storage) for system '<Root>' */
|
||||
typedef struct {
|
||||
DW_filtLowPass filtLowPass_l2; /* '<Root>/filtLowPass' */
|
||||
} DW;
|
||||
|
||||
/* External inputs (root inport signals with auto storage) */
|
||||
typedef struct {
|
||||
int16_T u; /* '<Root>/u' */
|
||||
uint16_T coef; /* '<Root>/coef' */
|
||||
} ExtU;
|
||||
|
||||
/* External outputs (root outports fed by signals with auto storage) */
|
||||
typedef struct {
|
||||
int16_T y; /* '<Root>/y' */
|
||||
} ExtY;
|
||||
|
||||
/* Real-time Model Data Structure */
|
||||
struct tag_RTM {
|
||||
ExtU *inputs;
|
||||
ExtY *outputs;
|
||||
DW *dwork;
|
||||
};
|
||||
|
||||
/* Model entry point functions */
|
||||
extern void filtLowPass_initialize(RT_MODEL *const rtM);
|
||||
extern void filtLowPass_step(RT_MODEL *const rtM);
|
||||
|
||||
/*-
|
||||
* The generated code includes comments that allow you to trace directly
|
||||
* back to the appropriate location in the model. The basic format
|
||||
* is <system>/block_name, where system is the system number (uniquely
|
||||
* assigned by Simulink) and block_name is the name of the block.
|
||||
*
|
||||
* Note that this particular code originates from a subsystem build,
|
||||
* and has its own system numbers different from the parent model.
|
||||
* Refer to the system hierarchy for this subsystem below, and use the
|
||||
* MATLAB hilite_system command to trace the generated code back
|
||||
* to the parent model. For example,
|
||||
*
|
||||
* hilite_system('BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F04_Field_Oriented_Control/filtLowPass') - opens subsystem BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F04_Field_Oriented_Control/filtLowPass
|
||||
* hilite_system('BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F04_Field_Oriented_Control/filtLowPass/Kp') - opens and selects block Kp
|
||||
*
|
||||
* Here is the system hierarchy for this model
|
||||
*
|
||||
* '<Root>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F04_Field_Oriented_Control'
|
||||
* '<S1>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F04_Field_Oriented_Control/filtLowPass'
|
||||
* '<S2>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F04_Field_Oriented_Control/filtLowPass/Low_Pass_Filter1'
|
||||
*/
|
||||
#endif /* RTW_HEADER_filtLowPass_h_ */
|
||||
|
||||
/*
|
||||
* File trailer for generated code.
|
||||
*
|
||||
* [EOF]
|
||||
*/
|
|
@ -0,0 +1,171 @@
|
|||
/*
|
||||
* File: filtLowPass.c
|
||||
*
|
||||
* Code generated for Simulink model 'filtLowPass'.
|
||||
*
|
||||
* Model version : 1.1160
|
||||
* Simulink Coder version : 8.13 (R2017b) 24-Jul-2017
|
||||
* C/C++ source code generated on : Fri Sep 27 08:08:04 2019
|
||||
*
|
||||
* Target selection: ert.tlc
|
||||
* Embedded hardware selection: ARM Compatible->ARM Cortex
|
||||
* Emulation hardware selection:
|
||||
* Differs from embedded hardware (MATLAB Host)
|
||||
* Code generation objectives:
|
||||
* 1. Execution efficiency
|
||||
* 2. RAM efficiency
|
||||
* Validation result: Not run
|
||||
*/
|
||||
|
||||
#include "filtLowPass.h"
|
||||
#ifndef UCHAR_MAX
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#if ( UCHAR_MAX != (0xFFU) ) || ( SCHAR_MAX != (0x7F) )
|
||||
#error Code was generated for compiler with different sized uchar/char. \
|
||||
Consider adjusting Test hardware word size settings on the \
|
||||
Hardware Implementation pane to match your compiler word sizes as \
|
||||
defined in limits.h of the compiler. Alternatively, you can \
|
||||
select the Test hardware is the same as production hardware option and \
|
||||
select the Enable portable word sizes option on the Code Generation > \
|
||||
Verification pane for ERT based targets, which will disable the \
|
||||
preprocessor word size checks.
|
||||
#endif
|
||||
|
||||
#if ( USHRT_MAX != (0xFFFFU) ) || ( SHRT_MAX != (0x7FFF) )
|
||||
#error Code was generated for compiler with different sized ushort/short. \
|
||||
Consider adjusting Test hardware word size settings on the \
|
||||
Hardware Implementation pane to match your compiler word sizes as \
|
||||
defined in limits.h of the compiler. Alternatively, you can \
|
||||
select the Test hardware is the same as production hardware option and \
|
||||
select the Enable portable word sizes option on the Code Generation > \
|
||||
Verification pane for ERT based targets, which will disable the \
|
||||
preprocessor word size checks.
|
||||
#endif
|
||||
|
||||
#if ( UINT_MAX != (0xFFFFFFFFU) ) || ( INT_MAX != (0x7FFFFFFF) )
|
||||
#error Code was generated for compiler with different sized uint/int. \
|
||||
Consider adjusting Test hardware word size settings on the \
|
||||
Hardware Implementation pane to match your compiler word sizes as \
|
||||
defined in limits.h of the compiler. Alternatively, you can \
|
||||
select the Test hardware is the same as production hardware option and \
|
||||
select the Enable portable word sizes option on the Code Generation > \
|
||||
Verification pane for ERT based targets, which will disable the \
|
||||
preprocessor word size checks.
|
||||
#endif
|
||||
|
||||
#if ( ULONG_MAX != (0xFFFFFFFFU) ) || ( LONG_MAX != (0x7FFFFFFF) )
|
||||
#error Code was generated for compiler with different sized ulong/long. \
|
||||
Consider adjusting Test hardware word size settings on the \
|
||||
Hardware Implementation pane to match your compiler word sizes as \
|
||||
defined in limits.h of the compiler. Alternatively, you can \
|
||||
select the Test hardware is the same as production hardware option and \
|
||||
select the Enable portable word sizes option on the Code Generation > \
|
||||
Verification pane for ERT based targets, which will disable the \
|
||||
preprocessor word size checks.
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
||||
/* Skip this size verification because of preprocessor limitation */
|
||||
#if ( ULLONG_MAX != (0xFFFFFFFFFFFFFFFFULL) ) || ( LLONG_MAX != (0x7FFFFFFFFFFFFFFFLL) )
|
||||
#error Code was generated for compiler with different sized ulong_long/long_long. \
|
||||
Consider adjusting Test hardware word size settings on the \
|
||||
Hardware Implementation pane to match your compiler word sizes as \
|
||||
defined in limits.h of the compiler. Alternatively, you can \
|
||||
select the Test hardware is the same as production hardware option and \
|
||||
select the Enable portable word sizes option on the Code Generation > \
|
||||
Verification pane for ERT based targets, which will disable the \
|
||||
preprocessor word size checks.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern int16_T filtLowPass_l(int32_T rtu_u, uint16_T rtu_coef, DW_filtLowPass
|
||||
*localDW);
|
||||
|
||||
/*===========*
|
||||
* Constants *
|
||||
*===========*/
|
||||
#define RT_PI 3.14159265358979323846
|
||||
#define RT_PIF 3.1415927F
|
||||
#define RT_LN_10 2.30258509299404568402
|
||||
#define RT_LN_10F 2.3025851F
|
||||
#define RT_LOG10E 0.43429448190325182765
|
||||
#define RT_LOG10EF 0.43429449F
|
||||
#define RT_E 2.7182818284590452354
|
||||
#define RT_EF 2.7182817F
|
||||
|
||||
/*
|
||||
* UNUSED_PARAMETER(x)
|
||||
* Used to specify that a function parameter (argument) is required but not
|
||||
* accessed by the function body.
|
||||
*/
|
||||
#ifndef UNUSED_PARAMETER
|
||||
# if defined(__LCC__)
|
||||
# define UNUSED_PARAMETER(x) /* do nothing */
|
||||
# else
|
||||
|
||||
/*
|
||||
* This is the semi-ANSI standard way of indicating that an
|
||||
* unused function parameter is required.
|
||||
*/
|
||||
# define UNUSED_PARAMETER(x) (void) (x)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Output and update for atomic system: '<Root>/filtLowPass' */
|
||||
int16_T filtLowPass_l(int32_T rtu_u, uint16_T rtu_coef, DW_filtLowPass *localDW)
|
||||
{
|
||||
int32_T rtb_Sum1;
|
||||
|
||||
/* Outputs for Atomic SubSystem: '<S1>/Low_Pass_Filter1' */
|
||||
/* Sum: '<S2>/Sum1' incorporates:
|
||||
* DataTypeConversion: '<S1>/Data Type Conversion'
|
||||
* Product: '<S2>/Divide1'
|
||||
* Product: '<S2>/Divide2'
|
||||
* Sum: '<S2>/Sum5'
|
||||
* UnitDelay: '<S2>/UnitDelay3'
|
||||
*/
|
||||
rtb_Sum1 = (int32_T)(((int64_T)(rtu_u << 16) * rtu_coef) >> 16) + (int32_T)
|
||||
(((int64_T)(65535U - rtu_coef) * localDW->UnitDelay3_DSTATE) >> 16);
|
||||
|
||||
/* Update for UnitDelay: '<S2>/UnitDelay3' */
|
||||
localDW->UnitDelay3_DSTATE = rtb_Sum1;
|
||||
|
||||
/* End of Outputs for SubSystem: '<S1>/Low_Pass_Filter1' */
|
||||
|
||||
/* DataTypeConversion: '<S1>/Data Type Conversion1' */
|
||||
return (int16_T)(rtb_Sum1 >> 16);
|
||||
}
|
||||
|
||||
/* Model step function */
|
||||
void filtLowPass_step(RT_MODEL *const rtM)
|
||||
{
|
||||
DW *rtDW = ((DW *) rtM->dwork);
|
||||
ExtU *rtU = (ExtU *) rtM->inputs;
|
||||
ExtY *rtY = (ExtY *) rtM->outputs;
|
||||
|
||||
/* Outputs for Atomic SubSystem: '<Root>/filtLowPass' */
|
||||
|
||||
/* Outport: '<Root>/y' incorporates:
|
||||
* Inport: '<Root>/coef'
|
||||
* Inport: '<Root>/u'
|
||||
*/
|
||||
rtY->y = (int16_T) filtLowPass_l(rtU->u, rtU->coef, &rtDW->filtLowPass_l2);
|
||||
|
||||
/* End of Outputs for SubSystem: '<Root>/filtLowPass' */
|
||||
}
|
||||
|
||||
/* Model initialize function */
|
||||
void filtLowPass_initialize(RT_MODEL *const rtM)
|
||||
{
|
||||
/* (no initialization code required) */
|
||||
UNUSED_PARAMETER(rtM);
|
||||
}
|
||||
|
||||
/*
|
||||
* File trailer for generated code.
|
||||
*
|
||||
* [EOF]
|
||||
*/
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* File: filtLowPass.h
|
||||
*
|
||||
* Code generated for Simulink model 'filtLowPass'.
|
||||
*
|
||||
* Model version : 1.1160
|
||||
* Simulink Coder version : 8.13 (R2017b) 24-Jul-2017
|
||||
* C/C++ source code generated on : Fri Sep 27 08:08:04 2019
|
||||
*
|
||||
* Target selection: ert.tlc
|
||||
* Embedded hardware selection: ARM Compatible->ARM Cortex
|
||||
* Emulation hardware selection:
|
||||
* Differs from embedded hardware (MATLAB Host)
|
||||
* Code generation objectives:
|
||||
* 1. Execution efficiency
|
||||
* 2. RAM efficiency
|
||||
* Validation result: Not run
|
||||
*/
|
||||
|
||||
#ifndef RTW_HEADER_filtLowPass_h_
|
||||
#define RTW_HEADER_filtLowPass_h_
|
||||
#ifndef filtLowPass_COMMON_INCLUDES_
|
||||
# define filtLowPass_COMMON_INCLUDES_
|
||||
#include "rtwtypes.h"
|
||||
#endif /* filtLowPass_COMMON_INCLUDES_ */
|
||||
|
||||
/* Macros for accessing real-time model data structure */
|
||||
|
||||
/* Forward declaration for rtModel */
|
||||
typedef struct tag_RTM RT_MODEL;
|
||||
|
||||
/* Block signals and states (auto storage) for system '<Root>/filtLowPass' */
|
||||
typedef struct {
|
||||
int32_T UnitDelay3_DSTATE; /* '<S2>/UnitDelay3' */
|
||||
} DW_filtLowPass;
|
||||
|
||||
/* Block signals and states (auto storage) for system '<Root>' */
|
||||
typedef struct {
|
||||
DW_filtLowPass filtLowPass_l2; /* '<Root>/filtLowPass' */
|
||||
} DW;
|
||||
|
||||
/* External inputs (root inport signals with auto storage) */
|
||||
typedef struct {
|
||||
int32_T u; /* '<Root>/u' */
|
||||
uint16_T coef; /* '<Root>/coef' */
|
||||
} ExtU;
|
||||
|
||||
/* External outputs (root outports fed by signals with auto storage) */
|
||||
typedef struct {
|
||||
int16_T y; /* '<Root>/y' */
|
||||
} ExtY;
|
||||
|
||||
/* Real-time Model Data Structure */
|
||||
struct tag_RTM {
|
||||
ExtU *inputs;
|
||||
ExtY *outputs;
|
||||
DW *dwork;
|
||||
};
|
||||
|
||||
/* Model entry point functions */
|
||||
extern void filtLowPass_initialize(RT_MODEL *const rtM);
|
||||
extern void filtLowPass_step(RT_MODEL *const rtM);
|
||||
|
||||
/*-
|
||||
* The generated code includes comments that allow you to trace directly
|
||||
* back to the appropriate location in the model. The basic format
|
||||
* is <system>/block_name, where system is the system number (uniquely
|
||||
* assigned by Simulink) and block_name is the name of the block.
|
||||
*
|
||||
* Note that this particular code originates from a subsystem build,
|
||||
* and has its own system numbers different from the parent model.
|
||||
* Refer to the system hierarchy for this subsystem below, and use the
|
||||
* MATLAB hilite_system command to trace the generated code back
|
||||
* to the parent model. For example,
|
||||
*
|
||||
* hilite_system('BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F04_Field_Oriented_Control/filtLowPass') - opens subsystem BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F04_Field_Oriented_Control/filtLowPass
|
||||
* hilite_system('BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F04_Field_Oriented_Control/filtLowPass/Kp') - opens and selects block Kp
|
||||
*
|
||||
* Here is the system hierarchy for this model
|
||||
*
|
||||
* '<Root>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F04_Field_Oriented_Control'
|
||||
* '<S1>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F04_Field_Oriented_Control/filtLowPass'
|
||||
* '<S2>' : 'BLDCmotorControl_FOC_R2017b_fixdt/BLDC_controller/F04_Field_Oriented_Control/filtLowPass/Low_Pass_Filter1'
|
||||
*/
|
||||
#endif /* RTW_HEADER_filtLowPass_h_ */
|
||||
|
||||
/*
|
||||
* File trailer for generated code.
|
||||
*
|
||||
* [EOF]
|
||||
*/
|
|
@ -0,0 +1,17 @@
|
|||
%% Copyright 2018 The MathWorks, Inc.%%
|
||||
clear all;
|
||||
bdclose all;
|
||||
clc;
|
||||
%% PMSM parameters
|
||||
Ld = 1.7e-3;
|
||||
Lq = 3.2e-3;
|
||||
Rs = 0.02;
|
||||
Lambda_m = 0.2205;
|
||||
Polepairs = 4;
|
||||
|
||||
%% Controller parameters
|
||||
Iq_reference = 100;
|
||||
Id_reference = -50;
|
||||
Gain_P = 1;
|
||||
Gain_I = 1;
|
||||
|
Binary file not shown.
|
@ -0,0 +1,21 @@
|
|||
%% Copyright 2018 The MathWorks, Inc.%%
|
||||
clear all;
|
||||
bdclose all;
|
||||
clc;
|
||||
%% PMSM parameters
|
||||
Ld = 1.7e-3;
|
||||
Lq = 3.2e-3;
|
||||
Rs = 0.02;
|
||||
Lambda_m = 0.2205;
|
||||
Polepairs = 4;
|
||||
|
||||
%% Current Loop PI Controller parameters
|
||||
|
||||
Gain_P = 7.74;
|
||||
Gain_I = 26.84;
|
||||
|
||||
%% Speed Loop PI Controller Parameters
|
||||
Speed_Gain_P = 0.1;
|
||||
Speed_Gain_I = 0.1;
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,4 @@
|
|||
1. All models are built in MATLAB R2018b. Prior releases cannot open them.
|
||||
2. Before running the model, please first run the corresponding initialization file.
|
||||
3. The initial PI Gain set for model_1 is not satisfactory. We are going to use SDO to tune the gains.
|
||||
4. Copyright 2018 The MathWorks, Inc.
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue