PageRenderTime 30ms CodeModel.GetById 17ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/matlab/Laser.asv

http://github.com/Yniold/liftsrc
Unknown | 646 lines | 559 code | 87 blank | 0 comment | 0 complexity | 788a0d2dc4c66b640f73c14a046b306c MD5 | raw file
  1function varargout = Laser(varargin)
  2% GUI for pump laser control
  3% diode current should be 35.4 for PSSN 120865, HEADSN 2363/710
  4% diode temperature should be 26.1?C for PSSN 120865, HEADSN 2363/710
  5% crystal temperature should be 151 for PSSN 120865, HEADSN 2363/710
  6
  7% LASER M-file for Laser.fig
  8%      LASER, by itself, creates a new LASER or raises the existing
  9%      singleton*.
 10%
 11%      H = LASER returns the handle to a new LASER or the handle to
 12%      the existing singleton*.
 13%
 14%      LASER('CALLBACK',hObject,eventData,handles,...) calls the local
 15%      function named CALLBACK in LASER.M with the given input arguments.
 16%
 17%      LASER('Property','Value',...) creates a new LASER or raises the
 18%      existing singleton*.  Starting from the left, property value pairs are
 19%      applied to the GUI before Laser_OpeningFunction gets called.  An
 20%      unrecognized property name or invalid value makes property application
 21%      stop.  All inputs are passed to Laser_OpeningFcn via varargin.
 22%
 23%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
 24%      instance to run (singleton)".
 25%
 26% See also: GUIDE, GUIDATA, GUIHANDLES
 27
 28% Copyright 2002-2003 The MathWorks, Inc.
 29
 30% Edit the above text to modify the response to help Laser
 31
 32% Last Modified by GUIDE v2.5 09-Feb-2005 14:06:24
 33
 34% Begin initialization code - DO NOT EDIT
 35gui_Singleton = 1;
 36gui_State = struct('gui_Name',       mfilename, ...
 37                   'gui_Singleton',  gui_Singleton, ...
 38                   'gui_OpeningFcn', @Laser_OpeningFcn, ...
 39                   'gui_OutputFcn',  @Laser_OutputFcn, ...
 40                   'gui_LayoutFcn',  [] , ...
 41                   'gui_Callback',   []);
 42if nargin && ischar(varargin{1})
 43    gui_State.gui_Callback = str2func(varargin{1});
 44end
 45
 46if nargout
 47    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
 48else
 49    gui_mainfcn(gui_State, varargin{:});
 50end
 51% End initialization code - DO NOT EDIT
 52
 53
 54% --- Executes just before Laser is made visible.
 55function Laser_OpeningFcn(hObject, eventdata, handles, varargin)
 56% This function has no output args, see OutputFcn.
 57% hObject    handle to figure
 58% eventdata  reserved - to be defined in a future version of MATLAB
 59% handles    structure with handles and user data (see GUIDATA)
 60% varargin   command line arguments to Laser (see VARARGIN)
 61
 62% Choose default command line output for Laser
 63handles.output = hObject;
 64
 65% get horus handle
 66if length(varargin)==2 & varargin{1}=='handle'
 67    handles.parenthandle=str2double(varargin{2});
 68end
 69
 70% open tcpip port for communication with Laser
 71echotcpip('on',10001);
 72tcpdata.tport=tcpip('10.111.111.20',10001);
 73set(tcpdata.tport,'ReadAsyncMode','continuous');
 74set(tcpdata.tport,'BytesAvailableFcn',{'tcpipdatacallback'});
 75fopen(tcpdata.tport);
 76tport=tcpdata.tport;
 77
 78% check which laser head and power supply is being used and display what
 79% the settings should be
 80fprintf(tport,'?PSSN'); 
 81pause(0.5);
 82PSSN=tport.UserData;
 83fprintf(tport,'?HEADSN'); 
 84pause(0.5);
 85HEADSN=tport.UserData;
 86
 87% diode current should be 35.4 for PSSN 120865, HEADSN 2363/710
 88% diode temperature should be 26.1?C for PSSN 120865, HEADSN 2363/710
 89% crystal temperature should be 151 for PSSN 120865, HEADSN 2363/710
 90
 91% diode current should be 36.0 for PSSN 120881, HEADSN 2366/712
 92% diode temperature should be 28.6?C for PSSN 120881, HEADSN 2366/712
 93% crystal temperature should be 130 for PSSN 120881, HEADSN 2366/712
 94
 95set(handles.txtsetReprate,'String','3000 kHz'); % pulses/s
 96if PSSN(1:6)=='120865'
 97    set(handles.txtsetDiodeCurrent,'String','35.4 A');
 98    set(handles.txtsetDiodeTemp,'String','26.1 C');
 99    set(handles.txtsetIRPower,'String','4.5 W'); % IR intern
