Closed DiSlord closed 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
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;
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)
FIX issue https://github.com/ttrftech/NanoVNA/issues/127 Fix Random jitters at band 1 and band change on some freq ranges
Fix this issue https://github.com/ttrftech/NanoVNA/issues/123
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)
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)
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
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)
Not use float in vbat measure (less size, more faster)
Fix 'frequencies' command, now output as uint32
Extend scan command
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