diff --git a/sa_cmd.c b/sa_cmd.c index 3477c71..2746b60 100644 --- a/sa_cmd.c +++ b/sa_cmd.c @@ -361,13 +361,19 @@ VNA_SHELL_FUNCTION(cmd_correction) { (void)argc; if (argc == 0) { - shell_printf("correction table\r\n"); shell_printf("index frequency value\r\n"); for (int i=0; i 200.0) actualStepDelay = 400; - else if (actual_rbw > 90.0) actualStepDelay = 500; - else if (actual_rbw > 75.0) actualStepDelay = 550; - else if (actual_rbw > 56.0) actualStepDelay = 650; - else if (actual_rbw > 37.0) actualStepDelay = 700; - else if (actual_rbw > 18.0) actualStepDelay = 1100; - else if (actual_rbw > 9.0) actualStepDelay = 2000; - else if (actual_rbw > 5.0) actualStepDelay = 3500; - else actualStepDelay = 6000; + if (actual_rbw >= 191.0) actualStepDelay = 280; + else if (actual_rbw >= 142.0) actualStepDelay = 350; + else if (actual_rbw >= 75.0) actualStepDelay = 450; + else if (actual_rbw >= 56.0) actualStepDelay = 650; + else if (actual_rbw >= 37.0) actualStepDelay = 700; + else if (actual_rbw >= 18.0) actualStepDelay = 1100; + else if (actual_rbw >= 9.0) actualStepDelay = 1700; + else if (actual_rbw >= 5.0) actualStepDelay = 3300; + else actualStepDelay = 6400; if (setting.step_delay == 1) actualStepDelay *= 2; } else @@ -2027,6 +2027,7 @@ common_silent: case TP_10MHZ: // 10MHz input set_mode(M_LOW); set_refer_output(2); + set_step_delay(1); // Precise scanning speed #ifdef __SPUR__ setting.spur = 1; #endif @@ -2042,6 +2043,7 @@ common_silent: case TP_30MHZ: set_mode(M_LOW); set_refer_output(0); + // set_step_delay(1); // Do not set !!!!! #ifdef __SPUR__ setting.spur = 1; #endif @@ -2154,12 +2156,12 @@ void self_test(int test) test_prepare(i); setting.step_delay = 8000; for (int j= 0; j < 57; j++ ) { - setting.step_delay = setting.step_delay * 4/3; + test_prepare(i); + setting.step_delay = setting.step_delay * 5 / 4; setting.rbw = SI4432_force_RBW(j); shell_printf("RBW = %d, ",setting.rbw); - test_prepare(i); set_sweep_frequency(ST_SPAN, (int32_t)(setting.rbw * 10000)); - + setting.repeat = 10; test_acquire(i); // Acquire test test_validate(i); // Validate test float saved_peakLevel = peakLevel; @@ -2170,15 +2172,16 @@ void self_test(int test) shell_printf("Start level = %f, ",peakLevel); while (setting.step_delay > 10 && peakLevel > saved_peakLevel - 1) { - setting.step_delay = setting.step_delay * 3 / 4; test_prepare(i); + setting.step_delay = setting.step_delay * 4 / 5; // shell_printf("\n\rRBW = %f",SI4432_force_RBW(j)); set_sweep_frequency(ST_SPAN, (int32_t)(setting.rbw * 10000)); + setting.repeat = 10; test_acquire(i); // Acquire test test_validate(i); // Validate test // shell_printf(" Step %f, %d",peakLevel, setting.step_delay); } - setting.step_delay = setting.step_delay * 4 / 3; + setting.step_delay = setting.step_delay * 5 / 4; shell_printf("End level = %f, step time = %d\n\r",peakLevel, setting.step_delay); } } else if (test == 0) { diff --git a/si4432.c b/si4432.c index 7aa7963..3671265 100644 --- a/si4432.c +++ b/si4432.c @@ -180,66 +180,126 @@ void SI4432_Receive(void) // User asks for an RBW of WISH, go through table finding the last triple // for which WISH is greater than the first entry, use those values, // Return the first entry of the following triple for the RBW actually achieved -static const short RBW_choices[] = { // Each quadrupple is: ndec, fils, WISH*10, corr*10 +static const short RBW_choices[] = +{ // Each quadrupple is: ndec, fils, WISH*10, corr*10 #if 1 - 5,1,26,0, - 5,2,28,0, - 5,3,31,-10, - 5,4,32,-10, - 5,5,37,-10, - 5,6,42,0, - 5,7,45,-5, - 4,1,49,-5, - 4,2,54,-10, - 4,3,59,-10, - 4,4,61,-10, - 4,5,72,-10, - 4,6,82,-5, - 4,7,88,0, - 3,1,95,0, - 3,2,106,0, - 3,3,115,-5, - 3,4,121,-5, - 3,5,142,-10, - 3,6,162,0, - 3,7,175,0, - 2,1,189,0, - 2,2,210,0, - 2,3,227,0, - 2,4,240,5, - 2,5,282,-5, - 2,6,322,0, - 2,7,347,0, - 1,1,377,0, - 1,2,417,0, - 1,3,452,0, - 1,4,479,5, - 1,5,562,0, - 1,6,641,0, - 1,7,692,0, - 0,1,752,5, - 0,2,832,5, - 0,3,900,0, - 0,4,953,5, - 0,5,1121,0, - 0,6,1279,0, - 0,7,1379,0, - 1,4,1428,-15, - 1,5,1678,-25, - 1,9,1811,50, - 0,15,1915,105, - 0,1,2251,-20, - 0,2,2488,0, - 0,3,2693,-15, - 0,4,2849,-10, - 0,8,3355,20, - 0,9,3618,55, - 0,10,4202,20, - 0,11,4684,20, - 0,12,5188,25, - 0,13,5770,15, - 0,14,6207,15, + 5,1,26,-5, + 5,2,28,-5, + 5,3,31,0, + 5,4,32,0, + 5,5,37,0, + 5,6,42,0, + 5,7,45,5, + 4,1,49,5, + 4,2,54,-5, + 4,3,59,-5, + 4,4,61,-5, + 4,5,72,0, + 4,6,82,0, + 4,7,88,-5, + 3,1,95,0, + 3,2,106,0, + 3,3,115,0, + 3,4,121,-5, + 3,5,142,0, + 3,6,162,0, + 3,7,175,0, + 2,1,189,0, + 2,2,210,-5, + 2,3,227,0, + 2,4,240,-5, + 2,5,282,0, + 2,6,322,0, + 2,7,347,0, + 1,1,377,0, + 1,2,417,-5, + 1,3,452,0, + 1,4,479,-5, + 1,5,562,0, + 1,6,641,0, + 1,7,692,0, + 0,1,752,-5, + 0,2,832,-5, + 0,3,900,0, + 0,4,953,-5, + 0,5,1121,0, + 0,6,1279,0, + 0,7,1379,0, + 1,4,1428,15, + 1,5,1678,20, + 1,9,1811,-55, + 0,15,1915,-105, + 0,1,2251,15, + 0,2,2488,20, + 0,3,2693,20, + 0,4,2849,15, + 0,8,3355,-15, + 0,9,3618,-55, + 0,10,4202,-15, + 0,11,4684,-15, + 0,12,5188,-20, + 0,13,5770,-15, + 0,14,6207,-10, #else +5,1,26,0, +5,2,28,0, +5,3,31,0, +5,4,32,0, +5,5,37,0, +5,6,42,0, +5,7,45,-5, +4,1,49,-5, +4,2,54,-10, +4,3,59,-10, +4,4,61,-10, +4,5,72,-10, +4,6,82,-5, +4,7,88,0, +3,1,95,0, +3,2,106,0, +3,3,115,-5, +3,4,121,-5, +3,5,142,-10, +3,6,162,0, +3,7,175,0, +2,1,189,0, +2,2,210,0, +2,3,227,0, +2,4,240,5, +2,5,282,-5, +2,6,322,0, +2,7,347,0, +1,1,377,0, +1,2,417,0, +1,3,452,0, +1,4,479,5, +1,5,562,0, +1,6,641,0, +1,7,692,0, +0,1,752,5, +0,2,832,5, +0,3,900,0, +0,4,953,5, +0,5,1121,0, +0,6,1279,0, +0,7,1379,0, +1,4,1428,-15, +1,5,1678,-25, +1,9,1811,50, +0,15,1915,105, +0,1,2251,-20, +0,2,2488,0, +0,3,2693,-15, +0,4,2849,-10, +0,8,3355,20, +0,9,3618,55, +0,10,4202,20, +0,11,4684,20, +0,12,5188,25, +0,13,5770,15, +0,14,6207,15, +#endif +#if 0 5,1,26,0, 5,2,28,0, 5,3,31,0, @@ -382,11 +442,11 @@ float SI4432_RSSI(uint32_t i, int s) i = setting.repeat; RSSI_RAW = 0; while (i-->0) - RSSI_RAW += (unsigned char)SI4432_Read_Byte( 0x26 ) ; + RSSI_RAW += (unsigned int)SI4432_Read_Byte( 0x26 ) << 4 ; RSSI_RAW = RSSI_RAW / setting.repeat; // if (MODE_INPUT(setting.mode) && RSSI_RAW == 0) // SI4432_Init(); - float dBm = (RSSI_RAW-240)/2.0 - SI4432_RSSI_correction; + float dBm = (((float)RSSI_RAW)/16.0 - 240.0)/2.0 + SI4432_RSSI_correction; #ifdef __SIMULATION__ dBm = Simulated_SI4432_RSSI(i,s); #endif