function msfun_foc(block)
%MSFUNTMPL A Template for a MATLAB S-Function
% The MATLAB S-function is written as a MATLAB function with the
% same name as the S-function. Replace 'msfuntmpl' with the name
% of your S-function.
%
% It should be noted that the MATLAB S-function is very similar
% to Level-2 C-Mex S-functions. You should be able to get more
% information for each of the block methods by referring to the
% documentation for C-Mex S-functions.
%
% Copyright 2003-2010 The MathWorks, Inc.
%
% The setup method is used to setup the basic attributes of the
% S-function such as ports, parameters, etc. Do not add any other
% calls to the main body of the function.
%
setup(block);
%endfunction
% Function: setup ===================================================
% Abstract:
% Set up the S-function block's basic characteristics such as:
% - Input ports
% - Output ports
% - Dialog parameters
% - Options
%
% Required : Yes
% C-Mex counterpart: mdlInitializeSizes
%
function setup(block)
% Register the number of ports.
block.NumInputPorts = 3;
block.NumOutputPorts = 5;
% Set up the port properties to be inherited or dynamic.
block.SetPreCompInpPortInfoToDynamic;
block.SetPreCompOutPortInfoToDynamic;
% Override the input port properties.
%i_abc
block.InputPort(1).DatatypeID = 0; % double
block.InputPort(1).Complexity = 'Real';
block.InputPort(1).Dimensions = 3;
block.InputPort(1).DirectFeedthrough = true; %是否存在直接反馈通道
%w
block.InputPort(3).DatatypeID = 0; % double
block.InputPort(3).Complexity = 'Real';
block.InputPort(3).Dimensions = 1;
block.InputPort(3).DirectFeedthrough = true; %是否存在直接反馈通道
%theta
block.InputPort(2).DatatypeID = 0; % double
block.InputPort(2).Complexity = 'Real';
block.InputPort(2).Dimensions = 1;
block.InputPort(2).DirectFeedthrough = true; %是否存在直接反馈通道
% Override the output port properties.
block.OutputPort(1).DatatypeID = 0; % double
block.OutputPort(1).Complexity = 'Real';
block.OutputPort(1).Dimensions = 1;
block.OutputPort(2).DatatypeID = 0; % double
block.OutputPort(2).Complexity = 'Real';
block.OutputPort(2).Dimensions = 1;
block.OutputPort(3).DatatypeID = 0; % double
block.OutputPort(3).Complexity = 'Real';
block.OutputPort(3).Dimensions = 1;
block.OutputPort(4).DatatypeID = 0; % double
block.OutputPort(4).Complexity = 'Real';
block.OutputPort(4).Dimensions = 1;
block.OutputPort(5).DatatypeID = 0; % double
block.OutputPort(5).Complexity = 'Real';
block.OutputPort(5).Dimensions = 1;
% block.OutputPort(4).DatatypeID = 0; % double
% block.OutputPort(4).Complexity = 'Real';
% block.OutputPort(4).Dimensions = 1;
% Register the parameters.
%w_set , kp_w,ki_w,id_set,kp_id,ki_id,kp_iq,ki_iq,ld,psi_f
block.NumDialogPrms = 16;
block.DialogPrmsTunable = {'Tunable','Tunable','Tunable','Tunable','Tunable','Tunable',...
'Tunable','Tunable','Tunable','Tunable','Tunable','Tunable',...
'Tunable','Tunable','Tunable','Tunable'};
% Set up the continuous states.
%block.NumContStates = 0;
% Register the sample times.
% [0 offset] : Continuous sample time
% [positive_num offset] : Discrete sample time
%
% [-1, 0] : Inherited sample time
% [-2, 0] : Variable sample time
ts = block.DialogPrm(11).Data;
block.SampleTimes = [ts 0];
% -----------------------------------------------------------------
% Options
% -----------------------------------------------------------------
% Specify if Accelerator should use TLC or call back to the
% MATLAB file
block.SetAccelRunOnTLC(false);
% Specify the block simStateCompliance. The allowed values are:
% 'UnknownSimState', < The default setting; warn and assume DefaultSimState
% 'DefaultSimState', < Same SimState as a built-in block
% 'HasNoSimState', < No SimState
% 'CustomSimState', < Has GetSimState and SetSimState methods
% 'DisallowSimState' < Errors out when saving or restoring the SimState
block.SimStateCompliance = 'DefaultSimState';
% -----------------------------------------------------------------
% The MATLAB S-function uses an internal registry for all
% block methods. You should register all relevant methods
% (optional and required) as illustrated below. You may choose
% any suitable name for the methods and implement these methods
% as local functions within the same file.
% -----------------------------------------------------------------
% -----------------------------------------------------------------
% Register the methods called during update diagram/compilation.
% -----------------------------------------------------------------
%
% CheckParameters:
% Functionality : Called in order to allow validation of the
% block dialog parameters. You are
% responsible for calling this method
% explicitly at the start of the setup method.
% C-Mex counterpart: mdlCheckParameters
%
block.RegBlockMethod('CheckParameters', @CheckPrms);
%
% PostPropagationSetup:
% Functionality : Set up the work areas and the state variables. You can
% also register run-time methods here.
% C-Mex counterpart: mdlSetWorkWidths
%
block.RegBlockMethod('PostPropagationSetup', @DoPostPropSetup);
% -----------------------------------------------------------------
% Register methods called at run-time
% -----------------------------------------------------------------
%
% ProcessParameters:
% Functionality : Call to allow an update of run-time parameters.
% C-Mex counterpart: mdlProcessParameters
%
% block.RegBlockMethod('ProcessParameters', @ProcessPrms);
%
% InitializeConditions:
% Functionality : Call to initialize the state and the work
% area values.
% C-Mex counterpart: mdlInitializeConditions
%
block.RegBlockMethod('InitializeConditions', @InitializeConditions);
%
%
% Start:
% Functionality : Call to initialize the state and the work
% area values.
% C-Mex counterpart: mdlStart
%
block.RegBlockMethod('Start', @Start);
%
% Outputs:
% Functionality : Call to generate the block outputs during a
% simulation step.
% C-Mex counterpart: mdlOutputs
%
block.RegBlockMethod('Outputs', @Outputs);
%
% Update:
% Functionality : Call to update the discrete states
% during a simulation step.
% C-Mex counterpart: mdlUpdate
%
block.RegBlockMethod('Update', @Update);
%
% Derivatives:
% Functionality : Call to update the derivatives of the
% continuous states during a simulation step.
% C-Mex counterpart: mdlDerivatives
%
% block.RegBlockMethod('Derivatives', @Derivatives);
%
%
% Projection:
% Functionality : Call to update the projections during a
% simulation step.
% C-Mex counterpart: mdlProjections
%
% block.RegBlockMethod('Projection', @Projection);
%
%
% SimStatusChange:
% Functionality : Call when simulation enters pause mode
% or leaves pause mode.
% C-Mex counterpart: mdlSimStatusChange
%
% block.RegBlockMethod('SimStatusChange', @SimStatusChange);
%
%
% Terminate:
% Functionality : Call at the end of a simulation for cleanup.
% C-Mex counterpart: mdlTerminate
%
block.RegBlockMethod('Terminate', @Terminate);
%
% GetSimState:
% Functionality : Return the SimState of the block.
% C-Mex counterpart: mdlGetSimState
%
% block.RegBlockMethod('GetSimState', @GetSimState);
%
%
% SetSimState:
%
永磁同步电机矢量控制simulink仿真(控制器采用s函数)
1星 需积分: 50 14 浏览量
2017-03-28
09:35:52
上传
评论 9
收藏 40KB ZIP 举报
liaoqing2
- 粉丝: 1
- 资源: 13
最新资源
- React项目基于JavaScript实现的全球新闻发布管理系统源码.zip
- 基于keras+fasterRCNN,在VOC格式的口罩数据集上训练,检测人群中有无戴口罩python源码+模型
- 基于opencv+qt5机器视觉的传统缺陷检测, 即采用标准图片和待测图片进行pixel to pixel的XOR操作源码+文档
- 管道内检测缺陷数据库管理系统源码+文档说明+sln
- 毕业设计-低功耗STM32F411开发板(原理图+PCB源文件+官方例程+驱动等)源码+文档说明+截图
- 基于yolov5-tensorRT检测+发动机缸体内壁缺陷检测系统源码+文档说明
- 基于C++实现的锂电池缺陷检测源码+文档说明
- push_version
- 软件自制图像批量压缩工具
- 经典缺陷检测算法源码整理包含PaDiM(2020ICPR)、PatchCore(2022CVPR)、SimpleNet+文档说明
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