Code covered by the BSD License  

Highlights from
Matlab driver DSO2090

from Matlab driver DSO2090 by Paul
Routine for obtaining data from digital storage oscilloscope DSO2090.

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

% for Matlab R2007b
% version 0.2 (july 2009)
% based on dso_2090usb.h and dso_2090usb.dll (version: 6.0.0.2, Hantek)
% dso_2090usb.dll can be found in C:\WINDOWS\system32\ after regular
% installation of the DSO2090.
% (c) Paul Brinkman
% email: brinkman_paul@hotmail.com

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

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = DSO_2090_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;

if ~libisloaded('dso_2090usb')
    loadlibrary( 'dso_2090usb.dll', 'dso_2090usb.h' );
end

handles.DeviceIndex = 0;
[dsoSearchDevice_1] = calllib('dso_2090usb', 'dsoSearchDevice', handles.DeviceIndex);
% this function can be used to make a error dialog when the device isn't
% connected.

handles.Ch1_Filt = 0;
handles.Ch2_Filt = 0;
handles.Trigger_Filt = 0;
handles.Trigger_Slope = 1;
handles.Control_Data1.TriggerSource = 1; 
handles.Control_Data1.ChannelSelect = 2; 
handles.Control_Data1.TIMEBASE = 12;
handles.Control_Data1.TriggerAddress = 50; 
handles.Control_Data1.DataLength = 1; 
handles.Control_Data1.BufferSize = 10; 
handles.Control_Data1.IsAlt = 0;
handles.Ch1_att = 6;
handles.Ch2_att = 6;
handles.Ch1_ACDC = 0;
handles.Ch2_ACDC = 0;


[dsoSetTriggerAndSampleRate_1 Control_Data1] =calllib( 'dso_2090usb' , 'dsoSetTriggerAndSampleRate', handles.DeviceIndex, handles.Trigger_Slope, libstruct('ControlStruct',handles.Control_Data1));

[dsoSetFilt_1] = calllib('dso_2090usb', 'dsoSetFilt', handles.DeviceIndex, handles.Ch1_Filt, handles.Ch2_Filt, handles.Trigger_Filt);

handles.TriggerSource=handles.Control_Data1.TriggerSource;

[dsoSetVoltageAndCoupling_1 ] =calllib('dso_2090usb','dsoSetVoltageAndCoupling', handles.DeviceIndex, handles.Ch1_att, handles.Ch2_att, handles.Ch1_ACDC, handles.Ch2_ACDC, handles.TriggerSource);

handles.Levers.Ch1Lever = 190;
handles.Levers.Ch1TrigLever = 23;
handles.Levers.Ch2Lever = 190;
handles.Levers.Ch2TrigLever = 40;
handles.Levers.ExtTrigLever = 0;
handles.Level = uint16([50 164 45 154 45 156 50 162 45 154 45 156 50 164 45 154 45 156 20 134 28 137 35 146 20 134 28 137 30 146 20 134 25 137 30 146 0 254 2202 242 170 30 170 30 170 30 170 30 170 30 170 30 170 30 160 30 180 40 180 90 4095]);

[dsoSetOffset_1 handles.Levers handles.Level ] =calllib('dso_2090usb', 'dsoSetOffset', handles.DeviceIndex, libstruct('LeversStruct',handles.Levers) , handles.Ch1_Filt, handles.Ch2_Filt, handles.TriggerSource, handles.Level );

handles.flag_auto_co = 0;
handles.Ram_Addr = 0;
handles.pos_trig = 50;
handles.ch1_data = uint16(zeros(1,30000));
handles.ch2_data = uint16(zeros(1,30000));
handles.calData = 1;
handles.ChannelData_1=uint16(zeros(1,30000));
handles.ChannelData_2=uint16(zeros(1,30000));

guidata(hObject,handles);

%%end of initiation%%%


