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