ttrftech / NanoVNA

Very Tiny Palmtop Vector Network Analyzer
1.06k stars 296 forks source link

Fix screen artifacts, change start/stop or center/span mode set, remove Mutex use #126

Closed DiSlord closed 4 years ago

DiSlord commented 4 years ago

Add some comments

DiSlord commented 4 years ago

In dsp_process data lost on divide, it equalent use sincos_tbl/16

    int32_t s = sincos_tbl[i][0];
    int32_t c = sincos_tbl[i][1];
    samp_s += smp * s / 16;
    samp_c += smp * c / 16;
    ref_s += ref * s / 16;
    ref_c += ref * c / 16;

On small signal values possible data lost This changes no affect to sweep speed (but little increase code ~120 bytes) Visually less noise no freq > 1500MHz in CH1

DiSlord commented 4 years ago

Need more think about DSP (i cant correct measure how good result give this changes), revert it

But as minimum lost data (float have 23 bit mantissa + sign, but int32 have 31 bit + sign)

  float rs = acc_ref_s;
  float rc = acc_ref_c;
  float ss = acc_samp_s;
  float sc = acc_samp_c;

and on accumulate drop lost 4 bit on every step

    int32_t s = sincos_tbl[i][0];
    int32_t c = sincos_tbl[i][1];
    samp_s += smp * s / 16;
    samp_c += smp * c / 16;
    ref_s += ref * s / 16;
    ref_c += ref * c / 16;

Added: Funny possibly use 8 bit size sin cos table, no difference (only in 0.005) :)

    int32_t s = sincos_tbl[i][0]>>8;
    int32_t c = sincos_tbl[i][1]>>8;
    samp_s += smp * s;
    samp_c += smp * c;
    ref_s += ref * s;
    ref_c += ref * c;
DiSlord commented 4 years ago

Fix screen artifacts

Rewrite mark_cells_from_index In most cases not decrease render speed (anyway render speed very fast), no errors

PS bigger screen buffer give not big render speedup (if need more RAM possible decrease CELLWIDTH to 32, in most cases speed decreased by 0-10%) More compact cells allow more better drop no update screen areas (less cell to update), but slowdown cell render (more cells)

DiSlord commented 4 years ago

FIX issue https://github.com/ttrftech/NanoVNA/issues/127 Fix Random jitters at band 1 and band change on some freq ranges

DiSlord commented 4 years ago

Fix this issue https://github.com/ttrftech/NanoVNA/issues/123

DiSlord commented 4 years ago

I add issues tab in my repo Not undestand why need dataf ? You can send "data 0" to get ch0 data, "data 1" for ch1 Additional you can get current callibration data "data 2" ... "data 6" Send pause, send scan, send data 0 for get ch0 data, send data 1 for get ch1 data (on pause data not changed and you get correct data measute for one scan.)

Also in future i plan write better variant sweep command, in allow use unlimited point (only execution time) and allow get all data in procees (apply/not apply internal calibration/edelay)

Color command, in plan use palette mode draw (it allow free some RAM, need check this variant) in this realisation for save space i use very dirty hack, i direct write to config struct, i dont won`t change it for now. In most cases it use one time.

#ifdef ENABLE_COLOR_COMMAND
VNA_SHELL_FUNCTION(cmd_color)
{
  uint32_t color;
  int i;
  if (argc != 2) {
    shell_printf("usage: color {id} {rgb24}\r\n");
    for (i=-3; i < TRACES_MAX; i++) {
#if 0
      switch(i){
        case -3: color = config.grid_color; break;
        case -2: color = config.menu_normal_color; break;
        case -1: color = config.menu_active_color; break;
        default: color = config.trace_color[i];break;
      }
#else
     // WARNING!!! Dirty hack for size, depend from config struct
      color = config.trace_color[i];
#endif
      color = ((color >>  3) & 0x001c00) |
              ((color >>  5) & 0x0000f8) |
              ((color << 16) & 0xf80000) |
              ((color << 13) & 0x00e000);
//    color = (color>>8)|(color<<8);
//    color = ((color<<8)&0xF80000)|((color<<5)&0x00FC00)|((color<<3)&0x0000F8);
      shell_printf("   %d: 0x%06x\r\n", i, color);
    }
    return;
  }
...................
#endif

PS you can write on Russian PSS at this moment i free about 18kB flash space (and know how free additional 2-5kB if need)

DiSlord commented 4 years ago

Don`t understand why si5351 non stable on band 2 then change from band 3 and back It fixed if set before sweep one frequency from band 1 (for example 50MHz) Possibly problem in tlv320aic3204_set_gain, call only si5351_set_frequency_with_offset not work

Before if set sweep from 150MHz to 600MHz possible see non correct amplitude if 150-300МHz, but if set 149MHz all ok.

Add: Reload and reset PLL and Multisynth settings on sweep begin (if current_freq > freq then need reset band for reset band settings)