## Downsampling from 2.0 MHz to 192kHz

Started by 6 years ago20 replieslatest reply 6 years ago888 views

I would like to downsample a signal (#SDR) from 2MHz to 192kHz.  I understand the general principle when you go from let's say 1.92MHz to 192 KHz but what happens here?  Is this feasible?

Thanks

[ - ]

Another way to look at is the common multiples.  2e6/192e3 = 125/12.  So you can up sample by 12 then decimate by 125.  This can be done in multiple steps so your filters do not have to be so tight.  For example you can go up by 3, then down by 5 then up by 4 then down by 5 twice.  That will take you from 2 MHz to 192 kHz exactly.

Mike

[ - ]

Hi Mike. I like your suggestion because its involves small numbers. Do you mean "go up by 3, then down by 5 then up by 2 then down by 5 twice"?

[-Rick-]

[ - ]

No, I think you need the full factor of 12 so it's up by 4 (and obviously it does not matter if you change the order of 3 and 4).  Otherwise it would be 2e6/125=16e3 * 6 = 96e3.  But you could even it out too, up 3, down 5 up 2 down 5 up 2 down 5 so the filters are really simple.  I'm not sure that saves anything though.

Mike

[ - ]

Hi,

First I do agree with all the replies so far: something seems odd with the problem statement from the OP.

Now assuming that the OP really needs to decimate by 125/12, using a polynomial filter for this type of problem is typically preferred as it avoids all the intermediate sampling rates required when doing ups/downs tricks (sometimes the intermediate rates are even unachievable).

However, it does push the complexity onto the filter coefficient calculations which is now done 'online'. Now if the decimating chain can be split in two or more stages, only the first stage can be of the more 'costly' polynomial form, taking care of the 'fractional part of the ratio', and that cost is modest since a low order filter could be used without performance degradation. You follow it by an standard integer decimator.

Interestingly, this is typically the approach taken by most if the problem is interpolation. A fixed integer rate filter is followed by a good old linear interpolator (straight line between two points) to take care of the fractional part. For decimation, the exact same thing applies, but one needs to use the transposed farrow structure to leverage all the polynomial filters in a decimating context.

[ - ]

If you prototype your code using MatLab, see resample and upfirdn functions help for a quickly implementation a fractional decimation.

Marcelo

[ - ]

Hi Tom,

As suggested by mike your decimation uses the ratio 12/125.

We are describing our solution at https://community.arm.com/people/laurentlefaucheur...

In your use-case I modified the free demonstrator Batch file commands with this new one:

DEBUG\ARBITRARY_SSRC TEST_PATTERN32.PCM B_TOM.PCM 2000000 192000 SRC_28FIR24B.COF

The computation complexity is in the range of 20MMAC/s to 60MMAC/s depending on the required roll-off and THD.

[ - ]

,Thank you for this. Interesting article.

Tom

[ - ]

So you're trying to decimate by:

2e6 / 192e3 = 10.4167

First I would question the requirements - is this really necessary? Can you change the system clocking so this problem goes away?

If so, you'll have to figure out performance requirements. How good does the decimating filter has to be, most importantly how much attenuation are you after for the aliasing bands.

Once you know this, you can decide if a cheesy implementation can do the job (like decimating by 10, and picking the 'closest' sample at the output). If that isn't good enough, I'd recommend looking at the 'transposed farrow structure', which lets you design non-integer rate decimator using standard polynomial filter responses. One hint here would be to use a low order transposed farrow (maybe linear?) to go down by 1.04167, followed by a standard integer decimator going down by 10.

Dave

[ - ]

There's precious little pertinent information here.

The original signal is sampled at 2MHz.  What's its frequency content?  Is there any noise?  How much of the signal needs to be retained when it's sampled at 192kHz?  Are you doing straight downsampling, or are you doing downconversion?

I suspect you'll have to do some sample-rate conversion, which means poly-phase filtering.  I don't have a good feel for whether this is a sensible candidate for doing on a DSP chip or if you need an FPGA -- I think it depends on how much processor loading you can stand, and whether you only have a bandlimited signal that's sampled at 2MHz, or if you have to filter out a bunch of extraneous signal or noise (which two look alike when you're getting rid of them).

[ - ]

I think it's best to explain this a little more.

I have a software defined radio that samples at 2mhz and higher. I do not have access to a lower sampling rate. The radio provides I and Q samples so this is the starting point. These samples are then processed to provide a spectrum scope with a bandwidth of 2 mhz.

I also want to be able to use this signal to provide samples at 192khz which will be output to an audio device. This audio device can be fed to a virtual audio cable which can proxide a 192khz sample to other processing software that only work with sound cards that can sample at 192khz.

These other software products cannot interface to this sdr so I wish to downsampling it to 192khz.

Now if there's a better way I'm all ears.

Thanks, Tom

[ - ]

I have a feeling that you are mixing up the concepts of modulation and information signal. I can hardly imagine that an audio signal has been up-converted to 2 MHz to be transmitted via radio. What you are looking for is not downsampling but I-Q demodulation. Use Google or this forum for more information.

Cheers,

Andy

[ - ]

No. I do not want to demodilate the signal. I want to pass this signal on to another application that requires a wide bandwidth so that it can scan a spectrum for signals.

I want to take the original 2mhz iq samples and convert them to 192kjz iq samples.

[ - ]

At the risk of being redundant with the other answers, your original question basically asked how to (in an equivalent analog domain) low pass filter a 1 MHz bandwidth signal to a 96 kHz bandwidth.

