SDR: Fix level range of IQ date; must not exceed range of -1 .. 1

LimeSDR mini (and maybe others) do not want IQ data to become a value below
-1 or above 1. This happens slightly when applying the IIR filter after
upsampling. To prevent this, we scale down the IQ level a little bit.

To test the problem:
- set the scale level to 1.0, so it does not take effect
- use LimeSDR mini
- use upsampling (sample rate differs SDR sample rate)
- run loopback mode 2 (-l 2)
- IIR filter must be initialized with 2 or more iterations to take effect
- check linear IQ graph; it will then plot dots inside the circle
This commit is contained in:
Andreas Eversberg 2018-08-25 08:13:16 +02:00
parent 0b22b0305a
commit 881d4a9f72
1 changed files with 5 additions and 2 deletions

View File

@ -51,6 +51,9 @@ enum paging_signal;
/* usable bandwidth of IQ rate, because no filter is perfect */
#define USABLE_BANDWIDTH 0.75
/* limit the IQ level to prevent IIR filter from exceeding range of -1 .. 1 */
#define LIMIT_IQ_LEVEL 0.95
int sdr_rx_overflow = 0;
typedef struct sdr_thread {
@ -446,8 +449,8 @@ static void *sdr_write_child(void *arg)
out = sdr->thread_write.out;
for (s = 0, ss = 0; s < num; s++) {
for (o = 0; o < sdr->oversample; o++) {
sdr->thread_write.buffer2[ss++] = sdr->thread_write.buffer[out];
sdr->thread_write.buffer2[ss++] = sdr->thread_write.buffer[out + 1];
sdr->thread_write.buffer2[ss++] = sdr->thread_write.buffer[out] * LIMIT_IQ_LEVEL;
sdr->thread_write.buffer2[ss++] = sdr->thread_write.buffer[out + 1] * LIMIT_IQ_LEVEL;
}
out = (out + 2) % sdr->thread_write.buffer_size;
}