comparison autocal/vcxomain.c @ 27:841dd03d5c85

fc-rfcal-vcxo: almost done
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 22 May 2017 23:10:34 +0000
parents a2e4da9d85cc
children ba4b6877e227
comparison
equal deleted inserted replaced
26:a2e4da9d85cc 27:841dd03d5c85
1 /* 1 /*
2 * This module contains the main() function for fc-rfcal-vcxo. 2 * This module contains the main() function for fc-rfcal-vcxo.
3 */ 3 */
4 4
5 #include <math.h>
5 #include <stdio.h> 6 #include <stdio.h>
6 #include <stdlib.h> 7 #include <stdlib.h>
7 #include <rvinterf/l1tm.h> 8 #include <rvinterf/l1tm.h>
8 #include <rvinterf/exitcodes.h> 9 #include <rvinterf/exitcodes.h>
9 #include "stdband.h" 10 #include "stdband.h"
16 17
17 static float freq_max_neg, freq_max_pos; 18 static float freq_max_neg, freq_max_pos;
18 static float lin_a, lin_b, lin_a2, lin_b2; 19 static float lin_a, lin_b, lin_a2, lin_b2;
19 static int zero_search_dac1, zero_search_dac2, zero_search_incr; 20 static int zero_search_dac1, zero_search_dac2, zero_search_incr;
20 static float zero_search_freq1, zero_search_freq2; 21 static float zero_search_freq1, zero_search_freq2;
22 static float dac_min, dac_max, dac_init;
23 static int dac_init_int;
24 static float Psi_sta, Psi_st;
21 25
22 prepare_rf_test_system() 26 prepare_rf_test_system()
23 { 27 {
24 char cmd[80]; 28 char cmd[80];
25 29
69 break; 73 break;
70 zero_search_dac1 = zero_search_dac2; 74 zero_search_dac1 = zero_search_dac2;
71 zero_search_freq1 = zero_search_freq2; 75 zero_search_freq1 = zero_search_freq2;
72 } 76 }
73 77
78 /* second linear approximation */
79 lin_a2 = (zero_search_freq2 - zero_search_freq1) /
80 (float)(zero_search_dac2 - zero_search_dac1);
81 lin_b2 = zero_search_freq2 - lin_a2 * zero_search_dac2;
82
83 /* DAC settings */
84 dac_min = (-13500.0f - lin_b) / lin_a;
85 dac_max = (13500.0f - lin_b) / lin_a;
86 dac_init = -lin_b2 / lin_a2;
87 dac_init_int = (int) dac_init;
88
89 /* check the frequency offset at the final DAC value */
90 vcxo_freq_meas(dac_init_int, "zero-check");
91
92 /* done with the measurements and the Tx */
74 printf("Stopping RF Tx on the DUT\n"); 93 printf("Stopping RF Tx on the DUT\n");
75 do_rfe(STOP_ALL); 94 do_rfe(STOP_ALL);
95
96 /* Psi computations */
97 Psi_sta = 2.0f * (float)M_PI * lin_a / 270833.0f;
98 Psi_st = Psi_sta * 0.8f;
99
100 /* afcparams output TBD */
101
76 exit(0); 102 exit(0);
77 } 103 }