WICHTIG: Der Betrieb von goMatlab.de wird privat finanziert fortgesetzt. - Mehr Infos...

Mein MATLAB Forum - goMatlab.de

Mein MATLAB Forum

 
Gast > Registrieren       Autologin?   

Partner:




Forum
      Option
[Erweitert]
  • Diese Seite per Mail weiterempfehlen
     


Gehe zu:  
Neues Thema eröffnen Neue Antwort erstellen

Timer Function: Too many input arguments

 

MATLAB-Novize

Gast


Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 23.11.2009, 14:03     Titel: Timer Function: Too many input arguments
  Antworten mit Zitat      
Hilfe, bitte kann mir jemand helfen!!

Ich habe folgendes Problem:

Zur eleganteren Handhabung einer timer-function möchte ich dieser mithilfe eines GUIs starten. Dabei (in der eigentlichen Funktion) geht es darum, externe Daten mithilfe von analoginput zu erfassen und zu plotten.

Die sich verändernden Daten sollen dabei in Form eines Punktes auf bestehende Kurvenverläufe, die in einer MAT-File hinterlegt sind, draufgeplottet werden.
Code:
%

% PISTPOS3
%
% Funktion zum Erkennen der Kolbenposition mittels Drehpotentiometer
%
% Diese Funktion erhält über "analoginput" (s. Zeile 25) Daten aus der Messkarte
% (National Instruments, M-Serie) und gibt sie abhängig von der Kolben-
% bzw. Kurbelwellenposition als Punkt auf dem Verlauf der Motorgrößen
% (Zylindertemperatur, Zylinderdruck, Masse im Zylinder,
% Ventilerhebungskurven und p-V-Diagramm) aus.
%  
% Datum:
% Verfasser: Benjamin Fahrentholz
%
% Lehrstuhl für Verbrennungskraftmaschinen der TU München


function pistpos3%(handles)

if(get(timer,'TasksExecuted')>1)
del=1;
else
    del=0;
    %handles=evalin('base','Handle');
    %p=evalin('base','o');
end

tic;
%addpath('Z:\Fahrentholz_Benjamin_AH\SEMESTERARBEIT_ABGABE\Matlab-Signalaufbereitung');

daqreset
%clear
ai=analoginput('nidaq','Dev1');
addchannel(ai,0);
ai.SampleRate= 1756;
ai.SamplesPerTrigger = 4;
ai.InputType = 'SingleEnded';
ai.TriggerType = 'Immediate';
ai.TriggerRepeat = inf;

start(ai)

[data] = getdata(ai);

stop(ai)
delete (ai)
clear ai

volt = mean(data,1);
deg = (volt * 1705)*(-1);
degkw = ceil(deg);

if      degkw > 720
        degkw = 720;
elseif  degkw <= 0
        degkw = 1;
end

D=load('Ausgabe.mat');
Z = D.Ausgabe_KW.Zylinder1;
[phi, IX] = sort(Z.phi_Zyl);

pos=degkw;

assignin('base','status',0)

toc;

check=evalin('pushbutton_Start_Callback','chckstrt');

