image thumbnail
from FlukeLogger by Tom
GUI for data aquisition with Fluke45

FlukeLogger(varargin)
function varargout = FlukeLogger(varargin)
% LCRREMOTE M-file for LCRremote.fig
%      LCRREMOTE, by itself, creates a new LCRREMOTE or raises the existing
%      singleton*.
%
%      H = LCRREMOTE returns the handle to a new LCRREMOTE or the handle to
%      the existing singleton*.
%
%      LCRREMOTE('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in LCRREMOTE.M with the given input arguments.
%
%      LCRREMOTE('Property','Value',...) creates a new LCRREMOTE or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before LCRremote_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to LCRremote_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 LCRremote

% Last Modified by GUIDE v2.5 05-Sep-2007 14:36:48

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @LCRremote_OpeningFcn, ...
                   'gui_OutputFcn',  @LCRremote_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 LCRremote is made visible.
function LCRremote_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 LCRremote (see VARARGIN)


handles.port=serial('COM1','BaudRate',9600,'BytesAvailableFcnMode','terminator','Terminator','CR/LF'); %'BytesAvailableFcn',{@ReadOut,handles});
handles.timer=timer('TimerFcn',{@FlukeRun,handles},'ExecutionMode','fixedSpacing','Period',1);



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

% Update handles structure
guidata(hObject, handles);

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



% --- Outputs from this function are returned to the command line.
function varargout = LCRremote_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 RadioBtnLog.
function RadioBtnLog_Callback(hObject, eventdata, handles)
% hObject    handle to RadioBtnLog (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of RadioBtnLog
global Logging Scale

switch get(hObject,'Value')
    case 1
        Logging.Vektor=[];
        Logging.Time=[];
        Scale.value=[];
        handles.port.BytesAvailableFcn={@FlukeOut,handles};
        fopen(handles.port);
        %handles.port.BytesAvailableFcn={@ReadOut,handles};
        set(handles.RadioBtnLog,'String','Stop loging');
        
        start(handles.timer);
       
    case 0
        set(handles.RadioBtnLog,'String','Start logging');
        stop(handles.timer);
        fclose(handles.port);
        switch get(handles.RadioBtnSave,'Value')
            
                
            case 1
        save(get(handles.EdtTxtFilename,'String'),'Logging');
        end
        
end


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

% Hint: get(hObject,'Value') returns toggle state of RadioBtnSave



function EdtTxtFilename_Callback(hObject, eventdata, handles)
% hObject    handle to EdtTxtFilename (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 EdtTxtFilename as text
%        str2double(get(hObject,'String')) returns contents of EdtTxtFilename as a double


% --- Executes during object creation, after setting all properties.
function EdtTxtFilename_CreateFcn(hObject, eventdata, handles)
% hObject    handle to EdtTxtFilename (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 EdtTxtPeriod_Callback(hObject, eventdata, handles)
% hObject    handle to EdtTxtPeriod (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 EdtTxtPeriod as text
%        str2double(get(hObject,'String')) returns contents of EdtTxtPeriod as a double

set(handles.timer,'Period',str2double(get(handles.EdtTxtPeriod,'String')));



% --- Executes during object creation, after setting all properties.
function EdtTxtPeriod_CreateFcn(hObject, eventdata, handles)
% hObject    handle to EdtTxtPeriod (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




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

% Hint: get(hObject,'Value') returns toggle state of RadioBtnPlot



function EdtTxtScaleA_Callback(hObject, eventdata, handles)
% hObject    handle to EdtTxtScaleA (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 EdtTxtScaleA as text
%        str2double(get(hObject,'String')) returns contents of EdtTxtScaleA as a double


% --- Executes during object creation, after setting all properties.
function EdtTxtScaleA_CreateFcn(hObject, eventdata, handles)
% hObject    handle to EdtTxtScaleA (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 EdtTxtScaleB_Callback(hObject, eventdata, handles)
% hObject    handle to EdtTxtScaleB (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 EdtTxtScaleB as text
%        str2double(get(hObject,'String')) returns contents of EdtTxtScaleB as a double


% --- Executes during object creation, after setting all properties.
function EdtTxtScaleB_CreateFcn(hObject, eventdata, handles)
% hObject    handle to EdtTxtScaleB (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


Contact us at files@mathworks.com