changeset 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
files autocal/vcxomain.c
diffstat 1 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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 <math.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <rvinterf/l1tm.h>
@@ -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);
 }