if check==1
   status=evalin('statusckeck','status');
   
   if status==1
       
       

        if exist ('handles','var');
           cla(handles.axes_Zylindertemperatur);
           cla(handles.axes_Zylinderdruck);
           cla(handles.axes_Masse);
           cla(handles.axes_Ventilerhebungskurven);
           cla(handles.axes_p_V_Diagramm);
        end


        %----------- Plot Zylindertemperatur --------------------------------------


        plot(handles.axes_Zylindertemperatur, Z.phi_Zyl(IX), Z.T(IX) );
        hold(handles.axes_Zylindertemperatur,'on');

        %p=evalin('base','p');
        %handles=evalin('base','Handle');

        %del=evalin('base','del');

        if(del==1)
            delete(p(1));
        end

        p(1)=plot(handles.axes_Zylindertemperatur, pos, Z.T(pos),'o','MarkerSize',8,'Color','r','MarkerFaceColor', 'r');
        xlabel(handles.axes_Zylindertemperatur, '\phi [°KW]', 'FontSize',12)
        ylabel(handles.axes_Zylindertemperatur, 'T [K]', 'FontSize',12)
        grid(handles.axes_Zylindertemperatur,'on')
        %hold(handles.axes_Zylindertemperatur,'off');


        %----------- Plot Zylinderdruck -------------------------------------------


        plot(handles.axes_Zylinderdruck, Z.phi_Zyl(IX), Z.p(IX))
        hold(handles.axes_Zylinderdruck, 'on')

        if(del==1)
            delete(p(2));
        end

        p(2)=plot(handles.axes_Zylinderdruck, pos, Z.p(pos),'o','MarkerSize',8,'Color','r','MarkerFaceColor', 'r');
        xlabel(handles.axes_Zylinderdruck, '\phi [°KW]', 'FontSize',12)
        ylabel(handles.axes_Zylinderdruck, 'p [bar]', 'FontSize',12)
        grid(handles.axes_Zylinderdruck, 'on')
        %hold(handles.axes_Zylinderdruck, 'off')


        %----------- Plot Masse (im Zylinder) -------------------------------------


        plot(handles.axes_Masse, Z.phi_Zyl(IX), Z.m(IX))
        hold(handles.axes_Masse, 'on')

        if(del==1)
            delete(p(3));
        end

        p(3)=plot(handles.axes_Masse, pos, Z.m(pos),'o','MarkerSize',8,'Color','r','MarkerFaceColor', 'r' );
        xlabel(handles.axes_Masse, '\phi [°KW]', 'FontSize',12)
        ylabel(handles.axes_Masse, 'm [g]', 'FontSize',12)
        grid(handles.axes_Masse, 'on')
        %hold(handles.axes_Masse, 'off')


        %----------- Plot Ventilerhebungskurven -----------------------------------


        plot(handles.axes_Ventilerhebungskurven, Z.phi_Zyl(IX), Z.Ventil_Ein1.A_eff(IX), 'r' );
        hold(handles.axes_Ventilerhebungskurven, 'on')

        if(del==1)
            delete(p(4));
        end

        p(4)=plot(handles.axes_Ventilerhebungskurven, pos, Z.Ventil_Ein1.A_eff(pos), 'o','MarkerSize',8,'Color','r','MarkerFaceColor', 'r' );

        plot(handles.axes_Ventilerhebungskurven, Z.phi_Zyl(IX), Z.Ventil_Aus1.A_eff(IX), 'b' );

        if(del==1)
            delete(p(5));
        end

        p(5)=plot(handles.axes_Ventilerhebungskurven, pos, Z.Ventil_Aus1.A_eff(pos), 'o','MarkerSize',8,'Color','r','MarkerFaceColor', 'r' );
        xlabel(handles.axes_Ventilerhebungskurven, '\phi [°KW]', 'FontSize',12)
        ylabel(handles.axes_Ventilerhebungskurven, 'A_{eff} [mm^2]', 'FontSize',12)
        grid(handles.axes_Ventilerhebungskurven, 'on')
        %hold(handles.axes_Ventilerhebungskurven, 'off')

        %----------- Plot p-V-Diagramm --------------------------------------------


        plot(handles.axes_p_V_Diagramm, Z.V(IX), Z.p(IX) );
        hold(handles.axes_p_V_Diagramm, 'on')

        if(del==1)
            delete(p(6));
        end

        p(6)=plot(handles.axes_p_V_Diagramm, Z.V(pos), Z.p(pos), 'o','MarkerSize',8,'Color','r','MarkerFaceColor', 'r' );
        xlabel(handles.axes_p_V_Diagramm, 'V [dm^3]', 'FontSize',12)
        ylabel(handles.axes_p_V_Diagramm, 'p [bar]', 'FontSize',12)
        grid(handles.axes_p_V_Diagramm, 'on')
        %hold(handles.axes_p_V_Diagramm, 'off')

        %assignin('base','p',p)
       
   end
end

 


Wenn ich den Timer mithilfe des GUIs (von der opening-function aus) starten möchte bekomme ich immer wieder die Fehlermeldung:

"Too many input arguments"!!!

GUI:
Code:

function varargout = User_Interface2(varargin)
% USER_INTERFACE2 M-file for User_Interface2.fig
%      USER_INTERFACE2, by itself, creates a new USER_INTERFACE2 or raises the existing
%      singleton*.
%
%      H = USER_INTERFACE2 returns the handle to a new USER_INTERFACE2 or the handle to
%      the existing singleton*.
%
%      USER_INTERFACE2('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in USER_INTERFACE2.M with the given input arguments.
%
%      USER_INTERFACE2('Property','Value',...) creates a new USER_INTERFACE2 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before User_Interface2_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to User_Interface2_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help User_Interface2

% Last Modified by GUIDE v2.5 17-Nov-2009 12:46:23

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @User_Interface2_OpeningFcn, ...
                   'gui_OutputFcn',  @User_Interface2_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before User_Interface2 is made visible.
function User_Interface2_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to User_Interface2 (see VARARGIN)

% pistpos3(handles)

%Handle=handles;
%p = zeros(6,1); % Handles auf Punkte
t = timer('TimerFcn',@pistpos3,'ExecutionMode','fixedDelay','BusyMode','queue','Period',0.8,'UserData', handles);
start(t)

%assignin('base','o',p);
%assignin('base','Handle',handles);



% Choose default command line output for User_Interface2
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes User_Interface2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = User_Interface2_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in pushbutton_Start.
function [status]=pushbutton_Start_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_Start (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

chckstrt=1;
statuscheck
%start(handles.t);


% --- Executes on button press in pushbutton_Stop.
function [status]=pushbutton_Stop_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_Stop (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%stop(handles.t);
statuscheck



function edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double


% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit3_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double


% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit4_Callback(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit4 as text
%        str2double(get(hObject,'String')) returns contents of edit4 as a double


% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit5_Callback(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit5 as text
%        str2double(get(hObject,'String')) returns contents of edit5 as a double


% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit6_Callback(hObject, eventdata, handles)
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit6 as text
%        str2double(get(hObject,'String')) returns contents of edit6 as a double


% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

 


Woran könnte das denn liegen?

Ist meine Funktion den zu groß? Zu mächtig?
Ich weiß absolut nicht weiter.


Wär super, wenn ihr mir weiterhelfen könntet!

Grüße
MATLAB-Novize

P.S. Der Vollständigkeit halber noch die Funktion statuscheck:
Code:

function [status]=statuscheck

status=evalin('base','status');

if status==0
   status=1;
else
   status=0;  
end
 


denny
Supporter

Supporter



Beiträge: 3.853
Anmeldedatum: 14.02.08
Wohnort: Ulm
Version: R2012b
     Beitrag Verfasst am: 23.11.2009, 14:15     Titel:
  Antworten mit Zitat      
Hallo
folgendes muss du ändern:
Code:

% die Fehlermeldung sagt,
% dass zu wenige Übergabe-Parameter definiert sind
%
function pistpos3(hObject, eventdata, handles)
 


und auch timer:
Code:

t = timer('TimerFcn',{@pistpos3,handles},'ExecutionMode','fixedDelay','BusyMode','queue','Period',0.8);
 
Private Nachricht senden Benutzer-Profile anzeigen
 
MATLAB-Novize

Gast


Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 30.11.2009, 10:47     Titel: Timer Function: Too many input arguments
  Antworten mit Zitat      
Vielen Dank für die Tipps!
Habs gleich ausprobiert.
Leider funktioniert es jetzt immer noch nicht.
Die Fehlermeldung besagt jetzt:

Code:

Elapsed time is 1.050705 seconds.
??? Error while evaluating TimerFcn for timer 'timer-1'

Unknown command option.
 


und wenn ich das GUI noch einmal starte hab ich aufeinmal schon meinen 3. Timer:

Code:

Elapsed time is 0.853535 seconds.
??? Error while evaluating TimerFcn for timer 'timer-3'

Unknown command option.

 



Zur besseren Übersicht hier noch einmal meine Quelltexte:

Code:
% User interface
function varargout = User_Interface2(varargin)
% USER_INTERFACE2 M-file for User_Interface2.fig
%      USER_INTERFACE2, by itself, creates a new USER_INTERFACE2 or raises the existing
%      singleton*.
%
%      H = USER_INTERFACE2 returns the handle to a new USER_INTERFACE2 or the handle to
%      the existing singleton*.
%
%      USER_INTERFACE2('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in USER_INTERFACE2.M with the given input arguments.
%
%      USER_INTERFACE2('Property','Value',...) creates a new USER_INTERFACE2 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before User_Interface2_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to User_Interface2_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help User_Interface2

% Last Modified by GUIDE v2.5 17-Nov-2009 12:46:23

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @User_Interface2_OpeningFcn, ...
                   'gui_OutputFcn',  @User_Interface2_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before User_Interface2 is made visible.
function User_Interface2_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to User_Interface2 (see VARARGIN)

% pistpos3(handles)

%Handle=handles;
%p = zeros(6,1); % Handles auf Punkte
t = timer('TimerFcn',{@pistpos3,handles},'ExecutionMode','fixedDelay','BusyMode','queue','Period',0.8);
start(t)

%assignin('base','o',p);
%assignin('base','Handle',handles);



% Choose default command line output for User_Interface2
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes User_Interface2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = User_Interface2_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in pushbutton_Start.
function [status]=pushbutton_Start_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_Start (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

chckstrt=1;
statuscheck
%start(handles.t);


% --- Executes on button press in pushbutton_Stop.
function [status]=pushbutton_Stop_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_Stop (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%stop(handles.t);
statuscheck



function edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double


% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit3_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double


% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit4_Callback(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit4 as text
%        str2double(get(hObject,'String')) returns contents of edit4 as a double


% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit5_Callback(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit5 as text
%        str2double(get(hObject,'String')) returns contents of edit5 as a double


% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit6_Callback(hObject, eventdata, handles)
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit6 as text
%        str2double(get(hObject,'String')) returns contents of edit6 as a double


% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


 


Code:
% pistpos 3
% PISTPOS3
%
% Funktion zum Erkennen der Kolbenposition mittels Drehpotentiometer
%
% Diese Funktion erhält über "analoginput" (s. Zeile 25) Daten aus der Messkarte
% (National Instruments, M-Serie) und gibt sie abhängig von der Kolben-
% bzw. Kurbelwellenposition als Punkt auf dem Verlauf der Motorgrößen
% (Zylindertemperatur, Zylinderdruck, Masse im Zylinder,
% Ventilerhebungskurven und p-V-Diagramm) aus.
%  
% Datum:
% Verfasser: Benjamin Fahrentholz
%
% Lehrstuhl für Verbrennungskraftmaschinen der TU München


function pistpos3(hObject, eventdata, handles)

if(get(timer,'TasksExecuted')>1)
del=1;
else
    del=0;
    %handles=evalin('base','Handle');
    %p=evalin('base','o');
end

tic;
%addpath('Z:\Fahrentholz_Benjamin_AH\SEMESTERARBEIT_ABGABE\Matlab-Signalaufbereitung');

daqreset
%clear
ai=analoginput('nidaq','Dev1');
addchannel(ai,0);
ai.SampleRate= 1756;
ai.SamplesPerTrigger = 4;
ai.InputType = 'SingleEnded';
ai.TriggerType = 'Immediate';
ai.TriggerRepeat = inf;

start(ai)

[data] = getdata(ai);

stop(ai)
delete (ai)
clear ai

volt = mean(data,1);
deg = (volt * 1705)*(-1);
degkw = ceil(deg);

if      degkw > 720
        degkw = 720;
elseif  degkw <= 0
        degkw = 1;
end

D=load('Ausgabe.mat');
Z = D.Ausgabe_KW.Zylinder1;
[phi, IX] = sort(Z.phi_Zyl);

pos=degkw;

assignin('base','status',0)

toc;

check=evalin('pushbutton_Start_Callback','chckstrt');

if check==1
   status=evalin('statusckeck','status');
   
   if status==1
       
       

        if exist ('handles','var');
           cla(handles.axes_Zylindertemperatur);
           cla(handles.axes_Zylinderdruck);
           cla(handles.axes_Masse);
           cla(handles.axes_Ventilerhebungskurven);
           cla(handles.axes_p_V_Diagramm);
        end


        %----------- Plot Zylindertemperatur --------------------------------------


        plot(handles.axes_Zylindertemperatur, Z.phi_Zyl(IX), Z.T(IX) );
        hold(handles.axes_Zylindertemperatur,'on');

        %p=evalin('base','p');
        %handles=evalin('base','Handle');

        %del=evalin('base','del');

        if(del==1)
            delete(p(1));
        end

        p(1)=plot(handles.axes_Zylindertemperatur, pos, Z.T(pos),'o','MarkerSize',8,'Color','r','MarkerFaceColor', 'r');
        xlabel(handles.axes_Zylindertemperatur, '\phi [°KW]', 'FontSize',12)
        ylabel(handles.axes_Zylindertemperatur, 'T [K]', 'FontSize',12)
        grid(handles.axes_Zylindertemperatur,'on')
        %hold(handles.axes_Zylindertemperatur,'off');


        %----------- Plot Zylinderdruck -------------------------------------------


        plot(handles.axes_Zylinderdruck, Z.phi_Zyl(IX), Z.p(IX))
        hold(handles.axes_Zylinderdruck, 'on')

        if(del==1)
            delete(p(2));
        end

        p(2)=plot(handles.axes_Zylinderdruck, pos, Z.p(pos),'o','MarkerSize',8,'Color','r','MarkerFaceColor', 'r');
        xlabel(handles.axes_Zylinderdruck, '\phi [°KW]', 'FontSize',12)
        ylabel(handles.axes_Zylinderdruck, 'p [bar]', 'FontSize',12)
        grid(handles.axes_Zylinderdruck, 'on')
        %hold(handles.axes_Zylinderdruck, 'off')


        %----------- Plot Masse (im Zylinder) -------------------------------------


        plot(handles.axes_Masse, Z.phi_Zyl(IX), Z.m(IX))
        hold(handles.axes_Masse, 'on')

        if(del==1)
            delete(p(3));
        end

        p(3)=plot(handles.axes_Masse, pos, Z.m(pos),'o','MarkerSize',8,'Color','r','MarkerFaceColor', 'r' );
        xlabel(handles.axes_Masse, '\phi [°KW]', 'FontSize',12)
        ylabel(handles.axes_Masse, 'm [g]', 'FontSize',12)
        grid(handles.axes_Masse, 'on')
        %hold(handles.axes_Masse, 'off')


        %----------- Plot Ventilerhebungskurven -----------------------------------


        plot(handles.axes_Ventilerhebungskurven, Z.phi_Zyl(IX), Z.Ventil_Ein1.A_eff(IX), 'r' );
        hold(handles.axes_Ventilerhebungskurven, 'on')

        if(del==1)
            delete(p(4));
        end

        p(4)=plot(handles.axes_Ventilerhebungskurven, pos, Z.Ventil_Ein1.A_eff(pos), 'o','MarkerSize',8,'Color','r','MarkerFaceColor', 'r' );

        plot(handles.axes_Ventilerhebungskurven, Z.phi_Zyl(IX), Z.Ventil_Aus1.A_eff(IX), 'b' );

        if(del==1)
            delete(p(5));
        end

        p(5)=plot(handles.axes_Ventilerhebungskurven, pos, Z.Ventil_Aus1.A_eff(pos), 'o','MarkerSize',8,'Color','r','MarkerFaceColor', 'r' );
        xlabel(handles.axes_Ventilerhebungskurven, '\phi [°KW]', 'FontSize',12)
        ylabel(handles.axes_Ventilerhebungskurven, 'A_{eff} [mm^2]', 'FontSize',12)
        grid(handles.axes_Ventilerhebungskurven, 'on')
        %hold(handles.axes_Ventilerhebungskurven, 'off')

        %----------- Plot p-V-Diagramm --------------------------------------------


        plot(handles.axes_p_V_Diagramm, Z.V(IX), Z.p(IX) );
        hold(handles.axes_p_V_Diagramm, 'on')

        if(del==1)
            delete(p(6));
        end

        p(6)=plot(handles.axes_p_V_Diagramm, Z.V(pos), Z.p(pos), 'o','MarkerSize',8,'Color','r','MarkerFaceColor', 'r' );
        xlabel(handles.axes_p_V_Diagramm, 'V [dm^3]', 'FontSize',12)
        ylabel(handles.axes_p_V_Diagramm, 'p [bar]', 'FontSize',12)
        grid(handles.axes_p_V_Diagramm, 'on')
        %hold(handles.axes_p_V_Diagramm, 'off')

        %assignin('base','p',p)
       
   end
end
 


Code:
%statuscheck
function [status]=statuscheck

status=evalin('base','status');

if status==0
   status=1;
else
   status=0;  
end
 


wär echt cool, wenn ihr mir da noch einmal weiterhelfen könntet! Ich weiß nicht weiter!
 
denny
Supporter

Supporter



Beiträge: 3.853
Anmeldedatum: 14.02.08
Wohnort: Ulm
Version: R2012b
     Beitrag Verfasst am: 30.11.2009, 12:50     Titel:
  Antworten mit Zitat      
Hallo,

kannst du vielleicht deine m-files und fig-files anhängen,
damit man es selbst ausprobieren kann.
Private Nachricht senden Benutzer-Profile anzeigen
 
MATLAB-Novize

Gast


Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 30.11.2009, 14:10     Titel: Timer Function: Too many input arguments
  Antworten mit Zitat      
Das würde wahrscheinlich schwierig werden, weil du dazu auch noch die Messkarte zur Generierung der Daten benötigst.

Aber inzwischen hats geklappt! Vielen Dank noch einmal für den super Tipp!
Es hat wirklich nur daran gelegen, dass ich der Timer-Funktion nicht das handle übergeben hatte.

Ich wusste bis zu deiner Antwort nicht, dass ich das in geschweifte Klammern schreiben muss...
 
denny
Supporter

Supporter



Beiträge: 3.853
Anmeldedatum: 14.02.08
Wohnort: Ulm
Version: R2012b
     Beitrag Verfasst am: 30.11.2009, 15:32     Titel:
  Antworten mit Zitat      
Ach so,

Dann freue mich. dass du es selbst herausgefunden hast.

Weiterhin Viel Erfolg!
Private Nachricht senden Benutzer-Profile anzeigen
 
Liz

Gast


Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 11.05.2010, 18:07     Titel: ??? Error while evaluating TimerFcn for timer
  Antworten mit Zitat      
Der Thread ist zwar schon etwas älter... aber ich bin nun beim Erstellen meiner GUI auf die selbe Fehlermeldung gestossen und bin nach langem Suchen und Probieren immer noch nicht weiter gekommen.

Ich soll eine GUI zu einer Simulink-Simulation erstellen, mit der ich dann auf Parameter einer S-Funktion zugreife. Nun möchte ich gerne, wenn ich die Simulation mit meinem Button starte auch einen Timer starten, der mir die verstrichene Zeit in einem Textfeld ausgibt.
Zunächst habe ich damit angefangen, die Oberfläche mit GUIDE zu erstellen, dwas zu folgender Funktion mit Timer geführt hat (hat auch funktionert):


Code:

function [] = ctime(varargin)
handles=guidata(meineGUI);
tmr = timer('Name','mytimer',...
            'Period',1,...
            'StartDelay',0,....
            'TasksToExecute',inf,...
            'ExecutionMode','fixedSpacing',...            
            'TimerFcn',{@updater});

z=0;
set(tmr,'UserData',z);        
start(tmr);

    function [] = updater(varargin)
                z = get(tmr,'UserData');
                z = z + 1;
                set(handles.time_elapsed,'string',z);
                set(tmr,'UserData',z);
                if  get(handles.sim_start_stop,'Value') == get(handles.sim_start_stop,'Min')                    
                    stop(tmr);
                    delete(tmr);
                    return
                end
    end
guidata(meineGUI,handles);
end
 



aufgerufen wurde meine Funktion aus:

Code:

function sim_startstop(hObject)
handles=guidata(hObject);

        %Button Beschriftung ändern    
            set(handles.bsim_start_stop,'String','Simulation Anhalten');
        %Plotfenster leeren
            cla(handles.pLHeart,'reset');
            cla(handles.pRHeart,'reset');
            cla(handles.pSVC,'reset');
            cla(handles.VAtrium,'reset');
            cla(handles.VKammer,'reset');
         %Simulationszeit auslesen
            sim_time=str2num(get(handles.sim_time,'string'));
         %timer starten                    
            ctime;
         %Simulation starten
            sim('meineSim',[0 sim_time],simset('DstWorkspace','base'));
            if get_param('meineSim','SimulationStatus')=='stopped'
               set(handles.bsim_start_stop,'Value',0,'String','Simulation Starten');
               get_HerzData(hObject);
            end
   
   
    guidata(hObject,handles);
   
end

 



Nun wollte ich aber meine Oberfläche ohne GUIDE erstellen und bekomme folgenden Fehler:

Zitat:

??? Error while evaluating TimerFcn for timer 'simtime'

Too many input arguments.



mit OnCallBack und OffCallback wird wieder meine sim_start und sim_stop funktion aus meiner Toolbar aufgerufen:
Code:

handles.hkl_sim_start_stop = uitoggletool(handles.hklGUIbar1,...
                'CData' ,           cdata1,...
                'TooltipString' ,   'sim_start',...
                'OnCallback',       @hkl_sim_start,...
                'OffCallback',      @hkl_sim_stop);
 


Code:

%OnCallback sim_start_stop
        function hkl_sim_start(hObject,eventdata)
                   
           bar1_icon1 = ['./ToolbarIcons/sim_stop.gif'];
                [cdata1,map1] = imread(bar1_icon1);
                cdata1 = ind2rgb(cdata1,map1);
                set(handles.hkl_sim_start_stop, 'CData' , cdata1);  
                sim_start(hklGUI);
               
        end
   
%OffCallback sim_start_stop
        function hkl_sim_stop(hObject,eventdata)
           
           bar1_icon1 = ['./ToolbarIcons/sim_start.gif'];
                [cdata1,map1] = imread(bar1_icon1);
                cdata1 = ind2rgb(cdata1,map1);
                set(handles.hkl_sim_start_stop, 'CData' , cdata1);
                sim_stop(hklGUI);
        end
 


Die sim_start Funktion sieht folgendermaßen aus:

Code:

function sim_start(hObject)
handles=guidata(hObject);


        %Plotfenster leeren
            cla(handles.ax_pLHeart,'reset');
            cla(handles.ax_pRHeart,'reset');
            cla(handles.ax_pSVC,'reset');
            cla(handles.ax_VAtrium,'reset');
            cla(handles.ax_VKammer,'reset');
         %Simulationszeit auslesen
            sim_time=str2num(get(handles.sim_time,'string'));
         
         %timer starten                    
            ctime(hObject);
         
   
         %Simulation starten
            sim('meineSim',[0 sim_time],simset('DstWorkspace','base'));
            if get_param('meineSim','SimulationStatus')=='stopped'
               set(handles.hkl_sim_start_stop, 'State','off');
               get_HerzData(hObject);
            end
   
   
    guidata(hObject,handles);
   
end
 


und mein timer so:


Code:

function ctime(hObject)
handles=guidata(hObject);

tmr = timer('Name','simtime',...
            'Period',1,...
            'StartDelay',0,....
            'TasksToExecute',inf,...
            'ExecutionMode','fixedSpacing',...            
            'TimerFcn',@updater);

z=0;
set(tmr,'UserData',z);        
start(tmr); % Start the timer object.

    function updater
                z = get(tmr,'UserData');
                z = z + 1;                
                set(handles.time_elapsed,'String',num2str(z));
                set(tmr,'UserData',z);
                if  get(handles.hkl_sim_start_stop, 'State') == 'off'                    
                    stop(tmr);
                    delete(tmr);
                    return
                end
    end

guidata(hObject,handles);
end
 



Und meine GUI hab ich folgendermaßen aufgebaut:


Code:

function meineGUI

%mein Kommentar
%zu meinerGUI

    % Initialize and hide the GUI as it is being constructed.
        gui_Position = [0,0,1810,900];
        gui_Name = mfilename;
        % Simple structure that allows only one instance.
        if findobj('type','figure','name',gui_Name)
            close(findobj('type','figure','name',gui_Name));
        end
       
       hklGUI = figure('Visible',  'off',...
                        'Position', gui_Position,...
                        'Name',     gui_Name,...
                        'Resize',   'on'...
                        );  
    % Move the GUI to the center of the screen.
        movegui(hklGUI,'center')
       

       
    % contruct the GUI components

   %... meine ganzen GUI Komponenten die ich hier jetzt mal der Einfachheit halber weglass....

    % Choose default command line output für meineGUI  
        handles.output = hklGUI;
       
    % Update handles structure
        guidata(hklGUI, handles);
             
    % Invisibly load Simulink model
        load_system('meineSim');
   
    % make the GUI visible after initializing all the components
        set(hklGUI,'Visible','on');


    %---------------- Callbacks--------------------------%

   %meine Callbacks wie oben beschrieben
end

 





ich hoffe das war jetzt nicht zu viel des Guten, und dass vielleicht jemand helfen kann.

Danke
Liz
 
Liz

Gast


Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 11.05.2010, 18:09     Titel: PS:
  Antworten mit Zitat      
das mit den {} geschweiften Klammern bei der TimerFcn hatte ich schon probiert... hat das Problem nicht behoben.
 
denny
Supporter

Supporter



Beiträge: 3.853
Anmeldedatum: 14.02.08
Wohnort: Ulm
Version: R2012b
     Beitrag Verfasst am: 11.05.2010, 18:28     Titel: Re: PS:
  Antworten mit Zitat      
Liz hat Folgendes geschrieben:
das mit den {} geschweiften Klammern bei der TimerFcn hatte ich schon probiert... hat das Problem nicht behoben.


Das liegt auch nicht an geschweiften klammern, sondern an fehlenden Parametern:
Wenn du z.B. TimerFcn ,ButtonDownFcn und CallbackFcn definierst
muss in der Funktion 2 Übergabeparameter immer definiert sein.

es wäre richtig:
Code:

    function updater(timer_handle, eventdata)
                z = get(tmr,'UserData');
                z = z + 1;                
                set(handles.time_elapsed,'String',num2str(z));
                set(tmr,'UserData',z);
                if  get(handles.hkl_sim_start_stop, 'State') == 'off'                    
                    stop(tmr);
                    delete(tmr);
                    return
                end
    end
 


oder VARARGIN, dass eine Art Container, welcher beliebige Anzahl Eingaben akzeptiert.
Code:

    function updater(varargin)
                z = get(tmr,'UserData');
                z = z + 1;                
                set(handles.time_elapsed,'String',num2str(z));
                set(tmr,'UserData',z);
                if  get(handles.hkl_sim_start_stop, 'State') == 'off'                    
                    stop(tmr);
                    delete(tmr);
                    return
                end
    end
 
Private Nachricht senden Benutzer-Profile anzeigen
 
Liz

Gast


Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 11.05.2010, 18:52     Titel:
  Antworten mit Zitat      
wenn ich varargin setze dann kommt:

Zitat:
??? Error while evaluating TimerFcn for timer 'simtime'

Matrix dimensions must agree.


was soll ich ihm denn übergeben? Hab echt so langsam nen Knoten im Hirn sorry ;[
 
Liz

Gast


Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 11.05.2010, 22:18     Titel:
  Antworten mit Zitat      
Also Danke erstmal für die schnelle Antwort. Hab's mir nach ner Pause nochmal angeschaut und natürlich hatte denny Recht. Smile
Konnte auch herausfinden woran der zweite Fehler lag. Deshalb zur Info nochmal für Dummies wie mich.
Habe zunächst bei der 'TimerFcn', {@updater,handles} belegt und folgendes übergeben:
Code:

   function updater(tmr, eventdata, handles)
                z = get(tmr,'UserData');
                z = z + 1;                
                set(handles.time_elapsed,'String',num2str(z));
                set(tmr,'UserData',z);
                if  get(handles.hkl_sim_start_stop, 'State') == 'off'                    
                    stop(tmr);
                    delete(tmr);
                    return
                end
    end

 

einmal. Bei Erreichen meiner if-Bedingung tritt der zweite Fehler auf, mit:

Zitat:

??? Error while evaluating TimerFcn for timer 'simtime'

Matrix dimensions must agree.

"Offensichtlich" kann man von einem normalen Togglebutton (mein sim_start_stop) zwar
Code:

 if  get(handles.sim_start_stop,'Value') == get(handles.sim_start_stop,'Min')
 

setzen. Es geht aber nicht
Code:

 if  get(handles.hkl_sim_start_stop, 'State') == 'off'
 

wenn hkl_sim_start_stop ein toggletool der uitoolbar ist.
Geht man aber über ein StringCompare funktioniert die Sache allerdings:
Code:

 function updater(tmr, eventdata, handles,varargin)
                x=get(handles.hkl_sim_start_stop, 'State');
                u = 'off';
                z = get(tmr,'UserData');
                z = z + 1;                
                set(handles.time_elapsed,'String',z);
                set(tmr,'UserData',z);
                if  strcmp(x,u)
                    stop(tmr);
                    delete(tmr);
                    return
                end
 


So läuft der Timer und wird auch brav gestoppt wenn ich mein ToggleTool erneut betätige.
Bestimmt gibt's dafür auch ne elegantere Lösung aber es funktioniert erstmal.
 
Liz

Gast


Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 11.05.2010, 22:21     Titel:
  Antworten mit Zitat      
...sollte mir wohl doch nen Account hier zulegen, dann kann ich meine Posts auch editieren.

nach dem ersten Codebrocken fehlt:

Dann läuft die TimerFcn aber nur einmal...
 
Neues Thema eröffnen Neue Antwort erstellen



Einstellungen und Berechtigungen
Beiträge der letzten Zeit anzeigen:

Du kannst Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.
Du kannst Dateien in diesem Forum posten
Du kannst Dateien in diesem Forum herunterladen
.





 Impressum  | Nutzungsbedingungen  | Datenschutz | FAQ | goMatlab RSS Button RSS

Hosted by:


Copyright © 2007 - 2025 goMatlab.de | Dies ist keine offizielle Website der Firma The Mathworks

MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.