Code covered by the BSD License  

Highlights from
MPC555 Motor Control Function Blockset

MPC555 Motor Control Function Blockset

by

 

20 Mar 2006 (Updated )

Additional I/O blocks for MPC555 target - specifically targetting TPU functionality

mpc555_mtrctrl_tpu_psp(block, callback_fn, varargin)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function varargout = mpc555_mtrctrl_tpu_psp(block, callback_fn, varargin)
%
function varargout = mpc555_mtrctrl_tpu_psp(block, callback_fn, varargin)
% This is the entry function to allow the appropriate callback functions to
% be run
switch callback_fn
    case 'psp_mode'
        i_callback_psp_mode(block);
    case 'link_specify'
        i_callback_link_specify(block);
    case 'param_ratio1'
        i_callback_param_ratio(block, callback_fn, 1);
    case 'param_ratio2'
        i_callback_param_ratio(block, callback_fn, 2);
    case 'param_angle1'
        i_callback_param_angle(block, callback_fn, 3);
    case 'param_angle2'
        i_callback_param_angle(block, callback_fn, 4);
    case 'param_hightime'
        i_callback_param_hightime(block, callback_fn, 5);
    otherwise
        error('Invalid callback');
end
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function parameterspecs = i_getparameterspecs()
% 
function parameterspecs = i_getparameterspecs()

i=0;

i = i+1;
parameterspecs(i).ParamName = 'param_ratio1';
parameterspecs(i).PrettyName = 'RATIO1';
parameterspecs(i).MinVal = 0;
parameterspecs(i).MaxVal = 1.99;
parameterspecs(i).DataType = 'double';
parameterspecs(i).ArrayLengthMin = 1;
parameterspecs(i).ArrayLengthMax = 1;
parameterspecs(i).ErrorMessage = '';
parameterspecs(i).SpecialConditions = [];
i = i+1;
parameterspecs(i).ParamName = 'param_ratio2';
parameterspecs(i).PrettyName = 'RATIO2';
parameterspecs(i).MinVal = 0;
parameterspecs(i).MaxVal = 1.99;
parameterspecs(i).DataType = 'double';
parameterspecs(i).ArrayLengthMin = 1;
parameterspecs(i).ArrayLengthMax = 1;
parameterspecs(i).ErrorMessage = '';
parameterspecs(i).SpecialConditions = [];
i = i+1;
parameterspecs(i).ParamName = 'param_angle1';
parameterspecs(i).PrettyName = 'ANGLE1';
parameterspecs(i).MinVal = 0;
parameterspecs(i).MaxVal = (2^8)-1;
parameterspecs(i).DataType = 'uint8';
parameterspecs(i).ArrayLengthMin = 1;
parameterspecs(i).ArrayLengthMax = 1;
parameterspecs(i).ErrorMessage = '';
parameterspecs(i).SpecialConditions = [];
i = i+1;
parameterspecs(i).ParamName = 'param_angle2';
parameterspecs(i).PrettyName = 'ANGLE2';
parameterspecs(i).MinVal = 0;
parameterspecs(i).MaxVal = (2^8)-1;
parameterspecs(i).DataType = 'uint8';
parameterspecs(i).ArrayLengthMin = 1;
parameterspecs(i).ArrayLengthMax = 1;
parameterspecs(i).ErrorMessage = '';
parameterspecs(i).SpecialConditions = [];
i = i+1;
parameterspecs(i).ParamName = 'param_hightime';
parameterspecs(i).PrettyName = 'HIGH_TIME';
parameterspecs(i).MinVal = 0;
parameterspecs(i).MaxVal = (2^16)-1;
parameterspecs(i).DataType = 'uint16';
parameterspecs(i).ArrayLengthMin = 1;
parameterspecs(i).ArrayLengthMax = 1;
parameterspecs(i).ErrorMessage = '';
parameterspecs(i).SpecialConditions = [];

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function i_callback_psp_mode(block)
%
function i_callback_psp_mode(block)
enable_conds(1).param_names = {'psp_mode'};
enable_conds(1).param_conditions = {'Angle-Angle Mode'};
enable_conds(1).to_enable = {'param_ratio2', 'param_angle2'};
enable_conds(1).to_disable = {'param_hightime'};
enable_conds(1).to_hide = {};
enable_conds(1).reciprocal = 1;

mpc555_mtrctrl_maskparam(enable_conds);

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function i_callback_link_specify(block)
%
function i_callback_link_specify(block)
enable_conds(1).param_names = {'link_specify'};
enable_conds(1).param_conditions = {'Alias'};
enable_conds(1).to_enable = {'alias_period_address'};
enable_conds(1).to_disable = {'link_channel', 'link_param'};
enable_conds(1).to_hide = {};
enable_conds(1).reciprocal = 1;

mpc555_mtrctrl_maskparam(enable_conds);

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function i_callback_param_ratio(block, param_ratio_name, id)
%
function i_callback_param_ratio(block, param_ratio_name, id)


parameterspecs = i_getparameterspecs();
[validate] = mpc555_mtrctrl_validate_mask_value(block, ...
    parameterspecs(id));

mpc555_mtrctrl_calc_mask_range(block, ...
    param_ratio_name, [param_ratio_name,'_raw'], ...
    0, 1.99, ...
    0, 255, ...
    'uint8');
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function i_callback_param_angle(block, param_angle_name, id)
%
function i_callback_param_angle(block, param_angle_name, id)
parameterspecs = i_getparameterspecs();
[validate] = mpc555_mtrctrl_validate_mask_value(block, ...
    parameterspecs(id));
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function i_callback_param_hightime(block, param_name, id)
%
function i_callback_param_hightime(block, param_name, id)
parameterspecs = i_getparameterspecs();
[validate] = mpc555_mtrctrl_validate_mask_value(block, ...
    parameterspecs(id));
end

Contact us