Now I think we're all confused as to what you really want to do as it sounds like the 2 MHz sample rate IQ data is not some sort of modulated signal but it's not baseband either...

If the signal is really 1 MHz bandwidth (or 2MHz depending on how you got to the IQ pairs) then you need to make clear what information content can be thrown away to lower the bandwidth.

[ - ]

Hi tomb18. You have a quadrature (I/Q) at a sample rate of 2 MHz. Such a signal has an information-carrying bandwidth of 2 MHz. (A critical question: Is that I/Q signal centered at zero Hz?)

Now you can't squeeze a 2 MHz-wide signal down to a bandwidth of 192 kHz and retain all the information that was in your original 2 MHz signal.

Scenario# 1: What you can do is 'select and isolate' (an operation called "tuning") some arbitrary 192 kHz-wide portion of the 2 MHz-wide signal and pass that 192 kHz-wide signal along to some follow-on processing. Does this Scenario# 1 describe what you want to do?

Scenario# 2: You can filter and decimate (my "decimate" means lowpass filter followed by downsampling) a 2 MHz signal to generate a 192 kHz bandwidth signal where the 192 kHz bandwidth signal is the center portion of your original 2 MHz signal. Does this Scenario# 2 describe what you want to do?

[ - ]

The IQ signal is centered at zero hz.  It is obtained by sampling the rf space around a tuned frequency.

So I guess its both. #1 is done in the sdr, but what i need is #2.

Thanks

[ - ]

On Second though it is #2.  I want to isolate the 192kHz and then pass this on.

[ - ]

I there another way? I do have a set of fft bins.

[ - ]

Hi tomb18. If I understand your wishes correctly, what you want to do is "resample" both of your 2-MHz I & Q signals by a factor of 12/125. (My verb "resample" means upsample by 12, followed by lowpass filtering, and finally downsample by 125.) This process is called "resampling by a rational factor", or "rational resampling", or "sample rate conversion by a rational factor." (Your "rational factor", a ratio of integers, is 12/125.)

There's more for you to understand about "resampling by a rational factor" than I am able to describe here. But the good news is there's much info on the Internet that can help you. Search the web for:

"resampling by a rational factor"

"rational resampling", and

"sample rate conversion by a rational factor."

Ya' know what would be nice? Two things:

[1] If your output sample rate was allowed to be 200 kHz then you only have a much simpler "decimate by 10" operation to perform.

[2] If your output sample rate was allowed to be 166.66 kHz then you only have a much simpler "decimate by 12" operation to perform. You could decimate by 12 in one operation (lowpass filter and downsample by 12) but the most computationally-efficient way to perform decimation by 12 is to perform "multistage decimation." That is 'decimate by 3' then 'decimate by 2' followed by another 'decimate by 2'. Decimations by 2 is quite efficient if you use "halfband" lowpass filters. See:

Good Luck.

[ - ]

I do get the idea of rational vs non-rational downsampling. I've been reading everything I can about it. Nonetheless it is not an easy field for a non-DSP professional to navigate.  So much of the DSP field is focused on the telecom professions that the amateur radio field is somewhat at a disadvantage.  While all the theory is out there, if I need to program such a resampling filter from scratch then I need to devote a huge amount of time in coding and debugging.  The alternative is to purchase third party libraries that typically cost an arm and a leg, like $2k and up. For someone programming amateur radio software that just pays the bills it is not economically feasible. LGPL software is out there too. But after my research, there seems to be nothing really available for the last 10 years and even then it's just for Linux. So it's a difficult field to navigate. There are a handful of DSP software utilities for the amateur radio field but many people do not have the background to effectively use them. We are all a bunch of old fogies. My idea in this minefield is to provide the ability to use a popular SDR, the SDRPlay and provide a way to take the 2MHz sampling rate which is the default (the other rate is 8Mhz, others too but they re not relevant) and bring it down to 192kHz so that it can be sent out through an audio interface and then be used by other products which only support sound cards. I don't know of any soundcards allowing 200Khz sampling. But there are many useful software products such as CWSkimmer which will simultaneously decode even hundreds of morse code signals. But they do not work with the new generation of SDR's. Furthermore, there's not that much active development for the traditional ham radio user. Why the designers of the hardware and software for the SDRPlay did not work with powers of 2 is beyond me. Even packet sizes are on the order of 373 bytes or something like that. My software hides pretty well all of the complexities of typical SDR software and attempts to make it all easy to use. You won't find things like FFT sizes, windowing algorithms etc in my software. No technical knowledge is needed it just works. So this is my attempt to make something useful to help out the amateur radio guys, who really helped design and shape the telecom industry in the first place. I guess there is some hope, because I once approached a developer of one of the most popular SDR packages and inquired about a license for some parts of his software. He quoted$5k and then $200+ per hour consulting. When I laughed and told him I would be lucky to make that in a year writing amateur radio software, he said, "Oh, if its for amateur radio it's free". So there are some developers and companies out there that understand what the amateur radio community has done for the telecom industry. But in general it's pretty tough to get anywhere where everyone has a product to sell. But some products are reasonable. I spent$700 for a license for my DSP, audio and plotting software.  But it has its limitations. Irrational resampling is not included.

So it seems I won't be able to do what I would like, but perhaps all the engineers reading might keep us non-professions in mind, and  not develop hardware and API's that place limits on what can be reasonably done.  Don't get me wrong, I really appreciate this forum and learned many things so it's no way a criticism. Just  general comment for the industry to remember their roots before we are all gone to remind them lol.

[ - ]