% --- Executes on button press in on_off.
function on_off_Callback(hObject, eventdata, handles)
% hObject    handle to on_off (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 on_off

handles.on_of_value=get(hObject,'Value');

if handles.on_of_value==1;
    set(hObject, 'string', 'OFF');
elseif handles.on_of_value==0;
    set(hObject, 'string', 'ON');
end

%i=1;
   
[dsoSetTriggerAndSampleRate_1 handles.Control_Data1] =calllib( 'dso_2090usb' , 'dsoSetTriggerAndSampleRate', handles.DeviceIndex, handles.Trigger_Slope, libstruct('ControlStruct',handles.Control_Data1));   

while get(hObject,'Value')==1;
    
    Ch2_att= get(findobj(gcf,'Tag','popupmenu4'),'value')-1;
    Ch1_att= get(findobj(gcf,'Tag','popupmenu6'),'value')-1;
    
    if Ch2_att~=handles.Ch2_att | Ch1_att~=handles.Ch1_att
        handles.Ch2_att=Ch2_att;
        handles.Ch1_att=Ch1_att;
        [dsoSetVoltageAndCoupling_1 ] =calllib('dso_2090usb','dsoSetVoltageAndCoupling', handles.DeviceIndex, handles.Ch1_att, handles.Ch2_att, handles.Ch1_ACDC, handles.Ch2_ACDC, handles.TriggerSource);
    end

    [dsoSetOffset_1 handles.Levers handles.Level ] =calllib('dso_2090usb', 'dsoSetOffset', handles.DeviceIndex, libstruct('LeversStruct',handles.Levers) , handles.Ch1_att, handles.Ch2_att, handles.TriggerSource, handles.Level );
    
    handles.Control_Data1.TIMEBASE= get(findobj(gcf,'Tag','popupmenu3'),'value')-1;
    set(findobj(gcf,'Tag','popupmenu5'),'value', handles.Control_Data1.TIMEBASE+1); 
    
    [dsoSetTriggerAndSampleRate_1 handles.Control_Data1] =calllib( 'dso_2090usb' , 'dsoSetTriggerAndSampleRate', handles.DeviceIndex, handles.Trigger_Slope,libstruct('ControlStruct',handles.Control_Data1));
    [dsoSetFilt_1] = calllib('dso_2090usb', 'dsoSetFilt', handles.DeviceIndex, handles.Ch1_Filt, handles.Ch2_Filt, handles.Trigger_Filt);
    
    [handles.dsoGetCaptureState_1 handles.Ram_Addr]= calllib('dso_2090usb', 'dsoGetCaptureState', handles.DeviceIndex, handles.Ram_Addr);
    if handles.dsoGetCaptureState_1 >= 2
        [dsoGetChannelData_1 handles.ChannelData_1 handles.ChannelData_2 handles.Control_Data1] = calllib('dso_2090usb', 'dsoGetChannelData',handles.DeviceIndex, handles.Ch1_att, handles.Ch2_att, handles.pos_trig, handles.ch1_data, handles.ch2_data, libstruct('ControlStruct',handles.Control_Data1), handles.Ram_Addr, handles.calData);     
        axes(handles.axes1) 
        plot(handles.ChannelData_1(1:10240),'r'); axis tight; ylim([0,255]);  hold on;
        plot(handles.ChannelData_2(1:10240),'g'); axis tight; ylim([0,255]);  hold off;
        [dsoCaptureStart_1] = calllib('dso_2090usb', 'dsoCaptureStart', handles.DeviceIndex);
        [dsoTriggerEnabled_1] = calllib('dso_2090usb', 'dsoTriggerEnabled', handles.DeviceIndex);
        handles.flag_auto_co=handles.flag_auto_co*0;
    elseif handles.dsoGetCaptureState_1 ==0
        handles.flag_auto_co=handles.flag_auto_co+1;
    end
    if handles.flag_auto_co > 3
        [dsoForceTrigger_1] = calllib('dso_2090usb','dsoForceTrigger',handles.DeviceIndex);
        if handles.flag_auto_co > 300
            handles.flag_auto_co=(handles.flag_auto_co*0)+300;
        end
    end
    drawnow
    guidata(hObject,handles)
end

if get(hObject,'Value')==0;
    axes(handles.axes1); cla;
end

guidata(hObject,handles);
    


% --- Executes on selection change in popupmenu3.
function popupmenu3_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu3 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu3

guidata(hObject,handles);


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

% Hint: popupmenu 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 selection change in popupmenu4.
function popupmenu4_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu4 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu4

guidata(hObject,handles);

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

% Hint: popupmenu 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 selection change in popupmenu5.
function popupmenu5_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

guidata(hObject,handles);

% Hints: contents = get(hObject,'String') returns popupmenu5 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu5


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

% Hint: popupmenu 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 selection change in popupmenu6.
function popupmenu6_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


guidata(hObject,handles);
% Hints: contents = get(hObject,'String') returns popupmenu6 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu6


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

% Hint: popupmenu 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

% --- Creates and returns a handle to the GUI figure. 
function h1 = DSO_2090_LayoutFcn(policy)
% policy - create a new figure or use a singleton. 'new' or 'reuse'.

persistent hsingleton;
if strcmpi(policy, 'reuse') & ishandle(hsingleton)
    h1 = hsingleton;
    return;
end

appdata = [];
appdata.GUIDEOptions = struct(...
    'active_h', [], ...
    'taginfo', struct(...
    'figure', 2, ...
    'axes', 5, ...
    'popupmenu', 7, ...
    'uipanel', 8, ...
    'checkbox', 2, ...
    'togglebutton', 4, ...
    'text', 6, ...
    'edit', 2), ...
    'override', 0, ...
    'release', 13, ...
    'resize', 'none', ...
    'accessibility', 'callback', ...
    'mfile', 1, ...
    'callbacks', 1, ...
    'singleton', 1, ...
    'syscolorfig', 1, ...
    'blocking', 0, ...
    'lastSavedFile', 'C:\Documents and Settings\Brinkman\Bureaublad\Drivers DSO 2090\Mathworks\DSO_2090.m', ...
    'lastFilename', 'C:\Documents and Settings\Brinkman\Bureaublad\Drivers DSO 2090\Mathworks\versie1.fig');
appdata.lastValidTag = 'figure1';
appdata.GUIDELayoutEditor = [];
appdata.initTags = struct(...
    'handle', [], ...
    'tag', 'figure1');

h1 = figure(...
'Units','characters',...
'PaperUnits',get(0,'defaultfigurePaperUnits'),...
'Color',[0.925490196078431 0.913725490196078 0.847058823529412],...
'Colormap',[0 0 0.5625;0 0 0.625;0 0 0.6875;0 0 0.75;0 0 0.8125;0 0 0.875;0 0 0.9375;0 0 1;0 0.0625 1;0 0.125 1;0 0.1875 1;0 0.25 1;0 0.3125 1;0 0.375 1;0 0.4375 1;0 0.5 1;0 0.5625 1;0 0.625 1;0 0.6875 1;0 0.75 1;0 0.8125 1;0 0.875 1;0 0.9375 1;0 1 1;0.0625 1 1;0.125 1 0.9375;0.1875 1 0.875;0.25 1 0.8125;0.3125 1 0.75;0.375 1 0.6875;0.4375 1 0.625;0.5 1 0.5625;0.5625 1 0.5;0.625 1 0.4375;0.6875 1 0.375;0.75 1 0.3125;0.8125 1 0.25;0.875 1 0.1875;0.9375 1 0.125;1 1 0.0625;1 1 0;1 0.9375 0;1 0.875 0;1 0.8125 0;1 0.75 0;1 0.6875 0;1 0.625 0;1 0.5625 0;1 0.5 0;1 0.4375 0;1 0.375 0;1 0.3125 0;1 0.25 0;1 0.1875 0;1 0.125 0;1 0.0625 0;1 0 0;0.9375 0 0;0.875 0 0;0.8125 0 0;0.75 0 0;0.6875 0 0;0.625 0 0;0.5625 0 0],...
'IntegerHandle','off',...
'InvertHardcopy',get(0,'defaultfigureInvertHardcopy'),...
'MenuBar','none',...
'Name','versie1',...
'NumberTitle','off',...
'PaperPosition',get(0,'defaultfigurePaperPosition'),...
'PaperSize',[20.98404194812 29.67743169791],...
'PaperType',get(0,'defaultfigurePaperType'),...
'Position',[103.8 11.3846153846154 240.2 50.0769230769231],...
'Resize','off',...
'UseHG2','off',...
'HandleVisibility','callback',...
'Tag','figure1',...
'UserData',[],...
'Visible','on',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'axes1';

h2 = axes(...
'Parent',h1,...
'Units','characters',...
'Position',[29.8 3.76923076923077 140.2 34.6923076923077],...
'CameraPosition',[0.5 0.5 9.16025403784439],...
'CameraPositionMode',get(0,'defaultaxesCameraPositionMode'),...
'Color',get(0,'defaultaxesColor'),...
'ColorOrder',get(0,'defaultaxesColorOrder'),...
'LooseInset',[25.948 5.08538461538462 18.962 3.46730769230769],...
'XColor',get(0,'defaultaxesXColor'),...
'YColor',get(0,'defaultaxesYColor'),...
'ZColor',get(0,'defaultaxesZColor'),...
'Tag','axes1',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

h3 = get(h2,'title');

set(h3,...
'Parent',h2,...
'Units','data',...
'FontUnits','points',...
'BackgroundColor','none',...
'Color',[0 0 0],...
'DisplayName',blanks(0),...
'EdgeColor','none',...
'EraseMode','normal',...
'DVIMode','auto',...
'FontAngle','normal',...
'FontName','Helvetica',...
'FontSize',10,...
'FontWeight','normal',...
'HorizontalAlignment','center',...
'LineStyle','-',...
'LineWidth',0.5,...
'Margin',2,...
'Position',[0.5 1.01441241685144 1.00005459937205],...
'Rotation',0,...
'String',blanks(0),...
'Interpreter','tex',...
'VerticalAlignment','bottom',...
'ButtonDownFcn',[],...
'CreateFcn', {@local_CreateFcn, [], ''} ,...
'DeleteFcn',[],...
'BusyAction','queue',...
'HandleVisibility','off',...
'HelpTopicKey',blanks(0),...
'HitTest','on',...
'Interruptible','on',...
'SelectionHighlight','on',...
'Serializable','on',...
'Tag',blanks(0),...
'UserData',[],...
'Visible','on',...
'XLimInclude','on',...
'YLimInclude','on',...
'ZLimInclude','on',...
'CLimInclude','on',...
'ALimInclude','on',...
'IncludeRenderer','on',...
'Clipping','off');

h4 = get(h2,'xlabel');

set(h4,...
'Parent',h2,...
'Units','data',...
'FontUnits','points',...
'BackgroundColor','none',...
'Color',[0 0 0],...
'DisplayName',blanks(0),...
'EdgeColor','none',...
'EraseMode','normal',...
'DVIMode','auto',...
'FontAngle','normal',...
'FontName','Helvetica',...
'FontSize',10,...
'FontWeight','normal',...
'HorizontalAlignment','center',...
'LineStyle','-',...
'LineWidth',0.5,...
'Margin',2,...
'Position',[0.498573466476462 -0.0521064301552108 1.00005459937205],...
'Rotation',0,...
'String',blanks(0),...
'Interpreter','tex',...
'VerticalAlignment','cap',...
'ButtonDownFcn',[],...
'CreateFcn', {@local_CreateFcn, [], ''} ,...
'DeleteFcn',[],...
'BusyAction','queue',...
'HandleVisibility','off',...
'HelpTopicKey',blanks(0),...
'HitTest','on',...
'Interruptible','on',...
'SelectionHighlight','on',...
'Serializable','on',...
'Tag',blanks(0),...
'UserData',[],...
'Visible','on',...
'XLimInclude','on',...
'YLimInclude','on',...
'ZLimInclude','on',...
'CLimInclude','on',...
'ALimInclude','on',...
'IncludeRenderer','on',...
'Clipping','off');

h5 = get(h2,'ylabel');

set(h5,...
'Parent',h2,...
'Units','data',...
'FontUnits','points',...
'BackgroundColor','none',...
'Color',[0 0 0],...
'DisplayName',blanks(0),...
'EdgeColor','none',...
'EraseMode','normal',...
'DVIMode','auto',...
'FontAngle','normal',...
'FontName','Helvetica',...
'FontSize',10,...
'FontWeight','normal',...
'HorizontalAlignment','center',...
'LineStyle','-',...
'LineWidth',0.5,...
'Margin',2,...
'Position',[-0.0406562054208274 0.497782705099778 1.00005459937205],...
'Rotation',90,...
'String',blanks(0),...
'Interpreter','tex',...
'VerticalAlignment','bottom',...
'ButtonDownFcn',[],...
'CreateFcn', {@local_CreateFcn, [], ''} ,...
'DeleteFcn',[],...
'BusyAction','queue',...
'HandleVisibility','off',...
'HelpTopicKey',blanks(0),...
'HitTest','on',...
'Interruptible','on',...
'SelectionHighlight','on',...
'Serializable','on',...
'Tag',blanks(0),...
'UserData',[],...
'Visible','on',...
'XLimInclude','on',...
'YLimInclude','on',...
'ZLimInclude','on',...
'CLimInclude','on',...
'ALimInclude','on',...
'IncludeRenderer','on',...
'Clipping','off');

h6 = get(h2,'zlabel');

set(h6,...
'Parent',h2,...
'Units','data',...
'FontUnits','points',...
'BackgroundColor','none',...
'Color',[0 0 0],...
'DisplayName',blanks(0),...
'EdgeColor','none',...
'EraseMode','normal',...
'DVIMode','auto',...
'FontAngle','normal',...
'FontName','Helvetica',...
'FontSize',10,...
'FontWeight','normal',...
'HorizontalAlignment','right',...
'LineStyle','-',...
'LineWidth',0.5,...
'Margin',2,...
'Position',[-0.213266761768902 1.33148558758315 1.00005459937205],...
'Rotation',0,...
'String',blanks(0),...
'Interpreter','tex',...
'VerticalAlignment','middle',...
'ButtonDownFcn',[],...
'CreateFcn', {@local_CreateFcn, [], ''} ,...
'DeleteFcn',[],...
'BusyAction','queue',...
'HandleVisibility','off',...
'HelpTopicKey',blanks(0),...
'HitTest','on',...
'Interruptible','on',...
'SelectionHighlight','on',...
'Serializable','on',...
'Tag',blanks(0),...
'UserData',[],...
'Visible','off',...
'XLimInclude','on',...
'YLimInclude','on',...
'ZLimInclude','on',...
'CLimInclude','on',...
'ALimInclude','on',...
'IncludeRenderer','on',...
'Clipping','off');

appdata = [];
appdata.lastValidTag = 'on_off';

h7 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'BackgroundColor',get(0,'defaultuicontrolBackgroundColor'),...
'Callback','DSO_2090(''on_off_Callback'',gcbo,[],guidata(gcbo))',...
'Position',[9.8 42.3076923076923 10.2 3.84615384615385],...
'String','ON',...
'Style','togglebutton',...
'Tag','on_off',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'uipanel4';

h8 = uipanel(...
'Parent',h1,...
'Units','characters',...
'Title',blanks(0),...
'Tag','uipanel4',...
'Clipping','on',...
'BackgroundColor',get(0,'defaultuipanelBackgroundColor'),...
'Position',[179.8 28.6923076923077 50.2 8],...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'popupmenu6';

h9 = uicontrol(...
'Parent',h8,...
'Units','characters',...
'BackgroundColor',[1 1 1],...
'Callback','DSO_2090(''popupmenu6_Callback'',gcbo,[],guidata(gcbo))',...
'Position',[4.6 5.07692307692308 40.2 1.69230769230769],...
'String',{  '10 mV'; '20 mV'; '50 mV'; '100 mV'; '200 mV'; '500 mV'; '1 V'; '2 V'; '5 V'; blanks(0) },...
'Style','popupmenu',...
'Value',4,...
'CreateFcn', {@local_CreateFcn, 'DSO_2090(''popupmenu6_CreateFcn'',gcbo,[],guidata(gcbo))', appdata} ,...
'Tag','popupmenu6');

appdata = [];
appdata.lastValidTag = 'popupmenu4';

h10 = uicontrol(...
'Parent',h8,...
'Units','characters',...
'BackgroundColor',[1 1 1],...
'Callback','DSO_2090(''popupmenu4_Callback'',gcbo,[],guidata(gcbo))',...
'Position',[4.4 1.30769230769231 40.2 1.69230769230769],...
'String',{  '10 mV'; '20 mV'; '50 mV'; '100 mV'; '200 mV'; '500 mV'; '1 V'; '2 V'; '5 V'; blanks(0) },...
'Style','popupmenu',...
'Value',6,...
'CreateFcn', {@local_CreateFcn, 'DSO_2090(''popupmenu4_CreateFcn'',gcbo,[],guidata(gcbo))', appdata} ,...
'Tag','popupmenu4');

appdata = [];
appdata.lastValidTag = 'uipanel5';

h11 = uipanel(...
'Parent',h1,...
'Units','characters',...
'Title',blanks(0),...
'Tag','uipanel5',...
'Clipping','on',...
'BackgroundColor',get(0,'defaultuipanelBackgroundColor'),...
'Position',[179.8 38.3846153846154 50.2 7.76923076923077],...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'popupmenu3';

h12 = uicontrol(...
'Parent',h11,...
'Units','characters',...
'BackgroundColor',[1 1 1],...
'Callback','DSO_2090(''popupmenu3_Callback'',gcbo,[],guidata(gcbo))',...
'Position',[5.6 5.15384615384615 40.2 1.53846153846154],...
'String',{  '4 nS'; '10 nS'; '20 nS'; '40 nS'; '0.1 uS'; '0.2 uS'; '0.4 uS'; '1 uS'; '2 uS'; '4 uS'; '10 uS'; '20 uS'; '40 uS'; '0.1 mS'; '0.2 mS'; '0.4 mS'; '1 mS'; '2 mS'; '4 mS'; '10 mS'; '20 mS'; '40 mS'; '0.1 S'; '0.2 S'; '0.4 S'; '1 S'; '2 S'; '4 S'; '10 S'; '20 S'; '40 S'; '1 Min'; '2 Min'; '4 Min'; '10 Min'; '20 Min'; '40 Min'; '1 Hour' },...
'Style','popupmenu',...
'Value',12,...
'CreateFcn', {@local_CreateFcn, 'DSO_2090(''popupmenu3_CreateFcn'',gcbo,[],guidata(gcbo))', appdata} ,...
'Tag','popupmenu3');

appdata = [];
appdata.lastValidTag = 'popupmenu5';

h13 = uicontrol(...
'Parent',h11,...
'Units','characters',...
'BackgroundColor',[1 1 1],...
'Callback','DSO_2090(''popupmenu5_Callback'',gcbo,[],guidata(gcbo))',...
'Enable','inactive',...
'Position',[5.6 1.23076923076923 40.2 1.53846153846154],...
'String',{  '100000000'; '100000000'; '100000000'; '100000000'; '100000000'; '100000000'; '100000000'; '100000000'; '100000000'; '100000000'; '100000000'; '50000000'; '25000000'; '10000000'; '5000000'; '2500000'; '1000000'; '500000'; '250000'; '100000'; '50000'; '25000'; '10000'; '5000'; '2500'; '50'; '25'; '12.5'; '5'; '2.5'; '1.25'; '0.83'; '0.42'; '0.21'; '0.083'; '0.042'; '0.021'; '0.014' },...
'Style','popupmenu',...
'Value',1,...
'CreateFcn', {@local_CreateFcn, 'DSO_2090(''popupmenu5_CreateFcn'',gcbo,[],guidata(gcbo))', appdata} ,...
'Tag','popupmenu5');


hsingleton = h1;


% --- Set application data first then calling the CreateFcn. 
function local_CreateFcn(hObject, eventdata, createfcn, appdata)

if ~isempty(appdata)
   names = fieldnames(appdata);
   for i=1:length(names)
       name = char(names(i));
       setappdata(hObject, name, getfield(appdata,name));
   end
end

if ~isempty(createfcn)
   eval(createfcn);
end


% --- Handles default GUIDE GUI creation and callback dispatch
function varargout = gui_mainfcn(gui_State, varargin)

gui_StateFields =  {'gui_Name'
    'gui_Singleton'
    'gui_OpeningFcn'
    'gui_OutputFcn'
    'gui_LayoutFcn'
    'gui_Callback'};
gui_Mfile = '';
for i=1:length(gui_StateFields)
    if ~isfield(gui_State, gui_StateFields{i})
        error('MATLAB:gui_mainfcn:FieldNotFound', 'Could not find field %s in the gui_State struct in GUI M-file %s', gui_StateFields{i}, gui_Mfile);
    elseif isequal(gui_StateFields{i}, 'gui_Name')
        gui_Mfile = [gui_State.(gui_StateFields{i}), '.m'];
    end
end

numargin = length(varargin);

if numargin == 0
    % DSO_2090
    % create the GUI only if we are not in the process of loading it
    % already
    gui_Create = true;
elseif local_isInvokeActiveXCallback(gui_State, varargin{:})
    % DSO_2090(ACTIVEX,...)
    vin{1} = gui_State.gui_Name;
    vin{2} = [get(varargin{1}.Peer, 'Tag'), '_', varargin{end}];
    vin{3} = varargin{1};
    vin{4} = varargin{end-1};
    vin{5} = guidata(varargin{1}.Peer);
    feval(vin{:});
    return;
elseif local_isInvokeHGCallbak(gui_State, varargin{:})
    % DSO_2090('CALLBACK',hObject,eventData,handles,...)
    gui_Create = false;
else
    % DSO_2090(...)
    % create the GUI and hand varargin to the openingfcn
    gui_Create = true;
end

if ~gui_Create
    % In design time, we need to mark all components possibly created in
    % the coming callback evaluation as non-serializable. This way, they
    % will not be brought into GUIDE and not be saved in the figure file
    % when running/saving the GUI from GUIDE.
    designEval = false;
    if (numargin>1 && ishghandle(varargin{2}))
        fig = varargin{2};
        while ~isempty(fig) && ~isa(handle(fig),'figure')
            fig = get(fig,'parent');
        end
        
        designEval = isappdata(0,'CreatingGUIDEFigure') || isprop(fig,'__GUIDEFigure');
    end
        
    if designEval
        beforeChildren = findall(fig);
    end
    
    % evaluate the callback now
    varargin{1} = gui_State.gui_Callback;
    if nargout
        [varargout{1:nargout}] = feval(varargin{:});
    else       
        feval(varargin{:});
    end
    
    % Set serializable of objects created in the above callback to off in
    % design time. Need to check whether figure handle is still valid in
    % case the figure is deleted during the callback dispatching.
    if designEval && ishandle(fig)
        set(setdiff(findall(fig),beforeChildren), 'Serializable','off');
    end
else
    if gui_State.gui_Singleton
        gui_SingletonOpt = 'reuse';
    else
        gui_SingletonOpt = 'new';
    end

    % Check user passing 'visible' P/V pair first so that its value can be
    % used by oepnfig to prevent flickering
    gui_Visible = 'auto';
    gui_VisibleInput = '';
    for index=1:2:length(varargin)
        if length(varargin) == index || ~ischar(varargin{index})
            break;
        end

        % Recognize 'visible' P/V pair
        len1 = min(length('visible'),length(varargin{index}));
        len2 = min(length('off'),length(varargin{index+1}));
        if ischar(varargin{index+1}) && strncmpi(varargin{index},'visible',len1) && len2 > 1
            if strncmpi(varargin{index+1},'off',len2)
                gui_Visible = 'invisible';
                gui_VisibleInput = 'off';
            elseif strncmpi(varargin{index+1},'on',len2)
                gui_Visible = 'visible';
                gui_VisibleInput = 'on';
            end
        end
    end
    
    % Open fig file with stored settings.  Note: This executes all component
    % specific CreateFunctions with an empty HANDLES structure.

    
    % Do feval on layout code in m-file if it exists
    gui_Exported = ~isempty(gui_State.gui_LayoutFcn);
    % this application data is used to indicate the running mode of a GUIDE
    % GUI to distinguish it from the design mode of the GUI in GUIDE. it is
    % only used by actxproxy at this time.   
    setappdata(0,genvarname(['OpenGuiWhenRunning_', gui_State.gui_Name]),1);
    if gui_Exported
        gui_hFigure = feval(gui_State.gui_LayoutFcn, gui_SingletonOpt);

        % make figure invisible here so that the visibility of figure is
        % consistent in OpeningFcn in the exported GUI case
        if isempty(gui_VisibleInput)
            gui_VisibleInput = get(gui_hFigure,'Visible');
        end
        set(gui_hFigure,'Visible','off')

        % openfig (called by local_openfig below) does this for guis without
        % the LayoutFcn. Be sure to do it here so guis show up on screen.
        movegui(gui_hFigure,'onscreen');
    else
        gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt, gui_Visible);
        % If the figure has InGUIInitialization it was not completely created
        % on the last pass.  Delete this handle and try again.
        if isappdata(gui_hFigure, 'InGUIInitialization')
            delete(gui_hFigure);
            gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt, gui_Visible);
        end
    end
    if isappdata(0, genvarname(['OpenGuiWhenRunning_', gui_State.gui_Name]))
        rmappdata(0,genvarname(['OpenGuiWhenRunning_', gui_State.gui_Name]));
    end

    % Set flag to indicate starting GUI initialization
    setappdata(gui_hFigure,'InGUIInitialization',1);

    % Fetch GUIDE Application options
    gui_Options = getappdata(gui_hFigure,'GUIDEOptions');
    % Singleton setting in the GUI M-file takes priority if different
    gui_Options.singleton = gui_State.gui_Singleton;

    if ~isappdata(gui_hFigure,'GUIOnScreen')
        % Adjust background color
        if gui_Options.syscolorfig
            set(gui_hFigure,'Color', get(0,'DefaultUicontrolBackgroundColor'));
        end

        % Generate HANDLES structure and store with GUIDATA. If there is
        % user set GUI data already, keep that also.
        data = guidata(gui_hFigure);
        handles = guihandles(gui_hFigure);
        if ~isempty(handles)
            if isempty(data)
                data = handles;
            else
                names = fieldnames(handles);
                for k=1:length(names)
                    data.(char(names(k)))=handles.(char(names(k)));
                end
            end
        end
        guidata(gui_hFigure, data);
    end

    % Apply input P/V pairs other than 'visible'
    for index=1:2:length(varargin)
        if length(varargin) == index || ~ischar(varargin{index})
            break;
        end

        len1 = min(length('visible'),length(varargin{index}));
        if ~strncmpi(varargin{index},'visible',len1)
            try set(gui_hFigure, varargin{index}, varargin{index+1}), catch break, end
        end
    end

    % If handle visibility is set to 'callback', turn it on until finished
    % with OpeningFcn
    gui_HandleVisibility = get(gui_hFigure,'HandleVisibility');
    if strcmp(gui_HandleVisibility, 'callback')
        set(gui_hFigure,'HandleVisibility', 'on');
    end

    feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});

    if isscalar(gui_hFigure) && ishandle(gui_hFigure)
        % Handle the default callbacks of predefined toolbar tools in this
        % GUI, if any
        guidemfile('restoreToolbarToolPredefinedCallback',gui_hFigure); 
        
        % Update handle visibility
        set(gui_hFigure,'HandleVisibility', gui_HandleVisibility);

        % Call openfig again to pick up the saved visibility or apply the
        % one passed in from the P/V pairs
        if ~gui_Exported
            gui_hFigure = local_openfig(gui_State.gui_Name, 'reuse',gui_Visible);
        elseif ~isempty(gui_VisibleInput)
            set(gui_hFigure,'Visible',gui_VisibleInput);
        end
        if strcmpi(get(gui_hFigure, 'Visible'), 'on')
            figure(gui_hFigure);
            
            if gui_Options.singleton
                setappdata(gui_hFigure,'GUIOnScreen', 1);
            end
        end

        % Done with GUI initialization
        if isappdata(gui_hFigure,'InGUIInitialization')
            rmappdata(gui_hFigure,'InGUIInitialization');
        end

        % If handle visibility is set to 'callback', turn it on until
        % finished with OutputFcn
        gui_HandleVisibility = get(gui_hFigure,'HandleVisibility');
        if strcmp(gui_HandleVisibility, 'callback')
            set(gui_hFigure,'HandleVisibility', 'on');
        end
        gui_Handles = guidata(gui_hFigure);
    else
        gui_Handles = [];
    end

    if nargout
        [varargout{1:nargout}] = feval(gui_State.gui_OutputFcn, gui_hFigure, [], gui_Handles);
    else
        feval(gui_State.gui_OutputFcn, gui_hFigure, [], gui_Handles);
    end

    if isscalar(gui_hFigure) && ishandle(gui_hFigure)
        set(gui_hFigure,'HandleVisibility', gui_HandleVisibility);
    end
end

function gui_hFigure = local_openfig(name, singleton, visible)

% openfig with three arguments was new from R13. Try to call that first, if
% failed, try the old openfig.
if nargin('openfig') == 2
    % OPENFIG did not accept 3rd input argument until R13,
    % toggle default figure visible to prevent the figure
    % from showing up too soon.
    gui_OldDefaultVisible = get(0,'defaultFigureVisible');
    set(0,'defaultFigureVisible','off');
    gui_hFigure = openfig(name, singleton);
    set(0,'defaultFigureVisible',gui_OldDefaultVisible);
else
    gui_hFigure = openfig(name, singleton, visible);
end

function result = local_isInvokeActiveXCallback(gui_State, varargin)

try
    result = ispc && iscom(varargin{1}) ...
             && isequal(varargin{1},gcbo);
catch
    result = false;
end

function result = local_isInvokeHGCallbak(gui_State, varargin)

try
    fhandle = functions(gui_State.gui_Callback);
    result = ~isempty(findstr(gui_State.gui_Name,fhandle.file)) || ...
             (ischar(varargin{1}) ...
             && isequal(ishandle(varargin{2}), 1) ...
             && ~isempty(strfind(varargin{1},[get(varargin{2}, 'Tag'), '_'])));
catch
    result = false;
end


Contact us at files@mathworks.com