0
$\begingroup$

I have a task to select only the area I need from the signal and shift its spectrum.

I am digitizing the signal at 48kHz. A useful signal for me is in the region of 5500-5995Hz and 6005-6500Hz. In order to extract it, I multiply the digitized signal by $$\cos(2\pi n/(48000/6000))$$ and $$-\sin(2\pi n/(48000/6000))$$ and then pass these two signals through a low-pass filter with a cutoff frequency of 500Hz and a high-pass filter with a cutoff frequency of 5Hz. After that, I transfer the received signal to the right by 500 Hz. So that it takes the region I need from 0-1000Hz by multiplying each component by $$\cos(2\pi n/(48000/500))$$ and $$\sin(2\pi n/(48000/500)).$$

In this picture, perhaps it is expressed in a more understandable form:

enter image description here enter image description here

But when I transferred this algorithm to the microcontroller, I noticed that it works, as I think, not quite right. Help me to understand what I'm doing wrong? Can you describe in more detail how the spectrum is transferred to the desired area?

P.S. I am also interested in if I want to do signal decimation, when is the best time to do it? After LPF and HPF (before transferring the signal to the right by 500Hz.) Or after all the transformations?

$\endgroup$
2
  • $\begingroup$ Can you explain what you're seeing that's not quite right ? $\endgroup$
    – Peter K.
    Apr 18, 2022 at 18:01
  • $\begingroup$ @Peter K. I see those frequencies, which should not be as I think. As if some spectrum is additionally superimposed on my signal and changes its amplitude. $\endgroup$
    – red15530
    Apr 18, 2022 at 18:25

1 Answer 1

1
$\begingroup$

There is no allowance for transition band between the passband of interest (5.5KHz to 6.5 KHz less a notch in the center) and the frequencies in aliasing zones to reject based on the translation frequencies chosen. This means implementing the required anti-alias filters is not possible. One solution is to maintain a complex signal by implementing a full complex multiplier as the aliasing occurs in the final conversion to a real output, otherwise the frequency of the second translation must be increased to allow for transition bands for realizable filters, or the actual bandwidth of interest reduced.

I suspect that this is the primary effect in that the signal quality is limited by the actual attenuation of the filters with finite noise and signal in the image locations. There also is the possibly for amplitude and phase imbalance in the quadrature mixing- quadrature phase and amplitude imbalance between the I and Q paths would be more likely if any of that is done in the analog while the OP appears to be doing all quadrature multiplication in the digital — still there is opportunity if care is not taken to have delay, phase or amplitude imbalances which will show up through the testing detailed further below.

Below shows spectrum diagrams of the processing if the filter rejection and quadrature balances were perfect. This is the operation the OP desires:

quadrature frequency conversions

Consider the first translation as multiplying a real signal as represented by the top spectrum (which would have a Hermitian symmetric spectrum: same magnitude in positive and negative frequencies but opposite phase) with the complex tone $e^{-j2\pi 6000 t} = e^{-j2\pi6n/24}$ once sampled. This shifts the entire spectrum to the left just as the OP has shown which is then selected by the low pass and high pass filter. The performance of the low pass if of particular interest as that sets the image rejection for the next translation.

