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

SerialHostScreen(serialport, SerDataDefinition)
function SerialHostScreen(serialport, SerDataDefinition)

% Create a new figure
handles.f = figure;

% Decide on the size of the new figure
set(handles.f, 'Menubar', 'none');
set(handles.f, 'Name', 'Monitor Serial Data');
set(handles.f, 'NumberTitle', 'Off');
set(handles.f, 'Resize', 'Off');
set(handles.f, 'Color', 'c');

NumDefinitions = length(SerDataDefinition);

fposition = get(handles.f, 'Position');
screensize = get(0, 'ScreenSize');



textboxwidth = 100;
textboxheight = 20;
textboxspacing = 30;

windowheight = 30 + (NumDefinitions + 1) * textboxspacing;

set(handles.f, 'Position', [10,screensize(4)-(windowheight+30), 440, windowheight]);


for n=1:NumDefinitions
    handles.textbox(n) = uicontrol('Style', 'text', ...
    'Position', [10, 30 + (NumDefinitions + 1 -n) * textboxspacing, textboxwidth, textboxheight], ...
    'BackgroundColor', 'c', ...
    'FontWeight', 'bold', ...
    'FontSize', 12,...
    'String', [SerDataDefinition{n},': ']);
end

for n=1:NumDefinitions
    handles.textdatabox(n) = uicontrol('Style', 'text', ...
    'Position', [20 + textboxwidth, 30 + (NumDefinitions + 1 - n) * textboxspacing, textboxwidth, textboxheight], ...
    'BackgroundColor', 'w', ...
    'FontSize', 12,...
    'String', '0');
end

handles.button1 = uicontrol('Style', 'pushbutton', ...
    'String', 'Read Values', ...
    'Position', [10, 10, 80, 20], ...
    'CallBack', {@i_get_data, handles, serialport, SerDataDefinition});

end


function i_get_data(source, eventdata, handles, serialporthandle, SerDataDefinition)

SerDataCapturedValue = SerialHostEnd(serialporthandle, SerDataDefinition);

for n=1:length(SerDataDefinition)
    set(handles.textdatabox(n), 'String', num2str(SerDataCapturedValue(n)));
end

end

Contact us