changeset 82:a094db1453b1

fc-rfcal-txband: implemented computation of APC from basis
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 15 Jul 2017 22:48:29 +0000
parents 83b24a1dfd4a
children 45ef4a06edfc
files autocal/Makefile autocal/txlevels.c
diffstat 2 files changed, 35 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/autocal/Makefile	Sat Jul 15 21:34:29 2017 +0000
+++ b/autocal/Makefile	Sat Jul 15 22:48:29 2017 +0000
@@ -11,7 +11,8 @@
 		rxupload.o sockopts.o tsidsock.o
 
 TXBAND_OBJS=	l1tmops.o rvinterf.o sockopts.o tsidsock.o txbandmain.o \
-		txbasis.o txcalchan.o txcalconf.o txpwrmeas.o txvout.o
+		txbasis.o txcalchan.o txcalconf.o txlevels.o txpwrmeas.o \
+		txvout.o
 
 TXBASIS_OBJS=	l1tmops.o rvinterf.o tsidsock.o txpwrmeas.o txstandbas.o
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/autocal/txlevels.c	Sat Jul 15 22:48:29 2017 +0000
@@ -0,0 +1,33 @@
+/*
+ * The calibration of Tx power levels is implemented here.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <rvinterf/l1tm.h>
+#include <rvinterf/exitcodes.h>
+#include "txband.h"
+
+extern double tx_power_meas();
+extern vout_t dbm_to_vout();
+
+extern struct txcal_band *txcal_band;
+extern struct tx_basis_point tx_basis[MAX_BASIS_POINTS];
+extern unsigned num_basis_points;
+extern struct tx_level tx_levels[MAX_TX_LEVELS];
+
+unsigned
+find_apc_for_target(target_dbm)
+	double target_dbm;
+{
+	vout_t target_vout;
+	unsigned n;
+	int apc_delta;
+
+	target_vout = dbm_to_vout(target_dbm);
+	for (n = 0; n < num_basis_points - 1; n++)
+		if (target_vout < tx_basis[n+1].vout)
+			break;
+	apc_delta = (target_vout - tx_basis[n].vout) / tx_basis[n].slope;
+	return tx_basis[n].apc + apc_delta;
+}