Resolves issue with tuning RTL2832 based tuners into the range of
799.555894 and 801.584395.  The pre-defined sample rates were slightly
off and causing issues with this tuning range.  I recalculated the 
sample rates and removed any that were not integral multiples of the 
48,000 Hz desired channel rate.

Updated the sample bit depth for RTL2832 and HackRF tuners.  Even though
the sample bit depth is 8 bits for each, the displayed noise floor was
off, so I increased the bit depth for each.
This commit is contained in:
denny
2015-11-08 11:42:24 -05:00
parent 2e2a8da13d
commit ae85201343
8 changed files with 27 additions and 138 deletions

View File

@@ -116,109 +116,4 @@ public class Oscillator
{
return mCurrentAngle.real();
}
public static void main( String[] args )
{
Oscillator o = new Oscillator( 1536, 4096 );
o.rotate();
float[] samples = new float[ 8192 ];
for( int x = 0; x < 8192; x++ )
{
samples[ x ] = o.inphase();
o.rotate();
}
logLargest( "Real: ", samples, false );
HilbertTransform ht = new HilbertTransform();
float[] transformed = ht.filter( samples );
logLargest( "Hilbert: ", transformed, true );
FloatFFT_1D fft = new FloatFFT_1D( 4096 );
fft.complexForward( transformed );
logLargest( "DFT:", transformed, true );
}
private static void logLargest( String label, float[] samples, boolean complex )
{
float largestI = 0.0f;
int indexLargestI = 0;
float largestQ = 0.0f;
int indexLargestQ = 0;
float smallestI = 0.0f;
int indexsmallestI = 0;
float smallestQ = 0.0f;
int indexsmallestQ = 0;
for( int x = 0; x < samples.length; x++ )
{
if( complex )
{
if( x % 2 == 0 )
{
if( samples[ x ] > largestI )
{
largestI = samples[ x ];
indexLargestI = x;
}
if( samples[ x ] < smallestI )
{
smallestI = samples[ x ];
indexsmallestI = x;
}
}
else
{
if( samples[ x ] > largestQ )
{
largestQ = samples[ x ];
indexLargestQ = x;
}
if( samples[ x ] < smallestQ )
{
smallestQ = samples[ x ];
indexsmallestQ = x;
}
}
}
else
{
if( samples[ x ] > largestI )
{
largestI = samples[ x ];
indexLargestI = x;
}
if( samples[ x ] < smallestI )
{
smallestI = samples[ x ];
indexsmallestI = x;
}
}
}
if( complex )
{
mLog.debug( label +
" largestI (" + indexLargestI + "): " + largestI +
" smallestI (" + indexsmallestI + "): " + smallestI +
" largestQ (" + indexLargestQ + "): " + largestQ +
" smallestQ (" + indexsmallestQ + "): " + smallestQ );
}
else
{
mLog.debug( label +
" largest (" + indexLargestI + "): " + largestI +
" smallest (" + indexsmallestI + "): " + smallestI );
}
}
}

View File

@@ -96,7 +96,7 @@ public class HackRFTuner extends Tuner
@Override
public double getSampleSize()
{
return 8.0;
return 11.0;
}
@Override

View File

