Author Topic: Simple diy SDR radio with Tayloe mixer and STM32  (Read 83561 times)

0 Members and 2 Guests are viewing this topic.

Offline timofonic

  • Frequent Contributor
  • **
  • Posts: 904
  • Country: es
  • Eternal Wannabe Geek
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #125 on: May 01, 2016, 02:00:30 am »
How does this work with GNU Radio?
 

Offline YansiTopic starter

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #126 on: May 06, 2016, 10:34:26 am »
Pardon, how does what work with what? To which post is your post related to?
 

Offline YansiTopic starter

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #127 on: June 09, 2016, 10:56:50 pm »
Finally got some spare time to make some small progress. This time, I studied (again) the basics of a SSB demodulation in a DSP.

This document describes very nicely all basic operations needed:
https://www.arrl.org/files/file/Technology/tis/info/pdf/98qex003.pdf

So I know, I need a Hilbert transform, to shift the Q signal another 90 degrees. (Note: Fine, I found myself a little tool from "Iowa Hills" which can do the thing as expected. Here are their very neat tools: http://www.iowahills.com/8DownloadPage.html )

So basically I need two lowpass filters, for I and Q baseband signal. And a third one, the hilbert transformer, to be able to demodulate the SSB. However the document above mentions (page 13, "Analythic Filter-pair Synthesis"), that the baseband filter coefficients may be modified by multiplying the impulse response with a complex exponential. Thus reducing the need for the third FIR, keeping only the two modified response ones.

That seemed interesting optimization. So I tried to test the theory in matlab.  My limited understanding of that technique is that I will get two filters, with the same magnitude response and phase different by 90degree between the two filters. However the results from matlab do tell otherwise.  :o

I have written a simple script, which generates a set of coefficients for a lowpass FIR filter. Then I try to apply Equation 43 from the document above to produce two sets of new coefficients for the modified filters. I did assume, that the multiplication by complex exponential will only result in shifting the filter's original passband, as the omega_0 changes. In reality, the passband just sits at half the nyquist frequency and changes its passband width in the case of a Q-filter, the I-filter does move the slope a bit, but has completely different magnitude response.

I have attached the matlab code and a few screenshots of the results. It is weird, I might be doing something wrong. Can you help please?
« Last Edit: June 09, 2016, 10:59:43 pm by Yansi »
 

Offline mark03

  • Frequent Contributor
  • **
  • Posts: 708
  • Country: us
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #128 on: June 10, 2016, 06:50:41 pm »
Some advice, not all directly related to your question, sorry, but I can't help myself  ;)

Don't use j as a variable.  MATLAB allows j or i as sqrt(-1) but this will eventually bite you when you can't figure out why a script isn't working, and then you realize it's because you redefined sqrt(-1) into something else.  (You probably shouldn't use i as a variable either but as we all know j is the true sqrt(-1)!)

Try to define vectors and use ".*" to multiply element-by-element.  Much easier then loops.

MATLAB is the only place in the known universe with their weird definition of frequency.  Keep sane by using "digital frequency" f = freq_in_Hz / sampling_freq_in_Hz such that 1/2 == Nyquist and follow that convention everywhere, only multiplying by two when you need to use a MATLAB function that thinks 1 == Nyquist.  Of course some people prefer omega too.  Personally I find it much easier to think in digital [non-angular] frequency and throw in the 2*pi factor wherever I need it.

Now to the stuff that might actually help...  To keep things simple, make your LPF with an odd number of taps.  Call this L.  Then in MATLAB-speak,

M = (L-1)/2;       % this is the filter order
n = [-M:M];
hi = h .* cos(2*pi*fc*n);   % where fc = desired center frequency / sampling frequency
hq = h .* sin(2*pi*fc*n);

BTW any linear-phase FIR filter of "type 3" or "type 4" automatically has the hilbert-transforming property.  That's basically what we're doing when we multiply by sin(2*pi*fc*n), changing from even-symmetric to odd-symmetric at the same time we shift the center frequency away from DC.

Instead of calling fir1 you could do the window design yourself and just specify both filters directly, as

hi = 2*B*sinc(B*n) .* hamming(L)' .* cos(2*pi*fc*n);
hq = 2*B*sinc(B*n) .* hamming(L)' .* sin(2*pi*fc*n);

where L, n, and fc are defined above and B is the desired bandwidth, again in proper normalized units of (true bandwidth / sampling frequency).  This is probably the best way to gain insight into what you are doing.  (B*sinc(B*n) gives a perfect brick-wall, unity-gain response if n goes on forever, but of course we are truncating it, so we multiply point-by-point with a window function to reduce the sidelobes at the expense of a less-sharp filter, then we modulate from DC to fc by multiplying point-by-point with 2*cos() or 2*sin().

I didn't delve too deeply into your script, but I suspect one of the problems is your LPF bandwidth is too wide and/or you are not modulating the filter far enough in frequency.  Remember that multiplication by a real sinusoid produces two copies in the spectral domain, one shifted up and the other shifted down.  (Also remember that freqz is only showing you the positive frequencies; the LPF extends the same distance in negative frequency.)  If you don't shift far enough, the two copies pile up and interfere with one another.  So, the half-band LPF you've designed has a cutoff at 0.25 (I am using proper/correct frequency units here, so 0.25 == halfway to Nyquist).  The width of that LPF is 0.5 if you measure its full extent in +/- frequency.  When you modulate it you can just barely avoid a spectral collision if you use fc=0.25 (multiply by cos(2*pi*n*0.25)):  One copy will be centered at 0.25 and the other at -0.25.  This will be essentially an all-pass filter because each copy will span from 0 to 0.5 (or -0.5).  Of course, that may be exactly what you want for your SDR.
 

Offline mark03

  • Frequent Contributor
  • **
  • Posts: 708
  • Country: us
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #129 on: June 10, 2016, 06:52:19 pm »
PS  Don't learn MATLAB.  Learn Numpy/Scipy instead.  But if you do learn MATLAB, follow my advice above  8)
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5315
  • Country: gb
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #130 on: June 10, 2016, 07:19:45 pm »
Yansi:

If you are demodulating with IQ from a Tayloe or other quadrature downconverter, then you won't need a Hilbert transformer.

One other point, personally I found Doug Smith's articles to be really difficult as an introduction to DSP: they tend to be very math(s) heavy, and theoretical with no practical examples. If you're good at dealing with abstract concepts in maths and engineering then that's fine but I find his articles (and his book) to be very hard going.

The alternatives that I found invaluable are:

o Gerald Youngblood's articles starting here https://www.arrl.org/files/file/Technology/tis/info/pdf/020708qex013.pdf

o Rick Lyons' Understanding Digital Signal Processing

I also use Excel extensively and Octave as a Matlab alternative.
 

Offline mark03

  • Frequent Contributor
  • **
  • Posts: 708
  • Country: us
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #131 on: June 10, 2016, 07:32:21 pm »
If you are demodulating with IQ from a Tayloe or other quadrature downconverter, then you won't need a Hilbert transformer.

Admittedly it has been a while since I played with it, but I don't think this is right.  He's trying to demodulate SSB.  Assuming you start with I and Q baseband signals as every comms text defines them, he's doing the right thing.  You may be thinking of "how to get the Q signal" which would involve a separate Hilbert transformer, if the downconversion didn't already provide quadrature outputs.

 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5315
  • Country: gb
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #132 on: June 10, 2016, 08:17:53 pm »
You only need the Hilbert to emulate the quadrature signal. So if you already have the I & Q there's no need for a Hilbert transformer.

Edit: I am assuming low IF, take a look here, at figure 4. http://www.microwavejournal.com/articles/3226-on-the-direct-conversion-receiver-a-tutorial

The main reason to avoid zero IF is any DC offset an LO phase noise present in analogue downconverters, but it's also handy for allowing you to use a quadrature NCO in software to to your demodulation.
« Last Edit: June 10, 2016, 08:44:32 pm by Howardlong »
 

Offline mark03

  • Frequent Contributor
  • **
  • Posts: 708
  • Country: us
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #133 on: June 10, 2016, 09:51:29 pm »
OK but the OP is trying to receive a single-sideband signal.  You have two real baseband signals, i(n) and q(n).  How do you combine them to obtain the demodulated audio?

See e.g. Figure 11 here: https://www.dsprelated.com/showarticle/176.php
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5315
  • Country: gb
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #134 on: June 10, 2016, 11:22:11 pm »
Ok, but assuming the OP is using an analogue downconverter (as the title and content of the posts suggest) I can't really recommend trying to demodulate at zero IF mixed in the analogue domain primarily due to the phase noise and DC offset complications around zero Hz.

This is why typical narrowband SSB implementations operate a second IF in software, say at 10kHz or so, perfoming identical dual channel filtering, second quadrature down conversion, and AGC all in the digital domain. The result is that the USB is simply calculated as I+Q and the LSB is I-Q, and you can avoid the Hilbert transform altogether and those nasty zero IF artefacts.

The reason I'm saying this is that I too got wound up some years ago into thinking I needed to use the HT, and became fixated on them when I really didn't need them, possibly as a result of reading texts such as Doug Ford's. In practice I've found them usually (but not always) unnecessary, and that they often add unnecessary confusion and complexity.

While Doug Smith's texts are, I am sure, of value to some, I just found that they had too much maths and too little real practical application, almost written as a supporting text for people who already know the answer, if that makes sense.

Edit: typos
« Last Edit: June 11, 2016, 12:02:26 am by Howardlong »
 

Online coppice

  • Super Contributor
  • ***
  • Posts: 8605
  • Country: gb
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #135 on: June 11, 2016, 04:06:51 pm »
So I know, I need a Hilbert transform, to shift the Q signal another 90 degrees. (Note: Fine, I found myself a little tool from "Iowa Hills" which can do the thing as expected. Here are their very neat tools: http://www.iowahills.com/8DownloadPage.html )
If you actually require a second 90 degree shift, why would you use something as complex as a Hilbert transform to get it? You have the I signal. Just invert it and you have your 90 + 90 degree shifted signal.
 

Offline seriouscoinage

  • Contributor
  • Posts: 31
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #136 on: June 12, 2016, 01:13:06 am »
That's not going to work. Adding I to an inverted version of itself will result in nothing. Adding/subtracting I to Q shifted by another 90degrees yields the portion of the frequency spectrum either above or below the mixer frequency.

edit: In general, a phase inversion is not the same thing as a phase shift.
« Last Edit: June 12, 2016, 02:42:21 am by seriouscoinage »
 

Online coppice

  • Super Contributor
  • ***
  • Posts: 8605
  • Country: gb
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #137 on: June 12, 2016, 08:44:10 am »
That's not going to work. Adding I to an inverted version of itself will result in nothing. Adding/subtracting I to Q shifted by another 90degrees yields the portion of the frequency spectrum either above or below the mixer frequency.

edit: In general, a phase inversion is not the same thing as a phase shift.
Er, yeah, I probably shouldn't post when half asleep. :)
 

Offline YansiTopic starter

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #138 on: June 12, 2016, 09:49:25 am »
I've been always told also, that "phase inversion" is a nonsense.  Phase can not be inverted. Polarity can be.  :)

I am quite lost in your explanations. Do I need hilbert transform or not to demodulate  SSB from I and Q signal? (Is it needed to shift the Q another 90 degrees with hilbert?)
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 2145
  • Country: fi
  • Embedded SW/HW.
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #139 on: June 12, 2016, 11:18:54 am »
Take a look at this. Quite a simple and straightforward design:
https://www.tapr.org/pdf/DCC2010-simpleSDR-KF6SJ.pdf
Although using PSoc3 as the implementation platform, the principles stay the same independent of your hardware.
Here is another design using PSoc5 for SSB and AM:
http://pa0rwe.nl/?page_id=32
You can extract quite a lot of useful information from those projects.
 

Offline YansiTopic starter

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #140 on: June 12, 2016, 11:37:07 am »
Thank you, I need Hilbert transform on the Q path, or the analytic filter pair (which I have failed to produce).

I think I have seen the Psoc3 project some time ago. Notice the opamp circuit after the mixer, seems there might be a mistake: If the opamp is supposed to work as a differential amp (which I think it is supposed to), then the + leg misses the matching resistor divider.



//From such projects it seems diy SDR is very doable... kind of like a motivation to do it. But I am still doing more wrong than good.
« Last Edit: June 12, 2016, 11:49:58 am by Yansi »
 

Offline seriouscoinage

  • Contributor
  • Posts: 31
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #141 on: June 13, 2016, 02:44:31 am »
I think there are two main ways to do SSB demodulation, from what I have read. See http://michaelgellis.tripod.com/mixerscom.html. There is a phasing method, using the Hilbert transform, and the "Weaver method," which does not. With the phasing method:
  • Apply quadrature mixing to RF signal, mixing it down to baseband (direct conversion)
  • Convert IQ channels to digital
  • Apply Hilbert transform to Q channel
  • Take sum or difference of I and Q to get USB or LSB
With the Weaver method
  • Apply quadrature mixing to RF signal, mixing it a low IF (e.g. 10kHz)
  • Convert IQ channels to digital
  • Apply digital filter to IQ to select USB or LSB
  • Mix IQ channels with a complex exponential down to baseband
  • Take sum/difference of I and Q to get baseband signal, which is either +/- 10kHz of the mixer frequency
 

Offline YansiTopic starter

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #142 on: June 13, 2016, 10:27:15 am »
Thank you for explanation.  The first method is that one I know from the QEX article. The second seems interesting, but also more computation hungry. 

The frequency translation (using a complex exponential) seems to be mandatory anyway, if I'd like to finetune the reception frequency. So the second "weaver method" might be also possible.

Unfortunately, I need to get some f*king HW going first, haven't got much luck last time. Now, I equipped myself with some better parts, like better multiplexers (FST3253, PI3B3253). Still I don't know, what purpose or performance effect has the bandwidth of the OPAmp after the mixer. Usually, people use very fast and expensive opamps there, like 200MHz BW or so, even that the bandwidth is limited to a few tens of kHz. Interestingly, the SDR project using the PSOC chip uses only a half decent opamp with 20MHz BW.

I should probably now draw some new version of schematic and consult it with you, to make some progress.
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5315
  • Country: gb
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #143 on: June 13, 2016, 10:57:25 am »

With the Weaver method
  • Apply quadrature mixing to RF signal, mixing it a low IF (e.g. 10kHz)
  • Convert IQ channels to digital
  • Apply digital filter to IQ to select USB or LSB
  • Mix IQ channels with a complex exponential down to baseband
  • Take sum/difference of I and Q to get baseband signal, which is either +/- 10kHz of the mixer frequency

Close, but not quite, you choose USB or LSB by choosing the the sum or the difference, not by using a filter. Here's a practical scheme:

o Downconvert RF to quadrature I/Q low IF in the analogue/hardware domain with LO 12kHz above or below target freq.

o Filter both channels with a 24kHz analogue LPF on each channel.

o Convert resulting I & Q channels to digital domain (2 x simultaneous sampling ADCs @ 48kSa/s *** each)

o Complex multiply with a quadrature NCO running at 12kHz to give digitally downconverted baseband

o Take either I+Q or I-Q depending on whether you want USB or LSB **

o Apply a single 3kHz LPF to the sum or difference created in the previous step

o Apply an AGC as necessary

o Send to your preferred audio device

** For AM, take sqrt(I^2 + Q^2).... yes, USB and LSB is easier to demodulate than AM!
*** strictly speaking for this scheme you could reasonably sample at, say, 24kSa/s as you're discarding potential aliased frequencies in the later 3kHz LPF anyway, but also 48kSa/s is a very common sampling rate Edit: no, I was thinking about this, because you wouldn't have much luck trying to make a 12kHz quadrature NCO with a sampling rate of 24kSa/s. 48kSa/s it is.

By using a low IF, the filters are kept reasonable simple and not too compute intensive as the cutoffs are in the same order of magnitude as the sampling rate.
« Last Edit: June 13, 2016, 11:58:07 am by Howardlong »
 

Offline YansiTopic starter

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #144 on: June 13, 2016, 11:37:14 am »
So here's the schematic v2.0 I could come up with. I will no longer use that simplified nonsense with opamp inputs directly on the mixer filter caps. I'll use the classic differential circuit. (That way I can be sure, it will work). The mixer is biased through an RF choke and resistor. I have used only the unbalanced input version, will connect both halves of the PI3B3253 in parallel to lower the switch impedance even more. (Yes, no longer 74HC4052).

I think there should be also a set of resistors in series with the switches, to linearize the switches and to better define the the mixer cutoff frequency. (From the input impedance and switch series impedance) the filter caps C could be calculated. The value of the series resistors I've seen is usually between 10 to 33ohms.

Also the only thing why to use a high GBW opamp there I can think of is to have butter commonmode rejection at HF. Is that right?

Another change from the previous circuit is here's no input amplifier. The last one worked more like an attenuator than amplifier. But would be actualy nice to have there some input amp and possibly also a filter (at least some lowpass). :-/

Can you please check and verify the schematic? Any suggestions will be welcome!

Thx, Yan
« Last Edit: June 13, 2016, 11:39:32 am by Yansi »
 

Offline seriouscoinage

  • Contributor
  • Posts: 31
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #145 on: June 13, 2016, 12:33:32 pm »

With the Weaver method
  • Apply quadrature mixing to RF signal, mixing it a low IF (e.g. 10kHz)
  • Convert IQ channels to digital
  • Apply digital filter to IQ to select USB or LSB
  • Mix IQ channels with a complex exponential down to baseband
  • Take sum/difference of I and Q to get baseband signal, which is either +/- 10kHz of the mixer frequency

Close, but not quite, you choose USB or LSB by choosing the the sum or the difference, not by using a filter. Here's a practical scheme:

o Downconvert RF to quadrature I/Q low IF in the analogue/hardware domain with LO 12kHz above or below target freq.

o Filter both channels with a 24kHz analogue LPF on each channel.

o Convert resulting I & Q channels to digital domain (2 x simultaneous sampling ADCs @ 48kSa/s *** each)

o Complex multiply with a quadrature NCO running at 12kHz to give digitally downconverted baseband

o Take either I+Q or I-Q depending on whether you want USB or LSB **

o Apply a single 3kHz LPF to the sum or difference created in the previous step

o Apply an AGC as necessary

o Send to your preferred audio device

** For AM, take sqrt(I^2 + Q^2).... yes, USB and LSB is easier to demodulate than AM!
*** strictly speaking for this scheme you could reasonably sample at, say, 24kSa/s as you're discarding potential aliased frequencies in the later 3kHz LPF anyway, but also 48kSa/s is a very common sampling rate Edit: no, I was thinking about this, because you wouldn't have much luck trying to make a 12kHz quadrature NCO with a sampling rate of 24kSa/s. 48kSa/s it is.

By using a low IF, the filters are kept reasonable simple and not too compute intensive as the cutoffs are in the same order of magnitude as the sampling rate.

This makes a little more sense than what I was thinking. I was thinking that you should apply a bandpass filter before complex multiplying to select the USB/LSB relative to the IF frequency (or select the AM signal,) but this filter is more complex than a LPF applied at baseband.
 

Offline YansiTopic starter

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #146 on: June 13, 2016, 08:00:53 pm »
A little update:

Few days ago, first important part for an SDR system was made fully functional: The AD/DA audio codec. In January, I have designed a simple board to test the codec (Wolfson WM8731), but I've had a lot of other work to do, so just on friday evening, I started to assemble the board and Saturday about lunch, it was fully working, filtering an audio signal with some biquad filters.

Here's the result. The ugly board with three pots is to control the PEQ programmed in (frequency, Q, gain).

Now I need working LO and the mixer. Could you please review the schematic above, if you see there any mistakes or problems?
 

Offline seriouscoinage

  • Contributor
  • Posts: 31
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #147 on: June 14, 2016, 12:33:17 am »
Looking at your schematic, it looks correct. The GBW of the op-amps does in theory restrict CMRR at high frequencies, but I think the matching of your resistors is more likely to be the limit on the circuit's CMRR. The speed of the op-amps will restrict the effectiveness of the LPF they implement at high frequencies, though. I have read that some op-amps have nonlinear behaviour with higher frequencies: http://electronicdesign.com/analog/op-amp-audio-realizing-high-performance-bandwidth-limitations. This is my biggest concern about using a low GBW op-amp - if e.g. a strong out-of-band AM signal reaches your op-amp input, it might be detected by the nonlinear op-amp input and turn up as audio interfering with your baseband signal.

In a few days I should be able to put together my own Tayloe detector board, and I'll make a post or thread about it - whether it works or not, perhaps it will help you design yours.
 

Offline seriouscoinage

  • Contributor
  • Posts: 31
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #148 on: June 18, 2016, 12:01:05 pm »
I hope I'm not hijacking your thread Yansi, but I got my Tayloe mixer working and thought it might be helpful to you. It is pretty similar to most other circuits on the web, with an Si570 feeding a Johnson counter which drives a CBT3253 switch, but it uses in-amps at the output. The antenna I am using currently is a very poor indoor one, so I can only pick up quite strong signals, but the circuit otherwise seems to work well. In retrospect the circuit probably doesn't need these fairly expensive in-amps, but I think an in-amp arrangement of some sort is a good choice for getting the differential signal.
 

Offline YansiTopic starter

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: Simple diy SDR radio with Tayloe mixer and STM32
« Reply #149 on: June 18, 2016, 05:18:21 pm »
Hmm, seems working. What is the image rejection? And why does the switch has different bias, than the opamps? (not in the middle of the VCC)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf