FreeCalypso > hg > fc-rfcal-tools
annotate autocal/txbasis.c @ 133:c99b1dce04ec default tip
fc-rfcal-txcheck: check and report ramp tolerance
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 20 Dec 2021 04:22:19 +0000 |
parents | 4c3f4231a021 |
children |
rev | line source |
---|---|
80
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * The basis steps of Tx power level calibration are implemented here. |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
101
b0618796d28d
fc-rfcal-txband: added safety checks for NaN power measurements and
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
5 #include <math.h> |
80
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdlib.h> |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <rvinterf/l1tm.h> |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <rvinterf/exitcodes.h> |
117
4c3f4231a021
autocal: vout_t definition factored out of txband.h into txvout.h
Mychaela Falconia <falcon@freecalypso.org>
parents:
104
diff
changeset
|
10 #include "txvout.h" |
80
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include "txband.h" |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 extern double tx_power_meas(); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 extern vout_t dbm_to_vout(); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 extern struct txcal_band *txcal_band; |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 extern struct tx_basis_point tx_basis[MAX_BASIS_POINTS]; |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 extern unsigned num_basis_points; |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 txcal_basis_run() |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 { |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 unsigned n; |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 double meas; |
101
b0618796d28d
fc-rfcal-txband: added safety checks for NaN power measurements and
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
24 int nanflag = 0; |
80
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 printf("Performing the calibration basis run\n"); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 do_txpw(TX_PWR_LEVEL, txcal_band->start_plnum); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 printf("Starting RF Tx on the DUT\n"); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 do_rfe(RX_TX_TCH); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 for (n = 0; n < num_basis_points; n++) { |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 do_txpw(TX_APC_DAC, tx_basis[n].apc); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 usleep(20000); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 meas = tx_power_meas(); |
81
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
35 printf("APC DAC=%u: %.2f dBm\n", tx_basis[n].apc, meas); |
101
b0618796d28d
fc-rfcal-txband: added safety checks for NaN power measurements and
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
36 if (isnan(meas)) |
b0618796d28d
fc-rfcal-txband: added safety checks for NaN power measurements and
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
37 nanflag = 1; |
80
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 tx_basis[n].vout = dbm_to_vout(meas); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 } |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 printf("Stopping RF Tx on the DUT\n"); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 do_rfe(STOP_ALL); |
101
b0618796d28d
fc-rfcal-txband: added safety checks for NaN power measurements and
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
43 if (nanflag) { |
b0618796d28d
fc-rfcal-txband: added safety checks for NaN power measurements and
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
44 printf("Error: got NaN power measurement, aborting\n"); |
104
7ad0495991ed
autocal: use the new ERROR_RFFAIL exit code
Mychaela Falconia <falcon@freecalypso.org>
parents:
101
diff
changeset
|
45 exit(ERROR_RFFAIL); |
101
b0618796d28d
fc-rfcal-txband: added safety checks for NaN power measurements and
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
46 } |
80
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 return(0); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 } |
81
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
49 |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
50 txcal_basis_compute() |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
51 { |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
52 unsigned n; |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
53 |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
54 for (n = 0; n < num_basis_points - 1; n++) { |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
55 if (tx_basis[n+1].vout <= tx_basis[n].vout) { |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
56 fprintf(stderr, |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
57 "error: Vout at APC=%u is not greater than at APC=%u\n", |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
58 tx_basis[n+1].apc, tx_basis[n].apc); |
104
7ad0495991ed
autocal: use the new ERROR_RFFAIL exit code
Mychaela Falconia <falcon@freecalypso.org>
parents:
101
diff
changeset
|
59 exit(ERROR_RFFAIL); |
81
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
60 } |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
61 tx_basis[n].slope = (tx_basis[n+1].vout - tx_basis[n].vout) / |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
62 (tx_basis[n+1].apc - tx_basis[n].apc); |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
63 } |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
64 return(0); |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
65 } |