Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 24 commits into from
Mar 21, 2020
Merged

Conversation

DiSlord
Copy link
Contributor

@DiSlord DiSlord commented Mar 8, 2020

  • Little code optimization
  • Add commented 600kHz I2C bus timings (work, give x1.5 speed, but need change DSP ready timings not by wait_count, need use chVTGetSystemTimeX() its better)
    Need select maximum ready time and check in on DSP ready.
    For example:
    tlv320aic3204_select need xxx time
    set_frequency need yyy, in some times zzz
    Need sellect maximum ready time and start dsp after, its allow more better optimise sweep
    On 600kHz I2C bus speed set_frequency req only 440 sys tick (on 400kHz need 700), and in some cases can be faster then tlv320aic3204_select
  • Fix screen artifacts
  • Fix Random jitters at band 1 and band change on some freq ranges
  • Change start/stop or center/span mode set
  • Remove Mutex use (CH_CFG_USE_MUTEXES = FALSE), now all Mutex depend functions run in sweep thread

It allow:
reduce shell thread stack size
more compact code
fix some hardcoded scan command code, allow write better scan version
run calibrate (not depend from pause sweep flag)

  • Rewrite uint32_t my_atoui(const char *p), now its allow read:
    hex 0xaAbBcC12
    dec 12345678
    bin 0b00011100
    oct 0o12345678

  • Implement color command, allow change color settings in config (enabled bu default ENABLE_COLOR_COMMAND)

Usage: usage: color {id} {rgb24}
Grid color: id = -3
Menu bg color: id = -2
Selected menu: id = -1
Trace 1-4: id = 0..3

  • Not use float in vbat measure (less size, more faster)
  • Fix 'frequencies' command, now output as uint32
  • Extend scan command

usage: scan {start(Hz)} {stop(Hz)} [points] [outmask]
[outmask] - optional, allow output measured data, its a mask (allow dec, hex, bin, oct)
0b001 - output frequency
0b010 - output CH0 data
0b100 - output CH1 data
Example:
'scan 1000000 5000000 101 0b111' - output data in format: freq ch0[0] ch0[1] ch1[0] ch1[1]
'scan 1000000 5000000 101 0b101' - output data in format: freq ch1[0] ch1[1]
'scan 1000000 5000000 101 0x7' - output data as 0b111

  • Fix interpolation range if sweep_points!=source calibration points count
    use sweep_points exept POINTS_COUNT on marker search and so
    Now possible change sweep_points in process (for faster sweep)

Add some comments

…arted but CH not ready)

Little code optimization
Add commented 600kHz I2C bus timings (work, give x1.5 speed, but need change DSP ready timings not by wait_count, need use chVTGetSystemTimeX() its better)
Use int64_t acc for values
Use double on calculation

Not cache freq on si5351_set_frequency_with_offset (to fast change in rare cases on cw mode, and process wrong DSP block) as i write before need change DSP delay tactic
@DiSlord
Copy link
Contributor Author

DiSlord commented Mar 8, 2020

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
Copy link
Contributor Author

DiSlord commented Mar 9, 2020

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;

In mark_cells_from_index(void) mark all rectangle (in most cases this not decrease render speed, and more fast in calculation, and no errors)
@DiSlord DiSlord changed the title Select CH0 reflect channel before set freq Select CH0 reflect channel before set freq, fix screen artifacts Mar 9, 2020
@DiSlord
Copy link
Contributor Author

DiSlord commented Mar 9, 2020

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 DiSlord mentioned this pull request Mar 9, 2020
#define FREQ_MODE_START_STOP    0x0
#define FREQ_MODE_CENTER_SPAN   0x1
Now sweep mode not defined from frequency0 > frequency1 or frequency0 < frequency1
frequency0 always < frequency1

All freq must get by use get_sweep_frequency(mode)

Revert Select CH0 reflect channel before set freq, add additional delay on 0 sweep point
@DiSlord DiSlord changed the title Select CH0 reflect channel before set freq, fix screen artifacts Fix screen artifacts, change start/stop or center/span mode set Mar 9, 2020
(For faster screen update on marker move, all old area update info invalidate after use draw_all_cells(TRUE) on page switch)
Force redraw all cells after end marker move
Improve frequency stability on band change (100 MHz, 150MHz, 300 MHz, 450MHz)

Restore freq cache in CW mode
@DiSlord
Copy link
Contributor Author

DiSlord commented Mar 11, 2020

FIX issue #127
Fix Random jitters at band 1 and band change on some freq ranges

…unctions run in sweep thread

It allow:
- reduce shell thread stack size
- more compact code
- fix some hardcoded scan command code, allow write better scan version
- run calibrate (not depend from pause sweep flag)

Rewrite uint32_t my_atoui(const char *p), now its allow read:
hex 0xaAbBcC1122
dec 12345678
bin 0b00011100
oct 0o12345678

Add some comments
@DiSlord DiSlord changed the title Fix screen artifacts, change start/stop or center/span mode set Fix screen artifacts, change start/stop or center/span mode set, remove Mutex use Mar 12, 2020
@DiSlord
Copy link
Contributor Author

DiSlord commented Mar 12, 2020

Fix this issue
#123

…ed bu default ENABLE_COLOR_COMMAND)

Usage: usage: color {id} {rgb24}
- Grid color: id = -3
- Menu bg color: id = -2
- Selected menu: id = -1
- Trace 1-4: id = 0..3
Color in hex RGB format (but possible any type input, dec, hex, bin. oct)
@DiSlord
Copy link
Contributor Author

DiSlord commented Mar 13, 2020

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)

In plot.c prepare for 8bit/pixel mode (test, allow increase cell buffer size by use 4 or 8bit/pixel mode, but not need for now)
main.c little change wait execute shell command in sweep thread
Define and move constants in nanovna.h, and use it
Fix command 'marker' - display marker freq (not current freq)
…, allow more faster get measured data

usage: scan {start(Hz)} {stop(Hz)} [points] [outmask]
[outmask] - optional, allow output measured data, its a mask (allow dec, hex, bin, oct)
0b001 - output frequency
0b010 - output CH0 data
0b100 - output CH1 data
Example:
'scan 1000000 5000000 101 0b111' - output data in format: freq ch0[0] ch0[1] ch1[0] ch1[1]
'scan 1000000 5000000 101 0b101' - output data in format: freq ch1[0] ch1[1]
'scan 1000000 5000000 101 0x7'   - output data as 0b111
Fix my tupo in extended scan command (not correctly parse point count)
use sweep_points exept POINTS_COUNT on marker search and so

Now possible change sweep_points in process (for faster sweep)
!!!!! Don`t understand why si5351 non stable on band 2 then change from band 3
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

Little faster call command from shell

Fix interpolation if points < POINTS_COUNT
@DiSlord
Copy link
Contributor Author

DiSlord commented Mar 15, 2020

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)

@edy555 edy555 merged commit a482160 into ttrftech:master Mar 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants