FreeCalypso > hg > freecalypso-tools
diff rfcal/vcxo-manual/linear.c @ 181:dcab0be3f67a
started manual VCXO calibration code: fc-vcxo-linear utility written
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 12 Apr 2017 06:45:45 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rfcal/vcxo-manual/linear.c Wed Apr 12 06:45:45 2017 +0000 @@ -0,0 +1,27 @@ +#include <stdio.h> +#include <stdlib.h> +#include "meas.h" + +struct meas meas[2]; +float lin_a, lin_b, target_off; +int target_dac; + +main(argc, argv) + char **argv; +{ + if (argc < 2 || argc > 3) { + fprintf(stderr, "usage: %s meas-file [target]\n", argv[0]); + exit(1); + } + read_meas_file(argv[1], meas, 2); + if (argc > 2) + target_off = atof(argv[2]); + else + target_off = 0; + lin_a = (float)(meas[1].freq_offset - meas[0].freq_offset) / + (float)(meas[1].dac_value - meas[0].dac_value); + lin_b = (float)meas[1].freq_offset - lin_a * meas[1].dac_value; + target_dac = (target_off - lin_b) / lin_a; + printf("%d\n", target_dac); + exit(0); +}