# HG changeset patch # User Mychaela Falconia # Date 1500158909 0 # Node ID a094db1453b1c190140bfc4fea35c31ee0790bac # Parent 83b24a1dfd4a0430902346718c1359562592b1c7 fc-rfcal-txband: implemented computation of APC from basis diff -r 83b24a1dfd4a -r a094db1453b1 autocal/Makefile --- 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 diff -r 83b24a1dfd4a -r a094db1453b1 autocal/txlevels.c --- /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 +#include +#include +#include +#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; +}