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_tsm_length(block, system, module, tablelocation, localacceltable)
function acceltablelength = mpc555_mtrctrl_tsm_length(block, system, module, tablelocation, localacceltable)

% Firstly decide which mode - if local then just return the local
% acceleration table length.
if tablelocation == 1
    acceltablelength = length(localacceltable);
    return;
end

% Define the blocks we wish to check for and what we wish to check
tocheckfor{1} = 'mpc555_mtrctrl/TPU3 TSM Split Table';

% Check for blocks of the specified type
realblocks = {};

for a = 1:length(tocheckfor)
    realblocks = [realblocks; ...
        find_system(bdroot(system), 'ReferenceBlock', ...
        tocheckfor{a})];
end

if isempty(realblocks)
    error('A TSM Split Table is required in the model if a TSM block is functioning in split table mode');
end

%% Assume that we haven't found the a split table block
foundblock = 0;

for a = 1:length(realblocks)
    refblk = get_param([realblocks{a}], 'ReferenceBlock');
    switch refblk
        case tocheckfor{1}
            % realblocks{a} is the block
            % system is the system
            if strcmp(get_param([realblocks{a}], 'module'), module)
                foundblock = 1;
                acceltablelength = length(localacceltable) + ...
                    length(str2num(get_param(realblocks{a}, 'param_table_values')));
            end
        otherwise
            % do nothing
    end
end

%% If we find no block corresponding to the correct TPU module then throw an error
if ~foundblock
    error(['A TSM Split Table is required configured for TPU Module ', module, '.  Please check that the correct TPU module is selected in both TSM and split table blocks.'])
end

end

Contact us