summaryrefslogtreecommitdiff
path: root/cesar/cp2/pwl/doc/scilab/estimate_acl_stable.sce
blob: da94eaf34587bbcff1aac810a36f69260a334d07 (plain)
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
// SPiDCOM Technologies.
// Nélio Laranjeiro
// 16-05-2008
// Cesar project.

// Launch a test to verify the estimation function.

// load the file, containing the function to generate a stable 50hz zero
// cross.
getf ('src/zc_capture.sce');
getf ('src/estimateBP.sce');

// C array writer
getf('convertc.sce');

// Initialise the environment.
date_ntb = [240000; 0];
// 50 Hz in ticks.
bp_ntb = 1e6;
zc_ntb = bp_ntb / 4;

// Number of points.
nb_points = 1e3;

//Vector of points.
result = zeros(nb_points,3);

for i = 1:nb_points
 res = cp_pwl_estimate_beacon_period (date_ntb, bp_ntb, zc_ntb);

 result (i,:) = res;

 bp_ntb = res(1) + 1e6;
 date_ntb(2) = res(2);
 date_ntb(1) = res(3);
end

// Write the result in a file.
result_file = file('open', 'result_stable.csv', 'unknown');
fprintf (result_file, "Per, Per(ATU), Zc 1, Zc 2\n");
for i = 1:nb_points
 fprintf (result_file, "%d, %d, %d, %d\n", result(i,1), int(result(i,1) / 256), result(i,3), result(i,2));
end
// Close the file.
file('close', result_file);

// Write the array.
res = result(:,3);
convertc_array ('table.h', 'ac_stable', res);

// Write the result of the simulation.
res = result (:,1);
convertc_array ('result_stable.h', 'result_ac_stable', res);