-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstLaser_Prototype.m
More file actions
54 lines (47 loc) · 1.6 KB
/
instLaser_Prototype.m
File metadata and controls
54 lines (47 loc) · 1.6 KB
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
%% instLaser_Prototype.m MN 2018-09-20
% Template for laser interface
%
% Requirements:
% - VISA interface functions in path
% - Equipment is connected on specified VISA address
%
% Usage: [power, wavelength] = instLaser_Prototype(visaAddr, option[, value])
% Returns:
% power: Returns current laser power when requested
% wavelength: Returns current laser wavelength when requested
%
% Parameters:
% visaAddr: Valid VISA address with a ThorLabs power meter connected
% 'option': One of available options below
% 'value': Value for options that require it
%
% Options:
% 'read' | 'curstate': Retreives present power and wavelength
% 'state', %i: Turns laser on or off
% 'on': Same as 'state', 1
% 'off': Same as 'state', 0
% 'power', %f: Sets power to this if possible (watts)
% 'wavelength', %f: Sets wavelength to this if possible
%
% TODO:
% - Add more options
% - Confirm units
function [power, wavelength] = instLaser_Prototype(visaAddr, option, value)
power = NaN; wavelength = NaN;
%% Helper functions
lasWrite = @(x) visaWrite(visaAddr, x);
lasQuery = @(x) str2num(visaRead(visaAddr, x));
%% Execute selected command
switch lower(option)
case {'state', 'on', 'off'}
% Change state
if ~exist('value', 'var'); value = find(strcmpi(option, {'off', 'on'}),1)-1; end % Find the state
case 'wavelength'
% Set wavelength
if ~exist('value', 'var'); error('Value not provided for wavelength!'); end
case 'power'
% Set power
case {'curstate', 'read'}
% Return power and wavelength
end
end