GUI to controll of SMULINK simulation - start/stop problems

1 view (last 30 days)
Hello,
I've been making a GUI in GUIDE to controll my Simulink mode, which controls an inverter using external mode. Since the purpose is to make a kind of a demo with it, I wanted to control the Simulink model through a GUI. In the GUI there are several text boxes to set parameters and a start and a stop button. And here is the problem: when I press "start" or "stop", the model always goes into "pause". Because I run in external mode, it is necessary to connect to the target first. When I connect with the target by pressing the connect-button in simulink and then press "start" in the GUI, the model's simulation status goes into "Pause". When I try to connect with the target by pressing the "start" button there is an error showing up:
-code for the start button:
function start_Callback(hObject, eventdata, handles)
set(get(handles.control,'Children'),'Enable','off'); %to disable some options once started
*status = get_param(CL_Buck_PI_hardware,'Simulationstatus');* %line 110
if ~strcmp(status,'running') %check if the model is
already running
set_param(CL_Buck_PI_hardware,'Simulationcommand','connect') %connect with target (ext mod)
set_param(CL_Buck_PI_hardware,'simulationcommand','start') %start the simulink model
end
% Assign handles and the startstop object to the base workspace
assignin('base','Buckconverter_handles',handles)
assignin('base','start_hObject',handles.start)
-error message:
Error using Buckconverter>start_Callback (line 110) %line 110 is market in bold in the code
Invalid Simulink object handle
Error in gui_mainfcn (line 96) feval(varargin{:});_
Error in Buckconverter (line 42) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)Buckconverter('start_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback _
Weird thing is that I can see the model starts to initiate but all of a sudden it stops and I get this error message.
The same kind of error appears when I start the simulation myself in the simulink window and then press the "stop"-button.
set(get(handles.control,'Children'),'Enable','on');%enable changes in GUI when "stop" = pressed
*status = get_param(CL_Buck_PI_hardware,'simulationstatus');* %Model running?
if strcmp(status, 'running') %if so, stop the model
set_param(CL_Buck_PI_hardware,'simulationcommand','stop')
end
% Assign handles and the startstop object to the base workspace
assignin('base','Buckconverter_handles',handles
The error message is the same as with the start button, and is marked in bold. I don't know what I'm doing wrong, because I thought I just follwed the set_param() instruction like showed in using real time applications
Who sees what I'm doing wrong?
Thanks in advance!
FYI: 'Buckconverter' is the name of my GUI and 'CL_Buck_PI_hardware' is the name of my simulink model
  2 Comments
Kaustubha Govind
Kaustubha Govind on 4 Apr 2014
Edited: Kaustubha Govind on 4 Apr 2014
When you say:
set_param(CL_Buck_PI_hardware,'simulationcommand','stop')
You're implying that CL_Buck_PI_hardware is a variable that holds the name of your model. Does such a variable exist in the function workspace? If not, you need to use single-quotes around it to indicate that the model name itself is CL_Buck_PI_hardware.
set_param('CL_Buck_PI_hardware','simulationcommand','stop')
Jannick
Jannick on 7 Apr 2014
OK, thank you very much for correcting my rookie mistake. 2 problems down, I hope not that many more to go!

Sign in to comment.

Answers (0)

Categories

Find more on Simulink Environment Customization in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!