-
Notifications
You must be signed in to change notification settings - Fork 0
/
Setup_Control_UI.m
245 lines (225 loc) · 15.4 KB
/
Setup_Control_UI.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
function [] = Setup_Control_UI ()
%% Create window and buttons
addpath(genpath(pwd))
window = figure();
set(window,'Name','PCS','NumberTitle','off','Position',[80 80 380 470],'MenuBar','none','Color',0.95*[1 1 1])
uicontrol('Parent',window,'Style','text','Position',[30 380 160 80],'FontSize',11,'String','V2 Nanolab May 2020');
% Create setup control object and start communication
addprop(window,'Control');
window.Control = SetupControl;
window.Control.InitComms;
set(0, 'CurrentFigure', window)
% Count connected equipments
addprop(window,'NumberOfLockins');
addprop(window,'NumberOfSourceMeters');
addprop(window,'NumberOfElectrometers');
addprop(window,'SourceMeterChannels');
addprop(window,'T'); %T stores all Temperature Controls
addprop(window,'UIHandles'); %UIHandles stores all uicontrols
window.NumberOfLockins = length(window.Control.equipment.LI);
window.NumberOfSourceMeters = length(window.Control.equipment.SM);
window.NumberOfElectrometers = length(window.Control.equipment.EM);
window.SourceMeterChannels = zeros(1,length(window.Control.equipment.SM));
% Detect number of SM channels
for ind = 1:window.NumberOfSourceMeters
SourceMeterModel=window.Control.IDN('SM',ind);
if contains(SourceMeterModel,'Model 2611')
window.SourceMeterChannels(ind)=1;
elseif contains(SourceMeterModel,'Model 2601')
window.SourceMeterChannels(ind)=1;
elseif contains(SourceMeterModel,'Model 2614B')
window.SourceMeterChannels(ind)=2;
end
end
%% LE Panel (Load Experiments)
panel_LE = uipanel('Title','Load Experiment','FontSize',10,'Units','pixels','Position',[30 350 160 80]);
LE.p_SelectExperiment = uicontrol('Parent',panel_LE,'Style','PopupMenu','String',ls('.scripts/*.m'),'Position',[10 30 140 25]);
LE_loadnow_callback = @(varargin) run(strcat('.scripts/',LE.p_SelectExperiment.String(LE.p_SelectExperiment.Value,:)));
LE.b_LoadExperiment = uicontrol('Parent',panel_LE,'Style','PushButton','String','Load Now','Position',[10 5 140 25],'Callback',LE_loadnow_callback);
%% LA PANEL (Laser)
panel_LA = uipanel('Title','Laser Control','FontSize',10,'Units','pixels','Position',[200 220 160 130]);
window.UIHandles.t_LApercent = uicontrol('Parent',panel_LA,'Style','text','Position',[7 7 55 20],'String','POWER %');
window.UIHandles.e_LAPower = uicontrol('Parent',panel_LA,'Style','edit','String','0','Position',[65 10 40 20],'BackgroundColor','w','Tag','LABias');
window.UIHandles.b_GoToLAPower = uicontrol('Parent',panel_LA,'Style','PushButton','String','Set','Position',[110 7 40 25],'Callback',@LA_go_callback);
window.UIHandles.t_LApercent = uicontrol('Parent',panel_LA,'Style','text','Position',[0 80 100 25],'String','Turn Emission');
window.UIHandles.b_LAOnPower = uicontrol('Parent',panel_LA,'Style','PushButton','String','ON','Position',[5 65 40 25],'BackgroundColor','green','ForegroundColor','black','Callback',@LA_on_callback);
window.UIHandles.b_LAOffPower = uicontrol('Parent',panel_LA,'Style','PushButton','String','OFF','Position',[50 65 40 25],'BackgroundColor','red','ForegroundColor','white','Callback',@LA_off_callback);
window.UIHandles.t_LARead = uicontrol('Parent',panel_LA,'Style','togglebutton','Position',[5 35 40 25],'String','Read','Callback',@LA_read_callback);
window.UIHandles.e_LAReadout = uicontrol('Parent',panel_LA,'Style','edit','Position',[50 35 80 25],'BackgroundColor','k','ForegroundColor','w','String',' ','Tag','LAReadout');
window.UIHandles.t_LApercent2 = uicontrol('Parent',panel_LA,'Style','text','Position',[132 42 15 15],'FontSize',11,'String','%');
%% LI Panel (Lock Ins)
panel_LIC=uipanel('Title','Lock-In Control','FontSize',10,'Units','pixels','Position',[30 220 160 130]);
window.UIHandles.txt_LIFreq=uicontrol('Parent',panel_LIC,'Style','text','Position',[7 4 55 20],'String','f(Hz)');
window.UIHandles.edit_LIFreq=uicontrol('Parent',panel_LIC,'Style','edit','String','0','Position',[65 6 40 20],'BackgroundColor','w','Tag','LIFreq');
window.UIHandles.b_GoToLIFreq=uicontrol('Parent',panel_LIC,'Style','PushButton','String','Go','Position',[110 5 40 22],'Callback',@UIHandles_GoToLIFreqCallback);
window.UIHandles.t_LIReadout = uicontrol('Parent',panel_LIC,'Style','togglebutton','Position',[5 30 40 22],'String','Read','Callback',@UIHandles_LIReadoutCallback);
window.UIHandles.txt_LIReadout = uicontrol('Parent',panel_LIC,'Style','text','Position',[50 32 55 20],'BackgroundColor','k','ForegroundColor','w','String',' ','Tag','LIReadout');
window.UIHandles.popup_LIReadoutVar = uicontrol('Parent',panel_LIC,'Style','popupmenu','Position',[110 33 40 20],'String',{'f','R','?','X','Y'},'Tag','LIReadout');
window.UIHandles.txt_LISens=uicontrol('Parent',panel_LIC,'Style','text','Position',[0 80 55 20],'String','Sensitivy');
window.UIHandles.popup_LISensitivity = uicontrol('Parent',panel_LIC,'Style','popupmenu','Position',[50 80 55 25],'String',{"2nV","5nV","10nV","20nV","50nV","100nV","200nV",...
"500nV","1muV","2muV","5muV","10muV","20muV","50muV",...
"100muV","200muV","500muV","1mV","2mV","5mV","10mV",...
"20mV","50mV","100mV","200mV","500mV","1V"},'Tag','LISens');
window.UIHandles.b_GoToLISens=uicontrol('Parent',panel_LIC,'Style','PushButton','String','Go','Position',[110 82 40 25],'Callback',@UIHandles_GoToLISensCallback);
window.UIHandles.t_LIReadSens = uicontrol('Parent',panel_LIC,'Style','PushButton','Position',[5 57 40 22],'String','Sens','Callback',@UIHandles_LIReadSensCallback);
window.UIHandles.txt_LIReadSens = uicontrol('Parent',panel_LIC,'Style','text','Position',[50 57 55 20],'BackgroundColor','k','ForegroundColor','w','String',' ','Tag','LIReadSens');
%% SM Panel (Source Meters)
panel_SM = uipanel('Title','Source-Meter Control','FontSize',10,'Units','pixels','Position',[30 20 160 190]);
window.UIHandles.txt_Vbias = uicontrol('Parent',panel_SM,'Style','text','Position',[0 5 50 25],'String','Vbias');
window.UIHandles.edit_Vbias = uicontrol('Parent',panel_SM,'Style','edit','String','0','Position',[50 10 40 25],'BackgroundColor','w','Tag','SMBias');
window.UIHandles.b_GoToVbias = uicontrol('Parent',panel_SM,'Style','PushButton','String','Go','Position',[100 10 40 25],'Callback',@SM_go_callback);
window.UIHandles.txt_Vstep = uicontrol('Parent',panel_SM,'Style','text','Position',[0 35 90 25],'String','Step Size (V)');
window.UIHandles.edit_Vstep = uicontrol('Parent',panel_SM,'Style','edit','String','0.01','Position',[100 40 40 25],'BackgroundColor','w');
window.UIHandles.txt_Vdelay = uicontrol('Parent',panel_SM,'Style','text','Position',[0 65 90 25],'String','Vdelay (s/step)');
window.UIHandles.edit_Vdelay = uicontrol('Parent',panel_SM,'Style','edit','String','0.1','Position',[100 70 40 25],'BackgroundColor','w');
window.UIHandles.txt_Index = uicontrol('Parent',panel_SM,'Style','text','Position',[0 125 40 25],'String','Index');
window.UIHandles.edit_Index = uicontrol('Parent',panel_SM,'Style','edit','Position',[40 135 20 20],'String','1','Tag','SMIndex');
window.UIHandles.txt_Channel = uicontrol('Parent',panel_SM,'Style','text','Position',[70 125 50 25],'String','Channel');
window.UIHandles.edit_Channel = uicontrol('Parent',panel_SM,'Style','edit','Position',[120 135 20 20],'String','1','Tag','SMChannel');
window.UIHandles.t_Readout = uicontrol('Parent',panel_SM,'Style','togglebutton','Position',[10 100 50 25],'String','Read','Callback',@SM_read_callback);
window.UIHandles.txt_Readout = uicontrol('Parent',panel_SM,'Style','edit','Position',[70 100 70 25],'BackgroundColor','k','ForegroundColor','w','String',' ','Tag','SMCurrent');
%% TC Panel (Temp Controller)
panel_TC = uipanel('Title','ITC 503 Control','FontSize',10,'Units','pixels','Position',[200 20 160 190]);
window.T.txt_T = uicontrol('Parent',panel_TC,'Style','text','Position',[0 5 50 25],'String','Set T(K)');
window.T.edit_T = uicontrol('Parent',panel_TC,'Style','edit','String','0','Position',[50 10 40 25],'BackgroundColor','w','Tag','T');
window.T.b_GoToT = uicontrol('Parent',panel_TC,'Style','PushButton','String','Go','Position',[100 10 40 25],'Callback',@TC_go_callback);
window.T.txt_Tol = uicontrol('Parent',panel_TC,'Style','text','Position',[0 35 50 25],'String','Tol(K)');
window.T.edit_Tol = uicontrol('Parent',panel_TC,'Style','edit','String','0.01','Position',[50 40 40 25],'BackgroundColor','w','Tag','Tol');
window.T.txt_Time = uicontrol('Parent',panel_TC,'Style','text','Position',[0 65 50 25],'String','Time(s)');
window.T.edit_Time = uicontrol('Parent',panel_TC,'Style','edit','String','10','Position',[50 70 40 25],'BackgroundColor','w','Tag','Time');
window.T.t_Readout = uicontrol('Parent',panel_TC,'Style','togglebutton','Position',[5 140 70 25],'String','Read T(K)','Callback',@TC_read_callback);
window.T.txt_Readout = uicontrol('Parent',panel_TC,'Style','edit','Position',[80 140 70 25],'BackgroundColor','k','ForegroundColor','w','String',' ','Tag','T');
window.T.t_SettReadout = uicontrol('Parent',panel_TC,'Style','togglebutton','Position',[5 110 70 25],'String','Set T(K)','Callback',@TC_set_callback);
window.T.txt_SettReadout = uicontrol('Parent',panel_TC,'Style','edit','Position',[80 110 70 25],'BackgroundColor','k','ForegroundColor','w','String',' ','Tag','SetT');
window.T.edit_OK = uicontrol('Parent',panel_TC,'Style','edit','String','OK','Position',[110 70 40 25],'BackgroundColor','w','Tag','OK');
%% WL Panel (Spectrometer and Monochromator)
panel_WL = uipanel('Title','Wavelength','FontSize',10,'Units','pixels','Position',[200 350 160 80]);
window.UIHandles.t_WL =uicontrol('Parent',panel_WL,'Style','togglebutton','String','Read WL(nm)','Position',[5 5 70 25],'Callback',@WL_read_callback);
window.UIHandles.txt_readout = uicontrol('Parent',panel_WL,'Style','edit','String','0','Position',[80 5 60 25],'BackgroundColor','k','ForegroundColor','w','String',' ', 'Tag','WL');
window.UIHandles.t_MS257move=uicontrol('Parent',panel_WL,'Style','PushButton','String','Set WL(nm)','Position',[5 35 70 25],'Callback',@WL_Set_callback);
window.UIHandles.e_WL = uicontrol('Parent',panel_WL,'Style','edit','String','0','Position',[80 35 60 25],'BackgroundColor','w','Tag','WL');
%% SM Callbacks
function [] = SM_read_callback(varargin)
while window.UIHandles.t_Readout.Value
ind = str2double(window.UIHandles.edit_Index.String);
channel = str2double(window.UIHandles.edit_Channel.String);
if ~isempty('window.Control.equipment.SM')
if length(window.Control.equipment.SM)>=ind
if channel<=window.SourceMeterChannels(ind)
r = str2double(window.Control.SM_ReadI(ind,channel));
window.UIHandles.txt_Readout.String = num2str(r(:),'%10.3e');
else
window.UIHandles.t_Readout.Value=0;
warning('not enougth channels')
end
else
window.UIHandles.t_Readout.Value=0;
warning('index exceeds number of Source Meters')
end
else
window.UIHandles.t_Readout.Value=0;
warning('No Source Meters found')
end
pause(0.01)
end
end
function [] = SM_go_callback(varargin)
ind = str2double(window.UIHandles.edit_Index.String);
channel = str2double(window.UIHandles.edit_Channel.String);
Vstart = str2double(window.Control.SM_ReadV(ind,channel));
Vend = str2double(window.UIHandles.edit_Vbias.String);
Vstep = str2double(window.UIHandles.edit_Vstep.String);
delay = str2double(window.UIHandles.edit_Vdelay.String);
window.Control.SM_RampV(ind,channel,Vstart,Vend,Vstep,delay)
end
%% TC Callbacks
function [] = TC_read_callback(varargin)
while window.T.t_Readout.Value
t = window.Control.ITC503_ReadT;
window.T.txt_Readout.String = num2str(t(:),'%10.3f');
pause(0.2);
end
end
function [] = TC_go_callback(varargin)
window.T.edit_OK.String = 'Not OK';
SetT = str2double(window.T.edit_T.String);
Tol = str2double(window.T.edit_Tol.String);
Time = str2double(window.T.edit_Time.String);
stabilization = window.Control.ITC503_SetT(SetT,Tol,Time);
x = stabilization;
if x==0
window.T.edit_OK.String = 'Not OK';
else
window.T.edit_OK.String = 'OK';
end
end
function [] = TC_set_callback(varargin)
St = window.Control.ITC503_ReadSetT;
window.T.txt_SettReadout.String = num2str(St(:),'%10.3f');
end
%% LI Callbacks
function [] = UIHandles_LIReadoutCallback(varargin)
while window.UIHandles.t_LIReadout.Value
switch window.UIHandles.popup_LIReadoutVar.Value
case 1
output = window.Control.LI_FreqRead;
case 2
[xr,yt] = window.Control.LI_Read('rt');
output = xr;
case 3
[xr,yt] = window.Control.LI_Read('rt');
output = yt;
case 4
[xr,yt] = window.Control.LI_Read('xy');
output = xr;
case 5
[xr,yt] = window.Control.LI_Read('xy');
output = yt;
end
window.UIHandles.txt_LIReadout.String=num2str(output,'%10.3f');
pause(0.1);
end
end
function [] = UIHandles_GoToLIFreqCallback(varargin)
ind = 1;
FREQ = str2num(window.UIHandles.edit_LIFreq.String)
window.Control.LI_FreqSet(ind,FREQ)
end
function [] = UIHandles_GoToLISensCallback(varargin)
ind=1;
i = window.UIHandles.popup_LISensitivity.Value;
window.Control.LI_SensSet(ind,i-1)
end
function [] = UIHandles_LIReadSensCallback(varargin)
window.UIHandles.txt_LIReadSens.String=window.Control.LI_SensRead;
end
%% LASER Callbacks
function [] = LA_read_callback(varargin)
while window.UIHandles.t_LARead.Value
p = window.Control.LAread;
window.UIHandles.e_LAReadout.String = str2double(p);
pause(1);
end
end
function [] = LA_go_callback(varargin)
pw=str2double(window.UIHandles.e_LAPower.String);
window.Control.LAgo(pw)
end
function [] = LA_on_callback(varargin)
window.Control.LAon()
end
function [] = LA_off_callback(varargin)
window.Control.LAoff()
end
%% Spectrometer Callbacks
function [] = WL_read_callback(varargin)
while window.UIHandles.t_WL.Value
window.UIHandles.txt_readout.String = num2str(window.Control.SPread);
pause(0.1)
end
end
function [] = WL_Set_callback(varargin)
WL=str2double(window.UIHandles.e_WL.String);
window.Control.MS257move(WL)
end
end