Test source: added a square pattern

This commit is contained in:
f4exb 2018-10-25 13:53:58 +02:00
parent acbaa14dbd
commit f43c07b9e5
6 changed files with 49 additions and 13 deletions

View File

@ -2,7 +2,7 @@
<h2>Introduction</h2>
This input sample source plugin is an internal continuous wave generator that can be used to carry out test of software internals.
This input sample source plugin is an internal continuous wave generator that can be used to carry out test of software internals.
<h2>Build</h2>
@ -22,19 +22,19 @@ This is the center frequency of reception in kHz.
<h4>1.2: Start/Stop</h4>
Device start / stop button.
Device start / stop button.
- Blue triangle icon: device is ready and can be started
- Green square icon: device is running and can be stopped
- Magenta (or pink) square icon: an error occurred. In the case the device was accidentally disconnected you may click on the icon, plug back in and start again.
<h4>1.3: Record</h4>
Record baseband I/Q stream toggle button
<h4>1.4: Stream sample rate</h4>
Baseband I/Q sample rate in kS/s. This is the device to host sample rate (3) divided by the decimation factor (4).
Baseband I/Q sample rate in kS/s. This is the device to host sample rate (3) divided by the decimation factor (4).
<h3>2: Various options</h3>
@ -57,10 +57,10 @@ This exercises the decimation chain.
<h4>2.3: Baseband center frequency position relative the center frequency</h4>
- **Cen**: the decimation operation takes place around the center frequency Fs
- **Inf**: the decimation operation takes place around Fs - Fc.
- **Inf**: the decimation operation takes place around Fs - Fc.
- **Sup**: the decimation operation takes place around Fs + Fc.
With SR as the sample rate before decimation Fc is calculated as:
With SR as the sample rate before decimation Fc is calculated as:
- if decimation n is 4 or lower: Fc = SR/2^(log2(n)-1). The device center frequency is on the side of the baseband. You need a RF filter bandwidth at least twice the baseband.
- if decimation n is 8 or higher: Fc = SR/n. The device center frequency is half the baseband away from the side of the baseband. You need a RF filter bandwidth at least 3 times the baseband.
@ -89,7 +89,10 @@ This controls the generator sample rate in samples per second.
- **P1**: Pattern 1 is a sawtooth pattern
- Pulse width: 1000 samples
- Starts at full amplitude then amplitude decreases linearly down to zero
- **P2**: Pattern 2 is a 50% duty cycle square pattern
- Pulse width: 1000 samples
- Starts with a full amplitude pulse then down to zero for the duration of one pulse
<h3>5: Modulating tone frequency</h3>
This controls the modulating tone frequency in kHz in 10 Hz steps.
@ -97,23 +100,23 @@ This controls the modulating tone frequency in kHz in 10 Hz steps.
<h3>6: Carrier shift from center frequency</h3>
Use this control to set the offset of the carrier from the center frequency of reception.
<h3>7: AM modulation factor</h3>
This controls the AM modulation factor from 0 to 99%
<h3>8: FM deviation</h3>
This controls the frequency modulation deviation in kHz in 100 Hz steps. It cannot exceed the sample rate.
This controls the frequency modulation deviation in kHz in 100 Hz steps. It cannot exceed the sample rate.
<h3>9: Amplitude coarse control</h3>
This slider controls the number of amplitude bits by steps of 100 bits. The total number of amplitude bits appear on the right.
<h3>10: Amplitude fine control</h3>
This slider controls the number of amplitude bits by steps of 1 bit. The signal power in dB relative to the maximum power (full bit range) appear on the right.
<h3>11: DC bias</h3>
Use this slider to give a DC component in percentage of maximum amplitude.

View File

@ -490,6 +490,11 @@
<string>P1</string>
</property>
</item>
<item>
<property name="text">
<string>P2</string>
</property>
</item>
</widget>
</item>
<item>

View File

@ -362,6 +362,8 @@ bool TestSourceInput::applySettings(const TestSourceSettings& settings, bool for
m_testSourceThread->setPattern0();
} else if (settings.m_modulation == TestSourceSettings::ModulationPattern1) {
m_testSourceThread->setPattern1();
} else if (settings.m_modulation == TestSourceSettings::ModulationPattern2) {
m_testSourceThread->setPattern2();
}
}
}

View File

@ -39,6 +39,7 @@ struct TestSourceSettings {
ModulationFM,
ModulationPattern0,
ModulationPattern1,
ModulationPattern2,
ModulationLast
} Modulation;

View File

@ -324,6 +324,24 @@ void TestSourceThread::generate(quint32 chunksize)
}
}
break;
case TestSourceSettings::ModulationPattern2: // 50% duty cycle square pattern
{
if (m_pulseSampleCount < m_pulseWidth) // 1
{
m_buf[i++] = (int16_t) (m_amplitudeBitsI + m_amplitudeBitsDC);
m_buf[i++] = (int16_t) (m_phaseImbalance * (float) m_amplitudeBitsQ);
} else { // 0
m_buf[i++] = m_amplitudeBitsDC;
m_buf[i++] = 0;
}
if (m_pulseSampleCount < 2*m_pulseWidth - 1) {
m_pulseSampleCount++;
} else {
m_pulseSampleCount = 0;
}
}
break;
case TestSourceSettings::ModulationNone:
default:
{
@ -419,3 +437,9 @@ void TestSourceThread::setPattern1()
m_pulseWidth = 1000;
m_pulseSampleCount = 0;
}
void TestSourceThread::setPattern2()
{
m_pulseWidth = 1000;
m_pulseSampleCount = 0;
}

View File

@ -77,6 +77,7 @@ public:
void setFMDeviation(float deviation);
void setPattern0();
void setPattern1();
void setPattern2();
private:
QMutex m_startWaitMutex;