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_validate_mask_value(block, ...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function [validate] = mpc555_mtrctrl_validate_mask_value(block, ...
% parameterspecs)
%
% This function is called from the mask callback to validate the input
% of a number into a mask parameter
%
% Arguments are:
%   'block':            The block in which the parameter has been changed
%   'parameterspecs':   Structure containing the specification to
%                       validate against.
%
%   'parameterspecs.ParamName':           Name of parameter in the mask of
%                                         the specified block
%   'parameterspecs.PrettyName':          A "pretty" name to use in errors
%   'parameterspecs.MinVal':              Minimum value that the parameter
%                                         may take
%   'parameterspecs.MaxVal':              Maximum value that the parameter
%                                         may take
%   'parameterspecs.DataType':            Data type of the parameter
%   'parameterspecs.ArrayLengthMin':      Minimum length of array if array
%   'parameterspecs.ArrayLengthMax':      Maximum length of array if array
%   'parameterspecs.SpecialConditions':   Any special conditions
%
%   Special conditions may be specified as SpecialConditions(n).Condition
%   and                                    SpecialConditions(n).ErrorMsg
function [validate] = mpc555_mtrctrl_validate_mask_value(block, ...
    parameterspecs)
                                    
% Get a copy of the parameter value
str_param_value = get_param(block, parameterspecs.ParamName);

% Convert the value to a number
param_value = str2num(str_param_value);

% Do the actual validation
[validate] = mpc555_mtrctrl_validate_value(param_value, parameterspecs);

% Now throw a customised error dialog if value isn't valid
if validate.Overall == 0
    str_message = mpc555_mtrctrl_validate_error(parameterspecs, validate);
    mpc555_mtrctrl_mask_error(block, str_message, 'Invalid value');
else
    % Back up the valid values
    mpc555_mtrctrl_mask_copy_values(block, 'save');
end

end

Contact us