The next translation is multiplying this complex result (we can refer to the upper path in the OP's functional sketch as "real" (I) and the lower path as "imaginary" (Q) and then treat the two path output in the filter stage as a complex signal given as $I + JQ$) with another complex tone when sampled at $e^{j 2\pi n/48}$ which shifts the entire spectrum to the right as shown, and then we effectively take the real part of this full complex multiplication by not doing two of the multiplications required for an actual full complex multiplication:

$$(I_1+jQ_1)(I_2+jQ_2) = I_1 I_2 - Q_1Q_2 + j(I_1 Q_2 + I_2Q_1)$$

The real part of the above represents the processing actually done in the second translation stage ($I_1 I_2 - Q_1Q_2$) where $I_1, Q_1$ is the signal path and $I_2, Q_2$ is the cosine and sine used for translation. The result of the full complex signal is centered at +0.5 KHz. When you take the real part it will be centered at +/-0.5 KHz.

Any leakage from the filter that results in signals at -1 KHz prior to the second stage will be centered at -0.5 KHz after the frequency translation. When you take the real of that, it will also end up at +/-0.5 KHz and be distortion in the result. This depicted in the next graphic below showing how spectral content in the alias region from 4.5 KHz to 5.5 KHz will fold onto the desired signal at the output if not filtered out (either at the very front-end, or after the first multipliers:

aliasing

The issue here is the OP is interested in maintaining the input spectrum from 5.5 KHz to 6.5 KHz (ignoring the center notch which is of no consequence). The band that will alias in from the second frequency translation (once converted to real) is from 4.5 KHz to 5.5 KHz (at the real input). This allows for no transition between the band to reject and the band to pass whether the filter is implemented at the front-end or after the first frequency translation! Filter complexity and performance is dictated by how much frequency we allow to transition from a passband to a stopband.

Any quadrature amplitude and phase imbalances will also lead to such image distortion. This is less likely in an all digital implementation, but to show the effect consider the spectrum plot below showing how quadrature imbalance in the first multiplier stage would appear and how distortion results:

imbalance

To test and validate against these effects (regardless of final frequency plan and bandwidth used), consider using a single tone at the frequency of interest and measure the “conversion gain” from input to output. Then put this tone at the image frequency locations and measure the image suppression. For example, to confirm the -6 KHz balance try a tone just at 6.25KHz and see how much appears at 0.75 KHz in the output as it should versus how much appears at 0.25 KHz which is dues to quadrature amplitude and phase imbalance in either of the two multiplier stages. (I suspect this should be quite good if done digitally but worth confirming). Then put a tone just at 4.75KHz to test the filter rejection. This will end up at -1.25 in the middle stage which will be rejected by the low pass filter (to some degree) and whatever is not rejected will shift to -0.75KHz after the second stage multiplier, and when you take the real of that will also be at +/-0.75KHz. (From this we also see as currently done, the appropriate filtering as we approach the 5.5 KHz edge is not feasible).

The best place to do decimation is after the filters and prior to translating to a higher frequency. Although depending on decimation ratios and approach it may not make any different. To decimate properly, understand where all the aliasing frequency bands are given the sampling rate and decimation ratio and ensure there is sufficient rejection in these zones specifically. See this post for further details on aliasing bands with decimation.

If the operations in the above spectrum plots are confusing, this post provides further detailed insight into the frequency translation of complex signals.

$\endgroup$
15
  • $\begingroup$ Part of the information I didn’t quite understand... If I’ve got something wrong please correct me: 1) I tried to use high-pass filter with 5Hz band to cut the unnecessary part of the spectrum 5995-6005Hz, after I shifted the spectrum to the left by 6kHz. If I’ve got this right, won’t it work? 2) In the second figure you explain that a nearby lying spectrum can penetrate the main signal. I take it you can fight this if you use a low-pass filter with a steeper cut bar (use a larger filter order or use, for example, an elliptical filter) $\endgroup$
    – red15530
    Apr 19, 2022 at 6:43
  • $\begingroup$ Now I see a solution like this (correct me if I misunderstood something): First, I left-shift the original signal by 6kHz by multiplying by cos and -sin of the appropriate frequency. Next, I pass the received signals through a low-pass filter with a cutoff frequency of 500 Hz (Elliptical low-pass filter of the 6th order). Next, I can decimate the signal by a factor of 24 and then shift the signal to the right by 0.5 kHz by multiplying by cos and sin of the corresponding frequency and take only the real part. $\endgroup$
    – red15530
    Apr 19, 2022 at 6:46
  • $\begingroup$ Also now I have a question about the last transformation - Complex Output (if full complex multiplier was used)->Real Output. At first I only have a real signal, after I multiply it with cos and -sin I get a complex signal. And then I work only with a complex signal, and at the end of all transformations, if I take only the real part. On the last graph, you showed that if you take only the real part, I will see a copy of the signal in negative frequency. I can't understand, since in the real world there is no negative frequency, how does this affect the positive frequency region? $\endgroup$
    – red15530
    Apr 19, 2022 at 7:09
  • $\begingroup$ No in your solutions you are not able to reject the pattern that will interfere. In the “real world” you mean a signal that you can measure with just one scope probe, you absolutely have negative frequencies. The only way to not have negative frequencies is to have a complex signal (which you have in the real world when you use two scope probes to measure the signal: the output after your first multiplier is a single complex waveform, where you need two scope probes to measure after each multiplier). As another example review the FT of a sinusoid- it has a positive and negative frequency. $\endgroup$ Apr 19, 2022 at 12:20
  • $\begingroup$ Your issue in all your cases where you shift by 0.5 KHz and want a bandwidth that extends out 0.6 KHz from your center frequency and you want the output to be real only is that you have allowed no transition band for your filter- there is no possible filter that can both pass 5.5KHz and reject 5.4999999 KHz. So everything at 5.5KHz and below will fold as I’ve shown. Please read through the link I pasted at the bottom of the answer- that will help you. $\endgroup$ Apr 19, 2022 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.