Hi Rob! Interesting problem. To get the discussion flowing, and because I'm right now thinking out aloud, might as well write things down: I think these are the osmocom gr-iqbal blocks, right? Let's look at what "IQ Bal Optimize" does! It's my understanding [1] that what they do is take an FFT of signal, look every positive frequency j bin, conjugate-multiply it with the opposite negative frequency -j bin; sum up over all positive j. So, assume that the *signal* in the FFT's bin j and bin -j (or fft_size-j, but that's semantics) are uncorrelated. Let's say we observe the signal with an ideal signal chain, Then, the conjugate complex product FFT[j]*FFT'[-j] is 0 on expectation, by definition of "uncorrelated"¹. (Note: this means that one *must not* have a signal that's conj symmetric to f=0, or it would get detected as IQ imbalance!) If, however, there's IQ imbalance, then there's some component in FFT[-j] that contains a (weighted) mirror image of FFT[j], i.e., FFT[-j] = FFT[j]·b + actual_signal_fft[-j], with b being some complex factor. Thus, let us define a function with p as parameter, and the FFT-ed signal as input; here, the expectation operator E{…} is meant to be understood pretty empirically, "across all j": f_p(FFT) := E{FFT[j]·p·FFT'[-j]} = E{FFT[j]·FFT'[j]·p·b + p·FFT[j]·actual_signal_fft'[-j]} = E{|FFT[j]|²·p·b} + p·E{FFT[j]·actual_signal_fft'[-j} = p·b·E{|FFT[j]|²} + 0 What then happens is that a bit of convex optimization is thrown at this f_p(FFT) := p·E{FFT[j]·FFT'[-j]}. Since the signal energy |…|² is constant, the p that is conj(b) maximizes the function. Neat; don't overdo it on iterations on that optimization, because this is all noisy and you can't know how uncorrelated signal at opposite frequencies really is in this instant! Then, that optimization is repeated when there's new input that can be transformed, using the previous p as initialization. Thus, assuming signal fluctuates, and noise is uncorrelated, thus converging against a good estimate of the actual conj(b). Now, your problem is that there's not a single b for all bins, but a different b[j] for each bin j>=0. Huh! That suddenly looks a lot like a frequency-domain equalizer problem, doesn't it? In the presence of enough time (and the absence of intended, f=0-mirrored signals), there's, as far as I can tell, nothing wrong about using numerical optimization to optimize a whole parameter vector p[0…fft_len/2] instead of just a single complex p. You'd only need to understand the "E{…}" in the definion of f_p above as "across time" instead of "across bins". Does that give you a start on how to implement this? Now, you'll notice a peculiarity: What you do with that p is use its inverse to calculate the image of positive frequencies mirrored onto negative frequencies (didn't check, tbh), and subtract that. Huh! That's literally an equalizer. So, LMS equalizer methods, trained on the FFT[j]·FFT'[-j]_{j=0…fft_len/2} vector, should work, too, potentially even better. I bet *someone* has implemented that before, but I didn't find, on short notice, someone in the realm of GNU Radio that did so. Best regards, Marcus ——————————————————————————————————————————————————————————————————————————————————————— ¹ If you're not happy with me saying "by definition of": think about white noise. At any two frequency bins, you should be getting independent random complex numbers, zero mean; if the complex number is not zero mean (attention not magnitude-zero-mean!), then there'd be a "tone" at that frequency, not white noise. Now, multiply a complex number with the conjugate of another one: the result should be zero-mean, because from probability theory we know that E{X·Y} = E{X}·E{Y} if X,Y independent (and correlation is weaker than independence, but says E{X·Y} = 0). Our two variables have E{X}=E{Y}=0. [1] https://gitea.osmocom.org/sdr/libosmo-dsp/src/branch/master/src/iqbal.c#L168 On 2026-04-13 4:02 AM, Rob Frohne wrote: > Hi All, > > I want to help my students fix an annual problem we have because our QSD SDR hardware > designs can never get good enough image rejection. I want to do that by adding a GnuRadio > flowgraph that uses some kind of LMS or other automatic algorithm (with more than two > parameters) to automatically balance the I and Q signals. My students are designing QSD > SDR radios that downconvert HF signals to audio for a sound card to digitize often using a > Tayloe mixer. I want something like this: > My problem with the above flowgraph is that it only optimizes the phase and amplitude at > one frequency. I want it to optimize over the whole IF, so there are no glaring images in > our spectragrams. I have seen a number of papers on doing this, but I'm looking for a > quick GnuRadio solution I can put between the soundcard and Quisk. Does anyone have > something like this we could try? > > Thanks, > > Rob > > -- > > Rob Frohne, PhD PE > > School of Engineering > > Walla Walla University > > 100 SW 4th St > > College Place, WA 99324 > > (509) 527-2075<http://voice.google.com/calls?a=nc,%2B15095272075> >
No comments:
Post a Comment