# HG changeset patch # User Mychaela Falconia # Date 1495494634 0 # Node ID 841dd03d5c85c92f60ba7582847d8222a6425b49 # Parent a2e4da9d85cc1ea46540e2afebefd97c4a71b188 fc-rfcal-vcxo: almost done diff -r a2e4da9d85cc -r 841dd03d5c85 autocal/vcxomain.c --- a/autocal/vcxomain.c Mon May 22 22:27:22 2017 +0000 +++ b/autocal/vcxomain.c Mon May 22 23:10:34 2017 +0000 @@ -2,6 +2,7 @@ * This module contains the main() function for fc-rfcal-vcxo. */ +#include #include #include #include @@ -18,6 +19,9 @@ static float lin_a, lin_b, lin_a2, lin_b2; static int zero_search_dac1, zero_search_dac2, zero_search_incr; static float zero_search_freq1, zero_search_freq2; +static float dac_min, dac_max, dac_init; +static int dac_init_int; +static float Psi_sta, Psi_st; prepare_rf_test_system() { @@ -71,7 +75,29 @@ zero_search_freq1 = zero_search_freq2; } + /* second linear approximation */ + lin_a2 = (zero_search_freq2 - zero_search_freq1) / + (float)(zero_search_dac2 - zero_search_dac1); + lin_b2 = zero_search_freq2 - lin_a2 * zero_search_dac2; + + /* DAC settings */ + dac_min = (-13500.0f - lin_b) / lin_a; + dac_max = (13500.0f - lin_b) / lin_a; + dac_init = -lin_b2 / lin_a2; + dac_init_int = (int) dac_init; + + /* check the frequency offset at the final DAC value */ + vcxo_freq_meas(dac_init_int, "zero-check"); + + /* done with the measurements and the Tx */ printf("Stopping RF Tx on the DUT\n"); do_rfe(STOP_ALL); + + /* Psi computations */ + Psi_sta = 2.0f * (float)M_PI * lin_a / 270833.0f; + Psi_st = Psi_sta * 0.8f; + + /* afcparams output TBD */ + exit(0); }