FreeCalypso > hg > fc-rfcal-tools
comparison vcxo-manual/linear.c @ 0:bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 20 May 2017 18:49:35 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bd62be88259d |
---|---|
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 } |