FreeCalypso > hg > freecalypso-tools
comparison 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 |
comparison
equal
deleted
inserted
replaced
180:e50c3aa1152a | 181:dcab0be3f67a |
---|---|
1 #include <stdio.h> | |
2 #include <stdlib.h> | |
3 #include "meas.h" | |
4 | |
5 struct meas meas[2]; | |
6 float lin_a, lin_b, target_off; | |
7 int target_dac; | |
8 | |
9 main(argc, argv) | |
10 char **argv; | |
11 { | |
12 if (argc < 2 || argc > 3) { | |
13 fprintf(stderr, "usage: %s meas-file [target]\n", argv[0]); | |
14 exit(1); | |
15 } | |
16 read_meas_file(argv[1], meas, 2); | |
17 if (argc > 2) | |
18 target_off = atof(argv[2]); | |
19 else | |
20 target_off = 0; | |
21 lin_a = (float)(meas[1].freq_offset - meas[0].freq_offset) / | |
22 (float)(meas[1].dac_value - meas[0].dac_value); | |
23 lin_b = (float)meas[1].freq_offset - lin_a * meas[1].dac_value; | |
24 target_dac = (target_off - lin_b) / lin_a; | |
25 printf("%d\n", target_dac); | |
26 exit(0); | |
27 } |