[hpsdr] Larger FFTs with PowerSDR for HPSDR
w3sz
73w3sz at gmail.com
Sat May 1 17:32:01 PDT 2010
Hi All,
This is a followup to my prior posting about increasing the sensitivity
of PowerSDR's waterfall. I got things working and am posting what I
found here in order to help others.
I got things working with the PowerSDR modified to use Linrad palette
and large FFTs. For those who are interested, here is a summary.
To be able to run FFTs of more than 32K with PowerSDR it is necessary to
run BUFFER_SIZES of more than 8K. But with the HPSDR PowerSDR version
v1.10.4 + BaseSVN 2025 the coding was such that with buffer sizes
[BUFFERSIZE] above 8192 an exception would be thrown of the type
"System.NullReferenceException" in system.dll. This was due to an
object reference not set to an instance of the object, and this was due
to a variable index being out of range. This error was noticed when
PanAdapter or Waterfall display types were selected, but may have
occurred with some but not all of the other possible selections as well.
It appeared that this exception was due to the coding of some
arithmetic that caused the intermediate values in some calculations to
exceed the permitted range of the variable types (int) in the affected
expressions. I modified the coding so that this would not occur, and
the exceptions disappeared.
I realize I may have redundant floats I don't need in my code.
In display.cs I changed the following:
In unsafe static private bool DrawPanadapter(Graphics g, int W, int H,
bool bottom)
/* original code changed by w3sz due to overflows
start_sample_index = (BUFFER_SIZE>>1) +(int)((Low * BUFFER_SIZE) /
sample_rate);
num_samples = (int)((High - Low) * BUFFER_SIZE / sample_rate);
*/
is changed to:
start_sample_index = (BUFFER_SIZE>>1) +(int)(BUFFER_SIZE /
(float)((float)sample_rate / (float)Low)); //w3sz to correct overflow
num_samples = (int)((High - Low) /
(float)((float)sample_rate/(float)BUFFER_SIZE)) ; //w3sz to correct
overflow
AND in unsafe static private bool DrawWaterfall(Graphics g, int W, int
H, bool bottom)
/* changed by w3sz to correct overflow problems
start_sample_index = (BUFFER_SIZE>>1) +(int)((Low * BUFFER_SIZE) /
sample_rate);
num_samples = (int)((High - Low) * BUFFER_SIZE / sample_rate);
*/
is changed to:
start_sample_index = (BUFFER_SIZE>>1) +(int)(BUFFER_SIZE /
(float)((float)sample_rate / (float)Low)); //w3sz to correct overflow
num_samples = (int)((High - Low) /
(float)((float)sample_rate/(float)BUFFER_SIZE)) ; //w3sz to correct
overflow
In general, to avoid an exception once the above code has been
corrected, the BUFFER_SIZE must be at least 1/4 of the DEFSPEC size.
Examples include:
BUFFER_SIZE 4096 and DEFSPEC 16384 and below: no exceptions.
BUFFER_SIZE 4096 and DEFSPEC 32768 and above; exceptions occur.
BUFFER_SIZE 8192 and DEFSPEC 32768 and below: no exceptions.
BUFFER_SIZE 8192 and DEFSPEC 65536 and above; exceptions occur.
BUFFER_SIZE 16384 and DEFSPEC 65536 and below: no exceptions.
BUFFER_SIZE 16384 and DEFSPEC 131072 and above; exceptions occur.
BUFFER_SIZE 32768 and DEFSPEC 131072 and below: no exceptions.
BUFFER_SIZE 32768 and DEFSPEC 262144 and above; exceptions occur.
BUFFER_SIZE 65536 and DEFSPEC 262144 and below: no exceptions.
BUFFER_SIZE 65536 and DEFSPEC 524288 and above; exceptions occur
Exceeding the permittted DEFSPEC size produced exceptions of the type
"System.NullReferenceException" in system.dll due to an object reference
not set to an instance of the object. This occurs with display types
PanAdapter, Waterfall, Spectrum, and Histogram.
To make the click tuning and display work properly with other than the
'standard' DEFSPEC and BUFFER_SIZE, the BUFFER_SIZE and the DEFSPEC
specsize need to be the same. When that is done, the spectrum and
waterfall displays appear to be correctly calibrated an dalligned, and
click tuning works properly as does dragging the signal across the
display to the filter window.
Other changes were needed to keep the frequency scale correct in those
situations where start_sample_index is negative, which occurs when zoom
is near zero, and maximal or near-maximal spectral width is being displayed.
The files I changed were:
1. defs.h : changed value for DEFSPEC . I am running with DEFSPEC
131072 [and of course BUFFER_SIZE 131072].
2. display.cs : made the changes above, changed palette to Linrad
palette, and inserted some print statements so I could figure out the code
3. ..\fftw_wisdom\main.c was modified to do estimates for larger transforms
4. various other files were temporarily changed for experimental
purposes or to insert print statements, but these changes are not necessary.
The modified files 1-3 are available at:
http://www.nitehawk.com/w3sz/defs.h
http://www.nitehawk.com/w3sz/display.cs
http://www.nitehawk.com/w3sz/main.c
A gif of the Modified PowerSDR running with full 192 kHz spectral width
is at:
http://www.nitehawk.com/w3sz/5-1-newspec1.GIF
A gif of it running with full zoom, showing the better frequency
resolution [look at the granularity of the noise floor], is at:
http://www.nitehawk.com/w3sz/5-1-newspec-nar2.GIF
Finally, many thanks to Frank Brickle for giving me very helpful info
that got me started on the right track, and to Leif Asbrink for his help
yet again!!!
73,
Roger Rehr
W3SZ
More information about the Hpsdr
mailing list