-
Notifications
You must be signed in to change notification settings - Fork 0
/
utest_cascader.m
108 lines (90 loc) · 2.31 KB
/
utest_cascader.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
clear all; close all;
C = CascadeCommunicator("COM10");
C.Disconnect();
for i = 1:10
C.Connect();
C.Disconnect();
end
C.Connect();
C.Identify();
% defining the number of averages our device needs to tolerate
fprintf("Setting number of averages... ");
nAv = uint32(1:10:100);
for (iAv = 1:length(nAv))
C.nAverages = nAv(iAv);
if (nAv(iAv) ~= C.nAverages)
error("Something went wrong during our precious get function for averages");
end
end
fprintf("done!\n");
fprintf("Setting number of shots... ");
nShots = uint32(0:10:100);
for (iShot = 1:length(nShots))
C.nShots = nShots(iShot);
returnVal = C.nShots;
if (nShots(iShot) ~= returnVal)
errMsg = sprintf("get function gives bad result %d instead of %d for nShots", ...
returnVal, nShots(iShot));
error(errMsg);
end
end
fprintf("done!\n");
% try to define different acquisition times
fprintf("Settings acquisition times... ");
tAcquire = single(0.0:0.2:6.0);
for iAc = 1:length(tAcquire)
C.tAcquire = tAcquire(iAc);
returnVal = C.tAcquire;
if (tAcquire(iAc) ~= returnVal)
errMsg = sprintf("get function gives bad result %f instead of %f for tAcuqire", ...
returnVal, tAcquire(iAc));
error(errMsg);
end
end
fprintf("done!\n");
% define timepoints
fprintf("Setting laser timepoints... ");
timepoints = single(rand(2, 4));
for iLaser = 0:1:3
C.Set_tOn(iLaser, timepoints(1, iLaser + 1));
if C.Get_tOn(iLaser) ~= timepoints(1, iLaser + 1)
error("incorrect on time returned");
end
C.Set_tOff(iLaser, timepoints(2, iLaser + 1));
if C.Get_tOff(iLaser) ~= timepoints(2, iLaser + 1)
error("incorrect off time returned");
end
end
fprintf("done!\n");
% set dac timepoints
fprintf("Setting DAC timepoints... ");
for iTest = 1:10
C.Set_tDac([0.1 * iTest, 0.2 * iTest, 0.3 * iTest, 0.4 * iTest]);
end
fprintf("done!\n");
% full initialization including all four channels and DAC
C.wavelengths = [532, 1064, 700];
fprintf("Starting calculation... ");
C.Calculate();
fprintf("done!\n");
C.Initialize();
fprintf("Defining different input pins... ");
for iPin = 1:4
C.inputPin = iPin;
if (C.inputPin ~= iPin)
error("Could not define input pin");
end
end
fprintf("done!\n");
C.trigType = "falling";
C.trigType
C.trigType = "rising";
C.trigType
C.trigType = "both";
C.trigType
C.nShots = 0;
C.Start();
C.Stop();
% this line should throw a warning
C.Stop();
clear all;