1 | function [D QF QD itime] = gettrackinghall(varargin) |
---|
2 | % GETTRACKINGHALL - get B-field measured with hallprobe for Dipole, QD and QF |
---|
3 | % |
---|
4 | % INPUTS |
---|
5 | % |
---|
6 | % |
---|
7 | % OUTPUTS |
---|
8 | % 1. D - Measured current on Dipole Dipole in au |
---|
9 | % 2. DF - Measured current on Dipole QF in au |
---|
10 | % 3. QD - Measured current on quadrupole QD in au |
---|
11 | % 4. itime - Time base in seconds |
---|
12 | % |
---|
13 | % NOTES |
---|
14 | % 1. Voltages are between -10 and 10 V and converted into amperes |
---|
15 | % 2/ time base is reconstruted by reading frequency and bufferdepth on |
---|
16 | % dserver tracking |
---|
17 | |
---|
18 | % |
---|
19 | % Written by Laurent S. Nadolski |
---|
20 | |
---|
21 | DisplayFlag = 1; |
---|
22 | |
---|
23 | % Input parser |
---|
24 | |
---|
25 | for i = length(varargin):-1:1 |
---|
26 | if strcmpi(varargin{i},'Display') |
---|
27 | DisplayFlag = 1; |
---|
28 | varargin(i) = []; |
---|
29 | elseif strcmpi(varargin{i},'NoDisplay') |
---|
30 | DisplayFlag = 0; |
---|
31 | varargin(i) = []; |
---|
32 | end |
---|
33 | end |
---|
34 | |
---|
35 | devName = 'BOO/AE/trackinghall'; |
---|
36 | % use this function to assure synchronous reading |
---|
37 | val = tango_read_attributes(devName, ... |
---|
38 | {'channel0','channel1','channel2','frequency','bufferDepth'}); |
---|
39 | |
---|
40 | if (tango_error == -1) |
---|
41 | %- handle error |
---|
42 | tango_print_error_stack; |
---|
43 | return |
---|
44 | end |
---|
45 | |
---|
46 | |
---|
47 | % Gets numerical values for current (it is a voltage with is read) |
---|
48 | % D QF QD |
---|
49 | |
---|
50 | D = val(1).value; |
---|
51 | QF = val(2).value; |
---|
52 | QD = val(3).value; |
---|
53 | |
---|
54 | freq = val(4).value(1); % read value |
---|
55 | timeTot = val(5).value(1); % read value |
---|
56 | |
---|
57 | itime = 0:1/freq:timeTot; |
---|
58 | itime = itime(2:end); |
---|
59 | |
---|
60 | |
---|
61 | if DisplayFlag |
---|
62 | subplot(2,1,1) |
---|
63 | plot(itime,D,itime,QF,itime,QD); |
---|
64 | grid on |
---|
65 | legend('D','QF','QD') |
---|
66 | xlabel('time (s)') |
---|
67 | % xlim([0.03 0.05]) |
---|
68 | hold off |
---|
69 | ylabel('u a') |
---|
70 | % title(['Dipole = ' num2str(max(D1+D2)/2) ' QF = ' num2str(max(QF)) ' QD = ' num2str(max(QD))]) |
---|
71 | subplot(2,1,2) |
---|
72 | plot(itime,QD./D,itime,QF./D); |
---|
73 | %hold off |
---|
74 | xlim([0.03 0.320]) |
---|
75 | grid on |
---|
76 | legend('QD/Dipole','QF/Dipole') |
---|
77 | xlabel('time (s)') |
---|
78 | ylabel('normalized voltage (-10V to 10 V)') |
---|
79 | |
---|
80 | end |
---|