Browse Source

Merge branch 'clk_calib'

klaute 2 years ago
parent
commit
6eb1e9a5dd
4 changed files with 61 additions and 15 deletions
  1. 40
    0
      firmware/command_ctrl.ino
  2. 7
    1
      firmware/globals.h
  3. 11
    11
      tools/all_band_test.sh
  4. 3
    3
      tools/meas.py

+ 40
- 0
firmware/command_ctrl.ino View File

@@ -31,6 +31,8 @@ void cc_getConfig(void);
31 31
 void cc_enableClk(void);
32 32
 void cc_disableClk(void);
33 33
 void cc_saveDefaults(void);
34
+void cc_setClkCorrection(void);
35
+void cc_getClkCorrection(void);
34 36
 
35 37
 /*****************************************************************************/
36 38
 
@@ -51,6 +53,8 @@ uint8_t cc_commands[] = {
51 53
     CC_CMD_EN_CLK,
52 54
     CC_CMD_DIS_CLK,
53 55
     CC_CMD_SAV_DFLT,
56
+    CC_CMD_SET_CLK_CORR,
57
+    CC_CMD_GET_CLK_CORR,
54 58
   };
55 59
 
56 60
 void (*cc_cmd_functions[])() = {
@@ -64,6 +68,8 @@ void (*cc_cmd_functions[])() = {
64 68
     CC_CMD_EN_CLK_FUNC,
65 69
     CC_CMD_DIS_CLK_FUNC,
66 70
     CC_CMD_SAV_DFLT_FUNC,
71
+    CC_CMD_SET_CLK_CORR_FUNC,
72
+    CC_CMD_GET_CLK_CORR_FUNC,
67 73
   };
68 74
 
69 75
 uint8_t cc_cmd_data_to_read[] = {
@@ -77,6 +83,8 @@ uint8_t cc_cmd_data_to_read[] = {
77 83
     CC_CMD_EN_CLK_DATA_TO_READ,
78 84
     CC_CMD_DIS_CLK_DATA_TO_READ,
79 85
     CC_CMD_SAV_DFLT_DATA_TO_READ,
86
+    CC_CMD_SET_CLK_CORR_DATA_TO_READ,
87
+    CC_CMD_GET_CLK_CORR_DATA_TO_READ,
80 88
   };
81 89
 
82 90
 uint8_t cc_read_data[CC_READ_DATA_MAX];
@@ -397,6 +405,38 @@ void cc_saveDefaults(void)
397 405
 
398 406
 /*****************************************************************************/
399 407
 
408
+void cc_setClkCorrection(void)
409
+{
410
+  uint32_t tmp_corr  = (uint32_t)cc_read_data[0] << 24;
411
+           tmp_corr += (uint32_t)cc_read_data[1] << 16;
412
+           tmp_corr += (uint32_t)cc_read_data[2] <<  8;
413
+           tmp_corr += (uint32_t)cc_read_data[3];
414
+
415
+  si5351.set_correction(tmp_corr);
416
+
417
+  Serial.write(MSG_SOM1);
418
+  Serial.write(MSG_SOM2);
419
+  Serial.write(MSG_TYPE_ANSWER_OK);
420
+  Serial.write(MSG_EOM1);
421
+  Serial.write(MSG_EOM2);
422
+}
423
+
424
+void cc_getClkCorrection(void)
425
+{
426
+  uint32_t tmp_corr = si5351.get_correction();
427
+
428
+  Serial.write(MSG_SOM1);
429
+  Serial.write(MSG_SOM2);
430
+  Serial.write((uint8_t)((tmp_corr & 0xff000000) >> 24));
431
+  Serial.write((uint8_t)((tmp_corr & 0x00ff0000) >> 16));
432
+  Serial.write((uint8_t)((tmp_corr & 0x0000ff00) >>  8));
433
+  Serial.write((uint8_t) (tmp_corr & 0x000000ff));
434
+  Serial.write(MSG_EOM1);
435
+  Serial.write(MSG_EOM2);
436
+}
437
+
438
+/*****************************************************************************/
439
+
400 440
 void cc_init()
401 441
 {
402 442
   cc_state                = CC_STATE_READ_SOM1;

+ 7
- 1
firmware/globals.h View File

@@ -45,6 +45,8 @@
45 45
 #define CC_CMD_EN_CLK               0x20
46 46
 #define CC_CMD_DIS_CLK              0x21
47 47
 #define CC_CMD_SAV_DFLT             0x22
48
+#define CC_CMD_SET_CLK_CORR         0x23
49
+#define CC_CMD_GET_CLK_CORR         0x24
48 50
 
49 51
 /*****************************************************************************/
50 52
 
@@ -58,6 +60,8 @@
58 60
 #define CC_CMD_EN_CLK_FUNC                &cc_enableClk
59 61
 #define CC_CMD_DIS_CLK_FUNC               &cc_disableClk
60 62
 #define CC_CMD_SAV_DFLT_FUNC              &cc_saveDefaults
63
+#define CC_CMD_SET_CLK_CORR_FUNC          &cc_setClkCorrection
64
+#define CC_CMD_GET_CLK_CORR_FUNC          &cc_getClkCorrection
61 65
 
62 66
 /*****************************************************************************/
63 67
 
@@ -71,10 +75,12 @@
71 75
 #define CC_CMD_EN_CLK_DATA_TO_READ              1
72 76
 #define CC_CMD_DIS_CLK_DATA_TO_READ             1
73 77
 #define CC_CMD_SAV_DFLT_DATA_TO_READ            0
78
+#define CC_CMD_SET_CLK_CORR_DATA_TO_READ        4
79
+#define CC_CMD_GET_CLK_CORR_DATA_TO_READ        0
74 80
 
75 81
 /*****************************************************************************/
76 82
 
77 83
 #define CC_READ_DATA_MAX 64
78 84
 
79 85
 /*****************************************************************************/
80
-
86
+

+ 11
- 11
tools/all_band_test.sh View File

@@ -1,27 +1,27 @@
1 1
 #!/bin/sh
2 2
 
3 3
 echo 160m
4
-python meas.py -o 160m.csv -s 1810000 -e 2000000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
4
+python meas.py -o 160m.csv -s 1810000 -e 2000000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
5 5
 echo 80m
6
-python meas.py -o 80m.csv -s 3500000 -e 3800000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
6
+python meas.py -o 80m.csv -s 3500000 -e 3800000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
7 7
 echo 40m
8
-python meas.py -o 40m.csv -s 7000000 -e 7200000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
8
+python meas.py -o 40m.csv -s 7000000 -e 7200000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
9 9
 echo 30m
10
-python meas.py -o 30m.csv -s 10100000 -e 10150000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
10
+python meas.py -o 30m.csv -s 10100000 -e 10150000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
11 11
 echo 20m
12
-python meas.py -o 20m.csv -s 14000000 -e 14350000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
12
+python meas.py -o 20m.csv -s 14000000 -e 14350000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
13 13
 echo 17m
14
-python meas.py -o 17m.csv -s 18068000 -e 18168000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
14
+python meas.py -o 17m.csv -s 18068000 -e 18168000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
15 15
 echo 15m
16
-python meas.py -o 15m.csv -s 21000000 -e 21450000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
16
+python meas.py -o 15m.csv -s 21000000 -e 21450000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
17 17
 echo 12m
18
-python meas.py -o 12m.csv -s 24890000 -e 24990000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
18
+python meas.py -o 12m.csv -s 24890000 -e 24990000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
19 19
 echo 10m
20
-python meas.py -o 10m.csv -s 28000000 -e 29700000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
20
+python meas.py -o 10m.csv -s 28000000 -e 29700000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
21 21
 echo 6m
22
-python meas.py -o 6m.csv -s 50080000 -e 51000000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
22
+python meas.py -o 6m.csv -s 50080000 -e 51000000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
23 23
 echo 2m
24
-python meas.py -o 2m.csv -s 144000000 -e 146000000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
24
+python meas.py -o 2m.csv -s 144000000 -e 146000000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
25 25
 
26 26
 echo 70cm and up is not supported
27 27
 

+ 3
- 3
tools/meas.py View File

@@ -500,8 +500,8 @@ def update_graph():
500 500
     x = arange(start_freq, end_freq, step_freq)
501 501
     lvswr, = axarr[0].plot(x[0], [1], label='VSWR', markevery=[vswr_marker[0]], markersize=4, marker="o", markerfacecolor="r")
502 502
     limp,  = axarr[1].plot(x[0], [50],  label='impedance', markevery=[vswr_marker[0]], markersize=4, marker="o", markerfacecolor="r")
503
-    la0,   = axarr[2].plot(x[0], [512], label='a0')
504
-    la1,   = axarr[2].plot(x[0], [512], label='a1')
503
+    la0,   = axarr[2].plot(x[0], [512], label='fwd')
504
+    la1,   = axarr[2].plot(x[0], [512], label='ref')
505 505
 
506 506
     axarr[0].legend(handles=[lvswr])
507 507
     axarr[0].set_xlim([start_freq, end_freq])
@@ -716,7 +716,7 @@ if __name__ == "__main__":
716 716
           ##### generate the output CSV file
717 717
           if args.output_file != None and args.start_meas == True:
718 718
             FILE = open(args.output_file, "w")
719
-            FILE.write("freqency;ratio;impedance;drive;a0;a1\n")
719
+            FILE.write("freqency;ratio;impedance;drive;fwd;ref\n")
720 720
             j = 0
721 721
             i = ((drive_str + 1) * 2.0) / 1000.0
722 722