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

//Estimate the beacon period using the synchronisation of the PWL.
//This shall use a function to generate the ACL frequency.

// The function phy_clock_get_zero_cross_captured_date shall be written in
// function of the test which is being done.
// WARN : Import the file containing the function before using this script.

// compute the estimation of the ACL period.
// @param  date_ntb  the matrix containing the previous zc cross.
// @param  bp_ntb  the beacon period in ntb clock base.
// @param  zc ntb  the acl zero cross.
// @return  the [per, date_ntb']
function [res] = cp_pwl_estimate_beacon_period (date_ntb, bp_ntb, zc_ntb)

date_ntb(1) = phy_clock_get_zero_cross_captured_date (date_ntb(2));
diff_ntb = modulo((date_ntb(1) - date_ntb(2)), bp_ntb + 10000);
per_ntb = (4-(diff_ntb / zc_ntb)) * zc_ntb + diff_ntb;

res = [per_ntb, date_ntb'];
return res;

endfunction