@@ -29,9 +29,9 @@ import source.tuner.hackrf.HackRFTunerController.HackRFVGAGain;
public class HackRFTunerConfiguration extends TunerConfiguration
{
private HackRFSampleRate mSampleRate = HackRFSampleRate.RATE2_016MHZ;
private HackRFLNAGain mLNAGain = HackRFLNAGain.GAIN_0;
private HackRFLNAGain mLNAGain = HackRFLNAGain.GAIN_16;
private HackRFVGAGain mVGAGain = HackRFVGAGain.GAIN_10;
private boolean mAmplifierEnabled = false;
private boolean mAmplifierEnabled = true;
private double mFrequencyCorrection = 0.0d;
/**

View File

@@ -131,7 +131,9 @@ public class RTL2832Tuner extends Tuner
@Override
public double getSampleSize()
{
return 8.0;
//Note: although sample size is 8, we set it to 11 to align with the
//actual noise floor.
return 11.0;
}
@Override

View File

@@ -1010,9 +1010,10 @@ public abstract class RTL2832TunerController extends TunerController
writeDemodRegister( mDeviceHandle, Page.ONE, (short)0x9F,
sampleRate.getRatioHighBits(), 2 );
/* Write low-order 16-bits of sample rate ratio to demod register */
writeDemodRegister( mDeviceHandle, Page.ONE, (short)0xA1,
sampleRate.getRatioLowBits(), 2 );
/* Write low-order 16-bits of sample rate ratio to demod register.
* Note: none of the defined rates have a low order ratio value, so we
* simply write a zero to the register */
writeDemodRegister( mDeviceHandle, Page.ONE, (short)0xA1, 0, 2 );
/* Set sample rate correction to 0 */
setSampleRateFrequencyCorrection( 0 );
@@ -1267,32 +1268,25 @@ public abstract class RTL2832TunerController extends TunerController
public enum SampleRate
{
/* Note: sample rates below 1.0MHz are subject to aliasing */
RATE_0_240MHZ( 0x0DFC, 0x0000, 240000, "0.240 MHz" ),
RATE_0_288MHZ( 0x08FC, 0x0000, 288000, "0.288 MHz" ),
RATE_0_912MHZ( 0x07E4, 0x0000, 912000, "0.912 MHz" ),
RATE_0_960MHZ( 0x0778, 0x0000, 960000, "0.960 MHz" ),
RATE_1_200MHZ( 0x05F4, 0x0000, 1200000, "1.200 MHz" ),
RATE_1_440MHZ( 0x04FC, 0x0000, 1440000, "1.440 MHz" ),
RATE_1_680MHZ( 0x0448, 0x0000, 1680000, "1.680 MHz" ),
RATE_1_824MHZ( 0x03F0, 0x0000, 1824000, "1.824 MHz" ),
RATE_2_016MHZ( 0x038C, 0x0000, 2016000, "2.016 MHz" ),
RATE_2_208MHZ( 0x0340, 0x0000, 2208000, "2.208 MHz" ),
RATE_2_400MHZ( 0x02FC, 0x0000, 2400000, "2.400 MHz" ),
RATE_2_640MHZ( 0x02B4, 0x8000, 2640000, "2.640 MHz" ),
RATE_2_880MHZ( 0x027C, 0x0000, 2880000, "2.880 MHz" );
RATE_0_240MHZ( 0x1E00, 240000, "0.240 MHz" ),
RATE_0_288MHZ( 0x1900, 288000, "0.288 MHz" ),
RATE_0_960MHZ( 0x0780, 960000, "0.960 MHz" ),
RATE_1_200MHZ( 0x0600, 1200000, "1.200 MHz" ),
RATE_1_440MHZ( 0x0500, 1440000, "1.440 MHz" ),
RATE_1_920MHZ( 0x03C0, 2016000, "2.016 MHz" ),
RATE_2_304MHZ( 0x0320, 2208000, "2.208 MHz" ),
RATE_2_400MHZ( 0x0300, 2400000, "2.400 MHz" ),
RATE_2_880MHZ( 0x0280, 2880000, "2.880 MHz" );
private int mRatioHigh;
private int mRatioLow;
private int mRate;
private String mLabel;
private SampleRate( int ratioHigh,
int ratioLow,
int rate,
String label )
{
mRatioHigh = ratioHigh;
mRatioLow = ratioLow;
mRate = rate;
mLabel = label;
}
@@ -1302,11 +1296,6 @@ public abstract class RTL2832TunerController extends TunerController
return mRatioHigh;
}
public int getRatioLowBits()
{
return mRatioLow;
}
public int getRate()
{
return mRate;

View File

@@ -34,7 +34,7 @@ public class E4KTunerConfiguration extends TunerConfiguration
private E4KLNAGain mLNAGain = E4KLNAGain.AUTOMATIC;
private E4KEnhanceGain mEnhanceGain = E4KEnhanceGain.AUTOMATIC;
private double mFrequencyCorrection = 8.9d;
private SampleRate mSampleRate = SampleRate.RATE_1_200MHZ;
private SampleRate mSampleRate = SampleRate.RATE_1_920MHZ;
/**
* Default constructor for JAXB

View File

@@ -34,7 +34,7 @@ public class R820TTunerConfiguration extends TunerConfiguration
private R820TLNAGain mLNAGain = R820TLNAGain.GAIN_222;
private R820TVGAGain mVGAGain = R820TVGAGain.GAIN_210;
private double mFrequencyCorrection = 0.0d;
private SampleRate mSampleRate = SampleRate.RATE_0_912MHZ;
private SampleRate mSampleRate = SampleRate.RATE_1_920MHZ;
/**
* Default constructor for JAXB

View File

@@ -95,13 +95,16 @@ public class ComplexDecibelConverter extends DFTResultsConverter
// We have to swap the upper and lower halves of the JTransforms
// DFT results for correct display
if( x / 2 >= middle )
int index = x / 2;
if( index >= middle )
{
processed[ x / 2 - middle ] = decibels;
processed[ index - middle ] = decibels;
}
else
{
processed[ x / 2 + middle ] = decibels;
processed[ index + middle ] = decibels;
}
}