100elseif PSSN(1:6)=='120881'
101    set(handles.txtsetDiodeCurrent,'String','36.0 A');
102    set(handles.txtsetDiodeTemp,'String','28.6 C');
103    set(handles.txtsetIRPower,'String','4.45 W'); % IR intern
104end
105if HEADSN(1:8)=='2363/710'
106    set(handles.txtsetCrtemp,'String','151'); % ADC Counts
107    set(handles.txtsetTowerTemp,'String','??? C');
108elseif HEADSN(1:8)=='2366/712'
109    set(handles.txtsetCrtemp,'String','130'); % ADC Counts
110    set(handles.txtsetTowerTemp,'String','28.6 C');    
111end
112
113% Update handles structure
114guidata(hObject, handles);
115
116setappdata(handles.output, 'tcpdata', tcpdata); 
117
118
119% --- Outputs from this function are returned to the command line.
120function varargout = Laser_OutputFcn(hObject, eventdata, handles) 
121% varargout  cell array for returning output args (see VARARGOUT);
122% hObject    handle to figure
123% eventdata  reserved - to be defined in a future version of MATLAB
124% handles    structure with handles and user data (see GUIDATA)
125
126% Get default command line output from handles structure
127varargout{1} = handles.output;
128
129
130% --- Executes on button press in toggleLaser.
131function toggleLaser_Callback(hObject, eventdata, handles)
132% hObject    handle to toggleLaser (see GCBO)
133% eventdata  reserved - to be defined in a future version of MATLAB
134% handles    structure with handles and user data (see GUIDATA)
135set(handles.txtStatus,'String','Query Status','ForegroundColor','r');
136Zeit=clock;
137set(handles.txtZeit,'String',datestr(Zeit,13));
138
139%mark strings to be updated
140set(handles.txtDiodeCurrent,'ForegroundColor','r');
141set(handles.txtIRPower,'ForegroundColor','r');
142set(handles.txtDiodeTemp,'ForegroundColor','r');
143set(handles.txtTowerTemp,'ForegroundColor','r');
144
145% switch laser on or off
146tcpdata = getappdata(handles.output, 'tcpdata'); 
147tport=tcpdata.tport;
148if get(hObject,'Value')
149    fprintf(tport,'D1'); 
150    set(hObject,'BackgroundColor','r');
151    set(hObject,'String','Laser switched ON')
152    pause(0.5);
153else
154    fprintf(tport,'D0');
155    set(hObject,'BackgroundColor','y');
156    set(hObject,'String','Laser switched OFF')
157    pause(0.5);
158end
159pause(3) 
160fprintf(tport,'?D'); 
161pause(0.5);
162DiodeStatus=tport.UserData;
163% check if switching was successfull and update laser toggle
164if strcmp(DiodeStatus(1:2),'ON')
165    set(hObject,'Value',1)
166    set(hObject,'BackgroundColor','r');
167    set(hObject,'String','Laser is ON')
168elseif strcmp(DiodeStatus(1:3),'OFF')
169    set(hObject,'Value',0)
170    set(hObject,'BackgroundColor','g');
171    set(hObject,'String','Laser is OFF')
172end
173
174% check diode parameters
175
176% diode current
177fprintf(tport,'?C1');
178pause(0.5);
179DiodeCurrent=tport.UserData;
180set(handles.txtDiodeCurrent,'String',DiodeCurrent,'ForegroundColor','k');
181% check diode current setting and update power toggle 
182fprintf(tport,'?CS1'); 
183pause(0.5);
184DiodeCurrentSet=tport.UserData;
185% current depends on power supply
186fprintf(tport,'?PSSN'); 
187pause(0.5);
188PSSN=tport.UserData;
189if PSSN(1:6)=='120865'
190    if str2double(DiodeCurrentSet)==35.4
191        set(handles.togglePower,'Value',1,'String','FULL Power','BackgroundColor','g');
192    elseif str2double(DiodeCurrentSet)==14
193        set(handles.togglePower,'Value',0,'String','LOW Power','BackgroundColor','c');
194    else
195        set(handles.togglePower,'Value',0,'String','medium Power','BackgroundColor','c');
196    end
197elseif PSSN(1:6)=='120881'
198    if str2double(DiodeCurrentSet)==36.0
199        set(handles.togglePower,'Value',1,'String','FULL Power','BackgroundColor','g');
200    elseif str2double(DiodeCurrentSet)==14
201        set(handles.togglePower,'Value',0,'String','LOW Power','BackgroundColor','c');
202    else
203        set(handles.togglePower,'Value',0,'String','medium Power','BackgroundColor','c');
204    end
205end
206
207% IR power
208fprintf(tport,'?P');
209pause(0.5);
210IRPower=tport.UserData;
211set(handles.txtIRPower,'String',IRPower,'ForegroundColor','k');
212
213% diode temperature
214fprintf(tport,'?T1');
215pause(0.5);
216DiodeTemp=tport.UserData;
217set(handles.txtDiodeTemp,'String',DiodeTemp,'ForegroundColor','k');
218
219% tower temperature
220fprintf(tport,'?TT');
221pause(0.5);
222TowerTemp=tport.UserData;
223set(handles.txtTowerTemp,'String',TowerTemp,'ForegroundColor','k');
224
225set(handles.txtStatus,'String','Idle','ForegroundColor','k');
226
227
228% --- Executes on button press in toggleShutter.
229function toggleShutter_Callback(hObject, eventdata, handles)
230% hObject    handle to toggleShutter (see GCBO)
231% eventdata  reserved - to be defined in a future version of MATLAB
232% handles    structure with handles and user data (see GUIDATA)
233set(handles.txtStatus,'String','Query Status','ForegroundColor','r');
234tcpdata = getappdata(handles.output, 'tcpdata'); 
235tport=tcpdata.tport;
236% switch shutter on or off
237if get(hObject,'Value')
238    fprintf(tport,'SHT:1'); 
239    set(hObject,'BackgroundColor','r')
240    set(hObject,'String','Shutter opened')
241    pause(0.5);
242else
243    fprintf(tport,'SHT:0');
244    set(hObject,'BackgroundColor','y')
245    set(hObject,'String','Shutter closed')
246    pause(0.5);
247end
248%check if switching was successfull
249fprintf(tport,'?SHT'); 
250pause(3);
251ShutterStatus=tport.UserData;
252if strcmp(ShutterStatus(1:4),'OPEN') %shutter is open
253    set(hObject,'Value',1)
254    set(hObject,'BackgroundColor','r')
255    set(hObject,'String','Shutter is OPEN')
256elseif strcmp(ShutterStatus(1:6),'CLOSED')
257    set(hObject,'Value',0)
258    set(hObject,'BackgroundColor','g')
259    set(hObject,'String','Shutter is CLOSED')
260end
261set(handles.txtStatus,'String','Idle','ForegroundColor','k');
262
263
264
265
266function edtCommand_Callback(hObject, eventdata, handles)
267% hObject    handle to edtCommand (see GCBO)
268% eventdata  reserved - to be defined in a future version of MATLAB
269% handles    structure with handles and user data (see GUIDATA)
270
271% Hints: get(hObject,'String') returns contents of edtCommand as text
272%        str2double(get(hObject,'String')) returns contents of edtCommand as a double
273set(handles.txtStatus,'String','Query Status','ForegroundColor','r');
274
275%mark strings to be updated
276set(handles.txtReprate,'ForegroundColor','r');
277set(handles.txtCrtemp,'ForegroundColor','r');
278set(handles.txtDiodeCurrent,'ForegroundColor','r');
279set(handles.txtDiodeMaxCurrent,'ForegroundColor','r');
280set(handles.txtIRPower,'ForegroundColor','r');
281set(handles.txtDiodeTemp,'ForegroundColor','r');
282set(handles.txtTowerTemp,'ForegroundColor','r');
283
284tcpdata = getappdata(handles.output, 'tcpdata'); 
285tport=tcpdata.tport;
286
287LaserCmd=get(hObject,'String');
288
289% if the command is laser switching, update Laser toggle button
290if LaserCmd(1)=='d' 
291    if LaserCmd(2)=='1'
292        set(handles.toggleLaser,'BackgroundColor','r');
293        set(handles.toggleLaser,'String','Laser switched ON')
294    elseif LaserCmd(2)=='0'
295        set(handles.toggleLaser,'BackgroundColor','y');
296        set(handles.toggleLaser,'String','Laser switched OFF')
297    end    
298end
299% send command and read answer, if any
300fprintf(tport,LaserCmd);
301pause(4);
302LaserAns=tport.UserData;
303% if command is a query, display answer 
304if LaserCmd(1)=='?'
305    set(handles.txtCommandAnswer,'String',LaserAns);
306else %if command is not a query, send query to check effect and display answer
307    fprintf(tport,['?',LaserCmd(isletter(LaserCmd))]);
308    pause(0.5);
309    LaserAns=tport.UserData;
310    if isempty(deblank(LaserAns)) % some queries require specifying #
311        fprintf(tport,['?',LaserCmd(isletter(LaserCmd)),'1']); % # is always 1 for our system 
312        pause(0.5);
313        LaserAns=tport.UserData;
314    end
315    set(handles.txtCommandAnswer,'String',LaserAns);
316end
317
318% update laser status info
319Zeit=clock;
320set(handles.txtZeit,'String',datestr(Zeit,13));
321
322% check diode switch status and update laser toggle
323fprintf(tport,'?D');
324pause(0.5);
325DiodeStatus=tport.UserData;
326if strcmp(DiodeStatus(1:2),'ON')
327    set(handles.toggleLaser,'Value',1)
328    set(handles.toggleLaser,'BackgroundColor','r');
329    set(handles.toggleLaser,'String','Laser is ON')
330elseif strcmp(DiodeStatus(1:3),'OFF')
331    set(handles.toggleLaser,'Value',0)
332    set(handles.toggleLaser,'BackgroundColor','g');
333    set(handles.toggleLaser,'String','Laser is OFF')
334end
335
336%check shutter and update shutter toggle
337fprintf(tport,'?SHT');
338pause(0.5);
339ShutterStatus=tport.UserData;
340if strcmp(ShutterStatus(1:6),'CLOSED')
341    set(handles.toggleShutter,'Value',0)
342    set(handles.toggleShutter,'BackgroundColor','g')
343    set(handles.toggleShutter,'String','Shutter is CLOSED')
344elseif strcmp(ShutterStatus(1:4),'OPEN')
345    set(handles.toggleShutter,'Value',1)
346    set(handles.toggleShutter,'BackgroundColor','r')
347    set(handles.toggleShutter,'String','Shutter is OPEN')
348end
349
350%check diode current
351fprintf(tport,'?C1'); 
352pause(0.5);
353DiodeCurrent=tport.UserData;
354set(handles.txtDiodeCurrent,'String',DiodeCurrent,'ForegroundColor','k');
355%check diode current setting and update power toggle
356fprintf(tport,'?CS1'); 
357pause(0.5);
358DiodeCurrentSet=tport.UserData;
359% current depends on power supply
360fprintf(tport,'?PSSN'); 
361pause(0.5);
362PSSN=tport.UserData;
363if PSSN(1:6)=='120865'
364    if str2double(DiodeCurrentSet)==35.4
365        set(handles.togglePower,'Value',1,'String','FULL Power','BackgroundColor','g');
366    elseif str2double(DiodeCurrentSet)==14
367        set(handles.togglePower,'Value',0,'String','LOW Power','BackgroundColor','c');
368    else
369        set(handles.togglePower,'Value',0,'String','medium Power','BackgroundColor','c');
370    end
371elseif PSSN(1:6)=='120881'
372    if str2double(DiodeCurrentSet)==36.0
373        set(handles.togglePower,'Value',1,'String','FULL Power','BackgroundColor','g');
374    elseif str2double(DiodeCurrentSet)==14
375        set(handles.togglePower,'Value',0,'String','LOW Power','BackgroundColor','c');
376    else
377        set(handles.togglePower,'Value',0,'String','medium Power','BackgroundColor','c');
378    end
379end
380
381% check repetition rate
382fprintf(tport,'?Q'); 
383pause(0.5);
384RepRate=tport.UserData;
385set(handles.txtReprate,'String',RepRate,'ForegroundColor','k');
386
387% check crystal temp.
388fprintf(tport,'?SHG'); 
389pause(0.5);
390CrystalTmp=tport.UserData;
391set(handles.txtCrtemp,'String',CrystalTmp,'ForegroundColor','k');
392
393% check tower temperature
394fprintf(tport,'?TT');
395pause(0.5);
396TowerTemp=tport.UserData;
397set(handles.txtTowerTemp,'String',TowerTemp,'ForegroundColor','k');
398
399% check max. allowed diode current
400fprintf(tport,'?DCL1');
401pause(0.5);
402DiodeMaxCurrent=tport.UserData;
403set(handles.txtDiodeMaxCurrent,'String',DiodeMaxCurrent,'ForegroundColor','k');
404    
405% check diode temp.
406fprintf(tport,'?T1');
407pause(0.5);
408DiodeTemp=tport.UserData;
409set(handles.txtDiodeTemp,'String',DiodeTemp,'ForegroundColor','k');
410
411% check IR power
412fprintf(tport,'?P');
413pause(0.5);
414IRPower=tport.UserData;
415set(handles.txtIRPower,'String',IRPower,'ForegroundColor','k');
416
417set(handles.txtStatus,'String','Idle','ForegroundColor','k');
418
419
420
421% --- Executes on button press in pubExit.
422function pubExit_Callback(hObject, eventdata, handles)
423% hObject    handle to pubExit (see GCBO)
424% eventdata  reserved - to be defined in a future version of MATLAB
425% handles    structure with handles and user data (see GUIDATA)
426% shut down tcpip connection
427tcpdata = getappdata(handles.output, 'tcpdata'); 
428tport=tcpdata.tport;
429fclose(tcpdata.tport);
430delete(tcpdata.tport);
431echotcpip('off');
432close(handles.figure1);
433
434
435
436
437
438% --- Executes on button press in Update.
439function Update_Callback(hObject, eventdata, handles)
440% hObject    handle to Update (see GCBO)
441% eventdata  reserved - to be defined in a future version of MATLAB
442% handles    structure with handles and user data (see GUIDATA)
443set(handles.txtStatus,'String','Query Status','ForegroundColor','r');
444
445tcpdata = getappdata(handles.output, 'tcpdata'); 
446tport=tcpdata.tport;
447
448Zeit=clock;
449set(handles.txtZeit,'String',datestr(Zeit,13));
450
451%mark strings to be updated
452set(handles.txtReprate,'ForegroundColor','r');
453set(handles.txtCrtemp,'ForegroundColor','r');
454set(handles.txtDiodeCurrent,'ForegroundColor','r');
455set(handles.txtDiodeMaxCurrent,'ForegroundColor','r');
456set(handles.txtIRPower,'ForegroundColor','r');
457set(handles.txtDiodeTemp,'ForegroundColor','r');
458set(handles.txtTowerTemp,'ForegroundColor','r');
459
460% check diode switch status and update laser toggle
461fprintf(tport,'?D');
462pause(0.5);
463DiodeStatus=tport.UserData;
464if strcmp(DiodeStatus(1:2),'ON')
465    set(handles.toggleLaser,'Value',1)
466    set(handles.toggleLaser,'BackgroundColor','r');
467    set(handles.toggleLaser,'String','Laser is ON')
468elseif strcmp(DiodeStatus(1:3),'OFF')
469    set(handles.toggleLaser,'Value',0)
470    set(handles.toggleLaser,'BackgroundColor','g');
471    set(handles.toggleLaser,'String','Laser is OFF')
472end
473
474% check shutter and update shutter toggle
475fprintf(tport,'?SHT');
476pause(0.5);
477ShutterStatus=tport.UserData;
478if strcmp(ShutterStatus(1:6),'CLOSED')
479    set(handles.toggleShutter,'Value',0)
480    set(handles.toggleShutter,'BackgroundColor','g')
481    set(handles.toggleShutter,'String','Shutter is CLOSED')
482elseif strcmp(ShutterStatus(1:4),'OPEN')
483    set(handles.toggleShutter,'Value',1)
484    set(handles.toggleShutter,'BackgroundColor','r')
485    set(handles.toggleShutter,'String','Shutter is OPEN')
486end
487
488% check diode current
489fprintf(tport,'?C1'); 
490pause(0.5);
491DiodeCurrent=tport.UserData;
492set(handles.txtDiodeCurrent,'String',DiodeCurrent,'ForegroundColor','k');
493%check diode current setting and update power toggle
494fprintf(tport,'?CS1'); 
495pause(0.5);
496DiodeCurrentSet=tport.UserData;
497% current depends on power supply
498fprintf(tport,'?PSSN'); 
499pause(0.5);
500PSSN=tport.UserData;
501if PSSN(1:6)=='120865'
502    if str2double(DiodeCurrentSet)==35.4
503        set(handles.togglePower,'Value',1,'String','FULL Power','BackgroundColor','g');
504    elseif str2double(DiodeCurrentSet)==14
505        set(handles.togglePower,'Value',0,'String','LOW Power','BackgroundColor','c');
506    else
507        set(handles.togglePower,'Value',0,'String','medium Power','BackgroundColor','c');
508    end
509elseif PSSN(1:6)=='120881'
510    if str2double(DiodeCurrentSet)==36.0
511        set(handles.togglePower,'Value',1,'String','FULL Power','BackgroundColor','g');
512    elseif str2double(DiodeCurrentSet)==14
513        set(handles.togglePower,'Value',0,'String','LOW Power','BackgroundColor','c');
514    else
515        set(handles.togglePower,'Value',0,'String','medium Power','BackgroundColor','c');
516    end
517end
518    
519% check repetition rate
520fprintf(tport,'?Q'); 
521pause(0.5);
522RepRate=tport.UserData;
523set(handles.txtReprate,'String',RepRate,'ForegroundColor','k');
524
525% check crystal temperature
526fprintf(tport,'?SHG'); 
527pause(0.5);
528CrystalTmp=tport.UserData;
529set(handles.txtCrtemp,'String',CrystalTmp,'ForegroundColor','k');
530
531% check tower temperature
532fprintf(tport,'?TT');
533pause(0.5);
534TowerTemp=tport.UserData;
535set(handles.txtTowerTemp,'String',TowerTemp,'ForegroundColor','k');
536
537% check max. allowed diode current
538fprintf(tport,'?DCL1');
539pause(0.5);
540DiodeMaxCurrent=tport.UserData;
541set(handles.txtDiodeMaxCurrent,'String',DiodeMaxCurrent,'ForegroundColor','k');
542    
543% check diode temperature
544fprintf(tport,'?T1');
545pause(0.5);
546DiodeTemp=tport.UserData;
547set(handles.txtDiodeTemp,'String',DiodeTemp,'ForegroundColor','k');
548
549% check IR power
550fprintf(tport,'?P');
551pause(0.5);
552IRPower=tport.UserData;
553set(handles.txtIRPower,'String',IRPower,'ForegroundColor','k');
554
555set(handles.txtStatus,'String','Idle','ForegroundColor','k');
556
557
558
559% --- Executes on button press in togglePower.
560function togglePower_Callback(hObject, eventdata, handles)
561% hObject    handle to togglePower (see GCBO)
562% eventdata  reserved - to be defined in a future version of MATLAB
563% handles    structure with handles and user data (see GUIDATA)
564
565% Hint: get(hObject,'Value') returns toggle state of togglePower
566set(handles.txtStatus,'String','Query Status','ForegroundColor','r');
567
568tcpdata = getappdata(handles.output, 'tcpdata'); 
569tport=tcpdata.tport;
570
571% mark strings to be updated
572set(handles.txtDiodeCurrent,'ForegroundColor','r');
573set(handles.txtIRPower,'ForegroundColor','r');
574set(handles.txtCrtemp,'ForegroundColor','r');
575set(handles.txtDiodeTemp,'ForegroundColor','r');
576set(handles.txtTowerTemp,'ForegroundColor','r');
577
578% current depends on power supply
579fprintf(tport,'?PSSN'); 
580pause(0.5);
581PSSN=tport.UserData;
582if PSSN(1:6)=='120865'
583    if get(hObject,'Value')
584        fprintf(tport,'C1:35.4'); % full power
585    else
586        fprintf(tport,'C1:14'); % lowest green power 
587    end    
588elseif PSSN(1:6)=='120881'
589    if get(hObject,'Value')
590        fprintf(tport,'C1:36.0'); % full power
591    else
592        fprintf(tport,'C1:14'); % lowest green power 
593    end    
594end
595
596% check effect
597pause(0.5)
598fprintf(tport,'?CS1'); 
599pause(0.5);
600DiodeCurrentSet=tport.UserData;
601% current depends on power supply
602if (PSSN(1:6)=='120865' & str2double(DiodeCurrentSet)==35.4)...
603    | (PSSN(1:6)=='120881' & str2double(DiodeCurrentSet)==36.0)
604    set(handles.togglePower,'Value',1)
605    set(handles.togglePower,'BackgroundColor','c');
606    set(handles.togglePower,'String','FULL Power')
607else
608    set(handles.togglePower,'Value',0)
609    set(handles.togglePower,'BackgroundColor','b');
610    set(handles.togglePower,'String','LOW Power')
611    if str2double(DiodeCurrentSet)~=14
612        set(handles.togglePower,'String','medium Power')
613    end
614end
615
616% check crystal temp.
617fprintf(tport,'?SHG'); 
618pause(0.5);
619CrystalTmp=tport.UserData;
620set(handles.txtCrtemp,'String',CrystalTmp,'ForegroundColor','k');
621
622% check tower temperature
623fprintf(tport,'?TT');
624pause(0.5);
625TowerTemp=tport.UserData;
626set(handles.txtTowerTemp,'String',TowerTemp,'ForegroundColor','k');
627
628% check diode temp.
629fprintf(tport,'?T1');
630pause(0.5);
631DiodeTemp=tport.UserData;
632set(handles.txtDiodeTemp,'String',DiodeTemp,'ForegroundColor','k');
633
634% check diode current
635fprintf(tport,'?C1'); 
636pause(0.5);
637DiodeCurrent=tport.UserData;
638set(handles.txtDiodeCurrent,'String',DiodeCurrent,'ForegroundColor','k');
639
640% check IR power
641fprintf(tport,'?P');
642pause(0.5);
643IRPower=tport.UserData;
644set(handles.txtIRPower,'String',IRPower,'ForegroundColor','k');
645
646set(handles.txtStatus,'String','Idle','ForegroundColor','k');